summaryrefslogtreecommitdiffstats
path: root/client/components/cards/cardDetails.js
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2017-09-09 01:12:15 +0300
committerLauri Ojansivu <x@xet7.org>2017-09-09 01:12:15 +0300
commitce98c86fb39793b1f9d72955ce9ac312b9bd5c9e (patch)
treeda1586d1d3c551aafdcd22e32e3e9b708042a248 /client/components/cards/cardDetails.js
parent5d12423b9dc79d8a26031c11082f47ce21e3049f (diff)
parent95c11415e25ee09d712fd783a163d205db281d59 (diff)
downloadwekan-ce98c86fb39793b1f9d72955ce9ac312b9bd5c9e.tar.gz
wekan-ce98c86fb39793b1f9d72955ce9ac312b9bd5c9e.tar.bz2
wekan-ce98c86fb39793b1f9d72955ce9ac312b9bd5c9e.zip
Merge branch 'frmwrk123-issue-519' into devel
Copy card within one board. Thanks to frmwrk123 !
Diffstat (limited to 'client/components/cards/cardDetails.js')
-rw-r--r--client/components/cards/cardDetails.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/client/components/cards/cardDetails.js b/client/components/cards/cardDetails.js
index 401a35ec..7c6c3ce7 100644
--- a/client/components/cards/cardDetails.js
+++ b/client/components/cards/cardDetails.js
@@ -157,6 +157,7 @@ Template.cardDetailsActionsPopup.events({
'click .js-start-date': Popup.open('editCardStartDate'),
'click .js-due-date': Popup.open('editCardDueDate'),
'click .js-move-card': Popup.open('moveCard'),
+ 'click .js-copy-card': Popup.open('copyCard'),
'click .js-move-card-to-top' (evt) {
evt.preventDefault();
const minOrder = _.min(this.list().cards().map((c) => c.sort));
@@ -206,6 +207,50 @@ Template.moveCardPopup.events({
},
});
+Template.copyCardPopup.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 textarea = $(evt.currentTarget).parents('.content').find('textarea');
+ const title = textarea.val().trim();
+ // insert new card to the bottom of new list
+ card.sort = Lists.findOne(this._id).cards().count();
+
+ if (title) {
+ card.title = title;
+ 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: