release v2.0.0 #4
|
@ -1,20 +1,19 @@
|
||||||
<template>
|
<template>
|
||||||
<q-card class="col-12">
|
<q-card class="col-12">
|
||||||
|
<q-form @submit="save" @reset="reset">
|
||||||
<q-card-section class="fit row justify-start content-center items-center">
|
<q-card-section class="fit row justify-start content-center items-center">
|
||||||
<q-input
|
<q-input
|
||||||
class="col-xs-12 col-sm-6 q-pa-sm"
|
class="col-xs-12 col-sm-6 q-pa-sm"
|
||||||
label="Vorname"
|
label="Vorname"
|
||||||
v-model="firstname"
|
|
||||||
:rules="[notEmpty]"
|
:rules="[notEmpty]"
|
||||||
ref="ref_firstname"
|
v-model="firstname"
|
||||||
filled
|
filled
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
class="col-xs-12 col-sm-6 q-pa-sm"
|
class="col-xs-12 col-sm-6 q-pa-sm"
|
||||||
label="Nachname"
|
label="Nachname"
|
||||||
v-model="lastname"
|
|
||||||
:rules="[notEmpty]"
|
:rules="[notEmpty]"
|
||||||
ref="ref_lastname"
|
v-model="lastname"
|
||||||
filled
|
filled
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
|
@ -27,17 +26,15 @@
|
||||||
<q-input
|
<q-input
|
||||||
class="col-xs-12 col-sm-6 q-pa-sm"
|
class="col-xs-12 col-sm-6 q-pa-sm"
|
||||||
label="E-Mail"
|
label="E-Mail"
|
||||||
v-model="mail"
|
|
||||||
:rules="[isEmail, notEmpty]"
|
:rules="[isEmail, notEmpty]"
|
||||||
ref="ref_mail"
|
v-model="mail"
|
||||||
filled
|
filled
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
class="col-xs-12 col-sm-6 q-pa-sm"
|
class="col-xs-12 col-sm-6 q-pa-sm"
|
||||||
label="Display Name"
|
label="Display Name"
|
||||||
v-model="display_name"
|
|
||||||
:rules="[notEmpty]"
|
:rules="[notEmpty]"
|
||||||
ref="ref_display_name"
|
v-model="display_name"
|
||||||
filled
|
filled
|
||||||
/>
|
/>
|
||||||
<q-select
|
<q-select
|
||||||
|
@ -62,9 +59,8 @@
|
||||||
label="Password"
|
label="Password"
|
||||||
type="password"
|
type="password"
|
||||||
hint="Password muss immer eingetragen werden"
|
hint="Password muss immer eingetragen werden"
|
||||||
v-model="password"
|
|
||||||
:rules="[notEmpty]"
|
:rules="[notEmpty]"
|
||||||
ref="ref_password"
|
v-model="password"
|
||||||
filled
|
filled
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
|
@ -78,17 +74,17 @@
|
||||||
class="col-xs-12 col-sm-6 col-md-4 q-pa-sm"
|
class="col-xs-12 col-sm-6 col-md-4 q-pa-sm"
|
||||||
label="Wiederhole neues Password"
|
label="Wiederhole neues Password"
|
||||||
type="password"
|
type="password"
|
||||||
v-model="new_password2"
|
|
||||||
:disable="new_password.length == 0"
|
:disable="new_password.length == 0"
|
||||||
:rules="[samePassword]"
|
:rules="[samePassword]"
|
||||||
ref="ref_new_password"
|
v-model="new_password2"
|
||||||
filled
|
filled
|
||||||
/>
|
/>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-card-actions align="right">
|
<q-card-actions align="right">
|
||||||
<q-btn label="Reset" @click="reset" />
|
<q-btn label="Reset" type="reset" />
|
||||||
<q-btn color="primary" label="Speichern" @click="save" />
|
<q-btn color="primary" type="submit" label="Speichern" />
|
||||||
</q-card-actions>
|
</q-card-actions>
|
||||||
|
</q-form>
|
||||||
</q-card>
|
</q-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -96,29 +92,31 @@
|
||||||
import { computed, defineComponent, ref } from '@vue/composition-api';
|
import { computed, defineComponent, ref } from '@vue/composition-api';
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Main',
|
name: 'Main',
|
||||||
setup(_, { root: { $store }, refs }) {
|
setup(_, { root: { $store } }) {
|
||||||
const user = computed<FG.User>(() => {
|
const user = computed<FG.User>(() => {
|
||||||
return <FG.User>$store.getters['user/user'];
|
return <FG.User>$store.getters['user/user'];
|
||||||
});
|
});
|
||||||
|
|
||||||
const firstname = ref<string>(user.value.firstname);
|
const firstname = ref(user.value.firstname);
|
||||||
const lastname = ref<string>(user.value.lastname);
|
const lastname = ref(user.value.lastname);
|
||||||
const mail = ref<string>(user.value.mail);
|
const mail = ref(user.value.mail);
|
||||||
const display_name = ref<string>(user.value.display_name);
|
const display_name = ref(user.value.display_name);
|
||||||
|
|
||||||
const password = ref<string>('');
|
const password = ref('');
|
||||||
const new_password = ref<string>('');
|
const new_password = ref('');
|
||||||
const new_password2 = ref<string>('');
|
const new_password2 = ref('');
|
||||||
|
|
||||||
function save() {
|
function save() {
|
||||||
let change_values = {
|
let change_values: { [index: string]: string } = {
|
||||||
firstname: firstname.value,
|
firstname: firstname.value,
|
||||||
lastname: lastname.value,
|
lastname: lastname.value,
|
||||||
mail: mail.value,
|
mail: mail.value,
|
||||||
display_name: display_name.value
|
display_name: display_name.value
|
||||||
};
|
};
|
||||||
Object.keys(change_values).forEach(key => {
|
Object.keys(change_values).forEach(key => {
|
||||||
if (change_values[key] === user.value[key]) {
|
if (
|
||||||
|
change_values[key] === (<{ [index: string]: any }>user.value)[key]
|
||||||
|
) {
|
||||||
delete change_values[key];
|
delete change_values[key];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -130,14 +128,9 @@ export default defineComponent({
|
||||||
new_password: new_password.value
|
new_password: new_password.value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (
|
$store.dispatch('user/updateUser', change_values).catch(error => {
|
||||||
Object.keys(refs).every(key => {
|
console.warn(error);
|
||||||
return refs[key].validate();
|
});
|
||||||
})
|
|
||||||
) {
|
|
||||||
$store.dispatch('user/updateUser', change_values);
|
|
||||||
resetPassword();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset() {
|
function reset() {
|
||||||
|
@ -148,27 +141,9 @@ export default defineComponent({
|
||||||
password.value = '';
|
password.value = '';
|
||||||
new_password.value = '';
|
new_password.value = '';
|
||||||
new_password2.value = '';
|
new_password2.value = '';
|
||||||
setTimeout(() => {
|
|
||||||
Object.keys(refs).forEach(key => {
|
|
||||||
refs[key].resetValidation();
|
|
||||||
});
|
|
||||||
}, 500);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetPassword() {
|
function samePassword(val: string) {
|
||||||
password.value = '';
|
|
||||||
new_password.value = '';
|
|
||||||
new_password2.value = '';
|
|
||||||
console.log(refs);
|
|
||||||
console.log(refs.ref_password);
|
|
||||||
console.log(refs.ref_new_password);
|
|
||||||
setTimeout(() => {
|
|
||||||
refs.ref_password.resetValidation();
|
|
||||||
refs.ref_new_password.resetValidation();
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
function samePassword(val) {
|
|
||||||
return val == new_password.value || 'Passwörter sind nicht identisch!';
|
return val == new_password.value || 'Passwörter sind nicht identisch!';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +151,7 @@ export default defineComponent({
|
||||||
return !!val || 'Feld darf nicht leer sein!';
|
return !!val || 'Feld darf nicht leer sein!';
|
||||||
}
|
}
|
||||||
|
|
||||||
function isEmail(val) {
|
function isEmail(val: string | null) {
|
||||||
return (
|
return (
|
||||||
!val ||
|
!val ||
|
||||||
/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w\w+)+$/.test(val) ||
|
/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w\w+)+$/.test(val) ||
|
||||||
|
|
Loading…
Reference in New Issue