2
0
mirror of https://github.com/tenrok/vue-form-wizard.git synced 2026-06-20 21:50:33 +03:00

Support vue-router integration

This commit is contained in:
cristijora
2017-04-20 10:36:46 +03:00
parent e8537463ff
commit e3cda5a502
6 changed files with 38 additions and 10 deletions
+13 -4
View File
@@ -17,12 +17,13 @@
<div class="icon-circle" :class="{checked:isChecked(index),square_shape:isStepSquare, tab_shape:isTabShape}"
:style="isChecked(index)? stepCheckedStyle : {}">
<transition :name="transition" mode="out-in">
<div v-if="tab.active" class="icon-container" :class="{square_shape:isStepSquare, tab_shape:isTabShape}" :style="tab.active ? iconActiveStyle: {}">
<div v-if="tab.active" class="icon-container" :class="{square_shape:isStepSquare, tab_shape:isTabShape}"
:style="tab.active ? iconActiveStyle: {}">
<i v-if="tab.icon" :class="tab.icon" class="icon"></i>
<i v-else class="icon">{{index+1}}</i>
<i v-else class="icon">{{index + 1}}</i>
</div>
<i v-if="!tab.active && tab.icon" :class="tab.icon" class="icon"></i>
<i v-if="!tab.active && !tab.icon" class="icon">{{index+1}}</i>
<i v-if="!tab.active && !tab.icon" class="icon">{{index + 1}}</i>
</transition>
</div>
<span class="stepTitle" :style="tab.active ? stepTitleStyle : {}">
@@ -42,7 +43,7 @@
<template>
<span @click="prevTab" v-if="displayPrevButton">
<slot name="prev">
<button type="button" class="btn btn-default btn-wd" :style="fillButtonStyle">
<button type="button" class="btn btn-default btn-wd" :style="fillButtonStyle">
{{backButtonText}}
</button>
</slot>
@@ -218,8 +219,14 @@
}
this.activeTabIndex = newIndex
this.checkStep()
this.tryChangeRoute(newTab)
return true
},
tryChangeRoute (tab) {
if (this.$router && tab.route) {
this.$router.push(tab.route)
}
},
checkStep () {
if (this.activeTabIndex === this.tabCount - 1) {
this.isLastStep = true
@@ -263,10 +270,12 @@
let firstTab = this.tabs[this.activeTabIndex]
firstTab.show = true
firstTab.active = true
this.tryChangeRoute(firstTab)
}
if (this.startIndex < this.tabs.length) {
this.activeTabIndex = this.startIndex
this.maxStep = this.startIndex
this.tryChangeRoute(this.tabs[this.startIndex])
} else {
console.warn(`Prop startIndex set to ${this.startIndex} is greater than the number of tabs - ${this.tabs.length}. Make sure that the starting index is less than the number of tabs registered`)
}
+3
View File
@@ -26,6 +26,9 @@
*/
beforeChange: {
type: Function
},
route: {
type: [String, Object]
}
},
data () {