mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-22 06:49:35 +00:00
108 lines
2.9 KiB
Vue
108 lines
2.9 KiB
Vue
<template>
|
|
<div class="border-bottom py-5 px-5">
|
|
<h1>Všeobecné informácie</h1>
|
|
<v-text-field class="w-75" variant="solo" label="Meno" :disabled="true" v-model="user.name"></v-text-field>
|
|
<v-text-field class="w-75" variant="solo" label="Priezvisko" v-model="user.surname" :disabled="true"></v-text-field>
|
|
</div>
|
|
<div class="py-5 px-5 border-bottom">
|
|
<h1>Pracovná doba</h1>
|
|
<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>
|
|
<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>
|
|
</div>
|
|
<div class="py-5 px-5">
|
|
<v-btn class="button primary" @click="updateUserInfo()">ULOŽIŤ ZMENY</v-btn>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import useVuelidate from "@vuelidate/core"
|
|
import { required } from "@vuelidate/validators"
|
|
import errorUtils from "@/plugins/lib@auth/_utils/error.utils"
|
|
import { mapGetters } from "vuex"
|
|
|
|
export default {
|
|
data() {
|
|
return {
|
|
errorUtils,
|
|
v$: useVuelidate(),
|
|
form: {}
|
|
}
|
|
},
|
|
|
|
computed: {
|
|
...mapGetters("auth", ["user"])
|
|
},
|
|
|
|
validations() {
|
|
return {
|
|
form: {
|
|
work_start: { required },
|
|
work_end: { required }
|
|
}
|
|
}
|
|
},
|
|
|
|
mounted() {
|
|
this._setDates()
|
|
},
|
|
|
|
methods: {
|
|
async updateUserInfo() {
|
|
if (!(await this.v$.$validate())) return
|
|
|
|
const [sHours, sMinutes] = this.form.work_start.split(':');
|
|
const [eHours, eMinutes] = this.form.work_end.split(':');
|
|
|
|
const data = {
|
|
id: this.user.id,
|
|
work_start: parseFloat(sHours) + parseFloat(sMinutes) / 60,
|
|
work_end: parseFloat(eHours) + parseFloat(eMinutes) / 60
|
|
}
|
|
|
|
try {
|
|
await this.$store.dispatch('auth/updateUserInfo', data)
|
|
this.$toast.success('Profil bol úspešne zmenený')
|
|
} catch (error) {
|
|
this.$toast.error(this.$parseError(error))
|
|
}
|
|
},
|
|
|
|
_setDates() {
|
|
this.form = {
|
|
work_start: this.decimalHoursToTime(this.user.work_start),
|
|
work_end: this.decimalHoursToTime(this.user.work_end)
|
|
}
|
|
},
|
|
|
|
// minutesToTime(minutes) {
|
|
// var hours = Math.floor(minutes / 60)
|
|
// var mins = minutes % 60
|
|
// hours = (hours < 10 ? '0' : '') + hours
|
|
// mins = (mins < 10 ? '0' : '') + mins
|
|
|
|
// return hours + ':' + mins
|
|
// },
|
|
|
|
decimalHoursToTime(decimalHours) {
|
|
var hours = Math.floor(decimalHours)
|
|
var mins = Math.floor((decimalHours * 60) % 60)
|
|
hours = (hours < 10 ? '0' : '') + hours
|
|
mins = (mins < 10 ? '0' : '') + mins
|
|
|
|
return hours + ':' + mins
|
|
}
|
|
},
|
|
|
|
watch: {
|
|
user() {
|
|
this._setDates()
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="sass" scoped>
|
|
.border-bottom
|
|
border-bottom: 1px solid #EDEDED
|
|
</style>
|