2018-09-25 16:28:26 +00:00
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import { alias } from '@ember/object/computed';
|
|
|
|
import Component from '@ember/component';
|
|
|
|
import { computed } from '@ember/object';
|
2018-08-28 05:03:55 +00:00
|
|
|
import { matchesState } from 'xstate';
|
|
|
|
|
2018-09-25 16:28:26 +00:00
|
|
|
export default Component.extend({
|
2018-08-28 05:03:55 +00:00
|
|
|
classNames: ['ui-wizard-container'],
|
2018-09-25 16:28:26 +00:00
|
|
|
wizard: service(),
|
|
|
|
auth: service(),
|
2018-08-28 05:03:55 +00:00
|
|
|
|
|
|
|
shouldRender: computed('wizard.showWhenUnauthenticated', 'auth.currentToken', function() {
|
|
|
|
return this.get('auth.currentToken') || this.get('wizard.showWhenUnauthenticated');
|
|
|
|
}),
|
2018-09-25 16:28:26 +00:00
|
|
|
currentState: alias('wizard.currentState'),
|
|
|
|
featureState: alias('wizard.featureState'),
|
|
|
|
featureComponent: alias('wizard.featureComponent'),
|
|
|
|
tutorialComponent: alias('wizard.tutorialComponent'),
|
|
|
|
componentState: alias('wizard.componentState'),
|
|
|
|
nextFeature: alias('wizard.nextFeature'),
|
|
|
|
nextStep: alias('wizard.nextStep'),
|
2018-08-28 05:03:55 +00:00
|
|
|
|
|
|
|
actions: {
|
|
|
|
dismissWizard() {
|
|
|
|
this.get('wizard').transitionTutorialMachine(this.get('currentState'), 'DISMISS');
|
|
|
|
},
|
|
|
|
|
|
|
|
advanceWizard() {
|
|
|
|
let inInit = matchesState('init', this.get('wizard.currentState'));
|
|
|
|
let event = inInit ? this.get('wizard.initEvent') || 'CONTINUE' : 'CONTINUE';
|
|
|
|
this.get('wizard').transitionTutorialMachine(this.get('currentState'), event);
|
|
|
|
},
|
|
|
|
|
|
|
|
advanceFeature() {
|
|
|
|
this.get('wizard').transitionFeatureMachine(this.get('featureState'), 'CONTINUE');
|
|
|
|
},
|
|
|
|
|
|
|
|
finishFeature() {
|
|
|
|
this.get('wizard').transitionFeatureMachine(this.get('featureState'), 'DONE');
|
|
|
|
},
|
|
|
|
|
|
|
|
repeatStep() {
|
|
|
|
this.get('wizard').transitionFeatureMachine(
|
|
|
|
this.get('featureState'),
|
|
|
|
'REPEAT',
|
|
|
|
this.get('componentState')
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
resetFeature() {
|
|
|
|
this.get('wizard').transitionFeatureMachine(
|
|
|
|
this.get('featureState'),
|
|
|
|
'RESET',
|
|
|
|
this.get('componentState')
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
pauseWizard() {
|
|
|
|
this.get('wizard').transitionTutorialMachine(this.get('currentState'), 'PAUSE');
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|