refactor(task-modal): enhance timeblock loading and rendering logic with validation and improved display conditions

This commit is contained in:
Matej Glasnák committed 2025-12-16 08:35:44 +01:00
1 parent dd3b754fb2
commit af1f946158
2 files changed
+42 -4

No files matched your search

@@ -93,8 +93,15 @@
@mousedown.stop="handlePreviewMouseDown" @mousedown.stop="handlePreviewMouseDown"
> >
<div class="preview-time-label"> <div class="preview-time-label">
{{ formatTime(previewBlock.start) }} - <div
{{ formatTime(previewBlock.end) }} v-if="getTimeWidth(previewBlock.start, previewBlock.end) <= 58"
>
{{ formatTime(previewBlock.start) }}
</div>
<div v-else>
{{ formatTime(previewBlock.start) }} -
{{ formatTime(previewBlock.end) }}
</div>
</div> </div>
</div> </div>
@@ -146,7 +153,18 @@
)}px`, )}px`,
}" }"
> >
<div class="preview-time-label"> <div
v-if="
getTimeWidth(
resizedCurrentBlock.start,
resizedCurrentBlock.end,
) <= 58
"
class="preview-time-label"
>
{{ formatTime(resizedCurrentBlock.start) }}
</div>
<div v-else class="preview-time-label">
{{ formatTime(resizedCurrentBlock.start) }} - {{ formatTime(resizedCurrentBlock.start) }} -
{{ formatTime(resizedCurrentBlock.end) }} {{ formatTime(resizedCurrentBlock.end) }}
</div> </div>
+21 -1
View File
@@ -857,12 +857,21 @@ export default {
// Load timeblocks from localStorage if they exist // Load timeblocks from localStorage if they exist
if (savedTimeblocks) { if (savedTimeblocks) {
try { try {
const parsedTimeblocks = JSON.parse(savedTimeblocks); let parsedTimeblocks = JSON.parse(savedTimeblocks);
// Filter out timeblocks that are not valid
parsedTimeblocks = parsedTimeblocks.filter(
(tb) =>
tb.employee_id && tb.starts_at_time && tb.ends_at_time,
);
if (Array.isArray(parsedTimeblocks)) { if (Array.isArray(parsedTimeblocks)) {
this.timeblocks = parsedTimeblocks.map((tb) => ({ this.timeblocks = parsedTimeblocks.map((tb) => ({
...tb, ...tb,
date: tb.date ? new Date(tb.date) : null, date: tb.date ? new Date(tb.date) : null,
})); }));
} else {
this.timeblocks = [];
} }
} catch (e) { } catch (e) {
console.error('Error parsing saved timeblocks:', e); console.error('Error parsing saved timeblocks:', e);
@@ -897,6 +906,17 @@ export default {
this.subtask.employees = [employee]; this.subtask.employees = [employee];
this.subtask.deadline = subtask.deadline; this.subtask.deadline = subtask.deadline;
this.subtask._deadline_time = subtask._deadline_time; this.subtask._deadline_time = subtask._deadline_time;
setTimeout(() => {
this.timeblocks = [
{
date: new Date(subtask.deadline),
starts_at_time: subtask._deadline_time,
ends_at_time: null,
employee_id: subtask.employee_id,
},
];
}, 500);
} }
if (subtask?.master_task_id && subtask?.project_code) { if (subtask?.master_task_id && subtask?.project_code) {