diff --git a/app/dist/js/index.js b/app/dist/js/index.js index 4dc770b..20550fb 100644 --- a/app/dist/js/index.js +++ b/app/dist/js/index.js @@ -1253,7 +1253,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var cor /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var core_js_modules_esnext_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_0__ = __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_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var core_js_modules_esnext_iterator_filter_js__WEBPACK_IMPORTED_MODULE_1__ = __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_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_filter_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var core_js_modules_esnext_iterator_map_js__WEBPACK_IMPORTED_MODULE_2__ = __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_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_map_js__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.runtime.esm-bundler.js\");\n/* harmony import */ var _vuelidate_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @vuelidate/core */ \"./node_modules/@vuelidate/core/dist/index.esm.js\");\n/* harmony import */ var _vuelidate_validators__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @vuelidate/validators */ \"./node_modules/@vuelidate/validators/dist/index.esm.js\");\n/* harmony import */ var _plugins_tm_utils_useEmployeeTimeline__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/plugins/tm@_utils/useEmployeeTimeline */ \"./src/plugins/tm@_utils/useEmployeeTimeline.ts\");\n/* harmony import */ var _plugins_tm_utils_timeblock_utils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/plugins/tm@_utils/timeblock.utils */ \"./src/plugins/tm@_utils/timeblock.utils.ts\");\n/* harmony import */ var _a_employee_timeblock_header_vue__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./a-employee-timeblock-header.vue */ \"./src/plugins/tm@modal/task/_components/employees/a-employee-timeblock-header.vue\");\n/* harmony import */ var _a_employee_timeblock_timeline_vue__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./a-employee-timeblock-timeline.vue */ \"./src/plugins/tm@modal/task/_components/employees/a-employee-timeblock-timeline.vue\");\n/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! moment */ \"./node_modules/moment/moment.js\");\n/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_10__);\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\n// Configuration: Set to false to allow editing timeblocks with existing IDs\nconst ALLOW_EDITING_EXISTING_TIMEBLOCKS = true;\nconst HOUR_WIDTH = 60; // pixels per hour (desktop)\nconst HOUR_WIDTH_MOBILE = 50; // pixels per hour (mobile)\nconst START_HOUR = 0; // Start from midnight\nconst END_HOUR = 24; // End at midnight\n// Check if mobile\n/* harmony default export */ __webpack_exports__[\"default\"] = (/*@__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_3__.defineComponent)({\n __name: 'a-employee-timeblock',\n props: {\n modelValue: {\n type: Object,\n required: true\n },\n employee: {\n type: [Object, null],\n required: true\n },\n allEmployeeTimeblocks: {\n type: Array,\n required: false,\n default: () => []\n },\n allTimeblocks: {\n type: Array,\n required: false,\n default: () => []\n },\n deletedTimeblockIds: {\n type: Array,\n required: false,\n default: () => []\n },\n currentIndex: {\n type: Number,\n required: false,\n default: 0\n },\n deletable: {\n type: Boolean,\n required: false,\n default: false\n },\n index: {\n type: Number,\n required: false,\n default: 0\n }\n },\n emits: [\"update:modelValue\", \"addTimeblock\", \"removeTimeblock\"],\n setup(__props, {\n expose: __expose,\n emit: __emit\n }) {\n const props = __props;\n const emit = __emit;\n const timelineRef = (0,vue__WEBPACK_IMPORTED_MODULE_3__.ref)(null);\n // Check if timeblock is editable (based on whether it has an ID)\n const isEditable = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n if (ALLOW_EDITING_EXISTING_TIMEBLOCKS) return true;\n return !props.modelValue.id;\n });\n // Minimum date is today (no past dates)\n const minDate = (0,vue__WEBPACK_IMPORTED_MODULE_3__.ref)(new Date());\n // Timeline configuration\n const isMobile = (0,vue__WEBPACK_IMPORTED_MODULE_3__.ref)(false);\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.onMounted)(() => {\n isMobile.value = window.innerWidth <= 768;\n window.addEventListener('resize', () => {\n isMobile.value = window.innerWidth <= 768;\n });\n // Center timeline on mount\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.nextTick)(() => {\n centerTimeline();\n });\n });\n const hourWidth = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => isMobile.value ? HOUR_WIDTH_MOBILE : HOUR_WIDTH);\n // Custom validator for time range\n const timeRangeValid = (value, siblings) => {\n if (!siblings.starts_at_time || !siblings.ends_at_time || !siblings.date) {\n return true;\n }\n const {\n start,\n end\n } = (0,_plugins_tm_utils_timeblock_utils__WEBPACK_IMPORTED_MODULE_7__.timeblockToDateRange)(siblings);\n if (!start || !end) return true;\n return end > start;\n };\n // Custom validator: field is required when start OR end time is filled\n // Uses siblings to check the current state of all fields\n const requiredWhenHasTime = (value, siblings) => {\n // Check if timeblock has any TIME data (start or end time)\n const hasStart = !!siblings.starts_at_time;\n const hasEnd = !!siblings.ends_at_time;\n const hasAnyTimeData = hasStart || hasEnd;\n // If no time data, no validation needed\n if (!hasAnyTimeData) return true;\n // When time data exists, field must have value (not null, undefined, or empty string)\n return value !== null && value !== undefined && value !== '';\n };\n // Vuelidate rules - if start OR end is filled, all three fields are required\n const rules = {\n date: {\n requiredWhenHasTime: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_5__.helpers.withMessage('Vyberte dátum', requiredWhenHasTime)\n },\n starts_at_time: {\n requiredWhenHasTime: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_5__.helpers.withMessage('Zadajte začiatok', requiredWhenHasTime)\n },\n ends_at_time: {\n requiredWhenHasTime: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_5__.helpers.withMessage('Zadajte koniec', requiredWhenHasTime),\n timeRangeValid: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_5__.helpers.withMessage('Koniec musí byť po začiatku', timeRangeValid)\n }\n };\n const v$ = (0,_vuelidate_core__WEBPACK_IMPORTED_MODULE_4__.useVuelidate)(rules, props.modelValue, {\n $autoDirty: true\n });\n // Error visibility logic: show errors if field is dirty OR if the opposite time field is filled\n const hasStartTimeError = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n // Show error if field is dirty and has error\n if (v$.value.starts_at_time.$dirty && v$.value.starts_at_time.$error) {\n return true;\n }\n // OR if end time is filled but start is not\n if (props.modelValue.ends_at_time && !props.modelValue.starts_at_time) {\n return v$.value.starts_at_time.$error;\n }\n return false;\n });\n const hasEndTimeError = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n // Show error if field is dirty and has error\n if (v$.value.ends_at_time.$dirty && v$.value.ends_at_time.$error) {\n return true;\n }\n // OR if start time is filled but end is not\n if (props.modelValue.starts_at_time && !props.modelValue.ends_at_time) {\n return v$.value.ends_at_time.$error;\n }\n return false;\n });\n const endTimeErrorMessage = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n if (hasEndTimeError.value) {\n return v$.value.ends_at_time.$errors.map(e => e.$message).join(', ');\n }\n return '';\n });\n // Reactive refs for composable\n const employeeRef = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => props.employee);\n const dateRef = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => props.modelValue.date);\n const timeblockRef = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => props.modelValue);\n // Get other timeblocks for the same date (excluding current one)\n // This includes timeblocks from both the current employee and other employees\n const otherTimeblocksForSameDate = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n if (!props.modelValue.date) return [];\n const currentDate = moment__WEBPACK_IMPORTED_MODULE_10___default()(props.modelValue.date).format('YYYY-MM-DD');\n // Use allEmployeeTimeblocks which contains timeblocks for this specific employee\n // Filter out the current timeblock by comparing index directly\n return props.allEmployeeTimeblocks.filter((tb, index) => {\n // Skip current timeblock by index\n if (index === props.currentIndex) {\n return false;\n }\n // Must have required fields\n if (!tb.date || !tb.starts_at_time || !tb.ends_at_time) return false;\n // Must be the same date\n return moment__WEBPACK_IMPORTED_MODULE_10___default()(tb.date).format('YYYY-MM-DD') === currentDate;\n });\n });\n // Use timeline composable\n const {\n isLoading,\n timelineTasks,\n scheduledTime: _scheduledTime,\n freeTime: _freeTime,\n timeblockDuration,\n refetch\n } = (0,_plugins_tm_utils_useEmployeeTimeline__WEBPACK_IMPORTED_MODULE_6__.useEmployeeTimeline)(employeeRef, dateRef, timeblockRef, otherTimeblocksForSameDate);\n // Force refetch when date changes\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.watch)(() => props.modelValue.date, () => {\n if (props.modelValue.date && props.employee?.id) {\n refetch();\n }\n });\n // All tasks from timelineTasks are already filtered for the selected date\n // Filter out timeblocks that are being edited or deleted locally\n const scheduledBlocks = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n // Combine IDs that should be filtered: edited locally or deleted\n const hiddenTimeblockIds = new Set([\n // Timeblock IDs being edited locally\n ...props.allTimeblocks.filter(tb => tb.id).map(tb => tb.id),\n // Timeblock IDs that have been deleted\n ...(props.deletedTimeblockIds || [])]);\n // Filter out tasks whose timeblock IDs should be hidden\n return timelineTasks.value.filter(task => !task._timeblock_id || !hiddenTimeblockIds.has(task._timeblock_id));\n });\n // Convert other unsaved timeblocks to task format for collision detection\n const otherTimeblocksAsTasks = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n return otherTimeblocksForSameDate.value.map(tb => {\n const {\n start,\n end\n } = (0,_plugins_tm_utils_timeblock_utils__WEBPACK_IMPORTED_MODULE_7__.timeblockToDateRange)(tb);\n if (!start || !end) return null;\n return {\n _real_start: start,\n _real_end: end,\n _timeblock_id: tb.id || null\n };\n }).filter(task => task !== null);\n });\n // Combine scheduled blocks with other unsaved timeblocks for collision detection\n const allBlocksForCollisionCheck = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n return [...scheduledBlocks.value, ...otherTimeblocksAsTasks.value];\n });\n // Recalculate collision using filtered scheduled blocks AND other unsaved timeblocks\n // This prevents false collisions with timeblocks being edited, but catches collisions with other unsaved timeblocks\n const collision = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n return (0,_plugins_tm_utils_timeblock_utils__WEBPACK_IMPORTED_MODULE_7__.detectCollision)(props.modelValue, allBlocksForCollisionCheck.value);\n });\n // Recalculate collision segments using filtered scheduled blocks AND other unsaved timeblocks\n const collisionSegments = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n return (0,_plugins_tm_utils_timeblock_utils__WEBPACK_IMPORTED_MODULE_7__.getCollisionSegments)(props.modelValue, allBlocksForCollisionCheck.value);\n });\n // Get current timeblock range\n const currentTimeblockRange = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n const {\n start,\n end\n } = (0,_plugins_tm_utils_timeblock_utils__WEBPACK_IMPORTED_MODULE_7__.timeblockToDateRange)(props.modelValue);\n return {\n start,\n end\n };\n });\n // Validate that end time is after start time\n const isTimeRangeValid = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n if (!props.modelValue.starts_at_time || !props.modelValue.ends_at_time) {\n return true; // Don't show error if fields are empty\n }\n const {\n start,\n end\n } = currentTimeblockRange.value;\n if (!start || !end) return true;\n return end > start;\n });\n // Center timeline around middle of work hours\n const centerTimeline = () => {\n if (!timelineRef.value?.timelineScroll) return;\n // Calculate the middle of work hours\n const workStart = props.employee?.work_start ?? 8;\n const workEnd = props.employee?.work_end ?? 17;\n const centerHour = (workStart + workEnd) / 2;\n const centerPosition = (centerHour - START_HOUR) * hourWidth.value;\n const containerWidth = timelineRef.value.timelineScroll.clientWidth;\n timelineRef.value.timelineScroll.scrollLeft = centerPosition - containerWidth / 2;\n };\n // Watch for date changes or employee changes to re-center\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.watch)(() => [props.modelValue.date, props.employee?.id], () => {\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.nextTick)(() => {\n centerTimeline();\n });\n });\n // Watch for timeline ref to become available and center it\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.watch)(timelineRef, newRef => {\n if (newRef?.timelineScroll) {\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.nextTick)(() => {\n centerTimeline();\n });\n }\n });\n // Watch for loading state - when data finishes loading, center the timeline\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.watch)(isLoading, (newIsLoading, oldIsLoading) => {\n // When loading changes from true to false, timeline is re-rendered\n if (oldIsLoading && !newIsLoading) {\n // Wait for DOM to update, then center\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.nextTick)(() => {\n setTimeout(() => {\n centerTimeline();\n }, 0); // Small delay to ensure DOM is fully rendered\n });\n }\n });\n // Date navigation\n const previousDay = () => {\n if (!props.modelValue.date) return;\n const currentDate = moment__WEBPACK_IMPORTED_MODULE_10___default()(props.modelValue.date);\n const newDate = currentDate.clone().subtract(1, 'day').toDate();\n // Don't allow going to past dates\n if (moment__WEBPACK_IMPORTED_MODULE_10___default()(newDate).isBefore(moment__WEBPACK_IMPORTED_MODULE_10___default()(), 'day')) return;\n updateDate(newDate);\n };\n const nextDay = () => {\n if (!props.modelValue.date) return;\n const currentDate = moment__WEBPACK_IMPORTED_MODULE_10___default()(props.modelValue.date);\n const newDate = currentDate.clone().add(1, 'day').toDate();\n updateDate(newDate);\n };\n // Update handlers\n const updateDate = date => {\n emit('update:modelValue', {\n ...props.modelValue,\n date\n });\n };\n const updateStartTime = event => {\n const target = event.target;\n emit('update:modelValue', {\n ...props.modelValue,\n starts_at_time: target.value\n });\n };\n const updateEndTime = event => {\n const target = event.target;\n emit('update:modelValue', {\n ...props.modelValue,\n ends_at_time: target.value\n });\n };\n // Handle timeblock updated from timeline (drag/drop or quick add)\n const handleTimeblockUpdated = payload => {\n const {\n starts_at_time\n } = payload;\n let {\n ends_at_time\n } = payload;\n // Fix accidental same start/end time by adding 1 hour to end\n if (starts_at_time === ends_at_time) {\n const [hours, minutes] = starts_at_time.split(':').map(Number);\n const newEndHour = (hours + 1) % 24; // Wrap around at midnight\n ends_at_time = `${String(newEndHour).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`;\n }\n emit('update:modelValue', {\n ...props.modelValue,\n starts_at_time,\n ends_at_time\n });\n // Trigger validation after timeline update\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.nextTick)(() => {\n v$.value.$touch();\n });\n };\n // Expose validate method\n const validate = async () => {\n v$.value.$touch();\n const isValid = await v$.value.$validate();\n return isValid && isTimeRangeValid.value;\n };\n __expose({\n validate\n });\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.watch)(() => props.modelValue.ends_at_time, () => {\n if (v$.value.ends_at_time.$model !== props.modelValue.ends_at_time) {\n v$.value.ends_at_time.$model = props.modelValue.ends_at_time;\n }\n });\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.watch)(() => props.modelValue.starts_at_time, () => {\n if (v$.value.starts_at_time.$model !== props.modelValue.starts_at_time) {\n v$.value.starts_at_time.$model = props.modelValue.starts_at_time;\n console.log('starts_at_time changed', v$.value.starts_at_time.$model);\n }\n });\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.watch)(() => props.modelValue.date, () => {\n if (v$.value.date.$model !== props.modelValue.date) {\n v$.value.date.$model = props.modelValue.date;\n }\n });\n const __returned__ = {\n ALLOW_EDITING_EXISTING_TIMEBLOCKS,\n props,\n emit,\n timelineRef,\n isEditable,\n minDate,\n HOUR_WIDTH,\n HOUR_WIDTH_MOBILE,\n START_HOUR,\n END_HOUR,\n isMobile,\n hourWidth,\n timeRangeValid,\n requiredWhenHasTime,\n rules,\n v$,\n hasStartTimeError,\n hasEndTimeError,\n endTimeErrorMessage,\n employeeRef,\n dateRef,\n timeblockRef,\n otherTimeblocksForSameDate,\n isLoading,\n timelineTasks,\n _scheduledTime,\n _freeTime,\n timeblockDuration,\n refetch,\n scheduledBlocks,\n otherTimeblocksAsTasks,\n allBlocksForCollisionCheck,\n collision,\n collisionSegments,\n currentTimeblockRange,\n isTimeRangeValid,\n centerTimeline,\n previousDay,\n nextDay,\n updateDate,\n updateStartTime,\n updateEndTime,\n handleTimeblockUpdated,\n validate,\n AEmployeeTimeblockHeader: _a_employee_timeblock_header_vue__WEBPACK_IMPORTED_MODULE_8__[\"default\"],\n AEmployeeTimeblockTimeline: _a_employee_timeblock_timeline_vue__WEBPACK_IMPORTED_MODULE_9__[\"default\"]\n };\n Object.defineProperty(__returned__, '__isScriptSetup', {\n enumerable: false,\n value: true\n });\n return __returned__;\n }\n}));\n\n//# sourceURL=webpack://jandl/./src/plugins/tm@modal/task/_components/employees/a-employee-timeblock.vue?./node_modules/webpack-plugin-vuetify/dist/scriptLoader.js!./node_modules/babel-loader/lib/index.js!./node_modules/ts-loader/index.js??clonedRuleSet-41.use%5B1%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_esnext_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_0__ = __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_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var core_js_modules_esnext_iterator_filter_js__WEBPACK_IMPORTED_MODULE_1__ = __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_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_filter_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var core_js_modules_esnext_iterator_map_js__WEBPACK_IMPORTED_MODULE_2__ = __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_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_map_js__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.runtime.esm-bundler.js\");\n/* harmony import */ var _vuelidate_core__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @vuelidate/core */ \"./node_modules/@vuelidate/core/dist/index.esm.js\");\n/* harmony import */ var _vuelidate_validators__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @vuelidate/validators */ \"./node_modules/@vuelidate/validators/dist/index.esm.js\");\n/* harmony import */ var _plugins_tm_utils_useEmployeeTimeline__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/plugins/tm@_utils/useEmployeeTimeline */ \"./src/plugins/tm@_utils/useEmployeeTimeline.ts\");\n/* harmony import */ var _plugins_tm_utils_timeblock_utils__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/plugins/tm@_utils/timeblock.utils */ \"./src/plugins/tm@_utils/timeblock.utils.ts\");\n/* harmony import */ var _a_employee_timeblock_header_vue__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./a-employee-timeblock-header.vue */ \"./src/plugins/tm@modal/task/_components/employees/a-employee-timeblock-header.vue\");\n/* harmony import */ var _a_employee_timeblock_timeline_vue__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./a-employee-timeblock-timeline.vue */ \"./src/plugins/tm@modal/task/_components/employees/a-employee-timeblock-timeline.vue\");\n/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! moment */ \"./node_modules/moment/moment.js\");\n/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_10__);\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\n// Configuration: Set to false to allow editing timeblocks with existing IDs\nconst ALLOW_EDITING_EXISTING_TIMEBLOCKS = true;\nconst HOUR_WIDTH = 60; // pixels per hour (desktop)\nconst HOUR_WIDTH_MOBILE = 50; // pixels per hour (mobile)\nconst START_HOUR = 0; // Start from midnight\nconst END_HOUR = 24; // End at midnight\n// Check if mobile\n/* harmony default export */ __webpack_exports__[\"default\"] = (/*@__PURE__*/(0,vue__WEBPACK_IMPORTED_MODULE_3__.defineComponent)({\n __name: 'a-employee-timeblock',\n props: {\n modelValue: {\n type: Object,\n required: true\n },\n employee: {\n type: [Object, null],\n required: true\n },\n allEmployeeTimeblocks: {\n type: Array,\n required: false,\n default: () => []\n },\n allTimeblocks: {\n type: Array,\n required: false,\n default: () => []\n },\n deletedTimeblockIds: {\n type: Array,\n required: false,\n default: () => []\n },\n currentIndex: {\n type: Number,\n required: false,\n default: 0\n },\n deletable: {\n type: Boolean,\n required: false,\n default: false\n },\n index: {\n type: Number,\n required: false,\n default: 0\n }\n },\n emits: [\"update:modelValue\", \"addTimeblock\", \"removeTimeblock\"],\n setup(__props, {\n expose: __expose,\n emit: __emit\n }) {\n const props = __props;\n const emit = __emit;\n const timelineRef = (0,vue__WEBPACK_IMPORTED_MODULE_3__.ref)(null);\n // Check if timeblock is editable (based on whether it has an ID)\n const isEditable = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n if (ALLOW_EDITING_EXISTING_TIMEBLOCKS) return true;\n return !props.modelValue.id;\n });\n // Minimum date is today (no past dates)\n const minDate = (0,vue__WEBPACK_IMPORTED_MODULE_3__.ref)(new Date());\n // Timeline configuration\n const isMobile = (0,vue__WEBPACK_IMPORTED_MODULE_3__.ref)(false);\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.onMounted)(() => {\n isMobile.value = window.innerWidth <= 768;\n window.addEventListener('resize', () => {\n isMobile.value = window.innerWidth <= 768;\n });\n // Center timeline on mount\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.nextTick)(() => {\n centerTimeline();\n });\n });\n const hourWidth = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => isMobile.value ? HOUR_WIDTH_MOBILE : HOUR_WIDTH);\n // Custom validator for time range\n const timeRangeValid = (value, siblings) => {\n if (!siblings.starts_at_time || !siblings.ends_at_time || !siblings.date) {\n return true;\n }\n const {\n start,\n end\n } = (0,_plugins_tm_utils_timeblock_utils__WEBPACK_IMPORTED_MODULE_7__.timeblockToDateRange)(siblings);\n if (!start || !end) return true;\n return end > start;\n };\n // Custom validator: field is required when start OR end time is filled\n // Uses siblings to check the current state of all fields\n // const requiredWhenHasTime = (value: any, siblings: any) => {\n // // Check if timeblock has any TIME data (start or end time)\n // const hasStart = !!siblings.starts_at_time;\n // const hasEnd = !!siblings.ends_at_time;\n // const hasAnyTimeData = hasStart || hasEnd;\n // // If no time data, no validation needed\n // if (!hasAnyTimeData) return true;\n // // When time data exists, field must have value (not null, undefined, or empty string)\n // return value !== null && value !== undefined && value !== '';\n // };\n // Vuelidate rules - if start OR end is filled, all three fields are required\n const rules = {\n date: {\n requiredWhenHasTime: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_5__.helpers.withMessage('Vyberte dátum', _vuelidate_validators__WEBPACK_IMPORTED_MODULE_5__.required)\n },\n starts_at_time: {\n requiredWhenHasTime: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_5__.helpers.withMessage('Zadajte začiatok', _vuelidate_validators__WEBPACK_IMPORTED_MODULE_5__.required)\n },\n ends_at_time: {\n requiredWhenHasTime: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_5__.helpers.withMessage('Zadajte koniec', _vuelidate_validators__WEBPACK_IMPORTED_MODULE_5__.required),\n timeRangeValid: _vuelidate_validators__WEBPACK_IMPORTED_MODULE_5__.helpers.withMessage('Koniec musí byť po začiatku', timeRangeValid)\n }\n };\n const v$ = (0,_vuelidate_core__WEBPACK_IMPORTED_MODULE_4__.useVuelidate)(rules, props.modelValue, {\n $autoDirty: true\n });\n // Error visibility logic: show errors if field is dirty OR if the opposite time field is filled\n const hasStartTimeError = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n // Show error if field is dirty and has error\n if (v$.value.starts_at_time.$dirty && v$.value.starts_at_time.$error) {\n return true;\n }\n // OR if end time is filled but start is not\n if (props.modelValue.ends_at_time && !props.modelValue.starts_at_time) {\n return v$.value.starts_at_time.$error;\n }\n return false;\n });\n const hasEndTimeError = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n // Show error if field is dirty and has error\n if (v$.value.ends_at_time.$dirty && v$.value.ends_at_time.$error) {\n return true;\n }\n // OR if start time is filled but end is not\n if (props.modelValue.starts_at_time && !props.modelValue.ends_at_time) {\n return v$.value.ends_at_time.$error;\n }\n return false;\n });\n const endTimeErrorMessage = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n if (hasEndTimeError.value) {\n return v$.value.ends_at_time.$errors.map(e => e.$message).join(', ');\n }\n return '';\n });\n // Reactive refs for composable\n const employeeRef = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => props.employee);\n const dateRef = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => props.modelValue.date);\n const timeblockRef = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => props.modelValue);\n // Get other timeblocks for the same date (excluding current one)\n // This includes timeblocks from both the current employee and other employees\n const otherTimeblocksForSameDate = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n if (!props.modelValue.date) return [];\n const currentDate = moment__WEBPACK_IMPORTED_MODULE_10___default()(props.modelValue.date).format('YYYY-MM-DD');\n // Use allEmployeeTimeblocks which contains timeblocks for this specific employee\n // Filter out the current timeblock by comparing index directly\n return props.allEmployeeTimeblocks.filter((tb, index) => {\n // Skip current timeblock by index\n if (index === props.currentIndex) {\n return false;\n }\n // Must have required fields\n if (!tb.date || !tb.starts_at_time || !tb.ends_at_time) return false;\n // Must be the same date\n return moment__WEBPACK_IMPORTED_MODULE_10___default()(tb.date).format('YYYY-MM-DD') === currentDate;\n });\n });\n // Use timeline composable\n const {\n isLoading,\n timelineTasks,\n scheduledTime: _scheduledTime,\n freeTime: _freeTime,\n timeblockDuration,\n refetch\n } = (0,_plugins_tm_utils_useEmployeeTimeline__WEBPACK_IMPORTED_MODULE_6__.useEmployeeTimeline)(employeeRef, dateRef, timeblockRef, otherTimeblocksForSameDate);\n // Force refetch when date changes\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.watch)(() => props.modelValue.date, () => {\n if (props.modelValue.date && props.employee?.id) {\n refetch();\n }\n });\n // All tasks from timelineTasks are already filtered for the selected date\n // Filter out timeblocks that are being edited or deleted locally\n const scheduledBlocks = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n // Combine IDs that should be filtered: edited locally or deleted\n const hiddenTimeblockIds = new Set([\n // Timeblock IDs being edited locally\n ...props.allTimeblocks.filter(tb => tb.id).map(tb => tb.id),\n // Timeblock IDs that have been deleted\n ...(props.deletedTimeblockIds || [])]);\n // Filter out tasks whose timeblock IDs should be hidden\n return timelineTasks.value.filter(task => !task._timeblock_id || !hiddenTimeblockIds.has(task._timeblock_id));\n });\n // Convert other unsaved timeblocks to task format for collision detection\n const otherTimeblocksAsTasks = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n return otherTimeblocksForSameDate.value.map(tb => {\n const {\n start,\n end\n } = (0,_plugins_tm_utils_timeblock_utils__WEBPACK_IMPORTED_MODULE_7__.timeblockToDateRange)(tb);\n if (!start || !end) return null;\n return {\n _real_start: start,\n _real_end: end,\n _timeblock_id: tb.id || null\n };\n }).filter(task => task !== null);\n });\n // Combine scheduled blocks with other unsaved timeblocks for collision detection\n const allBlocksForCollisionCheck = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n return [...scheduledBlocks.value, ...otherTimeblocksAsTasks.value];\n });\n // Recalculate collision using filtered scheduled blocks AND other unsaved timeblocks\n // This prevents false collisions with timeblocks being edited, but catches collisions with other unsaved timeblocks\n const collision = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n return (0,_plugins_tm_utils_timeblock_utils__WEBPACK_IMPORTED_MODULE_7__.detectCollision)(props.modelValue, allBlocksForCollisionCheck.value);\n });\n // Recalculate collision segments using filtered scheduled blocks AND other unsaved timeblocks\n const collisionSegments = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n return (0,_plugins_tm_utils_timeblock_utils__WEBPACK_IMPORTED_MODULE_7__.getCollisionSegments)(props.modelValue, allBlocksForCollisionCheck.value);\n });\n // Get current timeblock range\n const currentTimeblockRange = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n const {\n start,\n end\n } = (0,_plugins_tm_utils_timeblock_utils__WEBPACK_IMPORTED_MODULE_7__.timeblockToDateRange)(props.modelValue);\n return {\n start,\n end\n };\n });\n // Validate that end time is after start time\n const isTimeRangeValid = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n if (!props.modelValue.starts_at_time || !props.modelValue.ends_at_time) {\n return true; // Don't show error if fields are empty\n }\n const {\n start,\n end\n } = currentTimeblockRange.value;\n if (!start || !end) return true;\n return end > start;\n });\n // Center timeline around middle of work hours\n const centerTimeline = () => {\n if (!timelineRef.value?.timelineScroll) return;\n // Calculate the middle of work hours\n const workStart = props.employee?.work_start ?? 8;\n const workEnd = props.employee?.work_end ?? 17;\n const centerHour = (workStart + workEnd) / 2;\n const centerPosition = (centerHour - START_HOUR) * hourWidth.value;\n const containerWidth = timelineRef.value.timelineScroll.clientWidth;\n timelineRef.value.timelineScroll.scrollLeft = centerPosition - containerWidth / 2;\n };\n // Watch for date changes or employee changes to re-center\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.watch)(() => [props.modelValue.date, props.employee?.id], () => {\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.nextTick)(() => {\n centerTimeline();\n });\n });\n // Watch for timeline ref to become available and center it\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.watch)(timelineRef, newRef => {\n if (newRef?.timelineScroll) {\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.nextTick)(() => {\n centerTimeline();\n });\n }\n });\n // Watch for loading state - when data finishes loading, center the timeline\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.watch)(isLoading, (newIsLoading, oldIsLoading) => {\n // When loading changes from true to false, timeline is re-rendered\n if (oldIsLoading && !newIsLoading) {\n // Wait for DOM to update, then center\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.nextTick)(() => {\n setTimeout(() => {\n centerTimeline();\n }, 0); // Small delay to ensure DOM is fully rendered\n });\n }\n });\n // Date navigation\n const previousDay = () => {\n if (!props.modelValue.date) return;\n const currentDate = moment__WEBPACK_IMPORTED_MODULE_10___default()(props.modelValue.date);\n const newDate = currentDate.clone().subtract(1, 'day').toDate();\n // Don't allow going to past dates\n if (moment__WEBPACK_IMPORTED_MODULE_10___default()(newDate).isBefore(moment__WEBPACK_IMPORTED_MODULE_10___default()(), 'day')) return;\n updateDate(newDate);\n };\n const nextDay = () => {\n if (!props.modelValue.date) return;\n const currentDate = moment__WEBPACK_IMPORTED_MODULE_10___default()(props.modelValue.date);\n const newDate = currentDate.clone().add(1, 'day').toDate();\n updateDate(newDate);\n };\n // Update handlers\n const updateDate = date => {\n emit('update:modelValue', {\n ...props.modelValue,\n date\n });\n };\n const updateStartTime = event => {\n const target = event.target;\n emit('update:modelValue', {\n ...props.modelValue,\n starts_at_time: target.value\n });\n };\n const updateEndTime = event => {\n const target = event.target;\n emit('update:modelValue', {\n ...props.modelValue,\n ends_at_time: target.value\n });\n };\n // Handle timeblock updated from timeline (drag/drop or quick add)\n const handleTimeblockUpdated = payload => {\n const {\n starts_at_time\n } = payload;\n let {\n ends_at_time\n } = payload;\n // Fix accidental same start/end time by adding 1 hour to end\n if (starts_at_time === ends_at_time) {\n const [hours, minutes] = starts_at_time.split(':').map(Number);\n const newEndHour = (hours + 1) % 24; // Wrap around at midnight\n ends_at_time = `${String(newEndHour).padStart(2, '0')}:${String(minutes).padStart(2, '0')}`;\n }\n emit('update:modelValue', {\n ...props.modelValue,\n starts_at_time,\n ends_at_time\n });\n // Trigger validation after timeline update\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.nextTick)(() => {\n v$.value.$touch();\n });\n };\n // Expose validate method\n const validate = async () => {\n v$.value.$touch();\n const isValid = await v$.value.$validate();\n return isValid && isTimeRangeValid.value;\n };\n __expose({\n validate\n });\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.watch)(() => props.modelValue.ends_at_time, () => {\n if (v$.value.ends_at_time.$model !== props.modelValue.ends_at_time) {\n v$.value.ends_at_time.$model = props.modelValue.ends_at_time;\n }\n });\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.watch)(() => props.modelValue.starts_at_time, () => {\n if (v$.value.starts_at_time.$model !== props.modelValue.starts_at_time) {\n v$.value.starts_at_time.$model = props.modelValue.starts_at_time;\n console.log('starts_at_time changed', v$.value.starts_at_time.$model);\n }\n });\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.watch)(() => props.modelValue.date, () => {\n if (v$.value.date.$model !== props.modelValue.date) {\n v$.value.date.$model = props.modelValue.date;\n }\n });\n const __returned__ = {\n ALLOW_EDITING_EXISTING_TIMEBLOCKS,\n props,\n emit,\n timelineRef,\n isEditable,\n minDate,\n HOUR_WIDTH,\n HOUR_WIDTH_MOBILE,\n START_HOUR,\n END_HOUR,\n isMobile,\n hourWidth,\n timeRangeValid,\n rules,\n v$,\n hasStartTimeError,\n hasEndTimeError,\n endTimeErrorMessage,\n employeeRef,\n dateRef,\n timeblockRef,\n otherTimeblocksForSameDate,\n isLoading,\n timelineTasks,\n _scheduledTime,\n _freeTime,\n timeblockDuration,\n refetch,\n scheduledBlocks,\n otherTimeblocksAsTasks,\n allBlocksForCollisionCheck,\n collision,\n collisionSegments,\n currentTimeblockRange,\n isTimeRangeValid,\n centerTimeline,\n previousDay,\n nextDay,\n updateDate,\n updateStartTime,\n updateEndTime,\n handleTimeblockUpdated,\n validate,\n AEmployeeTimeblockHeader: _a_employee_timeblock_header_vue__WEBPACK_IMPORTED_MODULE_8__[\"default\"],\n AEmployeeTimeblockTimeline: _a_employee_timeblock_timeline_vue__WEBPACK_IMPORTED_MODULE_9__[\"default\"]\n };\n Object.defineProperty(__returned__, '__isScriptSetup', {\n enumerable: false,\n value: true\n });\n return __returned__;\n }\n}));\n\n//# sourceURL=webpack://jandl/./src/plugins/tm@modal/task/_components/employees/a-employee-timeblock.vue?./node_modules/webpack-plugin-vuetify/dist/scriptLoader.js!./node_modules/babel-loader/lib/index.js!./node_modules/ts-loader/index.js??clonedRuleSet-41.use%5B1%5D!./node_modules/vue-loader/dist/index.js??ruleSet%5B0%5D.use%5B0%5D\n}"); /***/ }),