2018-09-25 16:28:26 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import Route from '@ember/routing/route';
|
2018-04-03 14:16:57 +00:00
|
|
|
import { toolsActions } from 'vault/helpers/tools-actions';
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
export default Route.extend({
|
|
|
|
wizard: service(),
|
2018-08-28 05:03:55 +00:00
|
|
|
|
2018-04-03 14:16:57 +00:00
|
|
|
beforeModel(transition) {
|
|
|
|
const supportedActions = toolsActions();
|
2018-09-25 16:28:26 +00:00
|
|
|
const { selected_action: selectedAction } = this.paramsFor(this.routeName);
|
2018-04-03 14:16:57 +00:00
|
|
|
if (!selectedAction || !supportedActions.includes(selectedAction)) {
|
|
|
|
transition.abort();
|
|
|
|
return this.transitionTo(this.routeName, supportedActions[0]);
|
|
|
|
}
|
|
|
|
},
|
2018-09-25 16:28:26 +00:00
|
|
|
|
|
|
|
model(params) {
|
|
|
|
return params.selected_action;
|
|
|
|
},
|
|
|
|
|
|
|
|
setupController(controller, model) {
|
|
|
|
this._super(...arguments);
|
|
|
|
controller.set('selectedAction', model);
|
|
|
|
},
|
|
|
|
|
2018-04-03 14:16:57 +00:00
|
|
|
actions: {
|
|
|
|
didTransition() {
|
|
|
|
const params = this.paramsFor(this.routeName);
|
2018-10-18 19:19:50 +00:00
|
|
|
if (this.wizard.currentMachine === 'tools') {
|
|
|
|
this.wizard.transitionFeatureMachine(this.wizard.featureState, params.selected_action.toUpperCase());
|
2018-08-28 05:03:55 +00:00
|
|
|
}
|
2018-04-03 14:16:57 +00:00
|
|
|
this.controller.setProperties(params);
|
2018-08-28 05:03:55 +00:00
|
|
|
return true;
|
2018-04-03 14:16:57 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|