decide.nolog.cz/app/routes/create/settings.js
jelhan f3426b2a7d support creating polls with only one option
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.
2016-04-15 11:21:26 +02:00

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');
}
}
});