release v2.0.0 #4
|
@ -5,12 +5,16 @@
|
||||||
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"
|
v-model="firstname"
|
||||||
|
:rules="[notEmpty]"
|
||||||
|
ref="ref_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"
|
v-model="lastname"
|
||||||
|
:rules="[notEmpty]"
|
||||||
|
ref="ref_lastname"
|
||||||
filled
|
filled
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
|
@ -24,12 +28,16 @@
|
||||||
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"
|
v-model="mail"
|
||||||
|
:rules="[isEmail, notEmpty]"
|
||||||
|
ref="ref_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"
|
v-model="display_name"
|
||||||
|
:rules="[notEmpty]"
|
||||||
|
ref="ref_display_name"
|
||||||
filled
|
filled
|
||||||
/>
|
/>
|
||||||
<q-select
|
<q-select
|
||||||
|
@ -55,6 +63,8 @@
|
||||||
type="password"
|
type="password"
|
||||||
hint="Password muss immer eingetragen werden"
|
hint="Password muss immer eingetragen werden"
|
||||||
v-model="password"
|
v-model="password"
|
||||||
|
:rules="[notEmpty]"
|
||||||
|
ref="ref_password"
|
||||||
filled
|
filled
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
|
@ -62,7 +72,6 @@
|
||||||
label="Neues Password"
|
label="Neues Password"
|
||||||
type="password"
|
type="password"
|
||||||
v-model="new_password"
|
v-model="new_password"
|
||||||
:rules="[samePassword]"
|
|
||||||
filled
|
filled
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
|
@ -72,10 +81,12 @@
|
||||||
v-model="new_password2"
|
v-model="new_password2"
|
||||||
:disable="new_password.length == 0"
|
:disable="new_password.length == 0"
|
||||||
:rules="[samePassword]"
|
:rules="[samePassword]"
|
||||||
|
ref="ref_new_password"
|
||||||
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 color="primary" label="Speichern" @click="save" />
|
<q-btn color="primary" label="Speichern" @click="save" />
|
||||||
</q-card-actions>
|
</q-card-actions>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
@ -85,15 +96,15 @@
|
||||||
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 } }) {
|
setup(_, { root: { $store }, refs }) {
|
||||||
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(user.value.firstname);
|
const firstname = ref<string>(user.value.firstname);
|
||||||
const lastname = ref(user.value.lastname);
|
const lastname = ref<string>(user.value.lastname);
|
||||||
const mail = ref(user.value.mail);
|
const mail = ref<string>(user.value.mail);
|
||||||
const display_name = ref(user.value.display_name);
|
const display_name = ref<string>(user.value.display_name);
|
||||||
|
|
||||||
const password = ref<string>('');
|
const password = ref<string>('');
|
||||||
const new_password = ref<string>('');
|
const new_password = ref<string>('');
|
||||||
|
@ -119,13 +130,60 @@ export default defineComponent({
|
||||||
new_password: new_password.value
|
new_password: new_password.value
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
console.log(change_values);
|
if (
|
||||||
$store.dispatch('user/updateUser', change_values);
|
Object.keys(refs).every(key => {
|
||||||
|
return refs[key].validate();
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
$store.dispatch('user/updateUser', change_values);
|
||||||
|
resetPassword();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reset() {
|
||||||
|
firstname.value = user.value.firstname;
|
||||||
|
lastname.value = user.value.lastname;
|
||||||
|
mail.value = user.value.mail;
|
||||||
|
display_name.value = user.value.display_name;
|
||||||
|
password.value = '';
|
||||||
|
new_password.value = '';
|
||||||
|
new_password2.value = '';
|
||||||
|
setTimeout(() => {
|
||||||
|
Object.keys(refs).forEach(key => {
|
||||||
|
refs[key].resetValidation();
|
||||||
|
});
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetPassword() {
|
||||||
|
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) {
|
function samePassword(val) {
|
||||||
return val == new_password.value || 'Passwörter sind nicht identisch!';
|
return val == new_password.value || 'Passwörter sind nicht identisch!';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function notEmpty(val: string) {
|
||||||
|
return !!val || 'Feld darf nicht leer sein!';
|
||||||
|
}
|
||||||
|
|
||||||
|
function isEmail(val) {
|
||||||
|
return (
|
||||||
|
!val ||
|
||||||
|
/^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w\w+)+$/.test(val) ||
|
||||||
|
'E-Mail ist nicht valide.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
user,
|
user,
|
||||||
firstname,
|
firstname,
|
||||||
|
@ -136,7 +194,10 @@ export default defineComponent({
|
||||||
new_password,
|
new_password,
|
||||||
new_password2,
|
new_password2,
|
||||||
samePassword,
|
samePassword,
|
||||||
save
|
isEmail,
|
||||||
|
notEmpty,
|
||||||
|
save,
|
||||||
|
reset
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue