diff options
author | Lauri Ojansivu <x@xet7.org> | 2020-06-16 18:03:20 +0300 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2020-06-16 18:03:20 +0300 |
commit | b1d1c7c45a08674732fe28edaf53aba9d8bd50b4 (patch) | |
tree | 31b7129c96844ea493a38a0d9911f81382516a24 /models | |
parent | e4de42d487b8d965276fdb7ce770cf58d562e766 (diff) | |
parent | 2353f654deae2aa747a45ce4bf16a5ca91c55e34 (diff) | |
download | wekan-b1d1c7c45a08674732fe28edaf53aba9d8bd50b4.tar.gz wekan-b1d1c7c45a08674732fe28edaf53aba9d8bd50b4.tar.bz2 wekan-b1d1c7c45a08674732fe28edaf53aba9d8bd50b4.zip |
Merge branch 'NicoP-S-master'
Diffstat (limited to 'models')
-rw-r--r-- | models/cards.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/models/cards.js b/models/cards.js index 2e297d63..1ccc836a 100644 --- a/models/cards.js +++ b/models/cards.js @@ -1112,6 +1112,21 @@ Cards.helpers({ return Users.find({ _id: { $in: this.vote.negative } }); return []; }, + voteState() { + const userId = Meteor.userId(); + let state; + if (this.vote) { + if (this.vote.positive) { + state = _.contains(this.vote.positive, userId); + if (state === true) return true; + } + if (this.vote.negative) { + state = _.contains(this.vote.negative, userId); + if (state === true) return false; + } + } + return null; + }, getId() { if (this.isLinked()) { @@ -2374,6 +2389,10 @@ if (Meteor.isServer) { * @param {boolean} [isOverTime] the new isOverTime field of the card * @param {string} [customFields] the new customFields value of the card * @param {string} [color] the new color of the card + * @param {Object} [vote] the vote object + * @param {string} vote.question the vote question + * @param {boolean} vote.public show who voted what + * @param {boolean} vote.allowNonBoardMembers allow all logged in users to vote? * @return_type {_id: string} */ JsonRoutes.add( @@ -2473,6 +2492,24 @@ if (Meteor.isServer) { { $set: { color: newColor } }, ); } + if (req.body.hasOwnProperty('vote')) { + const newVote = req.body.vote; + newVote.positive = []; + newVote.negative = []; + if (!newVote.hasOwnProperty('public')) newVote.public = false; + if (!newVote.hasOwnProperty('allowNonBoardMembers')) + newVote.allowNonBoardMembers = false; + + Cards.direct.update( + { + _id: paramCardId, + listId: paramListId, + boardId: paramBoardId, + archived: false, + }, + { $set: { vote: newVote } }, + ); + } if (req.body.hasOwnProperty('labelIds')) { let newlabelIds = req.body.labelIds; if (_.isString(newlabelIds)) { |