From c9772400bd5417e2a52c00bbb7125e3fbe053440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Glasn=C3=A1k?= Date: Tue, 3 Feb 2026 04:18:40 +0100 Subject: [PATCH 1/2] fix(task-edit): fixed free time calculation --- .../plugins/tm@_utils/useEmployeeTimeline.ts | 35 ++++++++++++++----- .../employees/a-employee-timeblock.vue | 11 +++++- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/app/src/plugins/tm@_utils/useEmployeeTimeline.ts b/app/src/plugins/tm@_utils/useEmployeeTimeline.ts index 8a6333e..646a994 100644 --- a/app/src/plugins/tm@_utils/useEmployeeTimeline.ts +++ b/app/src/plugins/tm@_utils/useEmployeeTimeline.ts @@ -26,6 +26,7 @@ export function useEmployeeTimeline( otherLocalTimeblocks?: Ref, editingBlockerId?: Ref, draftTimeblocks?: Ref, + allEditingTimeblockIds?: Ref, ) { // Fetch employee's tasks for the selected date const { @@ -267,6 +268,11 @@ export function useEmployeeTimeline( if (!tasks || !d) return 0; + // Get IDs of timeblocks being edited locally to exclude them from scheduled time + const editingTimeblockIds = allEditingTimeblockIds + ? new Set(unref(allEditingTimeblockIds).filter((id) => id != null)) + : new Set(); + let totalMinutes = 0; tasks.forEach((task) => { @@ -278,6 +284,11 @@ export function useEmployeeTimeline( return; } + // Skip timeblocks that are being edited locally to avoid double-counting + if (task._timeblock_id && editingTimeblockIds.has(task._timeblock_id)) { + return; + } + totalMinutes += timelineUtils._getDifferenceInMinutes( task._real_end, task._real_start, @@ -287,14 +298,10 @@ export function useEmployeeTimeline( return (totalMinutes / 60).toFixed(1); }); - // Calculate free/unscheduled time for the day (in hours) - const freeTime = computed(() => { - const emp = unref(employee); - const d = unref(date); + // Calculate total planned time including local edits (for display purposes) + const totalPlannedTime = computed(() => { const scheduled = parseFloat(String(unref(scheduledTime))); - - if (!emp || !d) return '0'; - + // Calculate duration of other local unsaved timeblocks for the same date let localTimeblocksHours = 0; if (otherLocalTimeblocks) { @@ -313,9 +320,20 @@ export function useEmployeeTimeline( localTimeblocksHours += calculateTimeblockDuration(currentTb); } + return (scheduled + localTimeblocksHours).toFixed(1); + }); + + // Calculate free/unscheduled time for the day (in hours) + const freeTime = computed(() => { + const emp = unref(employee); + const d = unref(date); + const totalPlanned = parseFloat(String(unref(totalPlannedTime))); + + if (!emp || !d) return '0'; + const dailyCapacityHours = emp.work_end - emp.work_start; - return (dailyCapacityHours - scheduled - localTimeblocksHours).toFixed(1); + return (dailyCapacityHours - totalPlanned).toFixed(1); }); // Detect collisions with current timeblock @@ -367,6 +385,7 @@ export function useEmployeeTimeline( // Timeline data timelineTasks, scheduledTime, + totalPlannedTime, freeTime, // Collision detection diff --git a/app/src/plugins/tm@modal/task/_components/employees/a-employee-timeblock.vue b/app/src/plugins/tm@modal/task/_components/employees/a-employee-timeblock.vue index 6c31a79..3ab62ec 100644 --- a/app/src/plugins/tm@modal/task/_components/employees/a-employee-timeblock.vue +++ b/app/src/plugins/tm@modal/task/_components/employees/a-employee-timeblock.vue @@ -14,7 +14,7 @@ :has-start-time-error="hasStartTimeError" :has-end-time-error="hasEndTimeError" :end-time-error-message="endTimeErrorMessage" - :planned-time="_scheduledTime" + :planned-time="_totalPlannedTime" :free-time="_freeTime" :employee="employee" :index="index" @@ -238,6 +238,13 @@ const otherTimeblocksForSameDate = computed(() => { }); }); +// Get all timeblock IDs being edited locally for this employee (to exclude from server scheduled time) +const allEditingTimeblockIds = computed(() => { + return props.allEmployeeTimeblocks + .filter((tb) => tb.id != null) + .map((tb) => tb.id) as number[]; +}); + // Use timeline composable const editingBlockerIdRef = computed(() => props.editingBlockerId); const draftTimeblocksRef = computed(() => props.draftTimeblocks); @@ -246,6 +253,7 @@ const { isLoading, timelineTasks, scheduledTime: _scheduledTime, + totalPlannedTime: _totalPlannedTime, freeTime: _freeTime, timeblockDuration, refetch, @@ -256,6 +264,7 @@ const { otherTimeblocksForSameDate, editingBlockerIdRef, draftTimeblocksRef, + allEditingTimeblockIds, ); // Force refetch when date changes From 160ea41dafe2bf2d14f56c696beaaa6923302333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Glasn=C3=A1k?= Date: Tue, 3 Feb 2026 04:25:58 +0100 Subject: [PATCH 2/2] fix(timeblock): improved validation for time range and required fields in timeblock editing --- app/dist/js/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/dist/js/index.js b/app/dist/js/index.js index 5a4d4b1..b04c75d 100644 --- a/app/dist/js/index.js +++ b/app/dist/js/index.js @@ -1274,7 +1274,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 editingBlockerId: {\n type: [Number, null],\n required: false,\n default: null\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 draftTimeblocks: {\n type: Array,\n required: false,\n default: () => []\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 editingBlockerIdRef = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => props.editingBlockerId);\n const draftTimeblocksRef = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => props.draftTimeblocks);\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, editingBlockerIdRef, draftTimeblocksRef);\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 // conceptTasksRefetch();\n }\n });\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.onMounted)(() => {\n refetch();\n // conceptTasksRefetch();\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 editingBlockerIdRef,\n draftTimeblocksRef,\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 editingBlockerId: {\n type: [Number, null],\n required: false,\n default: null\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 draftTimeblocks: {\n type: Array,\n required: false,\n default: () => []\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 // Get all timeblock IDs being edited locally for this employee (to exclude from server scheduled time)\n const allEditingTimeblockIds = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => {\n return props.allEmployeeTimeblocks.filter(tb => tb.id != null).map(tb => tb.id);\n });\n // Use timeline composable\n const editingBlockerIdRef = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => props.editingBlockerId);\n const draftTimeblocksRef = (0,vue__WEBPACK_IMPORTED_MODULE_3__.computed)(() => props.draftTimeblocks);\n const {\n isLoading,\n timelineTasks,\n scheduledTime: _scheduledTime,\n totalPlannedTime: _totalPlannedTime,\n freeTime: _freeTime,\n timeblockDuration,\n refetch\n } = (0,_plugins_tm_utils_useEmployeeTimeline__WEBPACK_IMPORTED_MODULE_6__.useEmployeeTimeline)(employeeRef, dateRef, timeblockRef, otherTimeblocksForSameDate, editingBlockerIdRef, draftTimeblocksRef, allEditingTimeblockIds);\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 // conceptTasksRefetch();\n }\n });\n (0,vue__WEBPACK_IMPORTED_MODULE_3__.onMounted)(() => {\n refetch();\n // conceptTasksRefetch();\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 allEditingTimeblockIds,\n editingBlockerIdRef,\n draftTimeblocksRef,\n isLoading,\n timelineTasks,\n _scheduledTime,\n _totalPlannedTime,\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}"); /***/ }), @@ -1351,7 +1351,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa /***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; -eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ render: function() { return /* binding */ render; }\n/* harmony export */ });\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.runtime.esm-bundler.js\");\n\nconst _hoisted_1 = {\n key: 0,\n class: \"timeline-wrapper\"\n};\nfunction render(_ctx, _cache, $props, $setup, $data, $options) {\n return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)(\"div\", {\n class: (0,vue__WEBPACK_IMPORTED_MODULE_0__.normalizeClass)([\"timeblock\", {\n 'timeblock--finished': $props.modelValue.is_finished\n }])\n }, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)($setup[\"AEmployeeTimeblockHeader\"], {\n \"model-value\": $props.modelValue,\n \"min-date\": $setup.minDate,\n deletable: $props.deletable,\n \"is-editable\": $setup.isEditable,\n \"is-time-range-valid\": $setup.isTimeRangeValid,\n collision: $setup.collision,\n \"has-validation-errors\": $setup.v$.$error && $setup.v$.$anyDirty,\n \"has-start-time-error\": $setup.hasStartTimeError,\n \"has-end-time-error\": $setup.hasEndTimeError,\n \"end-time-error-message\": $setup.endTimeErrorMessage,\n \"planned-time\": $setup._scheduledTime,\n \"free-time\": $setup._freeTime,\n employee: $props.employee,\n index: $props.index,\n onPreviousDay: $setup.previousDay,\n onNextDay: $setup.nextDay,\n onUpdateDate: $setup.updateDate,\n onUpdateStartTime: $setup.updateStartTime,\n onUpdateEndTime: $setup.updateEndTime,\n onAddTimeblock: _cache[0] || (_cache[0] = $event => _ctx.$emit('addTimeblock')),\n onRemoveTimeblock: _cache[1] || (_cache[1] = $event => _ctx.$emit('removeTimeblock'))\n }, null, 8 /* PROPS */, [\"model-value\", \"min-date\", \"deletable\", \"is-editable\", \"is-time-range-valid\", \"collision\", \"has-validation-errors\", \"has-start-time-error\", \"has-end-time-error\", \"end-time-error-message\", \"planned-time\", \"free-time\", \"employee\", \"index\"]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)(\" Timeline Visualization \"), $props.modelValue.date && $props.employee ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)(\"div\", _hoisted_1, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)($setup[\"AEmployeeTimeblockTimeline\"], {\n ref: \"timelineRef\",\n \"is-loading\": $setup.isLoading,\n employee: $props.employee,\n date: $props.modelValue.date,\n \"scheduled-blocks\": $setup.scheduledBlocks,\n \"other-timeblocks\": $setup.otherTimeblocksForSameDate,\n \"current-timeblock-range\": $setup.currentTimeblockRange,\n collision: $setup.collision,\n \"collision-segments\": $setup.collisionSegments,\n \"timeblock-duration\": $setup.timeblockDuration,\n \"start-hour\": $setup.START_HOUR,\n \"end-hour\": $setup.END_HOUR,\n \"hour-width\": $setup.hourWidth,\n onTimeblockUpdated: $setup.handleTimeblockUpdated\n }, null, 8 /* PROPS */, [\"is-loading\", \"employee\", \"date\", \"scheduled-blocks\", \"other-timeblocks\", \"current-timeblock-range\", \"collision\", \"collision-segments\", \"timeblock-duration\", \"hour-width\"])])) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)(\"v-if\", true)], 2 /* CLASS */);\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/templateLoader.js??ruleSet%5B1%5D.rules%5B5%5D!./node_modules/vue-loader/dist/index.js??ruleSet%5B0%5D.use%5B0%5D\n}"); +eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ render: function() { return /* binding */ render; }\n/* harmony export */ });\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.runtime.esm-bundler.js\");\n\nconst _hoisted_1 = {\n key: 0,\n class: \"timeline-wrapper\"\n};\nfunction render(_ctx, _cache, $props, $setup, $data, $options) {\n return (0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)(\"div\", {\n class: (0,vue__WEBPACK_IMPORTED_MODULE_0__.normalizeClass)([\"timeblock\", {\n 'timeblock--finished': $props.modelValue.is_finished\n }])\n }, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)($setup[\"AEmployeeTimeblockHeader\"], {\n \"model-value\": $props.modelValue,\n \"min-date\": $setup.minDate,\n deletable: $props.deletable,\n \"is-editable\": $setup.isEditable,\n \"is-time-range-valid\": $setup.isTimeRangeValid,\n collision: $setup.collision,\n \"has-validation-errors\": $setup.v$.$error && $setup.v$.$anyDirty,\n \"has-start-time-error\": $setup.hasStartTimeError,\n \"has-end-time-error\": $setup.hasEndTimeError,\n \"end-time-error-message\": $setup.endTimeErrorMessage,\n \"planned-time\": $setup._totalPlannedTime,\n \"free-time\": $setup._freeTime,\n employee: $props.employee,\n index: $props.index,\n onPreviousDay: $setup.previousDay,\n onNextDay: $setup.nextDay,\n onUpdateDate: $setup.updateDate,\n onUpdateStartTime: $setup.updateStartTime,\n onUpdateEndTime: $setup.updateEndTime,\n onAddTimeblock: _cache[0] || (_cache[0] = $event => _ctx.$emit('addTimeblock')),\n onRemoveTimeblock: _cache[1] || (_cache[1] = $event => _ctx.$emit('removeTimeblock'))\n }, null, 8 /* PROPS */, [\"model-value\", \"min-date\", \"deletable\", \"is-editable\", \"is-time-range-valid\", \"collision\", \"has-validation-errors\", \"has-start-time-error\", \"has-end-time-error\", \"end-time-error-message\", \"planned-time\", \"free-time\", \"employee\", \"index\"]), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)(\" Timeline Visualization \"), $props.modelValue.date && $props.employee ? ((0,vue__WEBPACK_IMPORTED_MODULE_0__.openBlock)(), (0,vue__WEBPACK_IMPORTED_MODULE_0__.createElementBlock)(\"div\", _hoisted_1, [(0,vue__WEBPACK_IMPORTED_MODULE_0__.createVNode)($setup[\"AEmployeeTimeblockTimeline\"], {\n ref: \"timelineRef\",\n \"is-loading\": $setup.isLoading,\n employee: $props.employee,\n date: $props.modelValue.date,\n \"scheduled-blocks\": $setup.scheduledBlocks,\n \"other-timeblocks\": $setup.otherTimeblocksForSameDate,\n \"current-timeblock-range\": $setup.currentTimeblockRange,\n collision: $setup.collision,\n \"collision-segments\": $setup.collisionSegments,\n \"timeblock-duration\": $setup.timeblockDuration,\n \"start-hour\": $setup.START_HOUR,\n \"end-hour\": $setup.END_HOUR,\n \"hour-width\": $setup.hourWidth,\n onTimeblockUpdated: $setup.handleTimeblockUpdated\n }, null, 8 /* PROPS */, [\"is-loading\", \"employee\", \"date\", \"scheduled-blocks\", \"other-timeblocks\", \"current-timeblock-range\", \"collision\", \"collision-segments\", \"timeblock-duration\", \"hour-width\"])])) : (0,vue__WEBPACK_IMPORTED_MODULE_0__.createCommentVNode)(\"v-if\", true)], 2 /* CLASS */);\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/templateLoader.js??ruleSet%5B1%5D.rules%5B5%5D!./node_modules/vue-loader/dist/index.js??ruleSet%5B0%5D.use%5B0%5D\n}"); /***/ }), @@ -2699,7 +2699,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 export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ useEmployeeTimeline: function() { return /* binding */ useEmployeeTimeline; }\n/* harmony export */ });\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_esnext_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_1__ = __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_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var core_js_modules_esnext_iterator_find_js__WEBPACK_IMPORTED_MODULE_2__ = __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_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_find_js__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var core_js_modules_esnext_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core-js/modules/esnext.iterator.for-each.js */ \"./node_modules/core-js/modules/esnext.iterator.for-each.js\");\n/* harmony import */ var core_js_modules_esnext_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var _tanstack_vue_query__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @tanstack/vue-query */ \"./node_modules/@tanstack/vue-query/build/modern/useQuery.js\");\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.runtime.esm-bundler.js\");\n/* harmony import */ var _plugins_w_custom_axios_models_axios__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/plugins/w@custom/axios/models/axios */ \"./src/plugins/w@custom/axios/models/axios.ts\");\n/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! moment */ \"./node_modules/moment/moment.js\");\n/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_7__);\n/* harmony import */ var _plugins_tm_dashboard_tasks_utils_timeline_utils__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @/plugins/tm@dashboard/tasks/_utils/timeline.utils */ \"./src/plugins/tm@dashboard/tasks/_utils/timeline.utils.ts\");\n/* harmony import */ var _timeblock_utils__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./timeblock.utils */ \"./src/plugins/tm@_utils/timeblock.utils.ts\");\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\nfunction useEmployeeTimeline(employee, date, currentTimeblock, otherLocalTimeblocks, editingBlockerId, draftTimeblocks) {\n // Fetch employee's tasks for the selected date\n const {\n data: tasksData,\n isLoading,\n error,\n refetch\n } = (0,_tanstack_vue_query__WEBPACK_IMPORTED_MODULE_4__.useQuery)({\n queryKey: (0,vue__WEBPACK_IMPORTED_MODULE_5__.computed)(() => ['employee-timeline', (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(employee)?.id, (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(date) ? moment__WEBPACK_IMPORTED_MODULE_7___default()((0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(date)).format('YYYY-MM-DD') : null]),\n queryFn: async () => {\n const emp = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(employee);\n const d = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(date);\n if (!emp?.id || !d) {\n return null;\n }\n const dateStr = moment__WEBPACK_IMPORTED_MODULE_7___default()(d).format('YYYY-MM-DD');\n const queryParams = new URLSearchParams({\n start: dateStr,\n end: dateStr,\n employee_id: emp.id.toString()\n }).toString();\n const response = await _plugins_w_custom_axios_models_axios__WEBPACK_IMPORTED_MODULE_6__[\"default\"].get_auth(`v1/subtasks?${queryParams}`);\n return response;\n },\n enabled: (0,vue__WEBPACK_IMPORTED_MODULE_5__.computed)(() => {\n const emp = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(employee);\n const d = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(date);\n return !!(emp?.id && d);\n })\n });\n // const {\n // data: conceptTasksData,\n // isLoading: conceptTasksLoading,\n // error: conceptTasksError,\n // refetch: conceptTasksRefetch,\n // } = useQuery({\n // queryKey: computed(() => [\n // 'concept-employee-timeline',\n // unref(employee)?.id,\n // unref(date) ? moment(unref(date)).format('YYYY-MM-DD') : null,\n // ]),\n // queryFn: async () => {\n // const emp = unref(employee);\n // const d = unref(date);\n // if (!emp?.id || !d) {\n // return null;\n // }\n // const dateStr = moment(d).format('YYYY-MM-DD');\n // const queryParams = new URLSearchParams({\n // start: dateStr,\n // end: dateStr,\n // employee_id: emp.id.toString(),\n // type: 'draft',\n // }).toString();\n // const response = await axios.get_auth(`v1/subtasks?${queryParams}`);\n // return response;\n // },\n // enabled: computed(() => {\n // const emp = unref(employee);\n // const d = unref(date);\n // return !!(emp?.id && d);\n // }),\n // });\n // Generate timeline tasks from fetched data\n const timelineTasks = (0,vue__WEBPACK_IMPORTED_MODULE_5__.computed)(() => {\n const data = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(tasksData);\n // const conceptData = unref(conceptTasksData);\n const emp = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(employee);\n const d = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(date);\n const excludeBlockerId = editingBlockerId ? (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(editingBlockerId) : null;\n const draftTbs = draftTimeblocks ? (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(draftTimeblocks) : [];\n if (!data || !emp || !d) {\n return [];\n }\n const subtasks = [...(data.subtasks || []), ...(data.blockers || [])\n // ...(conceptData.subtasks || []),\n ];\n const selectedDateStr = moment__WEBPACK_IMPORTED_MODULE_7___default()(d).format('YYYY-MM-DD');\n try {\n // Process timeblocks directly instead of using timeline utils\n // which is designed for multi-day views\n const tasks = [];\n subtasks.forEach(subtask => {\n // Check if this is a blocker/adhoc/etc with direct start/end fields (no timeblocks array)\n if (!subtask.timeblocks && subtask.start && subtask.end && ['blocker', 'adhoc', 'home_office', 'vacation', 'free_day', 'office365_blocker'].includes(subtask.type)) {\n // Skip the blocker being edited\n if (excludeBlockerId && subtask.id === excludeBlockerId) {\n return;\n }\n const blockerDateStr = moment__WEBPACK_IMPORTED_MODULE_7___default()(subtask.start).format('YYYY-MM-DD');\n if (blockerDateStr === selectedDateStr) {\n const type = subtask.type;\n const task = {\n id: subtask.id,\n start: new Date(subtask.start),\n end: new Date(subtask.end),\n master_task: null,\n date: new Date(subtask.start),\n project_code: null,\n subtask: subtask,\n is_draft: !!subtask.is_draft,\n blocker: subtask,\n type,\n _timeblock_id: null,\n _timeblock_is_finished: subtask.is_finished || false,\n _real_start: new Date(subtask.start),\n _real_end: new Date(subtask.end)\n };\n tasks.push(task);\n }\n } else {\n // Determine the correct timeblocks array based on task type\n let timeblocks;\n // For draft tasks with employees array, get timeblocks from the matching employee\n if (subtask.is_draft && Array.isArray(subtask.employees)) {\n const employeeData = subtask.employees.find(empData => Number(empData.id) === Number(emp.id));\n timeblocks = employeeData?.timeblocks;\n } else {\n // For regular tasks, use root-level timeblocks array\n timeblocks = subtask.timeblocks;\n }\n // Process timeblocks (same logic for both regular and concept tasks)\n timeblocks?.forEach(timeblock => {\n const timeblockDateStr = moment__WEBPACK_IMPORTED_MODULE_7___default()(timeblock.start).format('YYYY-MM-DD');\n // Only include timeblocks for the selected date\n if (timeblockDateStr === selectedDateStr) {\n let type = 'subtask';\n if (subtask.type === 'office365') type = 'office365';\n const task = {\n id: subtask.id,\n start: new Date(timeblock.start),\n end: new Date(timeblock.end),\n master_task: subtask.master_task,\n date: new Date(timeblock.start),\n project_code: subtask.project_code,\n subtask: subtask,\n is_draft: !!subtask.is_draft,\n blocker: undefined,\n type,\n _timeblock_id: timeblock.id,\n _timeblock_is_finished: timeblock.is_finished,\n _real_start: new Date(timeblock.start),\n _real_end: new Date(timeblock.end)\n };\n tasks.push(task);\n }\n });\n }\n });\n // Process draft timeblocks from other employees in the same draft subtask\n draftTbs.forEach(timeblock => {\n // Skip if timeblock doesn't have required fields\n if (!timeblock.start || !timeblock.end) {\n return;\n }\n const timeblockDateStr = moment__WEBPACK_IMPORTED_MODULE_7___default()(timeblock.start).format('YYYY-MM-DD');\n // Only include timeblocks for the selected date\n if (timeblockDateStr === selectedDateStr) {\n const task = {\n id: null,\n start: new Date(timeblock.start),\n end: new Date(timeblock.end),\n master_task: null,\n date: new Date(timeblock.start),\n project_code: null,\n subtask: null,\n is_draft: true,\n blocker: undefined,\n type: 'draft_timeblock',\n _timeblock_id: timeblock.id || null,\n _timeblock_is_finished: timeblock.is_finished || false,\n _real_start: new Date(timeblock.start),\n _real_end: new Date(timeblock.end),\n _employee_id: timeblock.employee_id\n };\n tasks.push(task);\n }\n });\n return tasks;\n } catch (error) {\n console.error('Error generating timeline tasks:', error);\n return [];\n }\n });\n // Calculate scheduled time for the day (in hours)\n const scheduledTime = (0,vue__WEBPACK_IMPORTED_MODULE_5__.computed)(() => {\n const tasks = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(timelineTasks);\n const d = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(date);\n if (!tasks || !d) return 0;\n let totalMinutes = 0;\n tasks.forEach(task => {\n if (task.type === 'non-working-hours' || task.subtask?.is_finished || task.blocker?.is_finished) {\n return;\n }\n totalMinutes += _plugins_tm_dashboard_tasks_utils_timeline_utils__WEBPACK_IMPORTED_MODULE_8__[\"default\"]._getDifferenceInMinutes(task._real_end, task._real_start);\n });\n return (totalMinutes / 60).toFixed(1);\n });\n // Calculate free/unscheduled time for the day (in hours)\n const freeTime = (0,vue__WEBPACK_IMPORTED_MODULE_5__.computed)(() => {\n const emp = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(employee);\n const d = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(date);\n const scheduled = parseFloat(String((0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(scheduledTime)));\n if (!emp || !d) return '0';\n // Calculate duration of other local unsaved timeblocks for the same date\n let localTimeblocksHours = 0;\n if (otherLocalTimeblocks) {\n const localTbs = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(otherLocalTimeblocks) || [];\n localTbs.forEach(tb => {\n // Only count timeblocks with complete time data\n if (tb.starts_at_time && tb.ends_at_time) {\n localTimeblocksHours += (0,_timeblock_utils__WEBPACK_IMPORTED_MODULE_9__.calculateTimeblockDuration)(tb);\n }\n });\n }\n // Also include the current timeblock if it has both start and end times\n const currentTb = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(currentTimeblock);\n if (currentTb?.starts_at_time && currentTb?.ends_at_time) {\n localTimeblocksHours += (0,_timeblock_utils__WEBPACK_IMPORTED_MODULE_9__.calculateTimeblockDuration)(currentTb);\n }\n const dailyCapacityHours = emp.work_end - emp.work_start;\n return (dailyCapacityHours - scheduled - localTimeblocksHours).toFixed(1);\n });\n // Detect collisions with current timeblock\n const collision = (0,vue__WEBPACK_IMPORTED_MODULE_5__.computed)(() => {\n const timeblock = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(currentTimeblock);\n const tasks = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(timelineTasks);\n if (!timeblock || !tasks) {\n return {\n hasCollision: false,\n startCollides: false,\n endCollides: false,\n collidingTasks: []\n };\n }\n return (0,_timeblock_utils__WEBPACK_IMPORTED_MODULE_9__.detectCollision)(timeblock, tasks);\n });\n // Get collision segments for timeline visualization\n const collisionSegments = (0,vue__WEBPACK_IMPORTED_MODULE_5__.computed)(() => {\n const timeblock = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(currentTimeblock);\n const tasks = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(timelineTasks);\n if (!timeblock || !tasks) {\n return [];\n }\n return (0,_timeblock_utils__WEBPACK_IMPORTED_MODULE_9__.getCollisionSegments)(timeblock, tasks);\n });\n // Calculate current timeblock duration\n const timeblockDuration = (0,vue__WEBPACK_IMPORTED_MODULE_5__.computed)(() => {\n const timeblock = (0,vue__WEBPACK_IMPORTED_MODULE_5__.unref)(currentTimeblock);\n if (!timeblock) return 0;\n return (0,_timeblock_utils__WEBPACK_IMPORTED_MODULE_9__.calculateTimeblockDuration)(timeblock);\n });\n return {\n // Query states\n isLoading,\n error,\n refetch,\n // conceptTasksLoading,\n // conceptTasksError,\n // conceptTasksRefetch,\n // Timeline data\n timelineTasks,\n scheduledTime,\n freeTime,\n // Collision detection\n collision,\n collisionSegments,\n timeblockDuration\n };\n}\n\n//# sourceURL=webpack://jandl/./src/plugins/tm@_utils/useEmployeeTimeline.ts?\n}"); +eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ useEmployeeTimeline: function() { return /* binding */ useEmployeeTimeline; }\n/* harmony export */ });\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_esnext_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_1__ = __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_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var core_js_modules_esnext_iterator_filter_js__WEBPACK_IMPORTED_MODULE_2__ = __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_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_filter_js__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var core_js_modules_esnext_iterator_find_js__WEBPACK_IMPORTED_MODULE_3__ = __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_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_find_js__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var core_js_modules_esnext_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! core-js/modules/esnext.iterator.for-each.js */ \"./node_modules/core-js/modules/esnext.iterator.for-each.js\");\n/* harmony import */ var core_js_modules_esnext_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_esnext_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _tanstack_vue_query__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @tanstack/vue-query */ \"./node_modules/@tanstack/vue-query/build/modern/useQuery.js\");\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.runtime.esm-bundler.js\");\n/* harmony import */ var _plugins_w_custom_axios_models_axios__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @/plugins/w@custom/axios/models/axios */ \"./src/plugins/w@custom/axios/models/axios.ts\");\n/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! moment */ \"./node_modules/moment/moment.js\");\n/* harmony import */ var moment__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(moment__WEBPACK_IMPORTED_MODULE_8__);\n/* harmony import */ var _plugins_tm_dashboard_tasks_utils_timeline_utils__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @/plugins/tm@dashboard/tasks/_utils/timeline.utils */ \"./src/plugins/tm@dashboard/tasks/_utils/timeline.utils.ts\");\n/* harmony import */ var _timeblock_utils__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./timeblock.utils */ \"./src/plugins/tm@_utils/timeblock.utils.ts\");\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\nfunction useEmployeeTimeline(employee, date, currentTimeblock, otherLocalTimeblocks, editingBlockerId, draftTimeblocks, allEditingTimeblockIds) {\n // Fetch employee's tasks for the selected date\n const {\n data: tasksData,\n isLoading,\n error,\n refetch\n } = (0,_tanstack_vue_query__WEBPACK_IMPORTED_MODULE_5__.useQuery)({\n queryKey: (0,vue__WEBPACK_IMPORTED_MODULE_6__.computed)(() => ['employee-timeline', (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(employee)?.id, (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(date) ? moment__WEBPACK_IMPORTED_MODULE_8___default()((0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(date)).format('YYYY-MM-DD') : null]),\n queryFn: async () => {\n const emp = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(employee);\n const d = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(date);\n if (!emp?.id || !d) {\n return null;\n }\n const dateStr = moment__WEBPACK_IMPORTED_MODULE_8___default()(d).format('YYYY-MM-DD');\n const queryParams = new URLSearchParams({\n start: dateStr,\n end: dateStr,\n employee_id: emp.id.toString()\n }).toString();\n const response = await _plugins_w_custom_axios_models_axios__WEBPACK_IMPORTED_MODULE_7__[\"default\"].get_auth(`v1/subtasks?${queryParams}`);\n return response;\n },\n enabled: (0,vue__WEBPACK_IMPORTED_MODULE_6__.computed)(() => {\n const emp = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(employee);\n const d = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(date);\n return !!(emp?.id && d);\n })\n });\n // const {\n // data: conceptTasksData,\n // isLoading: conceptTasksLoading,\n // error: conceptTasksError,\n // refetch: conceptTasksRefetch,\n // } = useQuery({\n // queryKey: computed(() => [\n // 'concept-employee-timeline',\n // unref(employee)?.id,\n // unref(date) ? moment(unref(date)).format('YYYY-MM-DD') : null,\n // ]),\n // queryFn: async () => {\n // const emp = unref(employee);\n // const d = unref(date);\n // if (!emp?.id || !d) {\n // return null;\n // }\n // const dateStr = moment(d).format('YYYY-MM-DD');\n // const queryParams = new URLSearchParams({\n // start: dateStr,\n // end: dateStr,\n // employee_id: emp.id.toString(),\n // type: 'draft',\n // }).toString();\n // const response = await axios.get_auth(`v1/subtasks?${queryParams}`);\n // return response;\n // },\n // enabled: computed(() => {\n // const emp = unref(employee);\n // const d = unref(date);\n // return !!(emp?.id && d);\n // }),\n // });\n // Generate timeline tasks from fetched data\n const timelineTasks = (0,vue__WEBPACK_IMPORTED_MODULE_6__.computed)(() => {\n const data = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(tasksData);\n // const conceptData = unref(conceptTasksData);\n const emp = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(employee);\n const d = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(date);\n const excludeBlockerId = editingBlockerId ? (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(editingBlockerId) : null;\n const draftTbs = draftTimeblocks ? (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(draftTimeblocks) : [];\n if (!data || !emp || !d) {\n return [];\n }\n const subtasks = [...(data.subtasks || []), ...(data.blockers || [])\n // ...(conceptData.subtasks || []),\n ];\n const selectedDateStr = moment__WEBPACK_IMPORTED_MODULE_8___default()(d).format('YYYY-MM-DD');\n try {\n // Process timeblocks directly instead of using timeline utils\n // which is designed for multi-day views\n const tasks = [];\n subtasks.forEach(subtask => {\n // Check if this is a blocker/adhoc/etc with direct start/end fields (no timeblocks array)\n if (!subtask.timeblocks && subtask.start && subtask.end && ['blocker', 'adhoc', 'home_office', 'vacation', 'free_day', 'office365_blocker'].includes(subtask.type)) {\n // Skip the blocker being edited\n if (excludeBlockerId && subtask.id === excludeBlockerId) {\n return;\n }\n const blockerDateStr = moment__WEBPACK_IMPORTED_MODULE_8___default()(subtask.start).format('YYYY-MM-DD');\n if (blockerDateStr === selectedDateStr) {\n const type = subtask.type;\n const task = {\n id: subtask.id,\n start: new Date(subtask.start),\n end: new Date(subtask.end),\n master_task: null,\n date: new Date(subtask.start),\n project_code: null,\n subtask: subtask,\n is_draft: !!subtask.is_draft,\n blocker: subtask,\n type,\n _timeblock_id: null,\n _timeblock_is_finished: subtask.is_finished || false,\n _real_start: new Date(subtask.start),\n _real_end: new Date(subtask.end)\n };\n tasks.push(task);\n }\n } else {\n // Determine the correct timeblocks array based on task type\n let timeblocks;\n // For draft tasks with employees array, get timeblocks from the matching employee\n if (subtask.is_draft && Array.isArray(subtask.employees)) {\n const employeeData = subtask.employees.find(empData => Number(empData.id) === Number(emp.id));\n timeblocks = employeeData?.timeblocks;\n } else {\n // For regular tasks, use root-level timeblocks array\n timeblocks = subtask.timeblocks;\n }\n // Process timeblocks (same logic for both regular and concept tasks)\n timeblocks?.forEach(timeblock => {\n const timeblockDateStr = moment__WEBPACK_IMPORTED_MODULE_8___default()(timeblock.start).format('YYYY-MM-DD');\n // Only include timeblocks for the selected date\n if (timeblockDateStr === selectedDateStr) {\n let type = 'subtask';\n if (subtask.type === 'office365') type = 'office365';\n const task = {\n id: subtask.id,\n start: new Date(timeblock.start),\n end: new Date(timeblock.end),\n master_task: subtask.master_task,\n date: new Date(timeblock.start),\n project_code: subtask.project_code,\n subtask: subtask,\n is_draft: !!subtask.is_draft,\n blocker: undefined,\n type,\n _timeblock_id: timeblock.id,\n _timeblock_is_finished: timeblock.is_finished,\n _real_start: new Date(timeblock.start),\n _real_end: new Date(timeblock.end)\n };\n tasks.push(task);\n }\n });\n }\n });\n // Process draft timeblocks from other employees in the same draft subtask\n draftTbs.forEach(timeblock => {\n // Skip if timeblock doesn't have required fields\n if (!timeblock.start || !timeblock.end) {\n return;\n }\n const timeblockDateStr = moment__WEBPACK_IMPORTED_MODULE_8___default()(timeblock.start).format('YYYY-MM-DD');\n // Only include timeblocks for the selected date\n if (timeblockDateStr === selectedDateStr) {\n const task = {\n id: null,\n start: new Date(timeblock.start),\n end: new Date(timeblock.end),\n master_task: null,\n date: new Date(timeblock.start),\n project_code: null,\n subtask: null,\n is_draft: true,\n blocker: undefined,\n type: 'draft_timeblock',\n _timeblock_id: timeblock.id || null,\n _timeblock_is_finished: timeblock.is_finished || false,\n _real_start: new Date(timeblock.start),\n _real_end: new Date(timeblock.end),\n _employee_id: timeblock.employee_id\n };\n tasks.push(task);\n }\n });\n return tasks;\n } catch (error) {\n console.error('Error generating timeline tasks:', error);\n return [];\n }\n });\n // Calculate scheduled time for the day (in hours)\n const scheduledTime = (0,vue__WEBPACK_IMPORTED_MODULE_6__.computed)(() => {\n const tasks = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(timelineTasks);\n const d = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(date);\n if (!tasks || !d) return 0;\n // Get IDs of timeblocks being edited locally to exclude them from scheduled time\n const editingTimeblockIds = allEditingTimeblockIds ? new Set((0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(allEditingTimeblockIds).filter(id => id != null)) : new Set();\n let totalMinutes = 0;\n tasks.forEach(task => {\n if (task.type === 'non-working-hours' || task.subtask?.is_finished || task.blocker?.is_finished) {\n return;\n }\n // Skip timeblocks that are being edited locally to avoid double-counting\n if (task._timeblock_id && editingTimeblockIds.has(task._timeblock_id)) {\n return;\n }\n totalMinutes += _plugins_tm_dashboard_tasks_utils_timeline_utils__WEBPACK_IMPORTED_MODULE_9__[\"default\"]._getDifferenceInMinutes(task._real_end, task._real_start);\n });\n return (totalMinutes / 60).toFixed(1);\n });\n // Calculate total planned time including local edits (for display purposes)\n const totalPlannedTime = (0,vue__WEBPACK_IMPORTED_MODULE_6__.computed)(() => {\n const scheduled = parseFloat(String((0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(scheduledTime)));\n // Calculate duration of other local unsaved timeblocks for the same date\n let localTimeblocksHours = 0;\n if (otherLocalTimeblocks) {\n const localTbs = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(otherLocalTimeblocks) || [];\n localTbs.forEach(tb => {\n // Only count timeblocks with complete time data\n if (tb.starts_at_time && tb.ends_at_time) {\n localTimeblocksHours += (0,_timeblock_utils__WEBPACK_IMPORTED_MODULE_10__.calculateTimeblockDuration)(tb);\n }\n });\n }\n // Also include the current timeblock if it has both start and end times\n const currentTb = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(currentTimeblock);\n if (currentTb?.starts_at_time && currentTb?.ends_at_time) {\n localTimeblocksHours += (0,_timeblock_utils__WEBPACK_IMPORTED_MODULE_10__.calculateTimeblockDuration)(currentTb);\n }\n return (scheduled + localTimeblocksHours).toFixed(1);\n });\n // Calculate free/unscheduled time for the day (in hours)\n const freeTime = (0,vue__WEBPACK_IMPORTED_MODULE_6__.computed)(() => {\n const emp = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(employee);\n const d = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(date);\n const totalPlanned = parseFloat(String((0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(totalPlannedTime)));\n if (!emp || !d) return '0';\n const dailyCapacityHours = emp.work_end - emp.work_start;\n return (dailyCapacityHours - totalPlanned).toFixed(1);\n });\n // Detect collisions with current timeblock\n const collision = (0,vue__WEBPACK_IMPORTED_MODULE_6__.computed)(() => {\n const timeblock = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(currentTimeblock);\n const tasks = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(timelineTasks);\n if (!timeblock || !tasks) {\n return {\n hasCollision: false,\n startCollides: false,\n endCollides: false,\n collidingTasks: []\n };\n }\n return (0,_timeblock_utils__WEBPACK_IMPORTED_MODULE_10__.detectCollision)(timeblock, tasks);\n });\n // Get collision segments for timeline visualization\n const collisionSegments = (0,vue__WEBPACK_IMPORTED_MODULE_6__.computed)(() => {\n const timeblock = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(currentTimeblock);\n const tasks = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(timelineTasks);\n if (!timeblock || !tasks) {\n return [];\n }\n return (0,_timeblock_utils__WEBPACK_IMPORTED_MODULE_10__.getCollisionSegments)(timeblock, tasks);\n });\n // Calculate current timeblock duration\n const timeblockDuration = (0,vue__WEBPACK_IMPORTED_MODULE_6__.computed)(() => {\n const timeblock = (0,vue__WEBPACK_IMPORTED_MODULE_6__.unref)(currentTimeblock);\n if (!timeblock) return 0;\n return (0,_timeblock_utils__WEBPACK_IMPORTED_MODULE_10__.calculateTimeblockDuration)(timeblock);\n });\n return {\n // Query states\n isLoading,\n error,\n refetch,\n // conceptTasksLoading,\n // conceptTasksError,\n // conceptTasksRefetch,\n // Timeline data\n timelineTasks,\n scheduledTime,\n totalPlannedTime,\n freeTime,\n // Collision detection\n collision,\n collisionSegments,\n timeblockDuration\n };\n}\n\n//# sourceURL=webpack://jandl/./src/plugins/tm@_utils/useEmployeeTimeline.ts?\n}"); /***/ }),