decide.nolog.cz/app/components/create-options.js

33 lines
721 B
JavaScript
Raw Normal View History

import Ember from 'ember';
import {
validator, buildValidations
}
from 'ember-cp-validations';
let Validations = buildValidations({
options: [
validator('collection', true),
validator('length', {
dependentKeys: ['options.[]'],
min: 1
// 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() {
if (this.get('validations.isValid')) {
this.sendAction('nextPage');
2016-02-08 23:46:30 +01:00
} else {
this.set('shouldShowErrors', true);
}
}
2016-02-08 23:46:30 +01:00
},
shouldShowErrors: false
});