From 994d3449d32fe43225e5f217a12f3346f771d6c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Glasn=C3=A1k?= Date: Mon, 29 May 2023 11:07:20 +0200 Subject: [PATCH 1/4] [Subtask modal] Add multiple employees --- .../plugins/tm@modal/task/z-task-modal.vue | 114 ++++++++++++++---- 1 file changed, 88 insertions(+), 26 deletions(-) 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 5720772..d95f2b1 100644 --- a/app/src/plugins/tm@modal/task/z-task-modal.vue +++ b/app/src/plugins/tm@modal/task/z-task-modal.vue @@ -12,18 +12,24 @@ - + - - @@ -78,11 +84,9 @@ import SelectsMixin from "../master-task/_mixins/selects.mixin" import * as FileSaver from "file-saver" import tmUtils from "@/plugins/tm@_utils/tm.utils" import "@vueup/vue-quill/dist/vue-quill.snow.css" -import ZAutocomplete from "@/plugins/tm@_components/z-autocomplete.vue" import ZTaskReadonlyInfo from "./_components/z-task-readonly-info.vue" import { mapGetters } from "vuex" -import moment from "moment" export default { emits: ["close", "refresh"], @@ -91,8 +95,7 @@ export default { components: { ZTaskReadonlyInfo, ZFilesUpload, - QuillEditor, - // ZAutocomplete + QuillEditor }, data() { @@ -103,9 +106,9 @@ export default { subtask: null, errorUtils, v$: useVuelidate(), + employeeValidations: [], preventInputFocus: false, showDatePicker: false, - employeeError: false, selectedNewDate: [] } }, @@ -121,8 +124,7 @@ export default { return { subtask: { master_task_id: { required }, - duration: { required }, - name: { required } + // title: { required } } } }, @@ -152,7 +154,7 @@ export default { const data = await this.$axios.get_auth_data(`v1/subtasks/${subtask.id}`) this.subtask = this._enrichTask(data) } else { - this.subtask = { master_task: mastertask, employees: [], timeblocks: [] } + this.subtask = { master_task: mastertask, employees: [{}] } } this.editMode = editMode || !this.subtask.id @@ -167,13 +169,9 @@ export default { }, async save() { - if (!this.subtask.employee_id && !this.subtask.employees.length) - this.employeeError = true + const employeesValid = await this._validateEmployees() - if (!(await this.v$.$validate())) - return - - if (!this.subtask.employee_id && !this.subtask.employees.length) + if (!(await this.v$.$validate()) || !employeesValid) return this.subtask.description = this.$refs['description'].getHTML() @@ -181,14 +179,19 @@ export default { try { if (this.subtask?.id) { const { subtask } = await this.$axios.put_auth(`v1/subtasks/${this.subtask.id}`, this.subtask) + this.$store.commit('tm/update_subtask', subtask) + this.$events.emit("on-subtask-edited", this.subtask) } else { - const { subtask } = await this.$axios.post_auth(`v1/mastertasks/${this.subtask.master_task_id}/subtasks`, this.subtask) - this.subtask.id = subtask.id - this.$store.commit('tm/update_subtask', subtask) + const { subtasks } = await this.$axios.post_auth(`v1/mastertasks/${this.subtask.master_task_id}/subtasks`, this.subtask) + this.subtask.id = subtasks[0].id + + subtasks.forEach(subtask => { + this.$store.commit('tm/update_subtask', subtask) + this.$events.emit("on-subtask-edited", this.subtask) + }) } - this.$events.emit("on-subtask-edited", this.subtask) this.closeModal() } catch (error) { this.$toast.error(error) @@ -221,6 +224,45 @@ export default { this.subtask = subtask }, + _validateEmployees() { + return new Promise((resolve) => { + this.employeeValidations = [] + + if (this.subtask.id) { + if (this.subtask.employee && this.subtask.duration) + return + + this.employeeValidations[0] = {} + + if (!this.subtask.employee_id) + this.employeeValidations[0].employee = true + + if (!this.subtask.duration) + this.employeeValidations[0].duration = true + } else { + this.subtask.employees.forEach((employee, index) => { + if (index == this.subtask.employees.length - 1 && index > 0) + return // Skip the last which is allways empty + + if (employee.id && employee.duration) + return + + this.employeeValidations[index] = {} + + if (!employee.id) + this.employeeValidations[index].employee = true + + if (!employee.duration) + this.employeeValidations[index].duration = true + }) + } + + + const isError = this.employeeValidations.some(employee => employee.duration || employee.employee) + resolve(!isError) + }) + }, + _enrichTask(subtask) { return { ...subtask, @@ -233,15 +275,22 @@ export default { watch: { 'subtask.employee_id'(value, oldValue) { - this.employeeError = false if (!value || !oldValue) return this.subtask.timeblocks = [] this.subtask._employee = this.enrichedEmployees.find((employee) => employee.id == this.subtask.employee_id) }, - 'subtask.employees'() { - this.employeeError = false + 'subtask.employees': { + handler() { + if (!this.subtask?.employees) + return + + const lastEmployee = this.subtask.employees[this.subtask.employees.length - 1] + if (lastEmployee.id || lastEmployee.duration) + this.subtask.employees.push({}) + }, + deep: true }, 'subtask.master_task_id'(value) { @@ -275,4 +324,17 @@ export default { @media screen and (max-width: 522px) .files margin-top: 104px !important + +.multiple-employee-select + width: 100% + + .modal-input + display: inline-block + + .employee + width: 70% !important + + .duration + width: 25% !important + margin-left: 5% From fcd8199d8677e3c3a5b2e3f33c3f2fe742ce453f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Glasn=C3=A1k?= Date: Thu, 1 Jun 2023 14:07:08 +0200 Subject: [PATCH 2/4] [CHR WIP] CHR10, CHR12, CHR13, CHR14, CHR15, CHR17 - WIP not validated --- app/src/plugins/app/_config/App.vue | 11 +- .../app/_theme/_components/modals.sass | 18 ++- app/src/plugins/app/_theme/global.sass | 2 +- app/src/plugins/app@vendor/vue-cal/cell.vue | 21 +++- app/src/plugins/app@vendor/vue-cal/event.vue | 1 - .../tm@dashboard/_components/z-timeline.vue | 6 +- .../tasks/_components/a-tasks-filter.vue | 22 +++- .../master-task/_mixins/selects.mixin.ts | 1 + .../z-delete-team-member-modal.vue | 94 +++++++++++++++ .../master-task/z-master-task-modal.vue | 100 ++++++++++++++-- .../_components/a-task-timeblocks.vue | 20 +++- .../plugins/tm@modal/task/z-task-modal.vue | 109 ++++++++++++++---- 12 files changed, 353 insertions(+), 52 deletions(-) create mode 100644 app/src/plugins/tm@modal/master-task/z-delete-team-member-modal.vue diff --git a/app/src/plugins/app/_config/App.vue b/app/src/plugins/app/_config/App.vue index 3f7d31e..ced0bf6 100644 --- a/app/src/plugins/app/_config/App.vue +++ b/app/src/plugins/app/_config/App.vue @@ -16,7 +16,8 @@ - + + \ No newline at end of file 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 d23dbee..7033095 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 @@ -12,17 +12,33 @@ - +
+ + - + +
- + + + + @@ -30,7 +46,7 @@ - Pridať zamestnanca + Pridať zamestnanca