diff --git a/app/assets/javascripts/wizard/components/wizard-step.js.es6 b/app/assets/javascripts/wizard/components/wizard-step.js.es6 index 4732548e8d7..4420a5a65ad 100644 --- a/app/assets/javascripts/wizard/components/wizard-step.js.es6 +++ b/app/assets/javascripts/wizard/components/wizard-step.js.es6 @@ -40,6 +40,16 @@ export default Ember.Component.extend({ @computed("step.displayIndex", "wizard.totalSteps") showDoneButton: (current, total) => current === total, + @computed( + "step.index", + "step.displayIndex", + "wizard.totalSteps", + "wizard.completed" + ) + showFinishButton: (index, displayIndex, total, completed) => { + return index !== 0 && displayIndex !== total && completed; + }, + @computed("step.index") showBackButton: index => index > 0, @@ -112,6 +122,24 @@ export default Ember.Component.extend({ document.location = getUrl("/"); }, + exitEarly() { + const step = this.get("step"); + step.validate(); + + if (step.get("valid")) { + this.set("saving", true); + + step + .save() + .then(() => this.send("quit")) + .catch(() => this.animateInvalidFields()) + .finally(() => this.set("saving", false)); + } else { + this.animateInvalidFields(); + this.autoFocus(); + } + }, + backStep() { if (this.get("saving")) { return; diff --git a/app/assets/javascripts/wizard/templates/components/wizard-step.hbs b/app/assets/javascripts/wizard/templates/components/wizard-step.hbs index b7371dc1b5a..e271fde1d13 100644 --- a/app/assets/javascripts/wizard/templates/components/wizard-step.hbs +++ b/app/assets/javascripts/wizard/templates/components/wizard-step.hbs @@ -43,6 +43,12 @@ {{/if}} + {{#if showFinishButton}} + + {{/if}} + {{#if showDoneButton}}