浏览代码

wipon card description - prevention of unintentional exit deletesunsaved description

viehlieb 2 年之前
父节点
当前提交
b00169d24f
共有 2 个文件被更改,包括 12 次插入4 次删除
  1. 0 2
      client/components/cards/cardDescription.js
  2. 12 2
      client/components/cards/cardDetails.js

+ 0 - 2
client/components/cards/cardDescription.js

@@ -26,8 +26,6 @@ BlazeComponent.extendComponent({
         // was keydown
         // was keydown
         // extraevent for saving input. buffer of keydown vs buffer time
         // extraevent for saving input. buffer of keydown vs buffer time
         'keyup form textarea'(evt) {
         'keyup form textarea'(evt) {
-          const description = this.getInput()[0].value;
-          this.data().setDescription(description);
           if (evt.keyCode === 13 && (evt.metaKey || evt.ctrlKey)) {
           if (evt.keyCode === 13 && (evt.metaKey || evt.ctrlKey)) {
             const submitButton = this.find('button[type=submit]');
             const submitButton = this.find('button[type=submit]');
             if (submitButton) {
             if (submitButton) {

+ 12 - 2
client/components/cards/cardDetails.js

@@ -1714,10 +1714,20 @@ BlazeComponent.extendComponent({
 EscapeActions.register(
 EscapeActions.register(
   'detailsPane',
   'detailsPane',
   () => {
   () => {
+    currentDescription = document.getElementsByClassName("editor js-new-description-input").item(0)
     //save description editing on EscapeAction
     //save description editing on EscapeAction
-    if (document.getElementsByClassName("editor js-new-description-input").item(0))
+    if (currentDescription?.value && !(currentDescription.value === Utils.getCurrentCard().getDescription()))
     {
     {
-      Utils.getCurrentCard().setDescription(document.getElementsByClassName("editor js-new-description-input").item(0).value);
+      console.log("equal?",!(currentDescription === Utils.getCurrentCard().getDescription()));
+      if (confirm('Are you sure you want to save this thing into the database?')) {
+        Utils.getCurrentCard().setDescription(document.getElementsByClassName("editor js-new-description-input").item(0).value);
+        // Save it!
+        console.log(document.getElementsByClassName("editor js-new-description-input").item(0).value);
+        console.log("current description",Utils.getCurrentCard().getDescription());
+      } else {
+        // Do nothing!
+        console.log('Thing was not saved to the database.');
+      }
     }
     }
     if (Session.get('cardDetailsIsDragging')) {
     if (Session.get('cardDetailsIsDragging')) {
       // Reset dragging status as the mouse landed outside the cardDetails template area and this will prevent a mousedown event from firing
       // Reset dragging status as the mouse landed outside the cardDetails template area and this will prevent a mousedown event from firing