summaryrefslogtreecommitdiffstats
path: root/models/cards.js
diff options
context:
space:
mode:
Diffstat (limited to 'models/cards.js')
-rw-r--r--models/cards.js33
1 files changed, 31 insertions, 2 deletions
diff --git a/models/cards.js b/models/cards.js
index ff19a9a0..c733c7f8 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -246,7 +246,7 @@ Cards.attachSchema(new SimpleSchema({
* type of the card
*/
type: String,
- defaultValue: '',
+ defaultValue: 'cardType-card',
},
linkedId: {
/**
@@ -272,6 +272,31 @@ Cards.allow({
});
Cards.helpers({
+ copy() {
+ const oldId = this._id;
+ delete this._id;
+ const _id = Cards.insert(this);
+
+ // copy checklists
+ Checklists.find({cardId: oldId}).forEach((ch) => {
+ ch.copy(_id);
+ });
+
+ // copy subtasks
+ Cards.find({parentId: oldId}).forEach((subtask) => {
+ subtask.parentId = _id;
+ subtask._id = null;
+ Cards.insert(subtask);
+ });
+
+ // copy card comments
+ CardComments.find({cardId: oldId}).forEach((cmt) => {
+ cmt.copy(_id);
+ });
+
+ return _id;
+ },
+
list() {
return Lists.findOne(this.listId);
},
@@ -930,6 +955,10 @@ Cards.helpers({
return this.assignedBy;
}
},
+
+ isTemplateCard() {
+ return this.type === 'template-card';
+ },
});
Cards.mutations({
@@ -1230,7 +1259,7 @@ Cards.mutations({
function cardMove(userId, doc, fieldNames, oldListId, oldSwimlaneId) {
if ((_.contains(fieldNames, 'listId') && doc.listId !== oldListId) ||
- (_.contains(fieldNames, 'swimlaneId') && doc.swimlaneId !== oldSwimlaneId)){
+ (_.contains(fieldNames, 'swimlaneId') && doc.swimlaneId !== oldSwimlaneId)){
Activities.insert({
userId,
oldListId,