summaryrefslogtreecommitdiffstats
path: root/models/boards.js
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2018-07-06 01:14:53 +0300
committerLauri Ojansivu <x@xet7.org>2018-07-06 01:14:53 +0300
commitaaae3150c4b82b50e4e7adb86f573cd56f7277a7 (patch)
treea9a3d91e9297b1975b1f62a18f8968a2b6fa9b95 /models/boards.js
parentf4eac833ed5843816a760af49227bdaf87e25995 (diff)
parent5220111822913bbaa0378d5272f66608aad7b097 (diff)
downloadwekan-aaae3150c4b82b50e4e7adb86f573cd56f7277a7.tar.gz
wekan-aaae3150c4b82b50e4e7adb86f573cd56f7277a7.tar.bz2
wekan-aaae3150c4b82b50e4e7adb86f573cd56f7277a7.zip
Merge branch 'devel'
Diffstat (limited to 'models/boards.js')
-rw-r--r--models/boards.js102
1 files changed, 102 insertions, 0 deletions
diff --git a/models/boards.js b/models/boards.js
index 3b6c280b..76a8f704 100644
--- a/models/boards.js
+++ b/models/boards.js
@@ -151,6 +151,32 @@ Boards.attachSchema(new SimpleSchema({
type: String,
optional: true,
},
+ subtasksDefaultBoardId: {
+ type: String,
+ optional: true,
+ defaultValue: null,
+ },
+ subtasksDefaultListId: {
+ type: String,
+ optional: true,
+ defaultValue: null,
+ },
+ allowsSubtasks: {
+ type: Boolean,
+ defaultValue: true,
+ },
+ presentParentTask: {
+ type: String,
+ allowedValues: [
+ 'prefix-with-full-path',
+ 'prefix-with-parent',
+ 'subtext-with-full-path',
+ 'subtext-with-parent',
+ 'no-parent',
+ ],
+ optional: true,
+ defaultValue: 'no-parent',
+ },
}));
@@ -194,6 +220,10 @@ Boards.helpers({
return Swimlanes.find({ boardId: this._id, archived: false }, { sort: { sort: 1 } });
},
+ cards() {
+ return Cards.find({ boardId: this._id, archived: false }, { sort: { sort: 1 } });
+ },
+
hasOvertimeCards(){
const card = Cards.findOne({isOvertime: true, boardId: this._id, archived: false} );
return card !== undefined;
@@ -284,6 +314,61 @@ 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 === undefined)) {
+ 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 === undefined)) {
+ this.subtasksDefaultListId = Lists.insert({
+ title: TAPi18n.__('queue'),
+ boardId: this._id,
+ });
+ Boards.update(this._id, {$set: {
+ subtasksDefaultListId: this.subtasksDefaultListId,
+ }});
+ }
+ return this.subtasksDefaultListId;
+ },
+
+ getDefaultSubtasksList() {
+ return Lists.findOne(this.getDefaultSubtasksListId());
+ },
+
+ getDefaultSwimline() {
+ let result = Swimlanes.findOne({boardId: this._id});
+ if (result === undefined) {
+ Swimlanes.insert({
+ title: TAPi18n.__('default'),
+ boardId: this._id,
+ });
+ result = Swimlanes.findOne({boardId: this._id});
+ }
+ return result;
+ },
cardsInInterval(start, end) {
return Cards.find({
@@ -313,6 +398,7 @@ Boards.helpers({
});
+
Boards.mutations({
archive() {
return { $set: { archived: true } };
@@ -434,6 +520,22 @@ Boards.mutations({
},
};
},
+
+ setAllowsSubtasks(allowsSubtasks) {
+ return { $set: { allowsSubtasks } };
+ },
+
+ setSubtasksDefaultBoardId(subtasksDefaultBoardId) {
+ return { $set: { subtasksDefaultBoardId } };
+ },
+
+ setSubtasksDefaultListId(subtasksDefaultListId) {
+ return { $set: { subtasksDefaultListId } };
+ },
+
+ setPresentParentTask(presentParentTask) {
+ return { $set: { presentParentTask } };
+ },
});
if (Meteor.isServer) {