mirror of
https://bitbucket.org/studiotem/jandl-taskmanager-app.git
synced 2026-10-21 06:20:21 +00:00
refactor(timeline): fixed ux for creating time blocks over existing ones on the timeline
This commit is contained in:
1 parent
46f578feb9
commit
f3b4c0a862
1 file changed
+14
-26
+14
-26
@@ -17,10 +17,7 @@
|
|||||||
:hour-width="hourWidth"
|
:hour-width="hourWidth"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div
|
<div ref="timelineBar" class="timeline-bar">
|
||||||
ref="timelineBar"
|
|
||||||
class="timeline-bar"
|
|
||||||
>
|
|
||||||
<!-- Non-working hours - before work -->
|
<!-- Non-working hours - before work -->
|
||||||
<div
|
<div
|
||||||
class="non-working-hours"
|
class="non-working-hours"
|
||||||
@@ -431,14 +428,13 @@ const handleMouseMove = (event: MouseEvent) => {
|
|||||||
|
|
||||||
// Update cursor style based on work hours
|
// Update cursor style based on work hours
|
||||||
if (timelineScroll.value) {
|
if (timelineScroll.value) {
|
||||||
timelineScroll.value.style.cursor = isInWorkHours ? 'crosshair' : 'not-allowed';
|
timelineScroll.value.style.cursor = isInWorkHours
|
||||||
|
? 'crosshair'
|
||||||
|
: 'not-allowed';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't show preview if over existing block (using relative position)
|
// Allow preview to show even over existing blocks
|
||||||
if (isOverExistingBlock(x)) {
|
// This allows creating conflicting timeblocks
|
||||||
showPreview.value = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert to time and snap
|
// Convert to time and snap
|
||||||
const snappedStart = snappedTime;
|
const snappedStart = snappedTime;
|
||||||
@@ -493,24 +489,16 @@ const handleTimelineMouseDown = (event: MouseEvent) => {
|
|||||||
// Get the target element
|
// Get the target element
|
||||||
const target = event.target as HTMLElement;
|
const target = event.target as HTMLElement;
|
||||||
|
|
||||||
// Don't interfere with resize handles on current timeblock
|
// Only allow resize handles to work - don't interfere with them
|
||||||
if (target.classList.contains('resize-handle')) {
|
if (target.classList.contains('resize-handle')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if clicking on current timeblock (allow resize handles to work)
|
// Allow clicking anywhere else, including over the current timeblock,
|
||||||
if (target.closest('.current-timeblock')) {
|
// to create/redraw the block at the cursor position
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const rect = timelineScroll.value.getBoundingClientRect();
|
// Allow creating blocks even over existing blocks (scheduled or other timeblocks)
|
||||||
const scrollLeft = timelineScroll.value.scrollLeft;
|
// This enables creating conflicting timeblocks
|
||||||
const x = event.clientX - rect.left + scrollLeft;
|
|
||||||
|
|
||||||
// Don't start creating if over existing block
|
|
||||||
if (isOverExistingBlock(x)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if cursor is in work hours (cursor line must be visible)
|
// Check if cursor is in work hours (cursor line must be visible)
|
||||||
if (!showCursor.value || !showPreview.value || !previewBlock.value) {
|
if (!showCursor.value || !showPreview.value || !previewBlock.value) {
|
||||||
@@ -521,7 +509,7 @@ const handleTimelineMouseDown = (event: MouseEvent) => {
|
|||||||
dragState.value.isStretching = true;
|
dragState.value.isStretching = true;
|
||||||
dragState.value.startX = event.clientX;
|
dragState.value.startX = event.clientX;
|
||||||
dragState.value.initialStart = cursorPosition.value;
|
dragState.value.initialStart = cursorPosition.value;
|
||||||
|
|
||||||
// Calculate initial end time (1 hour later, capped at work_end)
|
// Calculate initial end time (1 hour later, capped at work_end)
|
||||||
let initialEnd = moment(cursorPosition.value).add(1, 'hour').toDate();
|
let initialEnd = moment(cursorPosition.value).add(1, 'hour').toDate();
|
||||||
const endHour = initialEnd.getHours() + initialEnd.getMinutes() / 60;
|
const endHour = initialEnd.getHours() + initialEnd.getMinutes() / 60;
|
||||||
@@ -535,7 +523,7 @@ const handleTimelineMouseDown = (event: MouseEvent) => {
|
|||||||
})
|
})
|
||||||
.toDate();
|
.toDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
dragState.value.initialEnd = initialEnd;
|
dragState.value.initialEnd = initialEnd;
|
||||||
|
|
||||||
// Set initial preview block (already has 1 hour duration from preview)
|
// Set initial preview block (already has 1 hour duration from preview)
|
||||||
@@ -622,7 +610,7 @@ const handleStretchEnd = () => {
|
|||||||
// Only emit if we have a valid block (start != end)
|
// Only emit if we have a valid block (start != end)
|
||||||
const startTime = previewBlock.value.start.getTime();
|
const startTime = previewBlock.value.start.getTime();
|
||||||
const endTime = previewBlock.value.end.getTime();
|
const endTime = previewBlock.value.end.getTime();
|
||||||
|
|
||||||
if (endTime > startTime) {
|
if (endTime > startTime) {
|
||||||
// Emit the new timeblock
|
// Emit the new timeblock
|
||||||
emit('timeblockUpdated', {
|
emit('timeblockUpdated', {
|
||||||
|
|||||||
Reference in new issue
Block a user