Skip to content
Merged
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
42 changes: 35 additions & 7 deletions src/HorizontalStepper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<div class="content">
<transition :enter-active-class="enterAnimation" :leave-active-class="leaveAnimation" mode="out-in">
<!--If keep alive-->
<keep-alive v-if="keepAlive">
<keep-alive v-if="keepAliveData">
<component :is="steps[currentStep.index].component" :clickedNext="nextButton[currentStep.name]" @can-continue="proceed" @change-next="changeNextBtnValue" :current-step="currentStep"></component>
</keep-alive>
<!--If not show component and destroy it in each step change-->
Expand Down Expand Up @@ -90,6 +90,10 @@ export default {
keepAlive: {
type: Boolean,
default: true
},
reset: {
type: Boolean,
default: false
}
},

Expand All @@ -99,7 +103,8 @@ export default {
previousStep: {},
nextButton: {},
canContinue: false,
finalStep: false
finalStep: false,
keepAliveData: this.keepAlive
};
},

Expand Down Expand Up @@ -194,15 +199,38 @@ export default {
changeNextBtnValue(payload) {
this.nextButton[this.currentStep.name] = payload.nextBtnValue;
this.$forceUpdate();
},

init() {
// Initiate stepper
this.activateStep(0);
this.steps.forEach(step => {
this.nextButton[step.name] = false;
});
}
},

watch: {
reset(val) {
if(!val) {
return;
}

this.keepAliveData = false;

this.init();
this.previousStep = {};

this.$nextTick(() => {
this.keepAliveData = this.keepAlive;
this.$emit('reset', true);
});

}
},

created() {
// Initiate stepper
this.activateStep(0);
this.steps.forEach(step => {
this.nextButton[step.name] = false;
});
this.init();
}
};
</script>
Expand Down