f3426b2a7d
There might be use cases and it simplifies validation a lot. Also fixes this missing translation message mentioned in #84: > /create/options-datetime: There isn't any validation error shown when validation fails due to not enough times.
23 lines
616 B
JavaScript
23 lines
616 B
JavaScript
import Ember from 'ember';
|
|
|
|
export default Ember.Route.extend({
|
|
model() {
|
|
return this.modelFor('create');
|
|
},
|
|
|
|
// redirect to create/options if not enough options are defined
|
|
afterModel(create) {
|
|
// check if only default options are defined
|
|
if (create.get('options.length') === 2) {
|
|
create.get('options').forEach((option) => {
|
|
if (option.title === '') {
|
|
this.transitionTo('create.options');
|
|
}
|
|
});
|
|
}
|
|
// check if less then two options are defined
|
|
else if (create.get('options.length') < 1) {
|
|
this.transitionTo('create.options');
|
|
}
|
|
}
|
|
});
|