release v2.0.0 #4
|
@ -4,15 +4,13 @@
|
||||||
<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"
|
||||||
readonly
|
v-model="firstname"
|
||||||
:value="user.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"
|
||||||
readonly
|
v-model="lastname"
|
||||||
:value="user.lastname"
|
|
||||||
filled
|
filled
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
|
@ -25,8 +23,13 @@
|
||||||
<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"
|
||||||
readonly
|
v-model="mail"
|
||||||
:value="user.mail"
|
filled
|
||||||
|
/>
|
||||||
|
<q-input
|
||||||
|
class="col-xs-12 col-sm-6 q-pa-sm"
|
||||||
|
label="Display Name"
|
||||||
|
v-model="display_name"
|
||||||
filled
|
filled
|
||||||
/>
|
/>
|
||||||
<q-select
|
<q-select
|
||||||
|
@ -50,33 +53,91 @@
|
||||||
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="Password"
|
label="Password"
|
||||||
type="password"
|
type="password"
|
||||||
|
hint="Password muss immer eingetragen werden"
|
||||||
|
v-model="password"
|
||||||
filled
|
filled
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
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="Neues Password"
|
label="Neues Password"
|
||||||
type="password"
|
type="password"
|
||||||
|
v-model="new_password"
|
||||||
|
:rules="[samePassword]"
|
||||||
filled
|
filled
|
||||||
/>
|
/>
|
||||||
<q-input
|
<q-input
|
||||||
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"
|
||||||
|
:rules="[samePassword]"
|
||||||
filled
|
filled
|
||||||
/>
|
/>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
<q-card-actions align="right">
|
||||||
|
<q-btn color="primary" label="Speichern" @click="save" />
|
||||||
|
</q-card-actions>
|
||||||
</q-card>
|
</q-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { computed, defineComponent } 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 } }) {
|
||||||
const user = computed(() => {
|
const user = computed<FG.User>(() => {
|
||||||
return $store.getters['user/user'];
|
return <FG.User>$store.getters['user/user'];
|
||||||
});
|
});
|
||||||
return { user };
|
|
||||||
|
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>('');
|
||||||
|
|
||||||
|
function save() {
|
||||||
|
let change_values = {
|
||||||
|
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]) {
|
||||||
|
delete change_values[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
change_values = Object.assign(change_values, {
|
||||||
|
password: password.value
|
||||||
|
});
|
||||||
|
if (new_password.value != '') {
|
||||||
|
change_values = Object.assign(change_values, {
|
||||||
|
new_password: new_password.value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
console.log(change_values);
|
||||||
|
$store.dispatch('user/updateUser', change_values);
|
||||||
|
}
|
||||||
|
function samePassword(val) {
|
||||||
|
return val == new_password.value || 'Passwörter sind nicht identisch!';
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
user,
|
||||||
|
firstname,
|
||||||
|
lastname,
|
||||||
|
mail,
|
||||||
|
display_name,
|
||||||
|
password,
|
||||||
|
new_password,
|
||||||
|
new_password2,
|
||||||
|
samePassword,
|
||||||
|
save
|
||||||
|
};
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -92,17 +92,33 @@ const actions: ActionTree<UserStateInterface, StateInterface> = {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
updateUser({ commit, getters }, data) {
|
||||||
|
commit('setLoginLoading', true);
|
||||||
|
axios
|
||||||
|
.put(`/users/${getters.user.userid}`, data)
|
||||||
|
.catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
commit('setLoginLoading', false);
|
||||||
|
});
|
||||||
|
},
|
||||||
loadFromLocalStorage({ commit }) {
|
loadFromLocalStorage({ commit }) {
|
||||||
console.log('load from store');
|
console.log('load from store');
|
||||||
let data = LocalStorage.getItem('user');
|
let data = LocalStorage.getItem('user');
|
||||||
commit('setUser', data ? data : {
|
commit(
|
||||||
|
'setUser',
|
||||||
|
data
|
||||||
|
? data
|
||||||
|
: {
|
||||||
display_name: '',
|
display_name: '',
|
||||||
firstname: '',
|
firstname: '',
|
||||||
lastname: '',
|
lastname: '',
|
||||||
mail: '',
|
mail: '',
|
||||||
roles: [],
|
roles: [],
|
||||||
userid: ''
|
userid: ''
|
||||||
});
|
}
|
||||||
|
);
|
||||||
data = LocalStorage.getItem('session');
|
data = LocalStorage.getItem('session');
|
||||||
commit(
|
commit(
|
||||||
'setSession',
|
'setSession',
|
||||||
|
|
Loading…
Reference in New Issue