2018-12-29 01:27:37 +01:00
|
|
|
import { alias } from '@ember/object/computed';
|
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import Route from '@ember/routing/route';
|
2018-12-29 21:16:18 +01:00
|
|
|
import config from 'croodle/config/environment';
|
2015-07-27 17:57:50 +02:00
|
|
|
/* global moment */
|
2014-10-30 21:44:22 +01:00
|
|
|
|
2018-12-29 01:27:37 +01:00
|
|
|
export default Route.extend({
|
2016-02-02 12:50:13 +01:00
|
|
|
actions: {
|
2016-01-28 23:48:14 +01:00
|
|
|
transitionToPoll(poll) {
|
2015-10-25 19:38:14 +01:00
|
|
|
this.transitionTo('poll', poll, {
|
|
|
|
queryParams: {
|
|
|
|
encryptionKey: this.get('encryptionKey')
|
|
|
|
}
|
|
|
|
});
|
2015-07-01 16:21:18 +02:00
|
|
|
}
|
|
|
|
},
|
2015-11-20 11:19:28 +01:00
|
|
|
|
2016-08-18 01:09:58 +02:00
|
|
|
beforeModel(transition) {
|
|
|
|
// enforce that wizzard is started at create.index
|
|
|
|
if (transition.targetName !== 'create.index') {
|
|
|
|
this.transitionTo('create.index');
|
|
|
|
}
|
|
|
|
|
2016-02-02 12:50:13 +01:00
|
|
|
// set encryption key
|
|
|
|
this.get('encryption').generateKey();
|
|
|
|
},
|
|
|
|
|
2018-12-29 01:27:37 +01:00
|
|
|
encryption: service(),
|
|
|
|
encryptionKey: alias('encryption.key'),
|
2016-02-02 12:50:13 +01:00
|
|
|
|
2016-01-28 23:48:14 +01:00
|
|
|
model() {
|
2014-07-06 20:15:15 +02:00
|
|
|
// create empty poll
|
|
|
|
return this.store.createRecord('poll', {
|
2015-11-20 23:02:35 +01:00
|
|
|
answerType: 'YesNo',
|
2016-01-28 23:48:14 +01:00
|
|
|
creationDate: new Date(),
|
2014-07-07 01:51:58 +02:00
|
|
|
forceAnswer: true,
|
|
|
|
anonymousUser: false,
|
2015-11-20 11:19:28 +01:00
|
|
|
pollType: 'FindADate',
|
2016-02-22 23:55:59 +01:00
|
|
|
timezone: null,
|
2015-07-26 19:41:59 +02:00
|
|
|
expirationDate: moment().add(3, 'month').toISOString(),
|
2018-12-29 21:16:18 +01:00
|
|
|
version: config.APP.version,
|
2014-07-06 20:15:15 +02:00
|
|
|
});
|
|
|
|
}
|
2014-09-29 13:17:54 +02:00
|
|
|
});
|