2
0
mirror of https://github.com/tenrok/vue-form-wizard.git synced 2026-06-08 08:12:24 +03:00

Add vue-router to dev deps

Revert router integration due to wrong merge
This commit is contained in:
cristi
2017-04-24 22:57:57 +03:00
parent 4f29fb639d
commit 4a9655edd3
5 changed files with 34 additions and 4 deletions
+6 -3
View File
@@ -7,19 +7,22 @@
class="card">
<tab-content title="Personal details"
:before-change="validateAsync"
route="/first"
icon="ti-user">
My first tab content
</tab-content>
<tab-content title="Additional Info"
:before-change="validate"
route="/second"
icon="ti-settings">
My second tab content
</tab-content>
<tab-content title="Last step"
:before-change="validateAsync"
route="/third"
icon="ti-check">
Yuhuuu! This seems pretty damn simple
</tab-content>
<transition name="fade" mode="out-in">
<router-view></router-view>
</transition>
<div class="loader" v-if="loadingWizard"></div>
</form-wizard>
</div>
+15
View File
@@ -1,14 +1,29 @@
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import VueRouter from 'vue-router'
import App from './App.vue'
import FormWizard from '../src/index'
const First = { template: '<div>First page</div>' }
const Second = { template: '<div>Second page</div>' }
const Third = { template: '<div>Third page</div>' }
const router = new VueRouter({
mode: 'history',
routes: [
{ path: '/first', component: First },
{ path: '/second', component: Second },
{ path: '/third', component: Third }
]
})
Vue.use(VueRouter)
Vue.use(FormWizard)
Vue.config.productionTip = false
/* eslint-disable no-new */
new Vue({
router,
el: '#app',
template: '<App/>',
components: {App}
+2 -1
View File
@@ -25,7 +25,6 @@
"url": "https://github.com/cristijora/vue-form-wizard"
},
"devDependencies": {
"vue": "^2.2.2",
"autoprefixer": "^6.7.2",
"babel-core": "^6.22.1",
"babel-eslint": "^7.1.1",
@@ -84,7 +83,9 @@
"sinon-chai": "^2.8.0",
"stats-webpack-plugin": "^0.6.0",
"url-loader": "^0.5.8",
"vue": "^2.2.2",
"vue-loader": "^11.1.4",
"vue-router": "^2.5.1",
"vue-style-loader": "^2.0.0",
"vue-template-compiler": "^2.2.4",
"webpack": "^2.2.1",
+8
View File
@@ -253,8 +253,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
@@ -300,12 +306,14 @@
if (this.tabs.length > 0 && this.startIndex === 0) {
let firstTab = this.tabs[this.activeTabIndex]
firstTab.active = true
this.tryChangeRoute(firstTab)
}
if (this.startIndex < this.tabs.length) {
let tabToActivate = this.tabs[this.startIndex]
this.activeTabIndex = this.startIndex
tabToActivate.active = true
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 () {