FEATURE: Allow poll results to be sorted.
This commit is contained in:
@@ -7,7 +7,9 @@ export default Em.Component.extend({
|
||||
|
||||
@computed("poll.voters", "poll.type", "poll.options.[]")
|
||||
options(voters, type) {
|
||||
const options = this.get("poll.options");
|
||||
const options = this.get("poll.options").slice(0).sort((a, b) => {
|
||||
return a.get("votes") < b.get("votes") ? 1 : 0;
|
||||
});
|
||||
|
||||
let percentages = voters === 0 ?
|
||||
Array(options.length).fill(0) :
|
||||
@@ -35,5 +37,4 @@ export default Em.Component.extend({
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -40,10 +40,8 @@ export default Ember.Component.extend({
|
||||
didInsertElement() {
|
||||
this._super();
|
||||
|
||||
Ember.run.schedule("afterRender", () => {
|
||||
this.set("numOfVotersToShow", Math.round(this.$().width() / 25) * 2);
|
||||
if (this.get("voterIds").length > 0) this._fetchUsers();
|
||||
});
|
||||
this.set("numOfVotersToShow", Math.round(this.$().width() / 25) * 2);
|
||||
if (this.get("voterIds").length > 0) this._fetchUsers();
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
||||
Reference in New Issue
Block a user