From 748e4d97f64008beb19e9e86581422ba6af1683a Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Wed, 20 Nov 2024 17:43:12 +0000 Subject: [PATCH] fix: spanning records feat: updated styles --- .../calendar/DateTimeSpanningContainer.vue | 304 ++++++++++++++++ .../smartsheet/calendar/DayView/DateField.vue | 8 +- .../calendar/DayView/DateTimeField.vue | 339 +++++++++--------- .../smartsheet/calendar/MonthView.vue | 44 ++- .../smartsheet/calendar/RecordCard.vue | 20 +- .../smartsheet/calendar/VRecordCard.vue | 12 +- .../calendar/WeekView/DateField.vue | 3 +- .../calendar/WeekView/DateTimeField.vue | 48 ++- .../smartsheet/toolbar/Calendar/Range.vue | 71 ++-- 9 files changed, 611 insertions(+), 238 deletions(-) create mode 100644 packages/nc-gui/components/smartsheet/calendar/DateTimeSpanningContainer.vue diff --git a/packages/nc-gui/components/smartsheet/calendar/DateTimeSpanningContainer.vue b/packages/nc-gui/components/smartsheet/calendar/DateTimeSpanningContainer.vue new file mode 100644 index 0000000000..a038dfd4a5 --- /dev/null +++ b/packages/nc-gui/components/smartsheet/calendar/DateTimeSpanningContainer.vue @@ -0,0 +1,304 @@ + + + + + diff --git a/packages/nc-gui/components/smartsheet/calendar/DayView/DateField.vue b/packages/nc-gui/components/smartsheet/calendar/DayView/DateField.vue index b49663127c..03a883a2b9 100644 --- a/packages/nc-gui/components/smartsheet/calendar/DayView/DateField.vue +++ b/packages/nc-gui/components/smartsheet/calendar/DayView/DateField.vue @@ -54,7 +54,7 @@ const recordsAcrossAllRange = computed(() => { dayRecordCount++ const style: Partial = { - top: `${(dayRecordCount - 1) * perRecordHeight}px`, + top: `${(dayRecordCount - 1) * perRecordHeight + dayRecordCount * 8}px`, width: '100%', } @@ -97,7 +97,7 @@ const recordsAcrossAllRange = computed(() => { style: { width: '100%', left: '0', - top: `${(dayRecordCount - 1) * perRecordHeight}px`, + top: `${(dayRecordCount - 1) * perRecordHeight + dayRecordCount * 8}px`, }, position: 'rounded', }, @@ -212,17 +212,15 @@ const newRecord = () => { v-for="(record, rowIndex) in recordsAcrossAllRange" :key="rowIndex" :style="record.rowMeta.style" - class="absolute mt-2" + class="absolute" data-testid="nc-calendar-day-record-card" @mouseleave="hoverRecord = null" @mouseover="hoverRecord = record.rowMeta.id as string" > diff --git a/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue b/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue index 512a4dc3ab..ed8e31f065 100644 --- a/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue +++ b/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue @@ -73,6 +73,10 @@ const overlayTop = computed(() => { return top }) +const shouldEnableOverlay = computed(() => { + return !isPublic.value && dayjs().isSame(selectedDate.value, 'day') +}) + onMounted(() => { const intervalId = setInterval(() => { currTime.value = dayjs() @@ -213,6 +217,7 @@ const getMaxOverlaps = ({ const recordsAcrossAllRange = computed<{ record: Row[] + spanningRecords: Row[] gridTimeMap: Map< number, { @@ -254,6 +259,7 @@ const recordsAcrossAllRange = computed<{ if (fromDate?.isValid() && toDate?.isValid()) { if (!fromDate.isSame(toDate, 'day')) { + // TODO: If multiple range is introduced, we have to make sure no duplicate records are inserted recordSpanningDays.push(record) return false } @@ -288,30 +294,10 @@ const recordsAcrossAllRange = computed<{ top: `${topInPixels + 1}px`, } - // This property is used to determine which side the record should be rounded. It can be top, bottom, both or none - // We use the start and end date to determine the position of the record - let position = 'none' - const isSelectedDay = (date: dayjs.Dayjs) => date.isSame(selectedDate.value, 'day') - const isBeforeSelectedDay = (date: dayjs.Dayjs) => date.isBefore(selectedDate.value, 'day') - const isAfterSelectedDay = (date: dayjs.Dayjs) => date.isAfter(selectedDate.value, 'day') - - if (isSelectedDay(startDate) && isSelectedDay(endDate)) { - position = 'rounded' - } else if (isBeforeSelectedDay(startDate) && isAfterSelectedDay(endDate)) { - position = 'none' - } else if (isSelectedDay(startDate) && isAfterSelectedDay(endDate)) { - position = 'topRounded' - } else if (isBeforeSelectedDay(startDate) && isSelectedDay(endDate)) { - position = 'bottomRounded' - } else { - position = 'none' - } - recordsByRange.push({ ...record, rowMeta: { ...record.rowMeta, - position, style, id, range: range as any, @@ -329,7 +315,6 @@ const recordsAcrossAllRange = computed<{ // The top of the record is calculated based on the start hour // Update such that it is also based on Minutes - const topInPixels = (startDate.minute() / 60 + startDate.hour()) * perRecordHeight // A minimum height of 80px is set for each record @@ -347,7 +332,6 @@ const recordsAcrossAllRange = computed<{ range: range as any, style, id, - position: 'rounded', }, }) } @@ -460,14 +444,15 @@ const recordsAcrossAllRange = computed<{ record.rowMeta.style = { ...record.rowMeta.style, display, - width: `${width.toFixed(2)}%`, - left: `${left.toFixed(2)}%`, + width: `calc(${width.toFixed(2)}% - 8px)`, + left: `calc(${left.toFixed(2)}% + 4px)`, } } return { gridTimeMap, record: recordsByRange, + spanningRecords: recordSpanningDays, } }) @@ -902,82 +887,83 @@ watch( }, { immediate: true }, ) + +const expandRecord = (record: Row) => { + emit('expandRecord', record) +}