Fixed wrong order of assignment votes caused by redis cache.

This commit is contained in:
Emanuel Schütze 2017-01-30 21:33:41 +01:00
parent 872f05ec31
commit 83e16b0b09
2 changed files with 19 additions and 4 deletions

View File

@ -33,7 +33,8 @@ angular.module('OpenSlidesApp.assignments', [])
_.forEach(this.votes, function (vote) { _.forEach(this.votes, function (vote) {
// Initial values for the vote // Initial values for the vote
var value = '', var order = '',
value = '',
percentStr = '', percentStr = '',
percentNumber; percentNumber;
@ -52,6 +53,19 @@ angular.module('OpenSlidesApp.assignments', [])
value = 0; // Vote was not defined. Set value to 0. value = 0; // Vote was not defined. Set value to 0.
} }
} }
switch (vote.value) {
case "Yes":
order = 1;
break;
case "No":
order = 2;
break;
case "Abstain":
order = 3;
break;
default:
order = 0;
}
// Special case where to skip percents // Special case where to skip percents
var skipPercents = config === 'YES_NO' && vote.value === 'Abstain'; var skipPercents = config === 'YES_NO' && vote.value === 'Abstain';
@ -61,13 +75,14 @@ angular.module('OpenSlidesApp.assignments', [])
percentStr = "(" + percentNumber + "%)"; percentStr = "(" + percentNumber + "%)";
} }
votes.push({ votes.push({
'order': order,
'label': gettextCatalog.getString(vote.value), 'label': gettextCatalog.getString(vote.value),
'value': value, 'value': value,
'percentStr': percentStr, 'percentStr': percentStr,
'percentNumber': percentNumber 'percentNumber': percentNumber
}); });
}); });
return votes; return _.sortBy(votes, 'order');
}, },
// Returns 0 or positive integer if quorum is reached or surpassed. // Returns 0 or positive integer if quorum is reached or surpassed.

View File

@ -48,11 +48,11 @@
<div ng-init="votes = option.getVotes()"> <div ng-init="votes = option.getVotes()">
<div ng-show="poll.pollmethod == 'yna' || poll.pollmethod == 'yn'"> <div ng-show="poll.pollmethod == 'yna' || poll.pollmethod == 'yn'">
<span ng-show="poll.pollmethod == 'yna'"> <span ng-show="poll.pollmethod == 'yna'">
{{ votes[0].label }}: <strong>{{ votes[0].value }}</strong> · {{ votes[0].label }}: {{ votes[0].value }} ·
{{ votes[1].label }}: {{ votes[1].value }} · {{ votes[1].label }}: {{ votes[1].value }} ·
{{ votes[2].label }}: {{ votes[2].value }} </span> {{ votes[2].label }}: {{ votes[2].value }} </span>
<span ng-show="poll.pollmethod == 'yn'"> <span ng-show="poll.pollmethod == 'yn'">
{{ votes[0].label }}: <strong>{{ votes[0].value }}</strong> · {{ votes[0].label }}: {{ votes[0].value }} ·
{{ votes[1].label }}: {{ votes[1].value }}</span> {{ votes[1].label }}: {{ votes[1].value }}</span>
<uib-progress ng-if="votes[0].percentNumber>=0"> <uib-progress ng-if="votes[0].percentNumber>=0">
<uib-bar value="votes[0].percentNumber" type="success"> <uib-bar value="votes[0].percentNumber" type="success">