Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
Add method to reset wizard
Browse files Browse the repository at this point in the history
Closes #101
  • Loading branch information
cristijora committed Nov 27, 2017
1 parent eeffd4e commit 8fe072f
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/components/FormWizard.vue
@@ -1,5 +1,6 @@
<template>
<div class="vue-form-wizard" :class="[stepSize, {vertical: isVertical}]" @keyup.right="focusNextTab" @keyup.left="focusPrevTab">
<div class="vue-form-wizard" :class="[stepSize, {vertical: isVertical}]" @keyup.right="focusNextTab"
@keyup.left="focusPrevTab">
<div class="wizard-header">
<slot name="title">
<h4 class="wizard-title">{{title}}</h4>
Expand Down Expand Up @@ -49,23 +50,23 @@
</div>

<div class="wizard-footer-right">
<slot name="custom-buttons-right" v-bind="slotProps"></slot>
<span @click="nextTab" @keyup.enter="nextTab" v-if="isLastStep" role="button" tabindex="0">
<slot name="custom-buttons-right" v-bind="slotProps"></slot>
<span @click="nextTab" @keyup.enter="nextTab" v-if="isLastStep" role="button" tabindex="0">
<slot name="finish" v-bind="slotProps">
<wizard-button :style="fillButtonStyle">
{{finishButtonText}}
</wizard-button>
</slot>
</span>
<span @click="nextTab" @keyup.enter="nextTab" role="button" tabindex="0" v-else>
<slot name="next" v-bind="slotProps" >
<slot name="next" v-bind="slotProps">
<wizard-button :style="fillButtonStyle"
:disabled="loading">
{{nextButtonText}}
</wizard-button>
</slot>
</span>
</div>
</div>

</slot>
</div>
Expand All @@ -75,7 +76,8 @@
import WizardButton from './WizardButton.vue'
import WizardStep from './WizardStep.vue'
import {isPromise, findElementAndFocus, getFocusedTabIndex} from './helpers'
export default{
export default {
name: 'form-wizard',
components: {
WizardButton,
Expand Down Expand Up @@ -255,6 +257,13 @@
tabs.splice(index, 1)
}
},
reset () {
this.maxStep = 0
this.tabs.forEach((tab) => {
tab.checked = false
})
this.navigateToTab(0)
},
navigateToTab (index) {
let validate = index > this.activeTabIndex
if (index <= this.maxStep) {
Expand Down

0 comments on commit 8fe072f

Please sign in to comment.