Use form row component

This commit is contained in:
Björn Fromme
2019-10-02 16:21:51 +02:00
parent 1e8a15b6f0
commit b1359611a6
@@ -4,18 +4,12 @@
<form @submit.prevent="submit()"> <form @submit.prevent="submit()">
<div class="row"> <div class="row">
<div class="col-xs-12 col-md-6"> <div class="col-xs-12 col-md-6">
<div class="form-group"> <form-group label="E-Mail" :error="formErrors.email">
<label for="email" class="control-label"> <input type="text" v-model="email" class="form-control">
E-Mail </form-group>
</label> <form-group label="Passwort" v-if="loginMode">
<input id="email" type="text" v-model="email" class="form-control"> <input type="password" v-model="password" class="form-control">
</div> </form-group>
<div class="form-group" v-if="loginMode">
<label for="password" class="control-label">
Passwort
</label>
<input id="password" type="password" v-model="password" class="form-control">
</div>
<div class="form-group"> <div class="form-group">
<div class="btn-group"> <div class="btn-group">
<button type="submit" class="button" :disabled="loading"> <button type="submit" class="button" :disabled="loading">
@@ -43,13 +37,16 @@
<script> <script>
import { mapState, mapGetters, mapMutations } from 'vuex' import { mapState, mapGetters, mapMutations } from 'vuex'
import FormGroup from "./components/FormGroup";
export default { export default {
data () { components: {FormGroup},
data () {
return { return {
mode: 'login', mode: 'login',
email: '', email: '',
password: '' password: '',
formErrors: {}
} }
}, },
methods: { methods: {
@@ -67,6 +64,7 @@
} }
}, },
login () { login () {
this.formErrors = {};
if (!this.email || !this.password) { if (!this.email || !this.password) {
this.alert({ this.alert({
message: 'Bitte E-Mail und Passwort eingeben', message: 'Bitte E-Mail und Passwort eingeben',
@@ -83,6 +81,7 @@
}); });
}, },
resetPassword () { resetPassword () {
this.formErrors = {};
if (!this.email) { if (!this.email) {
this.alert({ this.alert({
message: 'Bitte die E-Mail Adresse angeben', message: 'Bitte die E-Mail Adresse angeben',
@@ -106,6 +105,16 @@
}) })
} }
}).catch(error => { }).catch(error => {
this.alert({
message: 'Bitte überprüfe deine Eingaben.',
class: 'alert-danger'
});
const violations = error.response.data.violations;
if (typeof violations !== 'undefined') {
for (let violation of violations) {
this.$set(this.formErrors, violation.property_path, violation.message);
}
}
}); });
} }
}, },