diff --git a/app/controllers/create/options-datetime.js b/app/controllers/create/options-datetime.js index f754c8c..a96340b 100644 --- a/app/controllers/create/options-datetime.js +++ b/app/controllers/create/options-datetime.js @@ -99,20 +99,22 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, { datetimesCount = this.get('datetimesInputFields'), self = this; - dates.forEach(function(date){ - var o = { - title: date.title, - times: Ember.A() - }; - - for(var i = 1; i<=datetimesCount; i++) { - o.times.pushObject({ - value: '' - }); - } - - datetimes.pushObject(self.get('datetimesTimesArray').create({'contents':o})); - }); + if (typeof dates !== 'undefined') { + dates.forEach(function(date){ + var o = { + title: date.title, + times: Ember.A() + }; + + for(var i = 1; i<=datetimesCount; i++) { + o.times.pushObject({ + value: '' + }); + } + + datetimes.pushObject(self.get('datetimesTimesArray').create({'contents':o})); + }); + } return datetimes; }.property('options'), @@ -130,11 +132,7 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, { }.property('contents.times.@each.value') }), - /* - * Checks if input is valid - * runs after each changed input time - */ - isValid: function(){ + enoughTimes: function(){ var datetimes = this.get('datetimes'), self = this, isValid = true; @@ -157,14 +155,6 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, { return isValid; }.property('datetimes.@each.@eachTimesValue'), - /* - * invokes isValid state - * used to enable / disabled next button - */ - isNotValid: function(){ - return !this.get('isValid'); - }.property('isValid'), - getHoursAndMinutesFromInput: function(time){ // try to split time in minutes and hours var t; @@ -196,5 +186,13 @@ export default Ember.ObjectController.extend(Ember.Validations.Mixin, { else { return false; } + }, + + validations: { + enoughTimes: { + acceptance: { + message: Ember.I18n.t('create.options-datetime.error.notEnoughTimes') + } + } } }); \ No newline at end of file diff --git a/app/lang/translations.js b/app/lang/translations.js index c9500ee..15c5e8c 100644 --- a/app/lang/translations.js +++ b/app/lang/translations.js @@ -7,11 +7,13 @@ export default { "create.meta.input.description.label": "description", "create.meta.input.description.placeholder": "enter a description if you like", "create.next": "next", - "create.options.label": "options", + "create.options.options.label": "options", "create.options.add-another-option": "add another option", + "create.options.error.notEnoughOptions": "you must enter atleast two options", + "create.options-datetime.datetimes.label": "datetimes", "create.options-datetime.more-inputs": "more inputs for time", "create.options-datetime.copy-first-line": "copy first line", - "create.options.error.notEnoughOptions": "you must enter atleast two options", + "create.options-datetime.error.notEnoughTimes": "you must enter atleast one time per date", "errors.inclusion": "is not included in the list", "errors.exclusion": "is reserved", "errors.invalid": "is invalid", @@ -58,11 +60,13 @@ export default { "create.meta.input.description.label": "description", "create.meta.input.description.placeholder": "enter a description if you like", "create.next": "weiter", - "create.options.label": "Optionen", + "create.options.options.label": "Optionen", "create.options.add-another-option": "Mehr Optionen", + "create.options.error.notEnoughOptions": "mindestens zwei Optionen", + "create.options-datetime.datetimes.label": "datetimes", "create.options-datetime.more-inputs": "Mehr Zeiten eingeben", "create.options-datetime.copy-first-line": "Erste Zeile kopieren", - "create.options.error.notEnoughOptions": "mindestens zwei Optionen", + "create.options-datetime.error.notEnoughTimes": "mindestens eine Zeit pro Tag", "errors.inclusion": "is not included in the list", "errors.exclusion": "is reserved", "errors.invalid": "is invalid", diff --git a/app/templates/create/options-datetime.hbs b/app/templates/create/options-datetime.hbs index c4d384f..678346c 100644 --- a/app/templates/create/options-datetime.hbs +++ b/app/templates/create/options-datetime.hbs @@ -1,28 +1,34 @@
-
- - - {{#each datetime in datetimes}} - - - {{#each time in datetime.contents.times}} + {{#form-for controller}} + {{#input enoughTimes}} + {{label-field enoughTimes + textTranslation="create.options-datetime.datetimes.label" + }} +
- {{formattedDate datetime.contents.title 'll'}} -
+ + {{#each datetime in datetimes}} + - {{/each}} - - {{/each}} - -
-
- {{input value=time.value type="time" class="form-control" step="900"}} -
+ {{formattedDate datetime.contents.title 'll'}}
- -

- 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. -

+ {{#each time in datetime.contents.times}} + + {{#input time.value}} + {{input-field time.value as='time' + step='900' + }} + {{/input}} + + {{/each}} + + {{/each}} + + + {{hint-field enoughTimes + 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." + }} + {{error-field enoughTimes}} + {{/input}}
@@ -32,8 +38,6 @@
-
- -
-
+ {{submit 'next'}} + {{/form-for}}
\ No newline at end of file diff --git a/app/templates/create/options.hbs b/app/templates/create/options.hbs index 2f12df2..0b6bd8a 100644 --- a/app/templates/create/options.hbs +++ b/app/templates/create/options.hbs @@ -1,8 +1,12 @@
{{#if isMakeAPoll}} + {{#form-for controller}} + {{#input enoughOptions}} - {{label-field enoughOptions}} + {{label-field enoughOptions + textTranslation="create.options.options.label" + }} {{#each option in options}} {{#input option.title}} {{input-field option.title}} @@ -12,14 +16,19 @@ {{error-field enoughOptions}} {{/if}} {{/input}} +
+ {{submit 'next'}} + {{/form-for}} + {{/if}} {{#if isFindADate}} +
{{view 'datepicker'}}
@@ -35,5 +44,6 @@ }} {{submit 'next'}} {{/form-for}} + {{/if}}
\ No newline at end of file