2016-01-19 04:56:51 +01:00
|
|
|
import Ember from 'ember';
|
|
|
|
import {
|
|
|
|
validator, buildValidations
|
|
|
|
}
|
|
|
|
from 'ember-cp-validations';
|
|
|
|
|
2016-01-20 02:52:21 +01:00
|
|
|
let Validations = buildValidations({
|
2016-01-19 04:56:51 +01:00
|
|
|
options: [
|
|
|
|
validator('collection', true),
|
|
|
|
validator('length', {
|
|
|
|
dependentKeys: ['options.[]'],
|
2016-04-15 11:21:26 +02:00
|
|
|
min: 1
|
2016-01-19 04:56:51 +01:00
|
|
|
// message: Ember.I18n.t('create.options.error.notEnoughOptions')
|
|
|
|
}),
|
|
|
|
validator('valid-collection', {
|
|
|
|
dependentKeys: ['options.[]', 'options.@each.title']
|
|
|
|
})
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
export default Ember.Component.extend(Validations, {
|
|
|
|
actions: {
|
2016-01-28 22:49:14 +01:00
|
|
|
submit() {
|
2016-01-19 04:56:51 +01:00
|
|
|
if (this.get('validations.isValid')) {
|
|
|
|
this.sendAction('nextPage');
|
2016-02-08 23:46:30 +01:00
|
|
|
} else {
|
|
|
|
this.set('shouldShowErrors', true);
|
2016-01-19 04:56:51 +01:00
|
|
|
}
|
|
|
|
}
|
2016-02-08 23:46:30 +01:00
|
|
|
},
|
|
|
|
shouldShowErrors: false
|
2016-01-19 04:56:51 +01:00
|
|
|
});
|