summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2018-02-15 22:40:59 +0200
committerLauri Ojansivu <x@xet7.org>2018-02-15 22:40:59 +0200
commit8da1dd524d6d9db9eb1ff6a93e6be788ee4288a5 (patch)
tree44ccc7ae7a6f44910499a2b04f2e9779fd8dfc6c
parent55a53e26559d27765924efbcb80bc31dfb4d21a0 (diff)
parentcfaeb43f1f8e55ab1d6373ba06551ca281258ac4 (diff)
downloadwekan-8da1dd524d6d9db9eb1ff6a93e6be788ee4288a5.tar.gz
wekan-8da1dd524d6d9db9eb1ff6a93e6be788ee4288a5.tar.bz2
wekan-8da1dd524d6d9db9eb1ff6a93e6be788ee4288a5.zip
Merge branch 'copyMany' of https://github.com/erikturk/wekan into erikturk-copyMany
-rw-r--r--client/components/cards/cardDetails.jade11
-rw-r--r--client/components/cards/cardDetails.js55
-rw-r--r--i18n/en.i18n.json3
3 files changed, 69 insertions, 0 deletions
diff --git a/client/components/cards/cardDetails.jade b/client/components/cards/cardDetails.jade
index 0a7a8cd6..81f571d6 100644
--- a/client/components/cards/cardDetails.jade
+++ b/client/components/cards/cardDetails.jade
@@ -135,6 +135,7 @@ template(name="cardDetailsActionsPopup")
ul.pop-over-list
li: a.js-move-card {{_ 'moveCardPopup-title'}}
li: a.js-copy-card {{_ 'copyCardPopup-title'}}
+ li: a.js-copy-checklist-cards {{_ 'copyChecklistToManyCardsPopup-title'}}
unless archived
li: a.js-archive {{_ 'archive-card'}}
li: a.js-more {{_ 'cardMorePopup-title'}}
@@ -154,6 +155,16 @@ template(name="copyCardPopup")
else
+boardsAndLists
+
+template(name="copyChecklistToManyCardsPopup")
+ label(for='copy-checklist-cards-title') {{_ 'copyChecklistToManyCardsPopup-instructions'}}:
+ textarea#copy-card-title.minicard-composer-textarea.js-card-title(autofocus)
+ | {{_ 'copyChecklistToManyCardsPopup-format'}}
+ if isSandstorm
+ +boardLists
+ else
+ +boardsAndLists
+
template(name="boardsAndLists")
select.js-select-boards
each boards
diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js
index d70167ce..d72f46d4 100644
--- a/client/components/cards/cardDetails.js
+++ b/client/components/cards/cardDetails.js
@@ -170,6 +170,7 @@ Template.cardDetailsActionsPopup.events({
'click .js-spent-time': Popup.open('editCardSpentTime'),
'click .js-move-card': Popup.open('moveCard'),
'click .js-copy-card': Popup.open('copyCard'),
+ 'click .js-copy-checklist-cards': Popup.open('copyChecklistToManyCards'),
'click .js-move-card-to-top' (evt) {
evt.preventDefault();
const minOrder = _.min(this.list().cards(this.swimlaneId).map((c) => c.sort));
@@ -296,6 +297,60 @@ Template.copyCardPopup.events({
},
});
+
+Template.copyChecklistToManyCardsPopup.events({
+ 'click .js-select-list' (evt) {
+ const card = Cards.findOne(Session.get('currentCard'));
+ const oldId = card._id;
+ card._id = null;
+ card.listId = this._id;
+ const list = Lists.findOne(card.listId);
+ card.boardId = list.boardId;
+ const textarea = $(evt.currentTarget).parents('.content').find('textarea');
+ const titleEntry = textarea.val().trim();
+ // insert new card to the bottom of new list
+ card.sort = Lists.findOne(this._id).cards().count();
+
+ if (titleEntry) {
+ const titleList = JSON.parse(titleEntry);
+ for (let i = 0; i < titleList.length; i++){
+ const obj = titleList[i];
+ card.title = obj.title;
+ card.description = obj.description;
+ card.coverId = '';
+ const _id = Cards.insert(card);
+ // 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);
+
+ // copy checklists
+ let cursor = Checklists.find({cardId: oldId});
+ cursor.forEach(function() {
+ 'use strict';
+ const checklist = arguments[0];
+ checklist.cardId = _id;
+ checklist._id = null;
+ Checklists.insert(checklist);
+ });
+
+ // copy card comments
+ cursor = CardComments.find({cardId: oldId});
+ cursor.forEach(function () {
+ 'use strict';
+ const comment = arguments[0];
+ comment.cardId = _id;
+ comment._id = null;
+ CardComments.insert(comment);
+ });
+ }
+ Popup.close();
+ }
+ },
+});
+
+
Template.cardMorePopup.events({
'click .js-copy-card-link-to-clipboard' () {
// Clipboard code from:
diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json
index 92391c91..67b6fea7 100644
--- a/i18n/en.i18n.json
+++ b/i18n/en.i18n.json
@@ -159,6 +159,9 @@
"confirm-checklist-delete-dialog": "Are you sure you want to delete checklist",
"copy-card-link-to-clipboard": "Copy card link to clipboard",
"copyCardPopup-title": "Copy Card",
+ "copyChecklistToManyCardsPopup-title": "Copy Checklist Template to Many Cards",
+ "copyChecklistToManyCardsPopup-instructions": "Destination Card Titles and Descriptions in this JSON format",
+ "copyChecklistToManyCardsPopup-format": "[ {\"title\": \"First card title\", \"description\":\"First card description\"}, {\"title\":\"Second card title\",\"description\":\"Second card description\"},{\"title\":\"Last card title\",\"description\":\"Last card description\"} ]",
"create": "Create",
"createBoardPopup-title": "Create Board",
"chooseBoardSourcePopup-title": "Import board",