From 734a3fac6c664d76de88c1d32f5d9197ca92982d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Glasn=C3=A1k?= Date: Mon, 8 Dec 2025 11:31:30 +0100 Subject: [PATCH] refactor(task-modal): clean up console logs and improve code structure in z-master-task-modal --- app/dist/js/index.js | 2 +- .../plugins/tm@modal/master-task/z-master-task-modal.vue | 7 ------- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/app/dist/js/index.js b/app/dist/js/index.js index ad8fb9c..fde9bfd 100644 --- a/app/dist/js/index.js +++ b/app/dist/js/index.js @@ -345,7 +345,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _pl /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/modules/es.array.push.js */ \"./node_modules/core-js/modules/es.array.push.js\");\n/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var core_js_modules_es_json_stringify_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.json.stringify.js */ \"./node_modules/core-js/modules/es.json.stringify.js\");\n/* harmony import */ var core_js_modules_es_json_stringify_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_json_stringify_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var core_js_modules_esnext_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core-js/modules/esnext.iterator.constructor.js */ \"./node_modules/core-js/modules/esnext.iterator.constructor.js\");\n/* harmony import */ var core_js_modules_esnext_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var core_js_modules_esnext_iterator_filter_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core-js/modules/esnext.iterator.filter.js */ \"./node_modules/core-js/modules/esnext.iterator.filter.js\");\n/* harmony import */ var core_js_modules_esnext_iterator_filter_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_filter_js__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var core_js_modules_esnext_iterator_find_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! core-js/modules/esnext.iterator.find.js */ \"./node_modules/core-js/modules/esnext.iterator.find.js\");\n/* harmony import */ var core_js_modules_esnext_iterator_find_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_find_js__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var core_js_modules_esnext_iterator_map_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! core-js/modules/esnext.iterator.map.js */ \"./node_modules/core-js/modules/esnext.iterator.map.js\");\n/* harmony import */ var core_js_modules_esnext_iterator_map_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_map_js__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _plugins_tm_components_z_datepicker_vue__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/plugins/tm@_components/z-datepicker.vue */ \"./src/plugins/tm@_components/z-datepicker.vue\");\n/* harmony import */ var _plugins_tm_components_z_files_upload_vue__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/plugins/tm@_components/z-files-upload.vue */ \"./src/plugins/tm@_components/z-files-upload.vue\");\n/* harmony import */ var _vuelidate_core__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @vuelidate/core */ \"./node_modules/@vuelidate/core/dist/index.esm.js\");\n/* harmony import */ var _vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @vuelidate/validators */ \"./node_modules/@vuelidate/validators/dist/index.esm.js\");\n/* harmony import */ var _plugins_lib_auth_utils_error_utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @/plugins/lib@auth/_utils/error.utils */ \"./src/plugins/lib@auth/_utils/error.utils.ts\");\n/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! moment */ \"./node_modules/moment/moment.js\");\n/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_11__);\n/* harmony import */ var _vueup_vue_quill__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @vueup/vue-quill */ \"./node_modules/@vueup/vue-quill/dist/vue-quill.esm-bundler.js\");\n/* harmony import */ var _plugins_tm_modal_mixins_modal_mixin__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @/plugins/tm@modal/_mixins/modal.mixin */ \"./src/plugins/tm@modal/_mixins/modal.mixin.ts\");\n/* harmony import */ var _vueup_vue_quill_dist_vue_quill_snow_css__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! @vueup/vue-quill/dist/vue-quill.snow.css */ \"./node_modules/@vueup/vue-quill/dist/vue-quill.snow.css\");\n/* harmony import */ var _vueup_vue_quill_dist_vue_quill_snow_css__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(_vueup_vue_quill_dist_vue_quill_snow_css__WEBPACK_IMPORTED_MODULE_14__);\n/* harmony import */ var _mixins_selects_mixin__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./_mixins/selects.mixin */ \"./src/plugins/tm@modal/master-task/_mixins/selects.mixin.ts\");\n/* harmony import */ var _components_a_tasks_table_vue__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./_components/a-tasks-table.vue */ \"./src/plugins/tm@modal/master-task/_components/a-tasks-table.vue\");\n/* harmony import */ var _components_a_mastertask_description_vue__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./_components/a-mastertask-description.vue */ \"./src/plugins/tm@modal/master-task/_components/a-mastertask-description.vue\");\n/* harmony import */ var vuex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.esm-bundler.js\");\n/* harmony import */ var _plugins_tm_mixins_autocomplete_mixin__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! @/plugins/tm@_mixins/autocomplete.mixin */ \"./src/plugins/tm@_mixins/autocomplete.mixin.ts\");\n/* harmony import */ var _plugins_tm_modal_components_a_resize_handle_vue__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! @/plugins/tm@modal/_components/a-resize-handle.vue */ \"./src/plugins/tm@modal/_components/a-resize-handle.vue\");\n/* harmony import */ var _plugins_tm_modal_components_a_reset_size_button_vue__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! @/plugins/tm@modal/_components/a-reset-size-button.vue */ \"./src/plugins/tm@modal/_components/a-reset-size-button.vue\");\n/* harmony import */ var _plugins_tm_modal_components_a_close_button_vue__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! @/plugins/tm@modal/_components/a-close-button.vue */ \"./src/plugins/tm@modal/_components/a-close-button.vue\");\n/* provided dependency */ var console = __webpack_require__(/*! ./node_modules/console-browserify/index.js */ \"./node_modules/console-browserify/index.js\");\n\n\n\n\n\n\n\n\n\n\n\n// import ZAutocomplete from '@/plugins/tm@_components/z-autocomplete.vue'\n\n\n// import tmUtils from '@/plugins/tm@_utils/tm.utils'\n\n\n\n\n\n\n\n\n\n\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n // MIXINS\n // computed: employeesOptions, projectsOptions\n // methods: onProjectSelected, onEmployeeSelected, onEmployeeDurationChanged\n // watch: mastertask.team_id\n\n components: {\n AMastertaskDescription: _components_a_mastertask_description_vue__WEBPACK_IMPORTED_MODULE_17__[\"default\"],\n ATasksTable: _components_a_tasks_table_vue__WEBPACK_IMPORTED_MODULE_16__[\"default\"],\n ZDatepicker: _plugins_tm_components_z_datepicker_vue__WEBPACK_IMPORTED_MODULE_6__[\"default\"],\n ZFilesUpload: _plugins_tm_components_z_files_upload_vue__WEBPACK_IMPORTED_MODULE_7__[\"default\"],\n // ZAutocomplete,\n QuillEditor: _vueup_vue_quill__WEBPACK_IMPORTED_MODULE_12__.QuillEditor,\n AResizeHandle: _plugins_tm_modal_components_a_resize_handle_vue__WEBPACK_IMPORTED_MODULE_20__[\"default\"],\n AResetSizeButton: _plugins_tm_modal_components_a_reset_size_button_vue__WEBPACK_IMPORTED_MODULE_21__[\"default\"],\n ACloseButton: _plugins_tm_modal_components_a_close_button_vue__WEBPACK_IMPORTED_MODULE_22__[\"default\"]\n },\n mixins: [_mixins_selects_mixin__WEBPACK_IMPORTED_MODULE_15__[\"default\"], _plugins_tm_mixins_autocomplete_mixin__WEBPACK_IMPORTED_MODULE_19__[\"default\"], _plugins_tm_modal_mixins_modal_mixin__WEBPACK_IMPORTED_MODULE_13__[\"default\"]],\n // MIXINS\n // computed: employeesOptions, projectsOptions\n // methods: onProjectSelected, onEmployeeSelected, onEmployeeDurationChanged\n // watch: mastertask.team_id\n\n emits: ['master-task-edited', 'close'],\n data() {\n return {\n deadline: null,\n editMode: false,\n visible: false,\n errorUtils: _plugins_lib_auth_utils_error_utils__WEBPACK_IMPORTED_MODULE_10__[\"default\"],\n v$: (0,_vuelidate_core__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(),\n mastertask: null,\n isSaving: false,\n showAddEmployeeInput: false,\n date: null,\n projectCodeSearch: null,\n modalName: 'z-master-task-modal'\n };\n },\n computed: {\n ...(0,vuex__WEBPACK_IMPORTED_MODULE_18__.mapGetters)('tm', ['teams', 'projects', 'enrichedEmployees']),\n enrichedSubtasks() {\n if (!this.mastertask?.subtasks) return null;\n return this.mastertask.subtasks.map(subtask => {\n const employee = this.enrichedEmployees.find(employee => employee.id == subtask.employee_id);\n return {\n ...subtask,\n _initials: employee ? employee.name.charAt(0) + employee.surname.charAt(0) : '?',\n _fullName: employee ? `${employee.name} ${employee.surname}` : ''\n };\n }).filter(subtask => subtask !== null);\n }\n },\n validations() {\n const quillEditorRequired = value => {\n if (!value || !value.length || !value.replace(/<[^>]*>/g, '').length) return false;\n return true;\n };\n return {\n mastertask: {\n employees: {\n required: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__.required,\n minLength: (0,_vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__.minLength)(1),\n $each: {\n duration: {\n required: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__.required\n }\n }\n },\n project_id: {\n required: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__.required\n },\n name: {\n required: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__.required\n },\n description: {\n quillEditorRequired\n },\n deadline: {\n required: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__.required\n },\n estimated_duration: {\n required: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__.required\n },\n _deadline_time: {\n required: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__.required\n }\n }\n };\n },\n mounted() {\n this.$events.on('close-both-modals', this.closeBothModals);\n this.$events.on('master-task:team-member-deleted', ({\n teamId,\n memberId\n }) => {\n if (this.mastertask.team_id != teamId) return;\n this.mastertask.employees = this.mastertask.employees.filter(employee => employee.id != memberId);\n }), this.$events.on('on-mastertask-deleted', mastertask => {\n if (mastertask?.id == this.mastertask?.id) this.closeModal();\n });\n this.$events.on('on-subtask-deleted', task => {\n if (!this.mastertask) return;\n this.mastertask.subtasks = this.mastertask.subtasks.filter(subtask => subtask.id != task.id);\n });\n this.$events.on('on-subtask-edited', task => {\n if (!this.mastertask?.subtasks) return;\n if (this.mastertask.subtasks.find(subtask => subtask.id == task.id)) {\n this.mastertask.subtasks = this.mastertask.subtasks.map(t => t.id == task.id ? task : t);\n } else {\n this.mastertask.subtasks.push(task);\n }\n });\n },\n beforeUnmount() {\n this.$events.off('on-mastertask-deleted');\n this.$events.off('on-subtask-deleted');\n this.$events.off('on-subtask-edited');\n this.$events.off('master-task:team-member-deleted');\n this.$events.off('close-both-modals', this.closeBothModals);\n },\n methods: {\n closeBothModals() {\n this.$emit('close');\n this.visible = false;\n },\n removeEmployee({\n id\n }) {\n // const isEmployeeInTeam = this.mastertask.team?.employees.find(employee => employee.id == id)\n\n // if (isEmployeeInTeam) {\n // \tthis.mastertask.team_id = null\n // \tthis.mastertask.team = null\n // }\n\n this.mastertask.employees = this.mastertask.employees.filter(employee => employee.id != id);\n },\n removeMemberAlert(member) {\n const team = this.mastertask.team;\n this.$events.emit('show-delete-team-member-modal', {\n member,\n team\n });\n },\n async loadMastertask(id) {\n try {\n this.mastertask = await this.$axios.get_auth_data(`v1/mastertasks/${id}`);\n\n // TODO zmazat ked zacne prichadzat project_id a team_id\n const project = this.projects.find(project => project.code == this.mastertask.project_code);\n this.mastertask.project_id = project?.id || null;\n this.mastertask.team_id = this.mastertask.team?.id || null;\n this.mastertask._allEmployees = this.mastertask.subtasks.map(({\n employee_id,\n duration\n }) => {\n const employee = this.enrichedEmployees.find(({\n id\n }) => id == employee_id);\n if (!employee) {\n return null;\n }\n employee.duration = duration;\n return employee;\n }).filter(employee => employee !== null);\n } catch (error) {\n this.$toast.error(error.message || error);\n }\n },\n async showModal({\n mastertask,\n editMode = false\n }) {\n this.isSaving = false;\n this.editMode = null;\n\n // CRITICAL: Prevent v-dialog autofocus BEFORE modal opens\n this.preventInputFocus = true;\n /* eslint-disable */\n console.log(...oo_oo(`532727923_569_6_571_7_4`, '🟠 [z-master-task-modal] showModal - preventInputFocus set to true BEFORE modal opens'));\n this.visible = true;\n this.mastertask = null;\n this.$nextTick(() => {\n this.v$.$reset();\n\n // Reset after modal is fully rendered and v-dialog autofocus has been blocked\n setTimeout(() => {\n this.preventInputFocus = false;\n /* eslint-disable */\n console.log(...oo_oo(`532727923_582_10_584_11_4`, '🟠 [z-master-task-modal] showModal - preventInputFocus reset to false after 300ms'));\n }, 300);\n });\n try {\n if (mastertask?.id) {\n await this.loadMastertask(mastertask.id);\n\n // this.mastertask.project_code \t= project.code\n } else {\n const savedMastertask = localStorage.getItem('mastertaskData');\n try {\n if (savedMastertask) {\n const parsedMastertask = JSON.parse(savedMastertask);\n this.mastertask = parsedMastertask;\n // If the parsed result is not an object, reset to default\n if (typeof this.mastertask !== 'object' || this.mastertask === null) {\n throw new Error('Parsed mastertask is not an object');\n }\n this.$nextTick(() => {\n this.$refs['description']?.setHTML(this.mastertask.description || '');\n });\n } else {\n throw new Error('mastertaskData is null or undefined');\n }\n } catch (error) {\n this.mastertask = {\n employees: [],\n duration: 0,\n _deadline_time: '17:00'\n };\n }\n }\n this.editMode = editMode || !this.mastertask.id;\n } catch (error) {\n this.$toast.error(error.message || error);\n }\n },\n toggleIsFinished() {\n this.$events.emit('show-complete-master-task-modal', {\n mastertask: this.mastertask\n });\n },\n async save() {\n if (this.mastertask.id) {\n this.mastertask.employees = this.mastertask.employees.map(employee => {\n const {\n duration\n } = this.mastertask.subtasks.find(({\n employee_id\n }) => employee_id == employee.id) || {};\n employee.duration = duration || 0;\n return employee;\n });\n }\n const vuelidateValid = await this.v$.$validate();\n const employeesValid = await this._validateEmployees();\n if (!vuelidateValid || !employeesValid) return;\n if (this.$refs['description']) this.mastertask.description = this.$refs['description'].getHTML();\n this._mergeDeadlineTimeDate();\n try {\n this.isSaving = true;\n this.mastertask.deadline = moment__WEBPACK_IMPORTED_MODULE_11___default()(this.mastertask.deadline).format('YYYY-MM-DD HH:MM:SS');\n if (this.mastertask.id) await this.$axios.patch_auth_form(`v1/mastertasks/${this.mastertask.id}`, this.mastertask);else await this.$axios.post_auth_data('v1/mastertasks', this.mastertask);\n localStorage.removeItem('mastertaskData');\n this.$emit('master-task-edited', this.mastertask);\n this.closeModal();\n } catch (error) {\n this.$toast.error(this.$parseError(error));\n } finally {\n this.isSaving = false;\n }\n },\n filesUploaded(files) {\n this.mastertask.files = files;\n },\n closeModal() {\n this.visible = false;\n },\n openDeleteMasterTaskModal(mastertask) {\n this.$events.emit('show-delete-master-task-modal', {\n mastertask\n });\n },\n addTask() {\n this.$events.emit('show-subtask-modal', {\n subtask: {\n master_task_id: this.mastertask.id,\n project_code: this.mastertask.project_code\n }\n });\n },\n onQuillEditorInput() {\n this.mastertask.description = this.$refs['description'].getHTML();\n },\n _mergeDeadlineTimeDate() {\n const date = new Date(this.mastertask.deadline);\n const timeParts = this.mastertask._deadline_time.split(':');\n date.setHours(parseInt(timeParts[0]));\n date.setMinutes(parseInt(timeParts[1]));\n this.mastertask.deadline = date;\n },\n _validateEmployees() {\n let isValid = true;\n this.mastertask.employees = this.mastertask.employees.map(employee => {\n if (employee.duration === null || employee.duration === undefined) {\n employee.invalid = true;\n isValid = false;\n }\n return employee;\n });\n return isValid;\n }\n },\n watch: {\n editMode() {\n this.$nextTick(() => {\n this.$refs['description']?.setHTML(this.mastertask.description || '');\n if (!this.mastertask?.id) return;\n const date = new Date(this.mastertask.deadline);\n const hours = date.getHours();\n const minutes = date.getMinutes();\n this.mastertask._deadline_time = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;\n });\n },\n mastertask: {\n handler(val) {\n if (this.editMode && !this.mastertask?.id) {\n localStorage.setItem('mastertaskData', JSON.stringify(val));\n }\n },\n deep: true\n },\n 'mastertask.team_id': {\n handler(value, oldValue) {\n if (this.editMode && !value && oldValue) {\n // Removes only employees from the old team when team_id is removed\n const oldTeamEmployeesIds = this.teams.find(team => team.id == oldValue)?.employees.map(employee => employee?.id) || [];\n const employeesNotInOldTeam = this.mastertask.employees.filter(employee => !oldTeamEmployeesIds.includes(employee?.id));\n this.mastertask.employees = employeesNotInOldTeam;\n }\n },\n deep: true\n },\n '$route.query': {\n handler(_, oldValue) {\n if (oldValue?.subtask?.length && this.mastertask?.id) {\n this.loadMastertask(this.mastertask.id);\n }\n },\n deep: true\n }\n }\n});\n\n//# sourceURL=webpack://jandl/./src/plugins/tm@modal/master-task/z-master-task-modal.vue?./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use%5B0%5D!./node_modules/vue-loader/dist/index.js??ruleSet%5B0%5D.use%5B0%5D\n}"); +eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/modules/es.array.push.js */ \"./node_modules/core-js/modules/es.array.push.js\");\n/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var core_js_modules_es_json_stringify_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.json.stringify.js */ \"./node_modules/core-js/modules/es.json.stringify.js\");\n/* harmony import */ var core_js_modules_es_json_stringify_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_json_stringify_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var core_js_modules_esnext_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core-js/modules/esnext.iterator.constructor.js */ \"./node_modules/core-js/modules/esnext.iterator.constructor.js\");\n/* harmony import */ var core_js_modules_esnext_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var core_js_modules_esnext_iterator_filter_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core-js/modules/esnext.iterator.filter.js */ \"./node_modules/core-js/modules/esnext.iterator.filter.js\");\n/* harmony import */ var core_js_modules_esnext_iterator_filter_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_filter_js__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var core_js_modules_esnext_iterator_find_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! core-js/modules/esnext.iterator.find.js */ \"./node_modules/core-js/modules/esnext.iterator.find.js\");\n/* harmony import */ var core_js_modules_esnext_iterator_find_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_find_js__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var core_js_modules_esnext_iterator_map_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! core-js/modules/esnext.iterator.map.js */ \"./node_modules/core-js/modules/esnext.iterator.map.js\");\n/* harmony import */ var core_js_modules_esnext_iterator_map_js__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_map_js__WEBPACK_IMPORTED_MODULE_5__);\n/* harmony import */ var _plugins_tm_components_z_datepicker_vue__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/plugins/tm@_components/z-datepicker.vue */ \"./src/plugins/tm@_components/z-datepicker.vue\");\n/* harmony import */ var _plugins_tm_components_z_files_upload_vue__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/plugins/tm@_components/z-files-upload.vue */ \"./src/plugins/tm@_components/z-files-upload.vue\");\n/* harmony import */ var _vuelidate_core__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @vuelidate/core */ \"./node_modules/@vuelidate/core/dist/index.esm.js\");\n/* harmony import */ var _vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @vuelidate/validators */ \"./node_modules/@vuelidate/validators/dist/index.esm.js\");\n/* harmony import */ var _plugins_lib_auth_utils_error_utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @/plugins/lib@auth/_utils/error.utils */ \"./src/plugins/lib@auth/_utils/error.utils.ts\");\n/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! moment */ \"./node_modules/moment/moment.js\");\n/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_11__);\n/* harmony import */ var _vueup_vue_quill__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @vueup/vue-quill */ \"./node_modules/@vueup/vue-quill/dist/vue-quill.esm-bundler.js\");\n/* harmony import */ var _plugins_tm_modal_mixins_modal_mixin__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @/plugins/tm@modal/_mixins/modal.mixin */ \"./src/plugins/tm@modal/_mixins/modal.mixin.ts\");\n/* harmony import */ var _vueup_vue_quill_dist_vue_quill_snow_css__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! @vueup/vue-quill/dist/vue-quill.snow.css */ \"./node_modules/@vueup/vue-quill/dist/vue-quill.snow.css\");\n/* harmony import */ var _vueup_vue_quill_dist_vue_quill_snow_css__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(_vueup_vue_quill_dist_vue_quill_snow_css__WEBPACK_IMPORTED_MODULE_14__);\n/* harmony import */ var _mixins_selects_mixin__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./_mixins/selects.mixin */ \"./src/plugins/tm@modal/master-task/_mixins/selects.mixin.ts\");\n/* harmony import */ var _components_a_tasks_table_vue__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./_components/a-tasks-table.vue */ \"./src/plugins/tm@modal/master-task/_components/a-tasks-table.vue\");\n/* harmony import */ var _components_a_mastertask_description_vue__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./_components/a-mastertask-description.vue */ \"./src/plugins/tm@modal/master-task/_components/a-mastertask-description.vue\");\n/* harmony import */ var vuex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! vuex */ \"./node_modules/vuex/dist/vuex.esm-bundler.js\");\n/* harmony import */ var _plugins_tm_mixins_autocomplete_mixin__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! @/plugins/tm@_mixins/autocomplete.mixin */ \"./src/plugins/tm@_mixins/autocomplete.mixin.ts\");\n/* harmony import */ var _plugins_tm_modal_components_a_resize_handle_vue__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! @/plugins/tm@modal/_components/a-resize-handle.vue */ \"./src/plugins/tm@modal/_components/a-resize-handle.vue\");\n/* harmony import */ var _plugins_tm_modal_components_a_reset_size_button_vue__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! @/plugins/tm@modal/_components/a-reset-size-button.vue */ \"./src/plugins/tm@modal/_components/a-reset-size-button.vue\");\n/* harmony import */ var _plugins_tm_modal_components_a_close_button_vue__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! @/plugins/tm@modal/_components/a-close-button.vue */ \"./src/plugins/tm@modal/_components/a-close-button.vue\");\n\n\n\n\n\n\n\n\n\n\n\n// import ZAutocomplete from '@/plugins/tm@_components/z-autocomplete.vue'\n\n\n// import tmUtils from '@/plugins/tm@_utils/tm.utils'\n\n\n\n\n\n\n\n\n\n\n/* harmony default export */ __webpack_exports__[\"default\"] = ({\n // MIXINS\n // computed: employeesOptions, projectsOptions\n // methods: onProjectSelected, onEmployeeSelected, onEmployeeDurationChanged\n // watch: mastertask.team_id\n\n components: {\n AMastertaskDescription: _components_a_mastertask_description_vue__WEBPACK_IMPORTED_MODULE_17__[\"default\"],\n ATasksTable: _components_a_tasks_table_vue__WEBPACK_IMPORTED_MODULE_16__[\"default\"],\n ZDatepicker: _plugins_tm_components_z_datepicker_vue__WEBPACK_IMPORTED_MODULE_6__[\"default\"],\n ZFilesUpload: _plugins_tm_components_z_files_upload_vue__WEBPACK_IMPORTED_MODULE_7__[\"default\"],\n // ZAutocomplete,\n QuillEditor: _vueup_vue_quill__WEBPACK_IMPORTED_MODULE_12__.QuillEditor,\n AResizeHandle: _plugins_tm_modal_components_a_resize_handle_vue__WEBPACK_IMPORTED_MODULE_20__[\"default\"],\n AResetSizeButton: _plugins_tm_modal_components_a_reset_size_button_vue__WEBPACK_IMPORTED_MODULE_21__[\"default\"],\n ACloseButton: _plugins_tm_modal_components_a_close_button_vue__WEBPACK_IMPORTED_MODULE_22__[\"default\"]\n },\n mixins: [_mixins_selects_mixin__WEBPACK_IMPORTED_MODULE_15__[\"default\"], _plugins_tm_mixins_autocomplete_mixin__WEBPACK_IMPORTED_MODULE_19__[\"default\"], _plugins_tm_modal_mixins_modal_mixin__WEBPACK_IMPORTED_MODULE_13__[\"default\"]],\n // MIXINS\n // computed: employeesOptions, projectsOptions\n // methods: onProjectSelected, onEmployeeSelected, onEmployeeDurationChanged\n // watch: mastertask.team_id\n\n emits: ['master-task-edited', 'close'],\n data() {\n return {\n deadline: null,\n editMode: false,\n visible: false,\n errorUtils: _plugins_lib_auth_utils_error_utils__WEBPACK_IMPORTED_MODULE_10__[\"default\"],\n v$: (0,_vuelidate_core__WEBPACK_IMPORTED_MODULE_8__[\"default\"])(),\n mastertask: null,\n isSaving: false,\n showAddEmployeeInput: false,\n date: null,\n projectCodeSearch: null,\n modalName: 'z-master-task-modal'\n };\n },\n computed: {\n ...(0,vuex__WEBPACK_IMPORTED_MODULE_18__.mapGetters)('tm', ['teams', 'projects', 'enrichedEmployees']),\n enrichedSubtasks() {\n if (!this.mastertask?.subtasks) return null;\n return this.mastertask.subtasks.map(subtask => {\n const employee = this.enrichedEmployees.find(employee => employee.id == subtask.employee_id);\n return {\n ...subtask,\n _initials: employee ? employee.name.charAt(0) + employee.surname.charAt(0) : '?',\n _fullName: employee ? `${employee.name} ${employee.surname}` : ''\n };\n }).filter(subtask => subtask !== null);\n }\n },\n validations() {\n const quillEditorRequired = value => {\n if (!value || !value.length || !value.replace(/<[^>]*>/g, '').length) return false;\n return true;\n };\n return {\n mastertask: {\n employees: {\n required: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__.required,\n minLength: (0,_vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__.minLength)(1),\n $each: {\n duration: {\n required: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__.required\n }\n }\n },\n project_id: {\n required: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__.required\n },\n name: {\n required: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__.required\n },\n description: {\n quillEditorRequired\n },\n deadline: {\n required: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__.required\n },\n estimated_duration: {\n required: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__.required\n },\n _deadline_time: {\n required: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_9__.required\n }\n }\n };\n },\n mounted() {\n this.$events.on('close-both-modals', this.closeBothModals);\n this.$events.on('master-task:team-member-deleted', ({\n teamId,\n memberId\n }) => {\n if (this.mastertask.team_id != teamId) return;\n this.mastertask.employees = this.mastertask.employees.filter(employee => employee.id != memberId);\n }), this.$events.on('on-mastertask-deleted', mastertask => {\n if (mastertask?.id == this.mastertask?.id) this.closeModal();\n });\n this.$events.on('on-subtask-deleted', task => {\n if (!this.mastertask) return;\n this.mastertask.subtasks = this.mastertask.subtasks.filter(subtask => subtask.id != task.id);\n });\n this.$events.on('on-subtask-edited', task => {\n if (!this.mastertask?.subtasks) return;\n if (this.mastertask.subtasks.find(subtask => subtask.id == task.id)) {\n this.mastertask.subtasks = this.mastertask.subtasks.map(t => t.id == task.id ? task : t);\n } else {\n this.mastertask.subtasks.push(task);\n }\n });\n },\n beforeUnmount() {\n this.$events.off('on-mastertask-deleted');\n this.$events.off('on-subtask-deleted');\n this.$events.off('on-subtask-edited');\n this.$events.off('master-task:team-member-deleted');\n this.$events.off('close-both-modals', this.closeBothModals);\n },\n methods: {\n closeBothModals() {\n this.$emit('close');\n this.visible = false;\n },\n removeEmployee({\n id\n }) {\n // const isEmployeeInTeam = this.mastertask.team?.employees.find(employee => employee.id == id)\n\n // if (isEmployeeInTeam) {\n // \tthis.mastertask.team_id = null\n // \tthis.mastertask.team = null\n // }\n\n this.mastertask.employees = this.mastertask.employees.filter(employee => employee.id != id);\n },\n removeMemberAlert(member) {\n const team = this.mastertask.team;\n this.$events.emit('show-delete-team-member-modal', {\n member,\n team\n });\n },\n async loadMastertask(id) {\n try {\n this.mastertask = await this.$axios.get_auth_data(`v1/mastertasks/${id}`);\n\n // TODO zmazat ked zacne prichadzat project_id a team_id\n const project = this.projects.find(project => project.code == this.mastertask.project_code);\n this.mastertask.project_id = project?.id || null;\n this.mastertask.team_id = this.mastertask.team?.id || null;\n this.mastertask._allEmployees = this.mastertask.subtasks.map(({\n employee_id,\n duration\n }) => {\n const employee = this.enrichedEmployees.find(({\n id\n }) => id == employee_id);\n if (!employee) {\n return null;\n }\n employee.duration = duration;\n return employee;\n }).filter(employee => employee !== null);\n } catch (error) {\n this.$toast.error(error.message || error);\n }\n },\n async showModal({\n mastertask,\n editMode = false\n }) {\n this.isSaving = false;\n this.editMode = null;\n\n // CRITICAL: Prevent v-dialog autofocus BEFORE modal opens\n this.preventInputFocus = true;\n this.visible = true;\n this.mastertask = null;\n this.$nextTick(() => {\n this.v$.$reset();\n\n // Reset after modal is fully rendered and v-dialog autofocus has been blocked\n setTimeout(() => {\n this.preventInputFocus = false;\n }, 300);\n });\n try {\n if (mastertask?.id) {\n await this.loadMastertask(mastertask.id);\n\n // this.mastertask.project_code \t= project.code\n } else {\n const savedMastertask = localStorage.getItem('mastertaskData');\n try {\n if (savedMastertask) {\n const parsedMastertask = JSON.parse(savedMastertask);\n this.mastertask = parsedMastertask;\n // If the parsed result is not an object, reset to default\n if (typeof this.mastertask !== 'object' || this.mastertask === null) {\n throw new Error('Parsed mastertask is not an object');\n }\n this.$nextTick(() => {\n this.$refs['description']?.setHTML(this.mastertask.description || '');\n });\n } else {\n throw new Error('mastertaskData is null or undefined');\n }\n } catch (error) {\n this.mastertask = {\n employees: [],\n duration: 0,\n _deadline_time: '17:00'\n };\n }\n }\n this.editMode = editMode || !this.mastertask.id;\n } catch (error) {\n this.$toast.error(error.message || error);\n }\n },\n toggleIsFinished() {\n this.$events.emit('show-complete-master-task-modal', {\n mastertask: this.mastertask\n });\n },\n async save() {\n if (this.mastertask.id) {\n this.mastertask.employees = this.mastertask.employees.map(employee => {\n const {\n duration\n } = this.mastertask.subtasks.find(({\n employee_id\n }) => employee_id == employee.id) || {};\n employee.duration = duration || 0;\n return employee;\n });\n }\n const vuelidateValid = await this.v$.$validate();\n const employeesValid = await this._validateEmployees();\n if (!vuelidateValid || !employeesValid) return;\n if (this.$refs['description']) this.mastertask.description = this.$refs['description'].getHTML();\n this._mergeDeadlineTimeDate();\n try {\n this.isSaving = true;\n this.mastertask.deadline = moment__WEBPACK_IMPORTED_MODULE_11___default()(this.mastertask.deadline).format('YYYY-MM-DD HH:MM:SS');\n if (this.mastertask.id) await this.$axios.patch_auth_form(`v1/mastertasks/${this.mastertask.id}`, this.mastertask);else await this.$axios.post_auth_data('v1/mastertasks', this.mastertask);\n localStorage.removeItem('mastertaskData');\n this.$emit('master-task-edited', this.mastertask);\n this.closeModal();\n } catch (error) {\n this.$toast.error(this.$parseError(error));\n } finally {\n this.isSaving = false;\n }\n },\n filesUploaded(files) {\n this.mastertask.files = files;\n },\n closeModal() {\n this.visible = false;\n },\n openDeleteMasterTaskModal(mastertask) {\n this.$events.emit('show-delete-master-task-modal', {\n mastertask\n });\n },\n addTask() {\n this.$events.emit('show-subtask-modal', {\n subtask: {\n master_task_id: this.mastertask.id,\n project_code: this.mastertask.project_code\n }\n });\n },\n onQuillEditorInput() {\n this.mastertask.description = this.$refs['description'].getHTML();\n },\n _mergeDeadlineTimeDate() {\n const date = new Date(this.mastertask.deadline);\n const timeParts = this.mastertask._deadline_time.split(':');\n date.setHours(parseInt(timeParts[0]));\n date.setMinutes(parseInt(timeParts[1]));\n this.mastertask.deadline = date;\n },\n _validateEmployees() {\n let isValid = true;\n this.mastertask.employees = this.mastertask.employees.map(employee => {\n if (employee.duration === null || employee.duration === undefined) {\n employee.invalid = true;\n isValid = false;\n }\n return employee;\n });\n return isValid;\n }\n },\n watch: {\n editMode() {\n this.$nextTick(() => {\n this.$refs['description']?.setHTML(this.mastertask.description || '');\n if (!this.mastertask?.id) return;\n const date = new Date(this.mastertask.deadline);\n const hours = date.getHours();\n const minutes = date.getMinutes();\n this.mastertask._deadline_time = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}`;\n });\n },\n mastertask: {\n handler(val) {\n if (this.editMode && !this.mastertask?.id) {\n localStorage.setItem('mastertaskData', JSON.stringify(val));\n }\n },\n deep: true\n },\n 'mastertask.team_id': {\n handler(value, oldValue) {\n if (this.editMode && !value && oldValue) {\n // Removes only employees from the old team when team_id is removed\n const oldTeamEmployeesIds = this.teams.find(team => team.id == oldValue)?.employees.map(employee => employee?.id) || [];\n const employeesNotInOldTeam = this.mastertask.employees.filter(employee => !oldTeamEmployeesIds.includes(employee?.id));\n this.mastertask.employees = employeesNotInOldTeam;\n }\n },\n deep: true\n },\n '$route.query': {\n handler(_, oldValue) {\n if (oldValue?.subtask?.length && this.mastertask?.id) {\n this.loadMastertask(this.mastertask.id);\n }\n },\n deep: true\n }\n }\n});\n\n//# sourceURL=webpack://jandl/./src/plugins/tm@modal/master-task/z-master-task-modal.vue?./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use%5B0%5D!./node_modules/vue-loader/dist/index.js??ruleSet%5B0%5D.use%5B0%5D\n}"); /***/ }), 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 d061ce3..c2fa887 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 @@ -345,7 +345,6 @@ export default { // computed: employeesOptions, projectsOptions // methods: onProjectSelected, onEmployeeSelected, onEmployeeDurationChanged // watch: mastertask.team_id - components: { AMastertaskDescription, @@ -539,9 +538,6 @@ export default { // CRITICAL: Prevent v-dialog autofocus BEFORE modal opens this.preventInputFocus = true; - /* eslint-disable */console.log( - ...oo_oo(`532727923_569_6_571_7_4`,'🟠 [z-master-task-modal] showModal - preventInputFocus set to true BEFORE modal opens'), - ); this.visible = true; this.mastertask = null; @@ -551,9 +547,6 @@ export default { // Reset after modal is fully rendered and v-dialog autofocus has been blocked setTimeout(() => { this.preventInputFocus = false; - /* eslint-disable */console.log( - ...oo_oo(`532727923_582_10_584_11_4`,'🟠 [z-master-task-modal] showModal - preventInputFocus reset to false after 300ms'), - ); }, 300); });