decide.nolog.cz/app/routes/poll.js

37 lines
877 B
JavaScript
Raw Normal View History

2023-10-15 17:32:11 +02:00
import Route from '@ember/routing/route';
import { action } from '@ember/object';
2018-12-29 01:27:37 +01:00
import { inject as service } from '@ember/service';
2014-10-30 21:44:22 +01:00
export default class PollRoute extends Route {
2023-10-15 17:32:11 +02:00
@service encryption;
@service router;
@service store;
2023-10-15 17:32:11 +02:00
@action
error(error) {
if (error && error.status === 404) {
2023-10-15 17:32:11 +02:00
return this.router.transitionTo('404');
2014-10-28 06:00:37 +01:00
}
return true;
}
2016-01-28 23:48:14 +01:00
model(params) {
// get encryption key from query parameter in singleton
// before it's used by serializer to decrypt payload
this.set('encryption.key', params.encryptionKey);
return this.store.find('poll', params.poll_id);
}
2016-03-18 20:26:41 +01:00
redirect(poll, transition) {
if (transition.targetName === 'poll.index') {
this.router.transitionTo('poll.participation', poll, {
2016-03-18 20:26:41 +01:00
queryParams: {
encryptionKey: this.encryption.key,
},
2016-03-18 20:26:41 +01:00
});
}
2014-10-28 06:00:37 +01:00
}
}