2018-12-29 01:27:37 +01:00
|
|
|
import Route from '@ember/routing/route';
|
2023-10-15 15:27:02 +02:00
|
|
|
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
|
|
|
|
2020-01-18 10:13:50 +01:00
|
|
|
export default class MetaRoute extends Route {
|
2016-01-31 14:32:32 +01:00
|
|
|
model() {
|
2023-10-15 15:27:02 +02:00
|
|
|
const { title, description } = this.modelFor('create');
|
|
|
|
|
|
|
|
return {
|
|
|
|
formData: new FormData({ title, description }),
|
|
|
|
poll: this.modelFor('create'),
|
|
|
|
};
|
2015-07-07 11:52:46 +02:00
|
|
|
}
|
2020-01-18 10:13:50 +01:00
|
|
|
}
|