Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion dev/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
ref="wizard"
:steps="steps"
:onNext="nextClicked"
:onBack="backClicked">
:onBack="backClicked"
:completeStep="completeStepOptions"
>
<div slot="page1">
<h4>Step 1</h4>
<input
Expand All @@ -26,6 +28,9 @@
</div>
<div slot="page3">
</div>
<div slot="pageDone">
<h2>Congratulations! You can leave now...</h2>
</div>
</vue-good-wizard>
</div>
</template>
Expand Down Expand Up @@ -59,8 +64,13 @@ export default {
options: {
nextDisabled: true,
}
},
{
label: 'Complete',
slot: 'pageDone'
}
],
completeStepOptions: {has:true,showButton:false}
};
},
methods: {
Expand Down
32 changes: 28 additions & 4 deletions src/components/Wizard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,21 @@
</a>
<a
:class="{'disabled': options[currentStep].nextDisabled}"
v-if="currentStep != steps.length - 1" class="wizard__next pull-right"
v-if="isWizardStep() && !isFinalStep()" class="wizard__next pull-right"
@click="goNext()">
<span>{{nextStepLabel}}</span>
<i class="vgw-icon vgw-next"></i>
</a>
<a
:class="{'disabled': options[currentStep].nextDisabled}"
v-if="currentStep == steps.length - 1" class="wizard__next pull-right final-step" @click="goNext()">
v-if="isFinalStep()" class="wizard__next pull-right final-step" @click="goNext()">
{{finalStepLabel}}
</a>
<a
:class="{'disabled': options[currentStep].nextDisabled}"
v-if="isCompleteStep(true)" class="wizard__next pull-right complete-step" @click="goNext()">
{{completeStep.label||'Done'}}
</a>
</div>
</div>
</div>
Expand All @@ -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'},
Expand All @@ -75,7 +81,7 @@ export default {
isMounted: false,
resizer: null,
isMobile: false,
options: [],
options: []
};
},
computed: {
Expand Down Expand Up @@ -109,7 +115,7 @@ export default {
return this.steps[this.currentStep].slot;
},
backEnabled() {
return this.currentStep != 0;
return this.currentStep != 0 && !this.isCompleteStep();
}
},
methods: {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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{
Expand Down