2
0
mirror of https://github.com/tenrok/vue-form-wizard.git synced 2026-06-23 14:40:35 +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"> class="card">
<tab-content title="Personal details" <tab-content title="Personal details"
:before-change="validateAsync" :before-change="validateAsync"
route="/first"
icon="ti-user"> icon="ti-user">
My first tab content
</tab-content> </tab-content>
<tab-content title="Additional Info" <tab-content title="Additional Info"
:before-change="validate" :before-change="validate"
route="/second"
icon="ti-settings"> icon="ti-settings">
My second tab content
</tab-content> </tab-content>
<tab-content title="Last step" <tab-content title="Last step"
:before-change="validateAsync" :before-change="validateAsync"
route="/third"
icon="ti-check"> icon="ti-check">
Yuhuuu! This seems pretty damn simple
</tab-content> </tab-content>
<transition name="fade" mode="out-in">
<router-view></router-view>
</transition>
<div class="loader" v-if="loadingWizard"></div> <div class="loader" v-if="loadingWizard"></div>
</form-wizard> </form-wizard>
</div> </div>
+15
View File
@@ -1,14 +1,29 @@
// The Vue build version to load with the `import` command // The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias. // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue' import Vue from 'vue'
import VueRouter from 'vue-router'
import App from './App.vue' import App from './App.vue'
import FormWizard from '../src/index' 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.use(FormWizard)
Vue.config.productionTip = false Vue.config.productionTip = false
/* eslint-disable no-new */ /* eslint-disable no-new */
new Vue({ new Vue({
router,
el: '#app', el: '#app',
template: '<App/>', template: '<App/>',
components: {App} components: {App}
+2 -1
View File
@@ -25,7 +25,6 @@
"url": "https://github.com/cristijora/vue-form-wizard" "url": "https://github.com/cristijora/vue-form-wizard"
}, },
"devDependencies": { "devDependencies": {
"vue": "^2.2.2",
"autoprefixer": "^6.7.2", "autoprefixer": "^6.7.2",
"babel-core": "^6.22.1", "babel-core": "^6.22.1",
"babel-eslint": "^7.1.1", "babel-eslint": "^7.1.1",
@@ -84,7 +83,9 @@
"sinon-chai": "^2.8.0", "sinon-chai": "^2.8.0",
"stats-webpack-plugin": "^0.6.0", "stats-webpack-plugin": "^0.6.0",
"url-loader": "^0.5.8", "url-loader": "^0.5.8",
"vue": "^2.2.2",
"vue-loader": "^11.1.4", "vue-loader": "^11.1.4",
"vue-router": "^2.5.1",
"vue-style-loader": "^2.0.0", "vue-style-loader": "^2.0.0",
"vue-template-compiler": "^2.2.4", "vue-template-compiler": "^2.2.4",
"webpack": "^2.2.1", "webpack": "^2.2.1",
+8
View File
@@ -253,8 +253,14 @@
} }
this.activeTabIndex = newIndex this.activeTabIndex = newIndex
this.checkStep() this.checkStep()
this.tryChangeRoute(newTab)
return true return true
}, },
tryChangeRoute (tab) {
if (this.$router && tab.route) {
this.$router.push(tab.route)
}
},
checkStep () { checkStep () {
if (this.activeTabIndex === this.tabCount - 1) { if (this.activeTabIndex === this.tabCount - 1) {
this.isLastStep = true this.isLastStep = true
@@ -300,12 +306,14 @@
if (this.tabs.length > 0 && this.startIndex === 0) { if (this.tabs.length > 0 && this.startIndex === 0) {
let firstTab = this.tabs[this.activeTabIndex] let firstTab = this.tabs[this.activeTabIndex]
firstTab.active = true firstTab.active = true
this.tryChangeRoute(firstTab)
} }
if (this.startIndex < this.tabs.length) { if (this.startIndex < this.tabs.length) {
let tabToActivate = this.tabs[this.startIndex] let tabToActivate = this.tabs[this.startIndex]
this.activeTabIndex = this.startIndex this.activeTabIndex = this.startIndex
tabToActivate.active = true tabToActivate.active = true
this.maxStep = this.startIndex this.maxStep = this.startIndex
this.tryChangeRoute(this.tabs[this.startIndex])
} else { } 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`) 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: { beforeChange: {
type: Function type: Function
},
route: {
type: [String, Object]
} }
}, },
data () { data () {