2015-10-13 11:29:51 +02:00
|
|
|
import DS from 'ember-data';
|
2016-05-23 13:40:45 +02:00
|
|
|
import Ember from 'ember';
|
2016-01-19 04:56:51 +01:00
|
|
|
import {
|
|
|
|
validator, buildValidations
|
|
|
|
}
|
|
|
|
from 'ember-cp-validations';
|
2015-11-20 11:31:40 +01:00
|
|
|
/* global MF */
|
2015-10-13 11:29:51 +02:00
|
|
|
|
2016-01-28 23:48:14 +01:00
|
|
|
const Validations = buildValidations({
|
2016-01-19 04:56:51 +01:00
|
|
|
title: [
|
2016-02-13 18:37:33 +01:00
|
|
|
validator('iso8601', {
|
2016-01-19 04:56:51 +01:00
|
|
|
active() {
|
2016-02-13 18:37:33 +01:00
|
|
|
return this.get('model.poll.isFindADate');
|
|
|
|
},
|
|
|
|
validFormats: [
|
|
|
|
'YYYY-MM-DD',
|
|
|
|
'YYYY-MM-DDTHH:mmZ',
|
|
|
|
'YYYY-MM-DDTHH:mm:ssZ',
|
|
|
|
'YYYY-MM-DDTHH:mm:ss.SSSZ'
|
2016-05-23 13:40:45 +02:00
|
|
|
],
|
|
|
|
dependentKeys: ['i18n.locale']
|
|
|
|
}),
|
|
|
|
validator('presence', {
|
|
|
|
presence: true,
|
|
|
|
dependentKeys: ['i18n.locale']
|
2016-01-19 04:56:51 +01:00
|
|
|
}),
|
2016-05-20 21:49:29 +02:00
|
|
|
validator('unique', {
|
|
|
|
parent: 'poll',
|
|
|
|
attributeInParent: 'options',
|
2016-05-23 13:40:45 +02:00
|
|
|
dependentKeys: ['poll.options.[]', 'poll.options.@each.title', 'i18n.locale']
|
2016-05-20 21:49:29 +02:00
|
|
|
})
|
2016-01-19 04:56:51 +01:00
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
export default MF.Fragment.extend(Validations, {
|
|
|
|
poll: MF.fragmentOwner(),
|
2016-05-23 13:40:45 +02:00
|
|
|
title: DS.attr('string'),
|
|
|
|
|
|
|
|
i18n: Ember.inject.service(),
|
|
|
|
init() {
|
|
|
|
this.get('i18n.locale');
|
|
|
|
}
|
2015-11-20 01:09:37 +01:00
|
|
|
});
|