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

#12 Do not validate an previous step

This commit is contained in:
cristijora
2017-06-07 22:59:36 +03:00
parent a67fc7bc93
commit 45306e301d
3 changed files with 9 additions and 8 deletions
+4 -4
View File
@@ -9,7 +9,7 @@
@on-loading="setLoading"
@on-error="setError"
class="card" ref="wizard">
<tab-content title="1" icon="ti-settings">
<tab-content title="1" icon="ti-settings" :before-change="validateAsync">
First tab
</tab-content>
<tab-content title="2" icon="ti-settings" :before-change="validateAsync">
@@ -52,13 +52,13 @@
//simulating an error for the first time and a success for the second time
return new Promise((resolve, reject) => {
setTimeout(() => {
if (this.count < 1) {
this.count ++
if (this.count % 2 === 0) {
reject('Some custom error')
} else {
resolve(true)
}
}, 1000)
this.count ++
}, 100)
})
},
validate () {
+1 -1
View File
File diff suppressed because one or more lines are too long
+4 -3
View File
@@ -13,7 +13,7 @@
</div>
<ul class="wizard-nav wizard-nav-pills">
<li v-for="(tab, index) in tabs" :class="{active:tab.active}">
<a href="" @click.prevent="navigateToTab(index, false)">
<a href="" @click.prevent="navigateToTab(index)">
<div class="wizard-icon-circle"
:class="{checked:isChecked(index),square_shape:isStepSquare, tab_shape:isTabShape}"
:style="[isChecked(index)? stepCheckedStyle : {}, tab.validationError ? errorStyle : {}]">
@@ -221,15 +221,16 @@
isChecked (index) {
return index <= this.maxStep
},
navigateToTab (index, validate = true) {
navigateToTab (index) {
let validate = index > this.activeTabIndex
if (index <= this.maxStep) {
let cb = () => {
this.setValidationError(null)
this.changeTab(this.activeTabIndex, index)
}
if (validate) {
this.beforeTabChange(this.activeTabIndex, cb)
} else {
this.setValidationError(null)
cb()
}
}