diff options
author | Andrés Manelli <andresmanelli@gmail.com> | 2018-04-17 23:17:44 -0300 |
---|---|---|
committer | Andrés Manelli <andresmanelli@gmail.com> | 2018-08-11 00:07:29 +0200 |
commit | 724d26379c33afc2c3d44d3722b0c5c35c1b80ed (patch) | |
tree | 7678c5b0769bda94ea2237451989e8c7ece3f637 /models | |
parent | 0a62089df02b2ab308d4749a837e08c4164cb770 (diff) | |
download | wekan-724d26379c33afc2c3d44d3722b0c5c35c1b80ed.tar.gz wekan-724d26379c33afc2c3d44d3722b0c5c35c1b80ed.tar.bz2 wekan-724d26379c33afc2c3d44d3722b0c5c35c1b80ed.zip |
Add two way binding of card/board times
Diffstat (limited to 'models')
-rw-r--r-- | models/boards.js | 22 | ||||
-rw-r--r-- | models/cards.js | 161 |
2 files changed, 182 insertions, 1 deletions
diff --git a/models/boards.js b/models/boards.js index d5ccc954..a37981e0 100644 --- a/models/boards.js +++ b/models/boards.js @@ -177,6 +177,28 @@ Boards.attachSchema(new SimpleSchema({ optional: true, defaultValue: 'no-parent', }, + startAt: { + type: Date, + optional: true, + }, + dueAt: { + type: Date, + optional: true, + }, + endAt: { + type: Date, + optional: true, + }, + spentTime: { + type: Number, + decimal: true, + optional: true, + }, + isOvertime: { + type: Boolean, + defaultValue: false, + optional: true, + }, })); diff --git a/models/cards.js b/models/cards.js index de868dde..710b9d85 100644 --- a/models/cards.js +++ b/models/cards.js @@ -494,6 +494,166 @@ Cards.helpers({ return this.assignMember(memberId); } }, + + getReceived() { + if (this.isImportedCard()) { + const card = Cards.findOne({_id: this.importedId}); + return card.receivedAt; + } else { + return this.receivedAt; + } + }, + + setReceived(receivedAt) { + if (this.isImportedCard()) { + return Cards.update( + {_id: this.importedId}, + {$set: {receivedAt}} + ); + } else { + return {$set: {receivedAt}}; + } + }, + + getStart() { + if (this.isImportedCard()) { + const card = Cards.findOne({_id: this.importedId}); + return card.startAt; + } else if (this.isImportedBoard()) { + const board = Boards.findOne({_id: this.importedId}); + return board.startAt + } else { + return this.startAt; + } + }, + + setStart(startAt) { + if (this.isImportedCard()) { + return Cards.update( + { _id: this.importedId }, + {$set: {startAt}} + ); + } else if (this.isImportedBoard()) { + return Boards.update( + {_id: this.importedId}, + {$set: {startAt}} + ); + } else { + return {$set: {startAt}}; + } + }, + + getDue() { + if (this.isImportedCard()) { + const card = Cards.findOne({_id: this.importedId}); + return card.dueAt; + } else if (this.isImportedBoard()) { + const board = Boards.findOne({_id: this.importedId}); + return board.dueAt + } else { + return this.dueAt; + } + }, + + setDue(dueAt) { + if (this.isImportedCard()) { + return Cards.update( + { _id: this.importedId }, + {$set: {dueAt}} + ); + } else if (this.isImportedBoard()) { + return Boards.update( + {_id: this.importedId}, + {$set: {dueAt}} + ); + } else { + return {$set: {dueAt}}; + } + }, + + getEnd() { + if (this.isImportedCard()) { + const card = Cards.findOne({_id: this.importedId}); + return card.endAt; + } else if (this.isImportedBoard()) { + const board = Boards.findOne({_id: this.importedId}); + return board.endAt; + } else { + return this.endAt; + } + }, + + setEnd(endAt) { + if (this.isImportedCard()) { + return Cards.update( + { _id: this.importedId }, + {$set: {endAt}} + ); + } else if (this.isImportedBoard()) { + return Boards.update( + {_id: this.importedId}, + {$set: {endAt}} + ); + } else { + return {$set: {endAt}}; + } + }, + + getIsOvertime() { + if (this.isImportedCard()) { + const card = Cards.findOne({ _id: this.importedId }); + return card.isOvertime; + } else if (this.isImportedBoard()) { + const board = Boards.findOne({ _id: this.importedId}); + return board.isOvertime; + } else { + return this.isOvertime; + } + }, + + setIsOvertime(isOvertime) { + if (this.isImportedCard()) { + return Cards.update( + { _id: this.importedId }, + {$set: {isOvertime}} + ); + } else if (this.isImportedBoard()) { + return Boards.update( + {_id: this.importedId}, + {$set: {isOvertime}} + ); + } else { + return {$set: {isOvertime}}; + } + }, + + getSpentTime() { + if (this.isImportedCard()) { + const card = Cards.findOne({ _id: this.importedId }); + return card.spentTime; + } else if (this.isImportedBoard()) { + const board = Boards.findOne({ _id: this.importedId}); + return board.spentTime; + } else { + return this.spentTime; + } + }, + + setSpentTime(spentTime) { + if (this.isImportedCard()) { + return Cards.update( + { _id: this.importedId }, + {$set: {spentTime}} + ); + } else if (this.isImportedBoard()) { + return Boards.update( + {_id: this.importedId}, + {$set: {spentTime}} + ); + } else { + return {$set: {spentTime}}; + } + }, }); Cards.mutations({ @@ -657,7 +817,6 @@ Cards.mutations({ setParentId(parentId) { return {$set: {parentId}}; }, - }); |