From bb7b59cc0eaa5be41b13f80cabee8d7d2d47cf8e Mon Sep 17 00:00:00 2001 From: romankko2 Date: Thu, 12 Oct 2023 17:28:05 +0200 Subject: [PATCH] bugs + CR's --- app/src/plugins/app/_config/App.vue | 9 +- .../tm@dashboard/_components/z-timeline.vue | 54 +++++++++++- .../_components/a-project-calendar.vue | 3 +- .../projects/_components/a-project-filter.vue | 9 ++ .../tm@dashboard/projects/projects.vue | 13 +++ .../teams/_components/a-team-filter.vue | 10 ++- .../teams/_mixins/TeamsCalendar.mixin.ts | 2 +- .../tm@modal/blocker/z-blocker-modal.vue | 2 +- .../master-task/z-master-task-modal.vue | 2 +- .../_components/a-task-timeblocks.vue | 78 ++++++++++++++++- .../tm@modal/task/z-delete-task-modal.vue | 2 +- .../task/z-delete-timeblock-modal.vue | 83 +++++++++++++++++++ .../plugins/tm@modal/task/z-task-modal.vue | 7 +- app/src/plugins/w/i18n/models/i18n.ts | 3 +- .../plugins/w@custom/axios/models/axios.ts | 1 - 15 files changed, 258 insertions(+), 20 deletions(-) create mode 100644 app/src/plugins/tm@modal/task/z-delete-timeblock-modal.vue diff --git a/app/src/plugins/app/_config/App.vue b/app/src/plugins/app/_config/App.vue index e61cb51..b00a387 100644 --- a/app/src/plugins/app/_config/App.vue +++ b/app/src/plugins/app/_config/App.vue @@ -10,6 +10,7 @@ + @@ -26,6 +27,7 @@ import ZDeleteTeamModal from '@/plugins/tm@modal/team/z-delete-team-modal.vue' import ZTeamModal from '@/plugins/tm@modal/team/z-team-modal.vue' import ZDeleteTaskModal from '@/plugins/tm@modal/task/z-delete-task-modal.vue' +import ZDeleteTimeBlockModal from '@/plugins/tm@modal/task/z-delete-timeblock-modal.vue' import ZTaskModal from '@/plugins/tm@modal/task/z-task-modal.vue' import ZDeleteBlockerModal from '@/plugins/tm@modal/blocker/z-delete-blocker-modal.vue' import ZCompleteTaskModal from '@/plugins/tm@modal/task/z-complete-task-modal.vue' @@ -51,7 +53,8 @@ export default { ZDeleteMasterTaskModal, ZDeleteTeamMemberModal, ZShowMenuModal, - ZCompleteMasterTaskModal + ZCompleteMasterTaskModal, + ZDeleteTimeBlockModal }, mounted() { @@ -71,6 +74,10 @@ export default { this.$refs['z-delete-task-modal'].showModal({subtask}) }) + this.$events.on('show-delete-timeblock-modal', ({subtask}) => { + this.$refs['z-delete-timeblock-modal'].showModal({subtask}) + }) + this.$events.on('show-delete-blocker-modal', ({blocker}) => { this.$refs['z-delete-blocker-modal'].showModal({blocker}) }) diff --git a/app/src/plugins/tm@dashboard/_components/z-timeline.vue b/app/src/plugins/tm@dashboard/_components/z-timeline.vue index e9829cb..b15c63d 100644 --- a/app/src/plugins/tm@dashboard/_components/z-timeline.vue +++ b/app/src/plugins/tm@dashboard/_components/z-timeline.vue @@ -104,12 +104,30 @@ - + + @@ -157,7 +175,8 @@ export default { }, focusedEventId: null, timeCellHeight: 100, - tmUtils + tmUtils, + visible: false } }, @@ -173,6 +192,14 @@ export default { return moment(masterTask).format('DD.MM.yyyy') ? moment(masterTask.deadline).format('DD.MM.yyyy') : '' }, + isAfterDeadline(event) { + const deadline = this.getDeadline(event.subtask) + if (deadline) { + return this.tmUtils.isAfter(event.date, moment(deadline, 'DD.MM.yyyy')) + } + return false + }, + weekChanged() { const scrollContainer = this.$el.getElementsByClassName('vuecal__scrollable-body')[0] scrollContainer.scrollLeft = 0 @@ -199,6 +226,7 @@ export default { return timesheet }) } + try { const { subtask } = await this.$axios.put_auth(`v1/subtasks/${editedSubtask.id}`, editedSubtask) this.$events.emit('on-subtask-edited', subtask) @@ -208,6 +236,24 @@ export default { } catch (error) { this.$toast.error(error.message || error) } + + const isAfterDeadline = this.isAfterDeadline(event) + + if(isAfterDeadline) this.$toast.error('Timeblock, ktorý ste presunuli je po deadline !') + + // if (isAfterDeadline) { + // this.visible = true + // } else { + // try { + // const { subtask } = await this.$axios.put_auth(`v1/subtasks/${editedSubtask.id}`, editedSubtask) + // this.$events.emit('on-subtask-edited', subtask) + + // if (subtask.employee_id == this.$store.getters['auth/user'].id) + // this.$events.emit('show-task-add-time-modal', { subtask }) + // } catch (error) { + // this.$toast.error(error.message || error) + // } + // } } else if(this.$route.name == 'Dashboard - Teams') { const editedSubtask = { ...event.subtask, @@ -317,8 +363,8 @@ export default { this.$events.emit('show-subtask-modal', {subtask}) }, - deleteTask({ subtask }) { - this.$events.emit('show-delete-task-modal', {subtask}) + deleteTimeBlockInTask({ subtask }) { + this.$events.emit('show-delete-timeblock-modal', {subtask}) }, editBlocker({ blocker }) { diff --git a/app/src/plugins/tm@dashboard/projects/_components/a-project-calendar.vue b/app/src/plugins/tm@dashboard/projects/_components/a-project-calendar.vue index 6fb8ca5..0f832a4 100644 --- a/app/src/plugins/tm@dashboard/projects/_components/a-project-calendar.vue +++ b/app/src/plugins/tm@dashboard/projects/_components/a-project-calendar.vue @@ -58,6 +58,7 @@ export default { }, } + + diff --git a/app/src/plugins/tm@dashboard/projects/_components/a-project-filter.vue b/app/src/plugins/tm@dashboard/projects/_components/a-project-filter.vue index d53cd52..91d1e9e 100644 --- a/app/src/plugins/tm@dashboard/projects/_components/a-project-filter.vue +++ b/app/src/plugins/tm@dashboard/projects/_components/a-project-filter.vue @@ -58,6 +58,12 @@ export default { mounted() { const monthIndex = new Date().getMonth() this.filter.month = monthIndex < 9 ? `0${monthIndex + 1}` : `${monthIndex + 1}` + const savedTeamMT = localStorage.getItem('savedTeamMT') + const savedCreatedBy = localStorage.getItem('savedCreatedBy') + const savedEmployee = localStorage.getItem('savedEmployee') + if(savedTeamMT) this.filter.teamId = JSON.parse(savedTeamMT) + if(savedCreatedBy) this.filter.createdById = JSON.parse(savedCreatedBy) + if(savedEmployee) this.filter.employeeId = JSON.parse(savedEmployee) }, computed: { @@ -88,6 +94,9 @@ export default { filter: { handler() { this.$emit('filterChanged', this.filter) + localStorage.setItem('savedTeamMT', this.filter.teamId) + localStorage.setItem('savedCreatedBy', this.filter.createdById) + localStorage.setItem('savedEmployee', this.filter.employeeId) }, deep: true } diff --git a/app/src/plugins/tm@dashboard/projects/projects.vue b/app/src/plugins/tm@dashboard/projects/projects.vue index 25f4c8d..d393c52 100644 --- a/app/src/plugins/tm@dashboard/projects/projects.vue +++ b/app/src/plugins/tm@dashboard/projects/projects.vue @@ -59,6 +59,19 @@ export default { // }; // }); return this.mastertasks.map(event => { + // const currentDate = new Date() + // const eventDeadline = new Date(event.deadline) + + // const isEventOnCurrentDate = + // eventDeadline.getFullYear() === currentDate.getFullYear() && + // eventDeadline.getMonth() === currentDate.getMonth() && + // eventDeadline.getDate() === currentDate.getDate() + + // console.log("isEventOnCurrentDate:", isEventOnCurrentDate) + // console.log("eventDeadline:", eventDeadline) + + // const backgroundColor = isEventOnCurrentDate ? 'red' : event.color + // console.log("backgroundColor:", backgroundColor) return { id: event.id, title: `${event.project_code} - ${event.name}`, diff --git a/app/src/plugins/tm@dashboard/teams/_components/a-team-filter.vue b/app/src/plugins/tm@dashboard/teams/_components/a-team-filter.vue index 9164863..bce5969 100644 --- a/app/src/plugins/tm@dashboard/teams/_components/a-team-filter.vue +++ b/app/src/plugins/tm@dashboard/teams/_components/a-team-filter.vue @@ -2,7 +2,8 @@ this._updateFilters()) }, @@ -98,6 +100,8 @@ export default { if (!this.filter.start || !this.filter.end || !this.filter.team) return this.$emit('filter-changed', this.filter) + + localStorage.setItem('selectedTeam', this.filter.team.id) } }, diff --git a/app/src/plugins/tm@dashboard/teams/_mixins/TeamsCalendar.mixin.ts b/app/src/plugins/tm@dashboard/teams/_mixins/TeamsCalendar.mixin.ts index 94f68ad..53e9b11 100644 --- a/app/src/plugins/tm@dashboard/teams/_mixins/TeamsCalendar.mixin.ts +++ b/app/src/plugins/tm@dashboard/teams/_mixins/TeamsCalendar.mixin.ts @@ -57,7 +57,7 @@ export default { id: index + 1, name: employee.name, employee_id: employee.id, - // date: this.filter.start, + date: this.filter.start, fullname: `${employee.name} ${employee.surname}`, initials: employee.name.charAt(0).toUpperCase() + employee.surname.charAt(0).toUpperCase(), unscheduledTime: unscheduledTime > 0 ? (unscheduledTime / 60).toFixed(1) : 0, diff --git a/app/src/plugins/tm@modal/blocker/z-blocker-modal.vue b/app/src/plugins/tm@modal/blocker/z-blocker-modal.vue index 670ea67..475a1cd 100644 --- a/app/src/plugins/tm@modal/blocker/z-blocker-modal.vue +++ b/app/src/plugins/tm@modal/blocker/z-blocker-modal.vue @@ -17,7 +17,7 @@ :items="[...enrichedEmployees]" item-title="_fullName" item-value="id" variant="solo" class="modal-input" v-model="blocker.employee_id" /> - diff --git a/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue b/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue index 78a789f..cab59a9 100644 --- a/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue +++ b/app/src/plugins/tm@modal/master-task/z-master-task-modal.vue @@ -50,7 +50,7 @@ - Pridať zamestnanca + Pridať zamestnanca - + @@ -41,6 +41,24 @@ Potvrdiť + + +
+

Ste si istý, že chcete pridať timeblock po deadline
z mastertasku {{ subtask?.project_code }} ?

+ + +
+ + ÁNO + ZRUŠIŤ + +
+
@@ -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, diff --git a/app/src/plugins/tm@modal/task/z-delete-task-modal.vue b/app/src/plugins/tm@modal/task/z-delete-task-modal.vue index 8c6779d..3e78084 100644 --- a/app/src/plugins/tm@modal/task/z-delete-task-modal.vue +++ b/app/src/plugins/tm@modal/task/z-delete-task-modal.vue @@ -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 { diff --git a/app/src/plugins/tm@modal/task/z-delete-timeblock-modal.vue b/app/src/plugins/tm@modal/task/z-delete-timeblock-modal.vue new file mode 100644 index 0000000..d9439fc --- /dev/null +++ b/app/src/plugins/tm@modal/task/z-delete-timeblock-modal.vue @@ -0,0 +1,83 @@ + + + + + \ No newline at end of file diff --git a/app/src/plugins/tm@modal/task/z-task-modal.vue b/app/src/plugins/tm@modal/task/z-task-modal.vue index 3834ca9..9920825 100644 --- a/app/src/plugins/tm@modal/task/z-task-modal.vue +++ b/app/src/plugins/tm@modal/task/z-task-modal.vue @@ -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) } }, diff --git a/app/src/plugins/w/i18n/models/i18n.ts b/app/src/plugins/w/i18n/models/i18n.ts index 633fab8..fe1d429 100644 --- a/app/src/plugins/w/i18n/models/i18n.ts +++ b/app/src/plugins/w/i18n/models/i18n.ts @@ -81,14 +81,13 @@ export class I18n { (response) => { return response }, - // fixnut aby logger nezaznamenaval chybu ak padne requet kvoli loggeru (error) => { if(error.response) { axios.post('https://logger.wezeo.dev/cms/api/data/new', { data: JSON.stringify(error) }) } - return Promise.reject(error) + return Promise.reject(error.response) } ) } diff --git a/app/src/plugins/w@custom/axios/models/axios.ts b/app/src/plugins/w@custom/axios/models/axios.ts index 60547c2..03440fc 100644 --- a/app/src/plugins/w@custom/axios/models/axios.ts +++ b/app/src/plugins/w@custom/axios/models/axios.ts @@ -71,7 +71,6 @@ export default { async delete_auth(url: string, config?: any) { config = this._config(config) - return axios.delete(url, config) .then(response => response.data) .catch(error => Promise.reject(toastUtils.parseAndTranslate(error)))