decide.nolog.cz/app/routes/create.js
Jeldrik Hanschke 97605ec7d7
fix some deprecations (#659)
* get deprecation workflow up to date

* fix routing.transition-methods deprecation

* fix this-property-fallback deprecation

* fix implicit-injections deprecation

* argument-less-helper-paren-less-invocation

* remove unmaintained ember-transition-helper which triggers deprecated-run-loop-and-computed-dot-access deprecation

* reset to only log but not throw on errors to not block other development

* reset double quote to single quote changes in templates and fix Prettier config

* fix JS linting

* ugprade ember-template-lint to fix parser
2023-10-15 21:50:28 +02:00

48 lines
1.3 KiB
JavaScript

import classic from 'ember-classic-decorator';
import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import config from 'croodle/config/environment';
import answersForAnswerType from 'croodle/utils/answers-for-answer-type';
import { DateTime } from 'luxon';
@classic
export default class CreateRoute extends Route {
@service encryption;
@service router;
@service store;
beforeModel(transition) {
// enforce that wizzard is started at create.index
if (transition.targetName !== 'create.index') {
this.router.transitionTo('create.index');
}
// set encryption key
this.encryption.generateKey();
}
model() {
// create empty poll
return this.store.createRecord('poll', {
answerType: 'YesNo',
answers: answersForAnswerType('YesNo'),
creationDate: new Date(),
forceAnswer: true,
anonymousUser: false,
pollType: 'FindADate',
timezone: null,
expirationDate: DateTime.local().plus({ months: 3 }).toISO(),
version: config.APP.version,
});
}
activate() {
let controller = this.controllerFor(this.routeName);
controller.listenForStepChanges();
}
deactivate() {
let controller = this.controllerFor(this.routeName);
controller.clearListenerForStepChanges();
}
}