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