diff options
author | Andrés Manelli <andresmanelli@gmail.com> | 2018-04-18 02:30:24 -0300 |
---|---|---|
committer | Andrés Manelli <andresmanelli@gmail.com> | 2018-08-11 00:14:13 +0200 |
commit | 37306c8d2244c33aa924de375f2e17f438117d54 (patch) | |
tree | c0147504109f2fc7728a6b33e9d64c43b38d996d /models | |
parent | 4ffa8784a25913fda5ba2046b7e5d179569e5af8 (diff) | |
download | wekan-37306c8d2244c33aa924de375f2e17f438117d54.tar.gz wekan-37306c8d2244c33aa924de375f2e17f438117d54.tar.bz2 wekan-37306c8d2244c33aa924de375f2e17f438117d54.zip |
Add title binding
Diffstat (limited to 'models')
-rw-r--r-- | models/cards.js | 107 |
1 files changed, 31 insertions, 76 deletions
diff --git a/models/cards.js b/models/cards.js index b295a4fe..c48c5fa1 100644 --- a/models/cards.js +++ b/models/cards.js @@ -693,6 +693,37 @@ Cards.helpers({ ); } }, + + getTitle() { + if (this.isImportedCard()) { + const card = Cards.findOne({ _id: this.importedId }); + return card.title; + } else if (this.isImportedBoard()) { + const board = Boards.findOne({ _id: this.importedId}); + return board.title; + } else { + return this.title; + } + }, + + setTitle(title) { + if (this.isImportedCard()) { + return Cards.update( + { _id: this.importedId }, + {$set: {title}} + ); + } else if (this.isImportedBoard()) { + return Boards.update( + {_id: this.importedId}, + {$set: {title}} + ); + } else { + return Cards.update( + {_id: this._id}, + {$set: {title}} + ); + } + }, }); Cards.mutations({ @@ -712,22 +743,6 @@ Cards.mutations({ return {$set: {archived: false}}; }, - setTitle(title) { - return {$set: {title}}; - }, - - setDescription(description) { - return {$set: {description}}; - }, - - setRequestedBy(requestedBy) { - return {$set: {requestedBy}}; - }, - - setAssignedBy(assignedBy) { - return {$set: {assignedBy}}; - }, - move(swimlaneId, listId, sortIndex) { const list = Lists.findOne(listId); const mutatedFields = { @@ -756,22 +771,6 @@ Cards.mutations({ } }, - assignMember(memberId) { - return {$addToSet: {members: memberId}}; - }, - - unassignMember(memberId) { - return {$pull: {members: memberId}}; - }, - - toggleMember(memberId) { - if (this.members && this.members.indexOf(memberId) > -1) { - return this.unassignMember(memberId); - } else { - return this.assignMember(memberId); - } - }, - assignCustomField(customFieldId) { return {$addToSet: {customFields: {_id: customFieldId, value: null}}}; }, @@ -809,50 +808,6 @@ Cards.mutations({ return {$unset: {coverId: ''}}; }, - setReceived(receivedAt) { - return {$set: {receivedAt}}; - }, - - unsetReceived() { - return {$unset: {receivedAt: ''}}; - }, - - setStart(startAt) { - return {$set: {startAt}}; - }, - - unsetStart() { - return {$unset: {startAt: ''}}; - }, - - setDue(dueAt) { - return {$set: {dueAt}}; - }, - - unsetDue() { - return {$unset: {dueAt: ''}}; - }, - - setEnd(endAt) { - return {$set: {endAt}}; - }, - - unsetEnd() { - return {$unset: {endAt: ''}}; - }, - - setOvertime(isOvertime) { - return {$set: {isOvertime}}; - }, - - setSpentTime(spentTime) { - return {$set: {spentTime}}; - }, - - unsetSpentTime() { - return {$unset: {spentTime: '', isOvertime: false}}; - }, - setParentId(parentId) { return {$set: {parentId}}; }, |