mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01:00
edit_card start vote
better visibility what was voted
This commit is contained in:
parent
1617577378
commit
06b548f12e
5 changed files with 55 additions and 23 deletions
|
|
@ -220,8 +220,14 @@ template(name="cardDetails")
|
||||||
+viewer
|
+viewer
|
||||||
= getVoteQuestion
|
= getVoteQuestion
|
||||||
if showVotingButtons
|
if showVotingButtons
|
||||||
button.card-details-green.js-vote.js-vote-positive(class="{{#if voteState}}voted{{/if}}") {{_ 'vote-for-it'}}
|
button.card-details-green.js-vote.js-vote-positive(class="{{#if voteState}}voted{{/if}}")
|
||||||
button.card-details-red.js-vote.js-vote-negative(class="{{#if $eq voteState false}}voted{{/if}}") {{_ 'vote-against'}}
|
if voteState
|
||||||
|
i.fa.fa-thumbs-up
|
||||||
|
{{_ 'vote-for-it'}}
|
||||||
|
button.card-details-red.js-vote.js-vote-negative(class="{{#if $eq voteState false}}voted{{/if}}")
|
||||||
|
if $eq voteState false
|
||||||
|
i.fa.fa-thumbs-down
|
||||||
|
{{_ 'vote-against'}}
|
||||||
|
|
||||||
//- XXX We should use "editable" to avoid repetiting ourselves
|
//- XXX We should use "editable" to avoid repetiting ourselves
|
||||||
if canModifyCard
|
if canModifyCard
|
||||||
|
|
|
||||||
|
|
@ -38,22 +38,6 @@ BlazeComponent.extendComponent({
|
||||||
Meteor.subscribe('unsaved-edits');
|
Meteor.subscribe('unsaved-edits');
|
||||||
},
|
},
|
||||||
|
|
||||||
voteState() {
|
|
||||||
const card = this.currentData();
|
|
||||||
const userId = Meteor.userId();
|
|
||||||
let state;
|
|
||||||
if (card.vote) {
|
|
||||||
if (card.vote.positive) {
|
|
||||||
state = _.contains(card.vote.positive, userId);
|
|
||||||
if (state === true) return true;
|
|
||||||
}
|
|
||||||
if (card.vote.negative) {
|
|
||||||
state = _.contains(card.vote.negative, userId);
|
|
||||||
if (state === true) return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
isWatching() {
|
isWatching() {
|
||||||
const card = this.currentData();
|
const card = this.currentData();
|
||||||
return card.findWatcher(Meteor.userId());
|
return card.findWatcher(Meteor.userId());
|
||||||
|
|
@ -412,9 +396,9 @@ BlazeComponent.extendComponent({
|
||||||
const forIt = $(e.target).hasClass('js-vote-positive');
|
const forIt = $(e.target).hasClass('js-vote-positive');
|
||||||
let newState = null;
|
let newState = null;
|
||||||
if (
|
if (
|
||||||
this.voteState() === null ||
|
this.data().voteState() === null ||
|
||||||
(this.voteState() === false && forIt) ||
|
(this.data().voteState() === false && forIt) ||
|
||||||
(this.voteState() === true && !forIt)
|
(this.data().voteState() === true && !forIt)
|
||||||
) {
|
) {
|
||||||
newState = forIt;
|
newState = forIt;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,9 +106,9 @@ template(name="minicard")
|
||||||
span.badge-icon.fa.fa-align-left
|
span.badge-icon.fa.fa-align-left
|
||||||
if getVoteQuestion
|
if getVoteQuestion
|
||||||
.badge.badge-state-image-only(title=getVoteQuestion)
|
.badge.badge-state-image-only(title=getVoteQuestion)
|
||||||
span.badge-icon.fa.fa-thumbs-up
|
span.badge-icon.fa.fa-thumbs-up(class="{{#if voteState}}text-green{{/if}}")
|
||||||
span.badge-text {{ voteCountPositive }}
|
span.badge-text {{ voteCountPositive }}
|
||||||
span.badge-icon.fa.fa-thumbs-down
|
span.badge-icon.fa.fa-thumbs-down(class="{{#if $eq voteState false}}text-red{{/if}}")
|
||||||
span.badge-text {{ voteCountNegative }}
|
span.badge-text {{ voteCountNegative }}
|
||||||
if attachments.count
|
if attachments.count
|
||||||
.badge
|
.badge
|
||||||
|
|
|
||||||
|
|
@ -299,3 +299,8 @@ minicard-color(background, color...)
|
||||||
|
|
||||||
.minicard-indigo
|
.minicard-indigo
|
||||||
minicard-color(#4b0082, #ffffff) //White text for better visibility
|
minicard-color(#4b0082, #ffffff) //White text for better visibility
|
||||||
|
|
||||||
|
.text-red
|
||||||
|
color:red
|
||||||
|
.text-green
|
||||||
|
color:green
|
||||||
|
|
|
||||||
|
|
@ -1112,6 +1112,21 @@ Cards.helpers({
|
||||||
return Users.find({ _id: { $in: this.vote.negative } });
|
return Users.find({ _id: { $in: this.vote.negative } });
|
||||||
return [];
|
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() {
|
getId() {
|
||||||
if (this.isLinked()) {
|
if (this.isLinked()) {
|
||||||
|
|
@ -2374,6 +2389,10 @@ if (Meteor.isServer) {
|
||||||
* @param {boolean} [isOverTime] the new isOverTime field of the card
|
* @param {boolean} [isOverTime] the new isOverTime field of the card
|
||||||
* @param {string} [customFields] the new customFields value of the card
|
* @param {string} [customFields] the new customFields value of the card
|
||||||
* @param {string} [color] the new color 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}
|
* @return_type {_id: string}
|
||||||
*/
|
*/
|
||||||
JsonRoutes.add(
|
JsonRoutes.add(
|
||||||
|
|
@ -2473,6 +2492,24 @@ if (Meteor.isServer) {
|
||||||
{ $set: { color: newColor } },
|
{ $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')) {
|
if (req.body.hasOwnProperty('labelIds')) {
|
||||||
let newlabelIds = req.body.labelIds;
|
let newlabelIds = req.body.labelIds;
|
||||||
if (_.isString(newlabelIds)) {
|
if (_.isString(newlabelIds)) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue