2
0
mirror of https://github.com/tenrok/vue-form-wizard.git synced 2026-06-23 22:40:33 +03:00

Add method to reset wizard

Closes #101
This commit is contained in:
cristijora
2017-11-27 16:55:49 +02:00
parent eeffd4e52c
commit 8fe072fda8
+10 -1
View File
@@ -1,5 +1,6 @@
<template> <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"> <div class="wizard-header">
<slot name="title"> <slot name="title">
<h4 class="wizard-title">{{title}}</h4> <h4 class="wizard-title">{{title}}</h4>
@@ -75,6 +76,7 @@
import WizardButton from './WizardButton.vue' import WizardButton from './WizardButton.vue'
import WizardStep from './WizardStep.vue' import WizardStep from './WizardStep.vue'
import {isPromise, findElementAndFocus, getFocusedTabIndex} from './helpers' import {isPromise, findElementAndFocus, getFocusedTabIndex} from './helpers'
export default { export default {
name: 'form-wizard', name: 'form-wizard',
components: { components: {
@@ -255,6 +257,13 @@
tabs.splice(index, 1) tabs.splice(index, 1)
} }
}, },
reset () {
this.maxStep = 0
this.tabs.forEach((tab) => {
tab.checked = false
})
this.navigateToTab(0)
},
navigateToTab (index) { navigateToTab (index) {
let validate = index > this.activeTabIndex let validate = index > this.activeTabIndex
if (index <= this.maxStep) { if (index <= this.maxStep) {