diff options
author | Nicu Tofan <nicu.tofan@gmail.com> | 2018-06-23 23:22:38 +0300 |
---|---|---|
committer | Nicu Tofan <nicu.tofan@gmail.com> | 2018-06-26 14:32:49 +0300 |
commit | 5a023e431504f7573723db6e0d2262ecb1fc61c5 (patch) | |
tree | 46ac0e238fddc5e797eca27cc2545ad5975f86a9 /models | |
parent | adb7f5b2ca9e8394db314f7ff97d0d0f811c51c0 (diff) | |
download | wekan-5a023e431504f7573723db6e0d2262ecb1fc61c5.tar.gz wekan-5a023e431504f7573723db6e0d2262ecb1fc61c5.tar.bz2 wekan-5a023e431504f7573723db6e0d2262ecb1fc61c5.zip |
Can add cards as subtasks
Diffstat (limited to 'models')
-rw-r--r-- | models/boards.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/models/boards.js b/models/boards.js index 911d82a1..6836a320 100644 --- a/models/boards.js +++ b/models/boards.js @@ -151,6 +151,16 @@ Boards.attachSchema(new SimpleSchema({ type: String, optional: true, }, + subtasksDefaultBoardId: { + type: String, + optional: true, + defaultValue: null, + }, + subtasksDefaultListId: { + type: String, + optional: true, + defaultValue: null, + }, })); @@ -284,8 +294,52 @@ Boards.helpers({ return Cards.find(query, projection); }, + // A board alwasy has another board where it deposits subtasks of thasks + // that belong to itself. + getDefaultSubtasksBoardId() { + if (this.subtasksDefaultBoardId === null) { + this.subtasksDefaultBoardId = Boards.insert({ + title: `^${this.title}^`, + permission: this.permission, + members: this.members, + color: this.color, + description: TAPi18n.__('default-subtasks-board', {board: this.title}), + }); + + Swimlanes.insert({ + title: TAPi18n.__('default'), + boardId: this.subtasksDefaultBoardId, + }); + Boards.update(this._id, {$set: { + subtasksDefaultBoardId: this.subtasksDefaultBoardId, + }}); + } + return this.subtasksDefaultBoardId; + }, + + getDefaultSubtasksBoard() { + return Boards.findOne(this.getDefaultSubtasksBoardId()); + }, + + getDefaultSubtasksListId() { + if (this.subtasksDefaultListId === null) { + this.subtasksDefaultListId = Lists.insert({ + title: TAPi18n.__('new'), + boardId: this._id, + }); + Boards.update(this._id, {$set: { + subtasksDefaultListId: this.subtasksDefaultListId, + }}); + } + return this.subtasksDefaultListId; + }, + + getDefaultSubtasksList() { + return Lists.findOne(this.getDefaultSubtasksListId()); + }, }); + Boards.mutations({ archive() { return { $set: { archived: true } }; |