summaryrefslogtreecommitdiffstats
path: root/models/cards.js
diff options
context:
space:
mode:
authorNico <paetni1@gmail.com>2020-04-10 01:46:36 +0200
committerNico <paetni1@gmail.com>2020-04-10 01:46:36 +0200
commit8f28a409c7dd90319f785e3fc4c1b26803f67f31 (patch)
tree895c3522d86a7dbc1e8225586bbcfc4b10ae039f /models/cards.js
parente661d03e8d7ea8c1d2190de2c7c59eaf0700534b (diff)
downloadwekan-8f28a409c7dd90319f785e3fc4c1b26803f67f31.tar.gz
wekan-8f28a409c7dd90319f785e3fc4c1b26803f67f31.tar.bz2
wekan-8f28a409c7dd90319f785e3fc4c1b26803f67f31.zip
Public vote
Diffstat (limited to 'models/cards.js')
-rw-r--r--models/cards.js56
1 files changed, 44 insertions, 12 deletions
diff --git a/models/cards.js b/models/cards.js
index 94b174bb..5a812679 100644
--- a/models/cards.js
+++ b/models/cards.js
@@ -336,6 +336,10 @@ Cards.attachSchema(
optional: true,
defaultValue: null,
},
+ 'vote.public': {
+ type: Boolean,
+ defaultValue: false,
+ },
}),
);
@@ -728,7 +732,7 @@ Cards.helpers({
parentString(sep) {
return this.parentList()
- .map(function(elem) {
+ .map(function (elem) {
return elem.title;
})
.join(sep);
@@ -1028,6 +1032,33 @@ Cards.helpers({
}
},
+ getVotePublic() {
+ if (this.isLinkedCard()) {
+ const card = Cards.findOne({ _id: this.linkedId });
+ if (card && card.vote) return card.vote.public;
+ else return null;
+ } else if (this.isLinkedBoard()) {
+ const board = Boards.findOne({ _id: this.linkedId });
+ if (board && board.vote) return board.vote.public;
+ else return null;
+ } else if (this.vote) {
+ return this.vote.public;
+ } else {
+ return null;
+ }
+ },
+
+ voteMemberPositive() {
+ if (this.vote && this.vote.positive)
+ return Users.find({ _id: { $in: this.vote.positive } })
+ return []
+ },
+ voteMemberNegative() {
+ if (this.vote && this.vote.negative)
+ return Users.find({ _id: { $in: this.vote.negative } })
+ return []
+ },
+
getId() {
if (this.isLinked()) {
return this.linkedId;
@@ -1444,11 +1475,12 @@ Cards.mutations({
},
};
},
- setVoteQuestion(question) {
+ setVoteQuestion(question, public) {
return {
$set: {
vote: {
question,
+ public,
positive: [],
negative: [],
},
@@ -1897,7 +1929,7 @@ if (Meteor.isServer) {
});
//New activity for card moves
- Cards.after.update(function(userId, doc, fieldNames) {
+ Cards.after.update(function (userId, doc, fieldNames) {
const oldListId = this.previous.listId;
const oldSwimlaneId = this.previous.swimlaneId;
const oldBoardId = this.previous.boardId;
@@ -1943,7 +1975,7 @@ if (Meteor.isServer) {
// change list modifiedAt, when user modified the key values in timingaction array, if it's endAt, put the modifiedAt of list back to one year ago for sorting purpose
const modifiedAt = new Date(
new Date(value).getTime() -
- (action === 'endAt' ? 365 * 24 * 3600 * 1e3 : 0),
+ (action === 'endAt' ? 365 * 24 * 3600 * 1e3 : 0),
); // set it as 1 year before
const boardId = list.boardId;
Lists.direct.update(
@@ -1997,7 +2029,7 @@ if (Meteor.isServer) {
JsonRoutes.add(
'GET',
'/api/boards/:boardId/swimlanes/:swimlaneId/cards',
- function(req, res) {
+ function (req, res) {
const paramBoardId = req.params.boardId;
const paramSwimlaneId = req.params.swimlaneId;
Authentication.checkBoardAccess(req.userId, paramBoardId);
@@ -2007,7 +2039,7 @@ if (Meteor.isServer) {
boardId: paramBoardId,
swimlaneId: paramSwimlaneId,
archived: false,
- }).map(function(doc) {
+ }).map(function (doc) {
return {
_id: doc._id,
title: doc.title,
@@ -2031,7 +2063,7 @@ if (Meteor.isServer) {
* title: string,
* description: string}]
*/
- JsonRoutes.add('GET', '/api/boards/:boardId/lists/:listId/cards', function(
+ JsonRoutes.add('GET', '/api/boards/:boardId/lists/:listId/cards', function (
req,
res,
) {
@@ -2044,7 +2076,7 @@ if (Meteor.isServer) {
boardId: paramBoardId,
listId: paramListId,
archived: false,
- }).map(function(doc) {
+ }).map(function (doc) {
return {
_id: doc._id,
title: doc.title,
@@ -2066,7 +2098,7 @@ if (Meteor.isServer) {
JsonRoutes.add(
'GET',
'/api/boards/:boardId/lists/:listId/cards/:cardId',
- function(req, res) {
+ function (req, res) {
const paramBoardId = req.params.boardId;
const paramListId = req.params.listId;
const paramCardId = req.params.cardId;
@@ -2098,7 +2130,7 @@ if (Meteor.isServer) {
* @param {string} [assignees] the array of maximum one ID of assignee of the new card
* @return_type {_id: string}
*/
- JsonRoutes.add('POST', '/api/boards/:boardId/lists/:listId/cards', function(
+ JsonRoutes.add('POST', '/api/boards/:boardId/lists/:listId/cards', function (
req,
res,
) {
@@ -2205,7 +2237,7 @@ if (Meteor.isServer) {
JsonRoutes.add(
'PUT',
'/api/boards/:boardId/lists/:listId/cards/:cardId',
- function(req, res) {
+ function (req, res) {
Authentication.checkUserId(req.userId);
const paramBoardId = req.params.boardId;
const paramCardId = req.params.cardId;
@@ -2504,7 +2536,7 @@ if (Meteor.isServer) {
JsonRoutes.add(
'DELETE',
'/api/boards/:boardId/lists/:listId/cards/:cardId',
- function(req, res) {
+ function (req, res) {
Authentication.checkUserId(req.userId);
const paramBoardId = req.params.boardId;
const paramListId = req.params.listId;