Migrates Steps to V3
parent
98c20dbf3c
commit
32cc3b0357
|
@ -41,7 +41,6 @@
|
||||||
"node-sass": "^4.12.0",
|
"node-sass": "^4.12.0",
|
||||||
"sass-loader": "^8.0.2",
|
"sass-loader": "^8.0.2",
|
||||||
"axios": "^0.19.0",
|
"axios": "^0.19.0",
|
||||||
"vuelidate": "^0.7.4",
|
|
||||||
"chart.js": "2.7.3",
|
"chart.js": "2.7.3",
|
||||||
"gulp": "^3.9.1",
|
"gulp": "^3.9.1",
|
||||||
"gulp-concat": "^2.6.0",
|
"gulp-concat": "^2.6.0",
|
||||||
|
|
|
@ -88,9 +88,7 @@ import '@fullcalendar/core/main.min.css';
|
||||||
import '@fullcalendar/daygrid/main.min.css';
|
import '@fullcalendar/daygrid/main.min.css';
|
||||||
import '@fullcalendar/timegrid/main.min.css';
|
import '@fullcalendar/timegrid/main.min.css';
|
||||||
import './assets/styles/flags.css';
|
import './assets/styles/flags.css';
|
||||||
//import Vuelidate from 'vuelidate';
|
|
||||||
|
|
||||||
//Vue.use(Vuelidate);
|
|
||||||
/*router.beforeEach(function (to, from, next) {
|
/*router.beforeEach(function (to, from, next) {
|
||||||
window.scrollTo(0, 0);
|
window.scrollTo(0, 0);
|
||||||
next();
|
next();
|
||||||
|
|
|
@ -11,25 +11,24 @@
|
||||||
<div class="p-fluid">
|
<div class="p-fluid">
|
||||||
<div class="p-field">
|
<div class="p-field">
|
||||||
<label for="firstname">Firstname</label>
|
<label for="firstname">Firstname</label>
|
||||||
<InputText id="firstname" v-model="$v.firstname.$model" :class="{'p-invalid':$v.firstname.$invalid && submitted}" />
|
<InputText id="firstname" v-model="firstname" :class="{'p-invalid': validationErrors.firstname && submitted}" />
|
||||||
<small v-show="$v.firstname.$invalid && submitted" class="p-error">Firstname is required.</small>
|
<small v-show="validationErrors.firstname && submitted" class="p-error">Firstname is required.</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="p-field">
|
<div class="p-field">
|
||||||
<label for="lastname">Lastname</label>
|
<label for="lastname">Lastname</label>
|
||||||
<InputText v-model="$v.lastname.$model" :class="{'p-invalid':$v.lastname.$invalid && submitted}" />
|
<InputText id="lastname" v-model="lastname" :class="{'p-invalid': validationErrors.lastname && submitted}" />
|
||||||
<small v-show="$v.lastname.$invalid && submitted" class="p-error">Lastname is required.</small>
|
<small v-show="validationErrors.lastname && submitted" class="p-error">Lastname is required.</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="p-field">
|
<div class="p-field">
|
||||||
<label for="age">Age</label>
|
<label for="age">Age</label>
|
||||||
<InputText id="age" v-model="$v.age.$model" :class="{'p-invalid':$v.age.$error && submitted}" />
|
<InputNumber id="age" v-model="age" />
|
||||||
<small v-show="$v.age.$invalid && submitted" class="p-error">Age should be a number.</small>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-slot:footer>
|
<template v-slot:footer>
|
||||||
<div class="p-grid p-nogutter p-justify-between">
|
<div class="p-grid p-nogutter p-justify-between">
|
||||||
<i></i>
|
<i></i>
|
||||||
<Button label="Next" @click="nextPage(!$v.$invalid)" icon="pi pi-angle-right" iconPos="right" />
|
<Button label="Next" @click="nextPage()" icon="pi pi-angle-right" iconPos="right" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Card>
|
</Card>
|
||||||
|
@ -37,37 +36,35 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {required, integer} from 'vuelidate/lib/validators';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
firstname: '',
|
firstname: '',
|
||||||
lastname: '',
|
lastname: '',
|
||||||
age: '',
|
age: null,
|
||||||
submitted: false
|
submitted: false,
|
||||||
}
|
validationErrors: {}
|
||||||
},
|
|
||||||
validations: {
|
|
||||||
firstname: {
|
|
||||||
required
|
|
||||||
},
|
|
||||||
lastname: {
|
|
||||||
required
|
|
||||||
},
|
|
||||||
age: {
|
|
||||||
integer
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
nextPage(isFormValid) {
|
nextPage() {
|
||||||
this.submitted = true;
|
this.submitted = true;
|
||||||
|
if (this.validateForm() ) {
|
||||||
if (!isFormValid) {
|
this.$emit('next-page', {formData: {firstname: this.firstname, lastname: this.lastname, age: this.age}, pageIndex: 0});
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
validateForm() {
|
||||||
|
if (!this.firstname.trim())
|
||||||
|
this.validationErrors['firstname'] = true;
|
||||||
|
else
|
||||||
|
delete this.validationErrors['firstname'];
|
||||||
|
|
||||||
this.$emit('next-page', {formData: {firstname: this.firstname, lastname: this.lastname, age: this.age}, pageIndex: 0});
|
if (!this.lastname.trim())
|
||||||
|
this.validationErrors['lastname'] = true;
|
||||||
|
else
|
||||||
|
delete this.validationErrors['lastname'];
|
||||||
|
|
||||||
|
return !Object.keys(this.validationErrors).length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,9 +12,11 @@
|
||||||
<Steps :model="items" :readonly="true" />
|
<Steps :model="items" :readonly="true" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<keep-alive>
|
<router-view v-slot="{Component}" :formData="formObject" @prev-page="prevPage($event)" @next-page="nextPage($event)" @complete="complete">
|
||||||
<router-view :formData="formObject" @prev-page="prevPage($event)" @next-page="nextPage($event)" @complete="complete" />
|
<keep-alive>
|
||||||
</keep-alive>
|
<component :is="Component" />
|
||||||
|
</keep-alive>
|
||||||
|
</router-view>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<StepsDoc />
|
<StepsDoc />
|
||||||
|
|
|
@ -125,10 +125,15 @@ export default {
|
||||||
</a>
|
</a>
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<template v-pre>
|
<template v-pre>
|
||||||
<Steps :model="items" :readonly="true" style="margin-bottom: 1rem" />
|
<div class="card">
|
||||||
<keep-alive>
|
<Steps :model="items" :readonly="true" />
|
||||||
<router-view :formData="formObject" @prevPage="prev-page($event)" @next-page="nextPage($event)" @complete="complete" />
|
</div>
|
||||||
</keep-alive>
|
|
||||||
|
<router-view v-slot="{Component}" :formData="formObject" @prev-page="prevPage($event)" @next-page="nextPage($event)" @complete="complete">
|
||||||
|
<keep-alive>
|
||||||
|
<component :is="Component" />
|
||||||
|
</keep-alive>
|
||||||
|
</router-view>
|
||||||
</template>
|
</template>
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
||||||
|
@ -182,36 +187,34 @@ export default {
|
||||||
<template v-pre>
|
<template v-pre>
|
||||||
<div class="stepsdemo-content">
|
<div class="stepsdemo-content">
|
||||||
<Card>
|
<Card>
|
||||||
<template slot="title">
|
<template v-slot:title>
|
||||||
Personal Information
|
Personal Information
|
||||||
</template>
|
</template>
|
||||||
<template slot="subtitle">
|
<template v-slot:subtitle>
|
||||||
Enter your information
|
Enter your personal information
|
||||||
</template>
|
</template>
|
||||||
<template slot="content">
|
<template v-slot:content>
|
||||||
<p class="p-text-secondary">Enter your information</p>
|
|
||||||
<div class="p-fluid">
|
<div class="p-fluid">
|
||||||
<div class="p-field">
|
<div class="p-field">
|
||||||
<label for="firstname">Firstname</label>
|
<label for="firstname">Firstname</label>
|
||||||
<InputText id="firstname" v-model="$v.firstname.$model" :class="{'p-invalid':$v.firstname.$invalid && submitted}" />
|
<InputText id="firstname" v-model="firstname" :class="{'p-invalid': validationErrors.firstname && submitted}" />
|
||||||
<small v-show="$v.firstname.$invalid && submitted" class="p-error">Firstname is required.</small>
|
<small v-show="validationErrors.firstname && submitted" class="p-error">Firstname is required.</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="p-field">
|
<div class="p-field">
|
||||||
<label for="lastname">Lastname</label>
|
<label for="lastname">Lastname</label>
|
||||||
<InputText v-model="$v.lastname.$model" :class="{'p-invalid':$v.lastname.$invalid && submitted}" />
|
<InputText id="lastname" v-model="lastname" :class="{'p-invalid': validationErrors.lastname && submitted}" />
|
||||||
<small v-show="$v.lastname.$invalid && submitted" class="p-error">Lastname is required.</small>
|
<small v-show="validationErrors.lastname && submitted" class="p-error">Lastname is required.</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="p-field">
|
<div class="p-field">
|
||||||
<label for="age">Age</label>
|
<label for="age">Age</label>
|
||||||
<InputText id="age" v-model="$v.age.$model" :class="{'p-invalid':$v.age.$error && submitted}" />
|
<InputNumber id="age" v-model="age" />
|
||||||
<small v-show="$v.age.$invalid && submitted" class="p-error">Age should be a number.</small>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template slot="footer">
|
<template v-slot:footer>
|
||||||
<div class="p-grid p-nogutter p-justify-between">
|
<div class="p-grid p-nogutter p-justify-between">
|
||||||
<i></i>
|
<i></i>
|
||||||
<Button label="Next" @click="nextPage(!$v.$invalid)" icon="pi pi-angle-right" iconPos="right" />
|
<Button label="Next" @click="nextPage()" icon="pi pi-angle-right" iconPos="right" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</Card>
|
</Card>
|
||||||
|
@ -220,77 +223,76 @@ export default {
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
||||||
<CodeHighlight lang="javascript">
|
<CodeHighlight lang="javascript">
|
||||||
import {required, integer} from 'vuelidate/lib/validators';
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
firstname: '',
|
firstname: '',
|
||||||
lastname: '',
|
lastname: '',
|
||||||
age: '',
|
age: null,
|
||||||
submitted: false
|
submitted: false,
|
||||||
}
|
validationErrors: {}
|
||||||
},
|
|
||||||
validations: {
|
|
||||||
firstname: {
|
|
||||||
required
|
|
||||||
},
|
|
||||||
lastname: {
|
|
||||||
required
|
|
||||||
},
|
|
||||||
age: {
|
|
||||||
integer
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
nextPage(isFormValid) {
|
nextPage() {
|
||||||
this.submitted = true;
|
this.submitted = true;
|
||||||
|
if (this.validateForm() ) {
|
||||||
if (!isFormValid) {
|
this.$emit('next-page', {formData: {firstname: this.firstname, lastname: this.lastname, age: this.age}, pageIndex: 0});
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
validateForm() {
|
||||||
|
if (!this.firstname.trim())
|
||||||
|
this.validationErrors['firstname'] = true;
|
||||||
|
else
|
||||||
|
delete this.validationErrors['firstname'];
|
||||||
|
|
||||||
this.$emit('next-page', {formData: {firstname: this.firstname, lastname: this.lastname, age: this.age}, pageIndex: 0});
|
if (!this.lastname.trim())
|
||||||
|
this.validationErrors['lastname'] = true;
|
||||||
|
else
|
||||||
|
delete this.validationErrors['lastname'];
|
||||||
|
|
||||||
|
return !Object.keys(this.validationErrors).length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
|
|
||||||
<TabPanel header="Seat">
|
<TabPanel header="Seat">
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<template v-pre>
|
<template v-pre>
|
||||||
<div class="stepsdemo-content">
|
<div class="stepsdemo-content">
|
||||||
<Card>
|
<Card>
|
||||||
<template slot="title">
|
<template slot="title">
|
||||||
Seat Information
|
Seat Information
|
||||||
</template>
|
</template>
|
||||||
<template slot="subtitle">
|
<template slot="subtitle">
|
||||||
Choose your seat
|
Choose your seat
|
||||||
</template>
|
</template>
|
||||||
<template slot="content">
|
<template slot="content">
|
||||||
<div class="p-fluid p-formgrid p-grid">
|
<div class="p-fluid p-formgrid p-grid">
|
||||||
<div class="p-field p-col-12 p-md-6">
|
<div class="p-field p-col-12 p-md-6">
|
||||||
<label for="class">Class</label>
|
<label for="class">Class</label>
|
||||||
<Dropdown inputId="class" v-model="selectedClass" :options="classes" @change="setVagons($event)" optionLabel="name" placeholder="Select a Class" />
|
<Dropdown inputId="class" v-model="selectedClass" :options="classes" @change="setVagons($event)" optionLabel="name" placeholder="Select a Class" />
|
||||||
</div>
|
|
||||||
<div class="p-field p-col-12 p-md-6">
|
|
||||||
<label for="lastname">Wagon</label>
|
|
||||||
<Dropdown inputId="wagon" v-model="selectedVagon" :options="vagons" @change="setSeats($event)" optionLabel="vagon" placeholder="Select a Vagon" />
|
|
||||||
</div>
|
|
||||||
<div class="p-field p-col-12">
|
|
||||||
<label for="seat">Seat</label>
|
|
||||||
<Dropdown inputId="seat" v-model="selectedSeat" :options="seats" optionLabel="seat" placeholder="Select a Seat" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
<div class="p-field p-col-12 p-md-6">
|
||||||
<template slot="footer">
|
<label for="lastname">Wagon</label>
|
||||||
<div class="p-grid p-nogutter p-justify-between">
|
<Dropdown inputId="wagon" v-model="selectedVagon" :options="vagons" @change="setSeats($event)" optionLabel="vagon" placeholder="Select a Vagon" />
|
||||||
<Button label="Back" @click="prevPage()" icon="pi pi-angle-left" />
|
|
||||||
<Button label="Next" @click="nextPage()" icon="pi pi-angle-right" iconPos="right" />
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
<div class="p-field p-col-12">
|
||||||
</Card>
|
<label for="seat">Seat</label>
|
||||||
</div>
|
<Dropdown inputId="seat" v-model="selectedSeat" :options="seats" optionLabel="seat" placeholder="Select a Seat" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template slot="footer">
|
||||||
|
<div class="p-grid p-nogutter p-justify-between">
|
||||||
|
<Button label="Back" @click="prevPage()" icon="pi pi-angle-left" />
|
||||||
|
<Button label="Next" @click="nextPage()" icon="pi pi-angle-right" iconPos="right" />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
|
|
||||||
|
@ -406,6 +408,7 @@ export default {
|
||||||
}
|
}
|
||||||
</CodeHighlight>
|
</CodeHighlight>
|
||||||
</TabPanel>
|
</TabPanel>
|
||||||
|
|
||||||
<TabPanel header="Confirmation">
|
<TabPanel header="Confirmation">
|
||||||
<CodeHighlight>
|
<CodeHighlight>
|
||||||
<template v-pre>
|
<template v-pre>
|
||||||
|
|
Loading…
Reference in New Issue