浏览代码

Copy card dialog remembers now the last selected board

Martin Filser 3 年之前
父节点
当前提交
a06d1806df
共有 2 个文件被更改,包括 38 次插入32 次删除
  1. 1 1
      client/components/cards/cardDetails.jade
  2. 37 31
      client/components/cards/cardDetails.js

+ 1 - 1
client/components/cards/cardDetails.jade

@@ -718,7 +718,7 @@ template(name="copyCardPopup")
   label(for='copy-card-title') {{_ 'title'}}:
   label(for='copy-card-title') {{_ 'title'}}:
   textarea#copy-card-title.minicard-composer-textarea.js-card-title(autofocus)
   textarea#copy-card-title.minicard-composer-textarea.js-card-title(autofocus)
     = getTitle
     = getTitle
-  +boardsAndLists
+  +copyAndMoveCard
 
 
 template(name="copyChecklistToManyCardsPopup")
 template(name="copyChecklistToManyCardsPopup")
   label(for='copy-checklist-cards-title') {{_ 'copyChecklistToManyCardsPopup-instructions'}}:
   label(for='copy-checklist-cards-title') {{_ 'copyChecklistToManyCardsPopup-instructions'}}:

+ 37 - 31
client/components/cards/cardDetails.js

@@ -1020,6 +1020,43 @@ class DialogWithBoardSwimlaneList extends BlazeComponent {
   }
   }
 }).register('moveCardPopup');
 }).register('moveCardPopup');
 
 
+/** Copy Card Dialog */
+(class extends DialogWithBoardSwimlaneList {
+  getCardDialogOptions() {
+    const ret = Meteor.user().getMoveAndCopyDialogOptions();
+    return ret;
+  }
+  setDone(boardId, swimlaneId, listId, options) {
+    Meteor.user().setMoveAndCopyDialogOption(this.currentBoardId, options);
+    const card = this.data();
+
+    // const textarea = $('#copy-card-title');
+    const textarea = this.$('#copy-card-title');
+    const title = textarea.val().trim();
+
+    if (title) {
+      const oldTitle = card.title;
+      card.title = title;
+      card.coverId = '';
+
+      // insert new card to the top of new list
+      const minOrder = card.getMinSort(listId, swimlaneId);
+      card.sort = minOrder - 1;
+
+      const newCardId = card.copy(boardId, swimlaneId, listId);
+
+      // restore the old card title, otherwise the card title would change in the current view (only temporary)
+      card.title = oldTitle;
+
+      // In case the filter is active we need to add the newly inserted card in
+      // the list of exceptions -- cards that are not filtered. Otherwise the
+      // card will disappear instantly.
+      // See https://github.com/wekan/wekan/issues/80
+      Filter.addException(newCardId);
+    }
+  }
+}).register('copyCardPopup');
+
 BlazeComponent.extendComponent({
 BlazeComponent.extendComponent({
   onCreated() {
   onCreated() {
     this.currentBoardId = Utils.getCurrentBoardId();
     this.currentBoardId = Utils.getCurrentBoardId();
@@ -1127,37 +1164,6 @@ BlazeComponent.extendComponent({
   },
   },
 }).register('boardsAndLists');
 }).register('boardsAndLists');
 
 
-Template.copyCardPopup.events({
-  'click .js-done'() {
-    const card = Utils.getCurrentCard();
-    const lSelect = $('.js-select-lists')[0];
-    const listId = lSelect.options[lSelect.selectedIndex].value;
-    const slSelect = $('.js-select-swimlanes')[0];
-    const swimlaneId = slSelect.options[slSelect.selectedIndex].value;
-    const bSelect = $('.js-select-boards')[0];
-    const boardId = bSelect.options[bSelect.selectedIndex].value;
-    const textarea = $('#copy-card-title');
-    const title = textarea.val().trim();
-
-    // insert new card to the top of new list
-    const minOrder = card.getMinSort(listId, swimlaneId);
-    card.sort = minOrder - 1;
-
-    if (title) {
-      card.title = title;
-      card.coverId = '';
-      const _id = card.copy(boardId, swimlaneId, listId);
-      // In case the filter is active we need to add the newly inserted card in
-      // the list of exceptions -- cards that are not filtered. Otherwise the
-      // card will disappear instantly.
-      // See https://github.com/wekan/wekan/issues/80
-      Filter.addException(_id);
-
-      Popup.back(2);
-    }
-  },
-});
-
 Template.convertChecklistItemToCardPopup.events({
 Template.convertChecklistItemToCardPopup.events({
   'click .js-done'() {
   'click .js-done'() {
     const card = Utils.getCurrentCard();
     const card = Utils.getCurrentCard();