diff --git a/dev/App.vue b/dev/App.vue index f88bdbc..25590da 100644 --- a/dev/App.vue +++ b/dev/App.vue @@ -6,7 +6,9 @@ ref="wizard" :steps="steps" :onNext="nextClicked" - :onBack="backClicked"> + :onBack="backClicked" + :completeStep="completeStepOptions" + >

Step 1

+
+

Congratulations! You can leave now...

+
@@ -59,8 +64,13 @@ export default { options: { nextDisabled: true, } + }, + { + label: 'Complete', + slot: 'pageDone' } ], + completeStepOptions: {has:true,showButton:false} }; }, methods: { diff --git a/src/components/Wizard.vue b/src/components/Wizard.vue index d619710..a30eedb 100644 --- a/src/components/Wizard.vue +++ b/src/components/Wizard.vue @@ -31,16 +31,21 @@ {{nextStepLabel}} + v-if="isFinalStep()" class="wizard__next pull-right final-step" @click="goNext()"> {{finalStepLabel}} + + {{completeStep.label||'Done'}} + @@ -52,6 +57,7 @@ export default { name: 'vue-good-wizard', props: { + completeStep: {default:{has:false,showButton:false,label:'Done'}}, steps: {}, previousStepLabel: {default: 'Back'}, nextStepLabel: {default: 'Next'}, @@ -75,7 +81,7 @@ export default { isMounted: false, resizer: null, isMobile: false, - options: [], + options: [] }; }, computed: { @@ -109,7 +115,7 @@ export default { return this.steps[this.currentStep].slot; }, backEnabled() { - return this.currentStep != 0; + return this.currentStep != 0 && !this.isCompleteStep(); } }, methods: { @@ -161,6 +167,21 @@ export default { this.isMobile = this.$refs['wizard-body'].clientWidth < 620; }, 100); }, + isWizardStep() { + const lastStepValue = this.completeStep.has ? this.steps.length - 2 : this.steps.length -1; + if(lastStepValue < 0) console.log('Last step value was: '+lastStepValue); + return this.currentStep <= lastStepValue; + }, + isFinalStep() { + const lastStepValue = this.completeStep.has ? this.steps.length - 2 : this.steps.length -1; + if(lastStepValue < 0) console.log('Last step value was: '+lastStepValue); + return this.currentStep == lastStepValue; + }, + isCompleteStep() { + const isCompleteStep = this.completeStep.has && this.currentStep ==this.steps.length - 1; + console.log('checking for final step:'+isCompleteStep); + return isCompleteStep; + } }, mounted() { this.isMobile = this.$refs['wizard-body'].clientWidth < 620; @@ -365,6 +386,9 @@ export default { .wizard__body__actions a.final-step{ background-color: #6eb165; } +.wizard__body__actions a.complete-step{ + background-color: #2C7520; +} /* mobile */ .wizard__body.vgw-mobile{