diff --git a/plugins/poll/assets/javascripts/controllers/poll-ui-builder.js.es6 b/plugins/poll/assets/javascripts/controllers/poll-ui-builder.js.es6 index 3bb34f21d..61e703e74 100644 --- a/plugins/poll/assets/javascripts/controllers/poll-ui-builder.js.es6 +++ b/plugins/poll/assets/javascripts/controllers/poll-ui-builder.js.es6 @@ -2,27 +2,32 @@ import { default as computed, observes } from 'ember-addons/ember-computed-decor export default Ember.Controller.extend({ needs: ['modal'], + numberPollType: 'number', + multiplePollType: 'multiple', init() { this._super(); this._setupPoll(); }, - @computed - pollTypes() { - return [I18n.t("poll.ui_builder.poll_type.number"), I18n.t("poll.ui_builder.poll_type.multiple")].map(type => { - return { name: type, value: type }; - }); + @computed("numberPollType", "multiplePollType") + pollTypes(numberPollType, multiplePollType) { + let types = []; + + types.push({ name: I18n.t("poll.ui_builder.poll_type.number"), value: numberPollType }); + types.push({ name: I18n.t("poll.ui_builder.poll_type.multiple"), value: multiplePollType }); + + return types; }, - @computed("pollType", "pollOptionsCount") - isMultiple(pollType, count) { - return (pollType === I18n.t("poll.ui_builder.poll_type.multiple")) && count > 0; + @computed("pollType", "pollOptionsCount", "multiplePollType") + isMultiple(pollType, count, multiplePollType) { + return (pollType === multiplePollType) && count > 0; }, - @computed("pollType") - isNumber(pollType) { - return pollType === I18n.t("poll.ui_builder.poll_type.number"); + @computed("pollType", "numberPollType") + isNumber(pollType, numberPollType) { + return pollType === numberPollType; }, @computed("isNumber", "isMultiple") diff --git a/plugins/poll/test/javascripts/controllers/poll-ui-builder-test.js.es6 b/plugins/poll/test/javascripts/controllers/poll-ui-builder-test.js.es6 index ccbeb20e9..02c4ad8d0 100644 --- a/plugins/poll/test/javascripts/controllers/poll-ui-builder-test.js.es6 +++ b/plugins/poll/test/javascripts/controllers/poll-ui-builder-test.js.es6 @@ -6,7 +6,7 @@ test("isMultiple", function() { const controller = this.subject(); controller.setProperties({ - pollType: I18n.t("poll.ui_builder.poll_type.multiple"), + pollType: controller.get("multiplePollType"), pollOptionsCount: 1 }); @@ -29,7 +29,7 @@ test("isNumber", function() { equal(controller.get("isNumber"), false, "it should be false"); - controller.set("pollType", I18n.t("poll.ui_builder.poll_type.number")); + controller.set("pollType", controller.get("numberPollType")); equal(controller.get("isNumber"), true, "it should be true"); }); @@ -159,7 +159,7 @@ test("number pollOutput", function() { controller.setProperties({ isNumber: true, - pollType: I18n.t("poll.ui_builder.poll_type.number"), + pollType: controller.get("numberPollType"), pollMin: 1 }); @@ -208,7 +208,7 @@ test("multiple pollOutput", function() { controller.setProperties({ isMultiple: true, - pollType: I18n.t("poll.ui_builder.poll_type.multiple"), + pollType: controller.get("multiplePollType"), pollMin: 1, pollOptions: "1\n2" });