mirror of
https://github.com/wekan/wekan.git
synced 2026-01-02 15:48:49 +01:00
Additional vote features
This commit is contained in:
parent
fe7398faef
commit
7bb0aa7488
5 changed files with 62 additions and 32 deletions
|
|
@ -340,6 +340,10 @@ Cards.attachSchema(
|
|||
type: Boolean,
|
||||
defaultValue: false,
|
||||
},
|
||||
'vote.allowNonBoardMembers': {
|
||||
type: Boolean,
|
||||
defaultValue: false,
|
||||
},
|
||||
}),
|
||||
);
|
||||
|
||||
|
|
@ -347,8 +351,8 @@ Cards.allow({
|
|||
insert(userId, doc) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
||||
},
|
||||
update(userId, doc) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
||||
update(userId, doc, fields) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(doc.boardId)) || _.isEqual(fields, ['vote', 'modifiedAt', 'dateLastActivity']);
|
||||
},
|
||||
remove(userId, doc) {
|
||||
return allowIsBoardMember(userId, Boards.findOne(doc.boardId));
|
||||
|
|
@ -732,7 +736,7 @@ Cards.helpers({
|
|||
|
||||
parentString(sep) {
|
||||
return this.parentList()
|
||||
.map(function(elem) {
|
||||
.map(function (elem) {
|
||||
return elem.title;
|
||||
})
|
||||
.join(sep);
|
||||
|
|
@ -1152,6 +1156,26 @@ Cards.helpers({
|
|||
isTemplateCard() {
|
||||
return this.type === 'template-card';
|
||||
},
|
||||
|
||||
votePublic() {
|
||||
if (this.vote) return this.vote.public;
|
||||
return null;
|
||||
},
|
||||
voteAllowNonBoardMembers() {
|
||||
if (this.vote) return this.vote.allowNonBoardMembers;
|
||||
return null;
|
||||
},
|
||||
voteCountNegative() {
|
||||
if (this.vote && this.vote.negative) return this.vote.negative.length;
|
||||
return null;
|
||||
},
|
||||
voteCountPositive() {
|
||||
if (this.vote && this.vote.positive) return this.vote.positive.length;
|
||||
return null;
|
||||
},
|
||||
voteCount() {
|
||||
return this.voteCountPositive() + this.voteCountNegative()
|
||||
},
|
||||
});
|
||||
|
||||
Cards.mutations({
|
||||
|
|
@ -1475,12 +1499,13 @@ Cards.mutations({
|
|||
},
|
||||
};
|
||||
},
|
||||
setVoteQuestion(question, public) {
|
||||
setVoteQuestion(question, public, allowNonBoardMembers) {
|
||||
return {
|
||||
$set: {
|
||||
vote: {
|
||||
question,
|
||||
public,
|
||||
allowNonBoardMembers,
|
||||
positive: [],
|
||||
negative: [],
|
||||
},
|
||||
|
|
@ -1929,7 +1954,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;
|
||||
|
|
@ -1975,7 +2000,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(
|
||||
|
|
@ -2029,7 +2054,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);
|
||||
|
|
@ -2039,7 +2064,7 @@ if (Meteor.isServer) {
|
|||
boardId: paramBoardId,
|
||||
swimlaneId: paramSwimlaneId,
|
||||
archived: false,
|
||||
}).map(function(doc) {
|
||||
}).map(function (doc) {
|
||||
return {
|
||||
_id: doc._id,
|
||||
title: doc.title,
|
||||
|
|
@ -2063,7 +2088,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,
|
||||
) {
|
||||
|
|
@ -2076,7 +2101,7 @@ if (Meteor.isServer) {
|
|||
boardId: paramBoardId,
|
||||
listId: paramListId,
|
||||
archived: false,
|
||||
}).map(function(doc) {
|
||||
}).map(function (doc) {
|
||||
return {
|
||||
_id: doc._id,
|
||||
title: doc.title,
|
||||
|
|
@ -2098,7 +2123,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;
|
||||
|
|
@ -2130,7 +2155,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,
|
||||
) {
|
||||
|
|
@ -2237,7 +2262,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;
|
||||
|
|
@ -2536,7 +2561,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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue