summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorNico <paetni1@gmail.com>2020-06-11 19:52:44 +0200
committerNico <paetni1@gmail.com>2020-06-11 19:52:44 +0200
commit06b548f12ed853692db78dbbfbe7988382c0fdee (patch)
tree1919ad3963abb4591bde1eee4e4c1648a798e8ab /models
parent1617577378fc17ca09fd3ef34f24e02c2889aa9f (diff)
downloadwekan-06b548f12ed853692db78dbbfbe7988382c0fdee.tar.gz
wekan-06b548f12ed853692db78dbbfbe7988382c0fdee.tar.bz2
wekan-06b548f12ed853692db78dbbfbe7988382c0fdee.zip
edit_card start vote
better visibility what was voted
Diffstat (limited to 'models')
-rw-r--r--models/cards.js37
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)) {