summaryrefslogtreecommitdiffstats
path: root/models/swimlanes.js
diff options
context:
space:
mode:
Diffstat (limited to 'models/swimlanes.js')
-rw-r--r--models/swimlanes.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/models/swimlanes.js b/models/swimlanes.js
index be3f617c..205f1498 100644
--- a/models/swimlanes.js
+++ b/models/swimlanes.js
@@ -101,6 +101,23 @@ Swimlanes.allow({
});
Swimlanes.helpers({
+ copy() {
+ const oldId = this._id;
+ this._id = null;
+ const _id = Swimlanes.insert(this);
+
+ // Copy all lists in swimlane
+ Lists.find({
+ swimlaneId: oldId,
+ archived: false,
+ }).forEach((list) => {
+ list.type = 'list';
+ list.swimlaneId = _id;
+ list.boardId = this.boardId;
+ list.copy();
+ });
+ },
+
cards() {
return Cards.find(Filter.mongoSelector({
swimlaneId: this._id,
@@ -115,6 +132,10 @@ Swimlanes.helpers({
}), { sort: ['sort'] });
},
+ allLists() {
+ return Lists.find({ swimlaneId: this._id });
+ },
+
allCards() {
return Cards.find({ swimlaneId: this._id });
},
@@ -159,10 +180,20 @@ Swimlanes.mutations({
},
archive() {
+ if (this.isTemplateSwimlane()) {
+ this.lists().forEach((list) => {
+ return list.archive();
+ });
+ }
return { $set: { archived: true } };
},
restore() {
+ if (this.isTemplateSwimlane()) {
+ this.allLists().forEach((list) => {
+ return list.restore();
+ });
+ }
return { $set: { archived: false } };
},