Skip to content
This repository was archived by the owner on Apr 1, 2021. It is now read-only.

Commit c4f92b0

Browse files
committed
Merge branch 'feature/vuelidate' into develop
2 parents 1ac6d62 + c9fb0a9 commit c4f92b0

File tree

5 files changed

+84
-17
lines changed

5 files changed

+84
-17
lines changed

package-lock.json

Lines changed: 12 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"vue-router": "^3.0.1",
6666
"vue-sweetalert2": "^1.5.9",
6767
"vuejs-datepicker": "^1.5.4",
68+
"vuelidate": "^0.7.4",
6869
"vuex": "^3.0.1",
6970
"vuex-easy-access": "^3.1.4"
7071
},

resources/js/coreui/main.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Datepicker from 'vuejs-datepicker'
66
import { id } from 'vuejs-datepicker/dist/locale'
77
import Notifications from 'vue-notification'
88
import Sweetalert from 'vue-sweetalert2'
9+
import Vuelidate from 'vuelidate'
910
import Loading from './components/Loading'
1011
import Select2 from './components/Select'
1112
import App from './App'
@@ -15,6 +16,16 @@ import store from './store'
1516
Vue.use(BootstrapVue)
1617
Vue.use(Notifications)
1718
Vue.use(Sweetalert)
19+
Vue.use(Vuelidate)
20+
21+
Vue.filter('state', (value, dirtyOnly = true) => {
22+
if (dirtyOnly) {
23+
if (!value.$dirty)
24+
return null
25+
}
26+
27+
return !value.$invalid ? 'valid' : 'invalid'
28+
})
1829

1930
Vue.component('b-loading', Loading)
2031
Vue.component('b-select-2', Select2)

resources/js/coreui/views/pages/Login.vue

Lines changed: 54 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,45 @@
1111
<h1>Login</h1>
1212
<p class="text-muted">Sign In to your account</p>
1313
<b-input-group class="mb-3">
14-
<b-input-group-prepend><b-input-group-text><i class="icon-user"/></b-input-group-text></b-input-group-prepend>
15-
<input
14+
<b-input-group-prepend>
15+
<b-input-group-text>
16+
<i class="icon-user"/>
17+
</b-input-group-text>
18+
</b-input-group-prepend>
19+
<b-input
1620
type="text"
1721
class="form-control"
18-
placeholder="Username">
22+
placeholder="Username"
23+
:state="$v.form.username | state"
24+
v-model="form.username" />
25+
<b-form-invalid-feedback>
26+
Required
27+
</b-form-invalid-feedback>
1928
</b-input-group>
2029
<b-input-group class="mb-4">
21-
<b-input-group-prepend><b-input-group-text><i class="icon-lock"/></b-input-group-text></b-input-group-prepend>
22-
<input
30+
<b-input-group-prepend>
31+
<b-input-group-text>
32+
<i class="icon-lock"/>
33+
</b-input-group-text>
34+
</b-input-group-prepend>
35+
<b-input
2336
type="password"
2437
class="form-control"
25-
placeholder="Password">
38+
placeholder="Password"
39+
:state="$v.form.password | state"
40+
v-model="form.password" />
41+
<b-form-invalid-feedback>
42+
Required
43+
</b-form-invalid-feedback>
2644
</b-input-group>
2745
<b-row>
2846
<b-col cols="6">
2947
<b-button
3048
variant="primary"
31-
class="px-4">Login</b-button>
49+
class="px-4"
50+
@click="submit">
51+
Login
52+
</b-button>
3253
</b-col>
3354
<b-col
3455
cols="6"
@@ -62,5 +83,30 @@
6283
</template>
6384

6485
<script>
65-
export default { name: 'Login' }
86+
import { required } from 'validators'
87+
88+
export default {
89+
name: 'Login',
90+
data () {
91+
return {
92+
form: {
93+
username: '',
94+
password: '',
95+
},
96+
}
97+
},
98+
validations () {
99+
return {
100+
form: {
101+
username: { required },
102+
password: { required },
103+
},
104+
}
105+
},
106+
methods: {
107+
submit () {
108+
this.$v.$touch()
109+
},
110+
},
111+
}
66112
</script>

webpack.mix.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ mix.sass('resources/sass/app.scss', 'public/css')
2020
mix.webpackConfig({
2121
resolve: {
2222
alias: {
23-
'@' : path.resolve(__dirname, 'resources/js/coreui/'),
24-
'static': path.resolve(__dirname, 'resources/static/'),
23+
'@' : path.resolve(__dirname, 'resources/js/coreui/'),
24+
'static' : path.resolve(__dirname, 'resources/static/'),
25+
'validators': 'vuelidate/lib/validators',
2526
},
2627
},
2728
plugins: [
@@ -70,6 +71,7 @@ mix.extract([
7071
'chart.js',
7172
'jquery',
7273
'lodash',
74+
'moment',
7375
'popper.js',
7476
'select2',
7577
'vue',
@@ -79,7 +81,9 @@ mix.extract([
7981
'vue-router',
8082
'vue-sweetalert2',
8183
'vuejs-datepicker',
84+
'vuelidate',
8285
'vuex',
86+
'vuex-easy-access',
8387
])
8488

8589
mix.options({

0 commit comments

Comments
 (0)