decide.nolog.cz/app/routes/create/meta.js

39 lines
841 B
JavaScript
Raw Normal View History

2018-12-29 01:27:37 +01:00
import Route from '@ember/routing/route';
import { tracked } from '@glimmer/tracking';
import IntlMessage from '../../utils/intl-message';
class FormData {
@tracked title;
@tracked description;
get titleValidation() {
const { title } = this;
if (!title) {
return new IntlMessage('create.meta.input.title.validations.valueMissing');
}
if (title.length < 2) {
return new IntlMessage('create.meta.input.title.validations.tooShort');
}
return null;
}
constructor({ title, description }) {
this.title = title;
this.description = description;
}
}
2014-10-30 21:44:22 +01:00
export default class MetaRoute extends Route {
2016-01-31 14:32:32 +01:00
model() {
const { title, description } = this.modelFor('create');
return {
formData: new FormData({ title, description }),
poll: this.modelFor('create'),
};
2015-07-07 11:52:46 +02:00
}
}