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