release v2.0.0 #4
			
				
			
		
		
		
	| 
						 | 
				
			
			@ -1,20 +1,19 @@
 | 
			
		|||
<template>
 | 
			
		||||
  <q-card class="col-12">
 | 
			
		||||
    <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"
 | 
			
		||||
        v-model="firstname"
 | 
			
		||||
          :rules="[notEmpty]"
 | 
			
		||||
        ref="ref_firstname"
 | 
			
		||||
          v-model="firstname"
 | 
			
		||||
          filled
 | 
			
		||||
        />
 | 
			
		||||
        <q-input
 | 
			
		||||
          class="col-xs-12 col-sm-6 q-pa-sm"
 | 
			
		||||
          label="Nachname"
 | 
			
		||||
        v-model="lastname"
 | 
			
		||||
          :rules="[notEmpty]"
 | 
			
		||||
        ref="ref_lastname"
 | 
			
		||||
          v-model="lastname"
 | 
			
		||||
          filled
 | 
			
		||||
        />
 | 
			
		||||
        <q-input
 | 
			
		||||
| 
						 | 
				
			
			@ -27,17 +26,15 @@
 | 
			
		|||
        <q-input
 | 
			
		||||
          class="col-xs-12 col-sm-6 q-pa-sm"
 | 
			
		||||
          label="E-Mail"
 | 
			
		||||
        v-model="mail"
 | 
			
		||||
          :rules="[isEmail, notEmpty]"
 | 
			
		||||
        ref="ref_mail"
 | 
			
		||||
          v-model="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"
 | 
			
		||||
          v-model="display_name"
 | 
			
		||||
          filled
 | 
			
		||||
        />
 | 
			
		||||
        <q-select
 | 
			
		||||
| 
						 | 
				
			
			@ -62,9 +59,8 @@
 | 
			
		|||
          label="Password"
 | 
			
		||||
          type="password"
 | 
			
		||||
          hint="Password muss immer eingetragen werden"
 | 
			
		||||
        v-model="password"
 | 
			
		||||
          :rules="[notEmpty]"
 | 
			
		||||
        ref="ref_password"
 | 
			
		||||
          v-model="password"
 | 
			
		||||
          filled
 | 
			
		||||
        />
 | 
			
		||||
        <q-input
 | 
			
		||||
| 
						 | 
				
			
			@ -78,17 +74,17 @@
 | 
			
		|||
          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"
 | 
			
		||||
          v-model="new_password2"
 | 
			
		||||
          filled
 | 
			
		||||
        />
 | 
			
		||||
      </q-card-section>
 | 
			
		||||
      <q-card-actions align="right">
 | 
			
		||||
      <q-btn label="Reset" @click="reset" />
 | 
			
		||||
      <q-btn color="primary" label="Speichern" @click="save" />
 | 
			
		||||
        <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