From a06d1806df4b09c7c85d82f38b976ba549778d5f Mon Sep 17 00:00:00 2001 From: Martin Filser Date: Sun, 3 Jul 2022 14:41:12 +0200 Subject: [PATCH] Copy card dialog remembers now the last selected board --- client/components/cards/cardDetails.jade | 2 +- client/components/cards/cardDetails.js | 68 +++++++++++++----------- 2 files changed, 38 insertions(+), 32 deletions(-) diff --git a/client/components/cards/cardDetails.jade b/client/components/cards/cardDetails.jade index 990cbb181..b8a082f2f 100644 --- a/client/components/cards/cardDetails.jade +++ b/client/components/cards/cardDetails.jade @@ -718,7 +718,7 @@ template(name="copyCardPopup") label(for='copy-card-title') {{_ 'title'}}: textarea#copy-card-title.minicard-composer-textarea.js-card-title(autofocus) = getTitle - +boardsAndLists + +copyAndMoveCard template(name="copyChecklistToManyCardsPopup") label(for='copy-checklist-cards-title') {{_ 'copyChecklistToManyCardsPopup-instructions'}}: diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js index b74886ae4..6fc2fbf1e 100644 --- a/client/components/cards/cardDetails.js +++ b/client/components/cards/cardDetails.js @@ -1020,6 +1020,43 @@ class DialogWithBoardSwimlaneList extends BlazeComponent { } }).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({ onCreated() { this.currentBoardId = Utils.getCurrentBoardId(); @@ -1127,37 +1164,6 @@ BlazeComponent.extendComponent({ }, }).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({ 'click .js-done'() { const card = Utils.getCurrentCard();