mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-04 21:01:27 -05:00
26 lines
753 B
Text
26 lines
753 B
Text
|
import computed from 'ember-addons/ember-computed-decorators';
|
||
|
import User from 'discourse/models/user';
|
||
|
import PollVoters from 'discourse/plugins/poll/components/poll-voters';
|
||
|
|
||
|
export default PollVoters.extend({
|
||
|
@computed("pollsVoters", "option.voter_ids", "showMore", "isExpanded", "numOfVotersToShow")
|
||
|
users(pollsVoters, voterIds, showMore, isExpanded, numOfVotersToShow) {
|
||
|
var users = [];
|
||
|
|
||
|
if (showMore && !isExpanded) {
|
||
|
voterIds = voterIds.slice(0, numOfVotersToShow);
|
||
|
}
|
||
|
|
||
|
voterIds.forEach(voterId => {
|
||
|
users.push(pollsVoters[voterId]);
|
||
|
});
|
||
|
|
||
|
return users;
|
||
|
},
|
||
|
|
||
|
@computed("option.votes", "numOfVotersToShow")
|
||
|
showMore(numOfVotes, numOfVotersToShow) {
|
||
|
return !(numOfVotes < numOfVotersToShow);
|
||
|
}
|
||
|
});
|