mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-02 11:59:17 -05:00
a737090442
- add User.staff scope - inject MessageBus into Ember views (so it can be used by the poll plugin) - REFACTOR: use more accurate is_first_post? method instead of post_number == 1 - FEATURE: add support for JSON-typed custom fields - FEATURE: allow plugins to add validation - FEATURE: add post_custom_fields to PostSerializer - FEATURE: allow plugins to whitelist post_custom_fields - FIX: don't bump when post did not save successfully - FEATURE: polls are supported in any post - FEATURE: allow for multiple polls in the same post - FEATURE: multiple choice polls - FEATURE: rating polls - FEATURE: new dialect allowing users to preview polls in the composer
25 lines
761 B
JavaScript
25 lines
761 B
JavaScript
export default Em.Component.extend({
|
|
tagName: "table",
|
|
classNames: ["results"],
|
|
|
|
options: function() {
|
|
const totalVotes = this.get("poll.total_votes"),
|
|
backgroundColor = this.get("poll.background");
|
|
|
|
this.get("poll.options").forEach(option => {
|
|
const percentage = Math.floor(100 * option.get("votes") / totalVotes),
|
|
styles = ["width: " + percentage + "%"];
|
|
|
|
if (backgroundColor) { styles.push("background: " + backgroundColor); }
|
|
|
|
option.setProperties({
|
|
percentage: percentage,
|
|
title: I18n.t("poll.option_title", { count: option.get("votes") }),
|
|
style: styles.join(";")
|
|
});
|
|
});
|
|
|
|
return this.get("poll.options");
|
|
}.property("poll.total_votes", "poll.options.[]")
|
|
|
|
});
|