diff --git a/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue b/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue index 8678b6f077..dbaddab4c5 100644 --- a/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue +++ b/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue @@ -464,7 +464,7 @@ const dragElement = ref(null) const resizeDirection = ref<'right' | 'left' | null>() -const resizeRecord = ref() +const resizeRecord = ref(null) const dragTimeout = ref>() @@ -680,19 +680,13 @@ const stopDrag = (event: MouseEvent) => { const { newRow, updateProperty } = calculateNewRow(event, true) if (!newRow && !updateProperty) return - const allRecords = document.querySelectorAll('.draggable-record') - allRecords.forEach((el) => { - el.style.visibility = '' - el.style.opacity = '100%' - }) - if (dragElement.value) { dragElement.value.style.boxShadow = 'none' dragElement.value = null } if (dragRecord.value) { - dragRecord.value = undefined + dragRecord.value = null } if (!newRow) return @@ -719,17 +713,7 @@ const dragStart = (event: MouseEvent, record: Row) => { target = target.parentElement as HTMLElement } - // When the user starts dragging a record, we reduce opacity of all other records - const allRecords = document.querySelectorAll('.draggable-record') - allRecords.forEach((el) => { - if (!el.getAttribute('data-unique-id').includes(record.rowMeta.id!)) { - // el.style.visibility = 'hidden' - el.style.opacity = '30%' - } - }) - dragRecord.value = record - dragElement.value = target document.addEventListener('mousemove', onDrag) @@ -1050,7 +1034,14 @@ const expandRecord = (record: Row) => { v-if="record.rowMeta.style?.display !== 'none'" :data-testid="`nc-calendar-day-record-${record.row[displayField!.title!]}`" :data-unique-id="record.rowMeta.id" - :style="record.rowMeta.style" + :style="{ + ...record.rowMeta.style, + opacity: + (dragRecord === null || record.rowMeta.id === dragRecord?.rowMeta.id) && + (resizeRecord === null || record.rowMeta.id === resizeRecord?.rowMeta.id) + ? 1 + : 0.3, + }" class="absolute draggable-record transition group cursor-pointer pointer-events-auto" @mousedown="dragStart($event, record)" @mouseleave="hoverRecord = null" diff --git a/packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue b/packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue index a4805ba8e8..ac988d3f27 100644 --- a/packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue +++ b/packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue @@ -553,11 +553,11 @@ const hoverRecord = ref() const resizeDirection = ref<'right' | 'left' | null>() -const resizeRecord = ref() +const resizeRecord = ref(null) const isDragging = ref(false) -const dragRecord = ref() +const dragRecord = ref(null) const useDebouncedRowUpdate = useDebounceFn((row: Row, updateProperty: string[], isDelete: boolean) => { updateRowProperty(row, updateProperty, isDelete) @@ -771,16 +771,12 @@ const stopDrag = (event: MouseEvent) => { const { newRow, updatedProperty } = calculateNewRow(event, false, true) - // We set the visibility and opacity of the records back to normal - const allRecords = document.querySelectorAll('.draggable-record') - allRecords.forEach((el) => { - el.style.visibility = '' - el.style.opacity = '100%' - }) - if (newRow) { updateRowProperty(newRow, updatedProperty, false) } + + dragRecord.value = null + $e('c:calendar:week:drag-record') document.removeEventListener('mousemove', onDrag) @@ -802,14 +798,6 @@ const dragStart = (event: MouseEvent, record: Row) => { target = target.parentElement as HTMLElement } - const allRecords = document.querySelectorAll('.draggable-record') - allRecords.forEach((el) => { - if (!el.getAttribute('data-unique-id').includes(record.rowMeta.id!)) { - // el.style.visibility = 'hidden' - el.style.opacity = '30%' - } - }) - isDragging.value = true dragRecord.value = record @@ -1016,7 +1004,7 @@ watch( () => { selectedDate = hour selectedTime = hour - dragRecord = undefined + dragRecord = null } " > @@ -1043,7 +1031,14 @@ watch( v-if="record.rowMeta.style?.display !== 'none'" :data-testid="`nc-calendar-week-record-${record.row[displayField!.title!]}`" :data-unique-id="record.rowMeta!.id" - :style="record.rowMeta!.style " + :style="{ + ...record.rowMeta.style, + opacity: + (dragRecord === null || record.rowMeta.id === dragRecord?.rowMeta.id) && + (resizeRecord === null || record.rowMeta.id === resizeRecord?.rowMeta.id) + ? 1 + : 0.3, + }" :class="{ 'w-1/5': maxVisibleDays === 5, 'w-1/7': maxVisibleDays === 7, diff --git a/packages/nc-gui/components/smartsheet/toolbar/Calendar/Mode.vue b/packages/nc-gui/components/smartsheet/toolbar/Calendar/Mode.vue index d611949cf5..7fad49d118 100644 --- a/packages/nc-gui/components/smartsheet/toolbar/Calendar/Mode.vue +++ b/packages/nc-gui/components/smartsheet/toolbar/Calendar/Mode.vue @@ -13,6 +13,7 @@ const setActiveCalendarMode = (mode: 'day' | 'week' | 'month' | 'year', event: M changeCalendarView(mode) const tabElement = event.target as HTMLElement highlightStyle.value.left = `${tabElement.offsetLeft}px` + highlightStyle.value.width = `${tabElement.offsetWidth}px` } const updateHighlightPosition = () => { @@ -20,6 +21,7 @@ const updateHighlightPosition = () => { const activeTab = document.querySelector('.nc-calendar-mode-tab .tab.active') as HTMLElement if (activeTab) { highlightStyle.value.left = `${activeTab.offsetLeft}px` + highlightStyle.value.width = `${activeTab.offsetWidth}px` } }) } @@ -37,19 +39,21 @@ watch(activeCalendarView, () => {