FIX: Use internal value for poll builder.

This commit is contained in:
Guo Xiang Tan 2016-06-20 12:40:24 +08:00
parent 3d0be0d47c
commit 01c563ca85
No known key found for this signature in database
GPG Key ID: 19C321C8952B0F72
2 changed files with 20 additions and 15 deletions

View File

@ -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")

View File

@ -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"
});