mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 14:29:34 +00:00
[Profile] Update fixed
This commit is contained in:
1 parent
0d5bfa3b9b
commit
eb7b44fbfe
4 files changed
+54
-75
No files matched your search
@@ -44,13 +44,13 @@ const options: Options = {
|
|||||||
},
|
},
|
||||||
moxios: {
|
moxios: {
|
||||||
routes: {
|
routes: {
|
||||||
'GET v1/auth/info': true,
|
// 'GET v1/auth/info': true,
|
||||||
'POST v1/auth/forgot': true,
|
// 'POST v1/auth/forgot': true,
|
||||||
'POST v1/auth/reset': true,
|
// 'POST v1/auth/reset': true,
|
||||||
'POST v1/auth/info': true,
|
// 'POST v1/auth/info': true,
|
||||||
'POST v1/auth/invalidate': true,
|
// 'POST v1/auth/invalidate': true,
|
||||||
'POST v1/auth/login': true,
|
// 'POST v1/auth/login': true,
|
||||||
'POST v1/auth/post': true,
|
// 'POST v1/auth/post': true,
|
||||||
|
|
||||||
'GET v1/overview/teams': true,
|
'GET v1/overview/teams': true,
|
||||||
'GET v1/overview/tasks': true,
|
'GET v1/overview/tasks': true,
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import ZTimeline from '@/plugins/tm@dashboard/_components/z-timeline.vue
|
|||||||
import { addDays, subDays } from 'date-fns'
|
import { addDays, subDays } from 'date-fns'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
import timelineUtils from './_utils/timeline.utils'
|
import timelineUtils from './_utils/timeline.utils'
|
||||||
|
import { mapGetters } from 'vuex'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -30,6 +31,10 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
...mapGetters('auth', [
|
||||||
|
'user'
|
||||||
|
]),
|
||||||
|
|
||||||
splitDays() {
|
splitDays() {
|
||||||
const days = []
|
const days = []
|
||||||
const workingHours = {}
|
const workingHours = {}
|
||||||
@@ -89,8 +94,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
unmounted() {
|
unmounted() {
|
||||||
this.$events.off('on-subtask-edited')
|
this.$events.off('on-user-updated')
|
||||||
this.$events.off('on-subtask-deleted')
|
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -1,61 +1,13 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="border-bottom py-5 px-5">
|
<div class="border-bottom py-5 px-5">
|
||||||
<h1>Všeobecné informácie</h1>
|
<h1>Všeobecné informácie</h1>
|
||||||
<v-text-field
|
<v-text-field class="w-75" variant="solo" label="Meno" :disabled="true" v-model="user.name"></v-text-field>
|
||||||
class="w-75"
|
<v-text-field class="w-75" variant="solo" label="Priezvisko" v-model="user.surname" :disabled="true"></v-text-field>
|
||||||
variant="solo"
|
|
||||||
label="Meno"
|
|
||||||
v-model="user.name"
|
|
||||||
:class="{ error: v$.user.name.$errors.length }"
|
|
||||||
:hint="
|
|
||||||
v$.user.name.$errors
|
|
||||||
? errorUtils.parseErrors(v$.user.name.$errors)
|
|
||||||
: null
|
|
||||||
"
|
|
||||||
></v-text-field>
|
|
||||||
<v-text-field
|
|
||||||
class="w-75"
|
|
||||||
variant="solo"
|
|
||||||
label="Priezvisko"
|
|
||||||
v-model="user.surname"
|
|
||||||
:class="{ error: v$.user.surname.$errors.length }"
|
|
||||||
:hint="
|
|
||||||
v$.user.surname.$errors
|
|
||||||
? errorUtils.parseErrors(v$.user.surname.$errors)
|
|
||||||
: null
|
|
||||||
"
|
|
||||||
></v-text-field>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="py-5 px-5 border-bottom">
|
<div class="py-5 px-5 border-bottom">
|
||||||
<h1>Pracovná doba</h1>
|
<h1>Pracovná doba</h1>
|
||||||
<v-text-field
|
<v-text-field class="w-75" variant="solo" label="Začiatok" v-model="form.work_start" append-inner-icon="mdi-clock-outline" type="time" :class="{ error: v$.form.work_start.$errors.length }" :hint="v$.form.work_start.$errors ? errorUtils.parseErrors(v$.form.work_start.$errors) : null"></v-text-field>
|
||||||
class="w-75"
|
<v-text-field class="w-75" variant="solo" label="Koniec" v-model="form.work_end" append-inner-icon="mdi-clock-outline" type="time" :class="{ error: v$.form.work_end.$errors.length }" :hint="v$.form.work_end.$errors ? errorUtils.parseErrors(v$.form.work_end.$errors) : null"></v-text-field>
|
||||||
variant="solo"
|
|
||||||
label="Začiatok"
|
|
||||||
v-model="user.work_hours_from"
|
|
||||||
append-inner-icon="mdi-clock-outline"
|
|
||||||
type="time"
|
|
||||||
:class="{ error: v$.user.work_hours_from.$errors.length }"
|
|
||||||
:hint="
|
|
||||||
v$.user.work_hours_from.$errors
|
|
||||||
? errorUtils.parseErrors(v$.user.work_hours_from.$errors)
|
|
||||||
: null
|
|
||||||
"
|
|
||||||
></v-text-field>
|
|
||||||
<v-text-field
|
|
||||||
class="w-75"
|
|
||||||
variant="solo"
|
|
||||||
label="Koniec"
|
|
||||||
v-model="user.work_hours_to"
|
|
||||||
append-inner-icon="mdi-clock-outline"
|
|
||||||
:class="{ error: v$.user.work_hours_to.$errors.length }"
|
|
||||||
:hint="
|
|
||||||
v$.user.work_hours_to.$errors
|
|
||||||
? errorUtils.parseErrors(v$.user.work_hours_to.$errors)
|
|
||||||
: null
|
|
||||||
"
|
|
||||||
type="time"
|
|
||||||
></v-text-field>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="py-5 px-5">
|
<div class="py-5 px-5">
|
||||||
<v-btn class="button primary" @click="updateUserInfo()">ULOŽIŤ ZMENY</v-btn>
|
<v-btn class="button primary" @click="updateUserInfo()">ULOŽIŤ ZMENY</v-btn>
|
||||||
@@ -63,46 +15,69 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import useVuelidate from '@vuelidate/core'
|
import useVuelidate from "@vuelidate/core"
|
||||||
import { required } from '@vuelidate/validators'
|
import { required } from "@vuelidate/validators"
|
||||||
import errorUtils from '@/plugins/lib@auth/_utils/error.utils'
|
import errorUtils from "@/plugins/lib@auth/_utils/error.utils"
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from "vuex"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
errorUtils,
|
errorUtils,
|
||||||
v$: useVuelidate(),
|
v$: useVuelidate(),
|
||||||
|
form: {}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters('auth', ['user']),
|
...mapGetters("auth", ["user"])
|
||||||
},
|
},
|
||||||
|
|
||||||
validations() {
|
validations() {
|
||||||
return {
|
return {
|
||||||
user: {
|
form: {
|
||||||
name: { required },
|
work_start: { required },
|
||||||
surname: { required },
|
work_end: { required }
|
||||||
work_hours_from: { required },
|
|
||||||
work_hours_to: { required },
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
this._setDates()
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
async updateUserInfo() {
|
async updateUserInfo() {
|
||||||
if (!(await this.v$.$validate())) return
|
if (!(await this.v$.$validate())) return
|
||||||
try {
|
|
||||||
await this.$store.dispatch('auth/updateUserInfo', this.user)
|
|
||||||
|
|
||||||
|
const data = {
|
||||||
|
id: this.user.id,
|
||||||
|
work_start: parseInt(this.form.work_start.split(':')[0]),
|
||||||
|
work_end: parseInt(this.form.work_end.split(':')[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await this.$store.dispatch('auth/updateUserInfo', data)
|
||||||
this.$toast.success('Profil bol úspešne zmenený')
|
this.$toast.success('Profil bol úspešne zmenený')
|
||||||
|
this.$events.emit('on-user-updated', this.user)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.$toast.error(error)
|
this.$toast.error(error)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_setDates() {
|
||||||
|
this.form = {
|
||||||
|
work_start: this.user.work_start < 10 ? `0${this.user.work_start}:00` : `${this.user.work_start}:00`,
|
||||||
|
work_end: this.user.work_end < 10 ? `0${this.user.work_end}:00` : `${this.user.work_end}:00`
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
watch: {
|
||||||
|
user() {
|
||||||
|
this._setDates()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ export default {
|
|||||||
},
|
},
|
||||||
updateUserInfo({commit}: {commit: any}, data: any) {
|
updateUserInfo({commit}: {commit: any}, data: any) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
axios.post_auth_data('v1/auth/info', data)
|
axios.put_auth(`v1/users/${data.id}`, {data: data})
|
||||||
.then((response: any) => {
|
.then((response: any) => {
|
||||||
const user = response.user
|
const user = response.user
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user