diff --git a/app/controllers/create/index.js b/app/controllers/create/index.js index 97ba6b5..e39ad23 100644 --- a/app/controllers/create/index.js +++ b/app/controllers/create/index.js @@ -18,7 +18,7 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, { }) ]; }.property(), - + validations: { pollType: { presence: true, diff --git a/app/controllers/create/options.js b/app/controllers/create/options.js index d6c0bcb..7ee8f46 100644 --- a/app/controllers/create/options.js +++ b/app/controllers/create/options.js @@ -1,47 +1,36 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, { actions: { - /* - * handles submit of option input for poll of type MakeAPoll - */ - submitMakeAPoll: function() { - var options = this.get('model.options'), + submit: function() { + var pollType = this.get('pollType'); + + if (pollType === 'MakeAPoll') { + var options = this.get('model.options'), newOptions = []; - // remove options without value - options.forEach(function(option) { - if (option.title !== '') { - newOptions.pushObject(option); - } - }); + // remove options without value + options.forEach(function(option) { + if (option.title !== '') { + newOptions.pushObject(option); + } + }); - // set updated options - // - // we have to hardly set new options even if they wasn't changed to - // trigger computed property; push on array doesn't trigger computed - // property to recalculate - this.set('model.options', newOptions); - - // tricker save action - this.send('save'); - }, - - /* - * handles submit of selected dates for poll of type MakeAPoll - */ - submitFindADate: function() { - // tricker save action - this.send('save'); - }, - - save: function(){ - // redirect to crate/options-datetime route if datetime is true - // otherwise redirect directly to create/settings - if (this.get('isDateTime')) { - this.transitionToRoute('create.options-datetime'); + // set updated options + // + // we have to hardly set new options even if they wasn't changed to + // trigger computed property; push on array doesn't trigger computed + // property to recalculate + this.set('model.options', newOptions); + + this.transitionToRoute('create.settings'); } else { - this.transitionToRoute('create.settings'); - } + if (this.get('isDateTime')) { + this.transitionToRoute('create.options-datetime'); + } + else { + this.transitionToRoute('create.settings'); + } + } } }, diff --git a/app/index.html b/app/index.html index 38b6858..2168e83 100644 --- a/app/index.html +++ b/app/index.html @@ -54,7 +54,7 @@ - + diff --git a/app/templates/create/index.hbs b/app/templates/create/index.hbs index 35e9809..be63019 100644 --- a/app/templates/create/index.hbs +++ b/app/templates/create/index.hbs @@ -1,13 +1,12 @@
- {{#em-form model=controller submit_button=false}} - {{em-select - property="pollType" - label="poll type" - prompt="-select-" - contentBinding="pollTypes" - optionValuePath="content.id" - optionLabelPath="content.label" - prompt="Please select a poll type"}} - {{em-form-submit text="next"}} - {{/em-form}} + {{#form-for controller}} + {{input pollType as='select' + collection="pollTypes" + value="pollType" + optionValuePath="content.id" + optionLabelPath="content.label" + prompt="Please select a poll type" + }} + {{submit 'next'}} + {{/form-for}}
\ No newline at end of file diff --git a/app/templates/create/meta.hbs b/app/templates/create/meta.hbs index 8862a35..7903775 100644 --- a/app/templates/create/meta.hbs +++ b/app/templates/create/meta.hbs @@ -1,14 +1,14 @@
- {{#em-form model=controller submit_button=false}} - {{em-input - property="title" - label="title" - placeholder="Enter a title..."}} - {{em-text - property="description" - label="description" - placeholder="Enter a description if you like..." - rows=4}} - {{em-form-submit text="next"}} - {{/em-form}} + {{#form-for controller}} + {{input title + label="title" + placeholder="Enter a title..." + }} + {{input description as='text' + label="description" + placeholder="Enter a description if you like..." + rows=4 + }} + {{submit 'next'}} + {{/form-for}}
\ No newline at end of file diff --git a/app/templates/create/options-datetime.hbs b/app/templates/create/options-datetime.hbs index a160118..6ddf0b3 100644 --- a/app/templates/create/options-datetime.hbs +++ b/app/templates/create/options-datetime.hbs @@ -19,8 +19,10 @@ - {{em-form-control-help text="Hours and minutes have to be seperated by a color (e.g. 12:30). - You have to enter atleast one valid time for each date."}} +

+ Hours and minutes have to be seperated by a color (e.g. 12:30). + You have to enter atleast one valid time for each date. +

diff --git a/app/templates/create/options.hbs b/app/templates/create/options.hbs index 7f61096..8886395 100644 --- a/app/templates/create/options.hbs +++ b/app/templates/create/options.hbs @@ -5,14 +5,16 @@
{{#each option in options}} - {{view Ember.TextField valueBinding="option.title" class="form-control"}}
+ {{#form-for option}} + {{input option.title label=" "}}
+ {{/form-for}} {{/each}} - {{em-form-control-help text="You have to enter at least two options."}} +

You have to enter at least two options.

- +
{{/if}} @@ -20,15 +22,14 @@ {{#if isFindADate}}
{{view 'datepicker'}} - {{em-form-control-help text="You have to select at least two dates."}} +

You have to select at least two dates."

- {{#em-form model=controller submit_button=false}} - {{em-checkbox label="Define times?" property="isDateTime"}} - {{/em-form}} - -
- -
+ {{#form-for controller}} + {{input isDateTime as='checkbox' + label="Define times?" + }} + {{submit 'next'}} + {{/form-for}}
{{/if}} \ No newline at end of file diff --git a/app/templates/create/settings.hbs b/app/templates/create/settings.hbs index 33796f8..cf2c3c4 100644 --- a/app/templates/create/settings.hbs +++ b/app/templates/create/settings.hbs @@ -1,15 +1,19 @@
- {{#em-form model=controller submit_button=false}} - {{em-select - property="answerType" - label="available answers" - prompt="-select-" - contentBinding="answerTypes" + {{#form-for controller}} + {{input answerType as='select' + collection="answerTypes" + value="answerType" optionValuePath="content.id" optionLabelPath="content.label" - prompt="Please define available answers"}} - {{em-checkbox label="Allow anonym participation?" property="anonymousUser"}} - {{em-checkbox label="Force an answer?" property="forceAnswer"}} - {{em-form-submit text="save"}} - {{/em-form}} + label="available answers" + prompt="Please define available answers" + }} + {{input anonymousUser as='checkbox' + label="Allow anonym participation?" + }} + {{input forceAnswer as='checkbox' + label="Force an answer?" + }} + {{submit 'save'}} + {{/form-for}}
\ No newline at end of file diff --git a/app/templates/poll.hbs b/app/templates/poll.hbs index ea1f381..2ab8ae2 100644 --- a/app/templates/poll.hbs +++ b/app/templates/poll.hbs @@ -56,16 +56,18 @@ handlebar each helper }} - {{#em-form model=controller submit_button=false}} - {{em-form-label text="name" extraClass="sr-only"}} - {{em-input property="newUserName" placeholder="Enter your name..."}} - {{/em-form}} + {{#form-for controller}} + {{input newUserName + label=" " + placeholder="Enter your name..." + }} + {{/form-for}} {{#each newUserSelection in controller.newUserSelections}} - {{#em-form model=newUserSelection submit_button=false}} + {{#form-for newUserSelection}} {{#if isFreeText}} - {{em-input property="value"}} + {{input value label=" "}} {{else}} {{#each answer in answers}}
@@ -75,7 +77,7 @@
{{/each}} {{/if}} - {{/em-form}} + {{/form-for}} {{/each}} diff --git a/bower.json b/bower.json index cffc666..56667b1 100644 --- a/bower.json +++ b/bower.json @@ -17,13 +17,9 @@ "ember-validations": "http://builds.dockyard.com.s3.amazonaws.com/ember-validations/tags/v1.0.0/ember-validations.js", "bootstrap": "~3.2.0", "bootstrap-datepicker": "~1.3.0", - "ember-forms": "f6456c334a07950365ecfebd087596dedc1bdec5", + "ember-easyForm": "http://builds.dockyard.com/ember-easyForm/latest/ember-easyForm.js", "floatThead": "~1.2.8", "webshim": "~1.15.3", "modernizr": "~2.8.3" - }, - "resolutions": { - "ember": "~1.7.0", - "jquery": "~1.11.1" } }