bugs + CR's

This commit is contained in:
romankko2 committed 2023-10-12 17:28:05 +02:00
1 parent 9974d8b9e4
commit bb7b59cc0e
15 files changed
+258 -20

No files matched your search

@@ -17,7 +17,7 @@
:items="[...enrichedEmployees]" item-title="_fullName" item-value="id" variant="solo"
class="modal-input" v-model="blocker.employee_id" />
<!-- <Z-autocomplete label="Vyhľadať zamestnanca" :value="blocker?.employee ? `${blocker?.employee?.name} ${blocker?.employee?.surname}` : ''" :options="enrichedEmployees.map(employee => ({key: employee.id, value: employee._fullName}))" :clear-on-submit="false" :class="{ error: v$.blocker.employee.$errors.length }" class="modal-input" @option-selected="onEmployeeSelected" /> -->
<Datepicker class="modal-input mb-5" v-model="datepicker" format="dd.MM.yyyy" locale="sk"
<Datepicker class="modal-input mb-5" v-model="datepicker" :auto-apply="true" format="dd.MM.yyyy" locale="sk"
:class="{ error: v$.datepicker.$errors?.length }" :validations="v$.datepicker" select-text="Vybrať"
cancel-text="Zrušiť" placeholder="Dátum" :enable-time-picker="false" ref="datepicker" />
@@ -50,7 +50,7 @@
<!-- <Z-autocomplete label="Vyhľadať zamestnanca" :options="employeesOptions" class="modal-input" @option-selected="onEmployeeSelected" /> -->
<v-btn class="w-100 mb-5 button secondary" :class="{error: v$.mastertask.project_id.$errors.length}" @click="showAddEmployeeInput = true"> <v-icon class="mx-1" icon="mdi-plus" />Pridať zamestnanca </v-btn>
<v-btn :disabled="mastertask.id" class="w-100 mb-5 button secondary" :class="{error: v$.mastertask.project_id.$errors.length}" @click="showAddEmployeeInput = true"> <v-icon class="mx-1" icon="mdi-plus" />Pridať zamestnanca </v-btn>
<div class="w-100 modal-input" :class="{ error: v$.mastertask.description.$errors.length }">
<QuillEditor ref="description" v-model="mastertask.description" placeholder="Popis" theme="snow" class="rich-text-editor" @keyup="onQuillEditorInput" />
@@ -33,7 +33,7 @@
</div>
<v-card-actions class="mt-10 d-flex flex-column modal-content">
<Datepicker v-model="form.date" format="dd.MM.yyyy" locale="sk" select-text="Vybrať" cancel-text="Zrušiť" placeholder="Dátum" :enable-time-picker="false" class="mb-5 modal-input" :class="{error: v$.form.date.$errors.length}" />
<Datepicker v-model="form.date" format="dd.MM.yyyy" locale="sk" select-text="Vybrať" cancel-text="Zrušiť" placeholder="Dátum" :auto-apply="true" :enable-time-picker="false" class="mb-5 modal-input" :class="{error: v$.form.date.$errors.length}" />
<v-text-field v-model="form.starts_at_time" type="time" variant="solo" bg-color="white" :hint="v$.form.starts_at_time.$errors ? errorUtils.parseErrors(v$.form.starts_at_time.$errors) : null" :class="{ error: v$.form.starts_at_time.$errors.length }" class="mb-1 modal-input" label="Začiatok" />
<v-text-field v-model="form.ends_at_time" type="time" variant="solo" bg-color="white" :hint="v$.form.ends_at_time.$errors ? errorUtils.parseErrors(v$.form.ends_at_time.$errors) : null" :class="{ error: v$.form.ends_at_time.$errors.length }" class="modal-input" label="Koniec" />
</v-card-actions>
@@ -41,6 +41,24 @@
<v-btn @click="submit()" class="button primary mt-5">Potvrdiť</v-btn>
</v-card>
</v-dialog>
<v-dialog v-model="visible" max-width="750" persistent>
<v-card>
<div class="d-flex justify-space-between align-center">
<h1 class="text-red">Ste si istý, že chcete pridať timeblock po deadline <br> <b class="text-black">z mastertasku {{ subtask?.project_code }} ?</b></h1>
<v-icon
@click.stop="visible = false"
icon="mdi-close"
size="large"
class="mb-15"
></v-icon>
</div>
<v-card-actions class="mt-10 d-flex justify-start align-center mobile-view">
<v-btn class="button primary half" variant="flat" @click.stop="confirmSubmit()">ÁNO</v-btn>
<v-btn class="button primary half outline" @click.stop="visible = false">ZRUŠIŤ</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</template>
@@ -52,6 +70,8 @@ import { required } from '@vuelidate/validators'
import Datepicker from '@vuepic/vue-datepicker'
import moment from 'moment'
import modalMixin from '@/plugins/tm@modal/_mixins/modal.mixin'
import { mapGetters } from 'vuex'
export default {
mixins: [ modalMixin ],
@@ -79,6 +99,7 @@ export default {
errorUtils,
tmUtils,
showModal: false,
visible: false,
form: {
date: null,
starts_at_time: '09:00',
@@ -97,6 +118,10 @@ export default {
}
},
computed: {
...mapGetters('tm', ['mastertasks'])
},
methods: {
async submit() {
if (!await this.v$.$validate())
@@ -121,12 +146,46 @@ export default {
if(subtask.deadline) subtask.deadline = tmUtils.formatDateTimeForBackend(subtask.deadline)
const isAfterDeadline = this.isAfterDeadline()
if (isAfterDeadline) {
this.visible = true
} else {
if (!subtask.id) {
this.$emit('update-unfinished-subtask', subtask)
} else {
this._update(subtask)
}
}
},
async confirmSubmit() {
const subtask = JSON.parse(JSON.stringify(this.subtask))
const splittedStartsAtTime = this.form.starts_at_time.split(':')
const splittedEndsAtTime = this.form.ends_at_time.split(':')
const start = moment(this.form.date).hours(parseInt(splittedStartsAtTime[0])).minutes(parseInt(splittedStartsAtTime[1])).toISOString()
const end = moment(this.form.date).hours(parseInt(splittedEndsAtTime[0])).minutes(parseInt(splittedEndsAtTime[1])).toISOString()
if (!subtask?.timeblocks) { subtask.timeblocks = [] }
if (!subtask?.timesheets) { subtask.timesheets = [] }
if (!subtask?.is_finished) { subtask.is_finished = 0 }
subtask.timeblocks.push({
end: tmUtils.formatDateTimeForBackend(end),
id: null,
is_finished: 0,
start: tmUtils.formatDateTimeForBackend(start)
})
if(subtask.deadline) subtask.deadline = tmUtils.formatDateTimeForBackend(subtask.deadline)
if (!subtask.id) {
this.$emit('update-unfinished-subtask', subtask)
this.closeModal()
return
}
this.visible = false
this._update(subtask)
},
@@ -185,6 +244,21 @@ export default {
}
},
isAfterDeadline() {
const deadline = this.getDeadline(this.subtask)
if (deadline) {
return this.tmUtils.isAfter(this.form.date, moment(deadline, 'DD.MM.yyyy'))
}
return false
},
getDeadline(subtask) {
if(subtask.deadline) return moment(subtask.deadline).format('DD.MM.yyyy')
else if(!this.mastertasks) return ''
const masterTask = this.mastertasks.find((mt) => mt.id === subtask.master_task_id)
return moment(masterTask).format('DD.MM.yyyy') ? moment(masterTask.deadline).format('DD.MM.yyyy') : ''
},
closeModal() {
this.form = {
date: null,
@@ -53,8 +53,8 @@ export default {
await this.$axios.delete_auth(`v1/subtasks/${this.subtask.id}`)
this.$store.commit('tm/delete_subtask', this.subtask)
this.$emit('on-subtask-deleted', this.subtask)
this.closeModal()
this.$emit('on-subtask-deleted', this.subtask)
} catch (error) {
this.$toast.error(error)
} finally {
@@ -0,0 +1,83 @@
<template>
<v-dialog v-model="visible" max-width="500" persistent>
<v-card>
<div class="d-flex justify-space-between align-center">
<h4 class="mt-3">Vyberte časový úsek, ktorý chcete odstrániť</h4>
<v-icon
@click.stop="closeModal()"
icon="mdi-close"
size="large"
></v-icon>
</div>
<div v-for="(timeblock, index) in subtask.timeblocks" :key="timeblock.id" class="d-flex align-center justify-center mb-3 mt-3">
<p class="task-badge rounded-pill" :class="{'strike-through': timeblock.is_finished}">{{ tmUtils.formatDateTime(timeblock.start) }} - {{ tmUtils.formatDateTime(timeblock.end) }}</p>
<v-icon @click.stop="subtask.id ? deleteTimeblock(timeblock) : deleteTimeblockWithoutId(index)" class="close-icon circle-border cursor-pointer ml-3 text-red" icon="mdi-close" size="medium" />
</div>
</v-card>
</v-dialog>
</template>
<script>
import modalMixin from '@/plugins/tm@modal/_mixins/modal.mixin'
import tmUtils from '@/plugins/tm@_utils/tm.utils'
export default {
mixins: [ modalMixin ],
emits: ['on-subtask-edited'],
data() {
return {
visible: false,
subtask: null,
isDeleting: false,
tmUtils
}
},
methods: {
async showModal({ subtask }) {
this.subtask = subtask
this.visible = true
},
closeModal() {
this.visible = false
},
async deleteTimeblock({ id }) {
const subtask = JSON.parse(JSON.stringify(this.subtask))
subtask.timeblocks = subtask.timeblocks.filter(timeblock => timeblock.id != id)
if(subtask.deadline) subtask.deadline = tmUtils.formatDateTimeForBackend(subtask.deadline)
this._update(subtask)
},
deleteTimeblockWithoutId(i) {
this.$emit('delete-timeblock')
},
async _update(data) {
try {
const timesheets = data.timesheets.map((timesheet) => {
delete timesheet.employee_name
return timesheet
})
const { subtask } = await this.$axios.put_auth(`v1/subtasks/${data.id}`, {...data, timesheets})
this.closeModal()
this.$events.emit('on-subtask-edited', subtask)
} catch (error) {
this.$toast.error(error.message || error)
}
},
}
}
</script>
<style lang="sass" scoped>
.close-icon:hover
background: red
color: #fff !important
</style>
@@ -211,7 +211,10 @@ export default {
if (subtask?.id) {
const data = await this.$axios.get_auth_data(`v1/subtasks/${subtask.id}`)
if (!data.deadline) return (this.subtask = this._enrichTask(data))
if (!data.deadline) {
this.editMode = editMode || !data.id
return (this.subtask = this._enrichTask(data))
}
const splittedDeadline = data.deadline.split(' ')
data.deadline = moment(splittedDeadline[0])
@@ -231,9 +234,9 @@ export default {
this.subtask.project_code = subtask.project_code
}
}
this.editMode = editMode || !this.subtask.id
} catch (error) {
console.error('ERROR', error)
this.$toast.error(error)
}
},