From f362ed43458b45f3ff99d4e4cd75d6b19a7fc1d6 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Wed, 6 Mar 2024 10:54:33 +0000 Subject: [PATCH] fix(nc-gui): overlap issue --- .../smartsheet/calendar/MonthView.vue | 19 +++++++++---------- .../composables/useCalendarViewStore.ts | 9 ++++++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/nc-gui/components/smartsheet/calendar/MonthView.vue b/packages/nc-gui/components/smartsheet/calendar/MonthView.vue index 6296b7caf0..17b23ce398 100644 --- a/packages/nc-gui/components/smartsheet/calendar/MonthView.vue +++ b/packages/nc-gui/components/smartsheet/calendar/MonthView.vue @@ -133,13 +133,12 @@ const recordsToDisplay = computed<{ // Filter out records that don't satisfy the range and sort them by start date const sortedFormattedData = [...formattedData.value].filter((record) => { - const fromDate = record.row[startCol!.title!] ? dayjs(record.row[startCol!.title!]) : null - if (startCol && endCol) { - const fromDate = record.row[startCol!.title!] ? dayjs(record.row[startCol!.title!]) : null - const toDate = record.row[endCol!.title!] ? dayjs(record.row[endCol!.title!]) : null + const fromDate = record.row[startCol.title!] ? dayjs(record.row[startCol.title!]) : null + const toDate = record.row[endCol.title!] ? dayjs(record.row[endCol.title!]) : null return fromDate && toDate && !toDate.isBefore(fromDate) } else if (startCol && !endCol) { + const fromDate = record.row[startCol!.title!] ? dayjs(record.row[startCol!.title!]) : null return !!fromDate } return false @@ -148,7 +147,7 @@ const recordsToDisplay = computed<{ sortedFormattedData.forEach((record: Row) => { if (!endCol && startCol) { // If there is no end date, we just display the record on the start date - const startDate = dayjs(record.row[startCol!.title!]) + const startDate = dayjs(record.row[startCol.title!]) const dateKey = startDate.format('YYYY-MM-DD') if (!recordsInDay[dateKey]) { @@ -200,13 +199,13 @@ const recordsToDisplay = computed<{ }) } else if (startCol && endCol) { // If the range specifies fromCol and endCol - const startDate = dayjs(record.row[startCol!.title!]) - const endDate = dayjs(record.row[endCol!.title!]) + const startDate = dayjs(record.row[startCol.title!]) + const endDate = dayjs(record.row[endCol.title!]) let currentWeekStart = startDate.startOf('week') const id = record.rowMeta.id ?? generateRandomNumber() - // Since the records can span multiple weeks, to display, we render multiple records + // Since the records can span multiple weeks, to display, we render multiple elements // for each week the record spans. The id is used to identify the elements that belong to the same record while ( @@ -263,8 +262,7 @@ const recordsToDisplay = computed<{ overflowCount: 0, } } - const recordIndex = recordsInDay[dateKey].count - maxRecordCount = Math.max(maxRecordCount, recordIndex) + maxRecordCount = Math.max(maxRecordCount, recordsInDay[dateKey].count) } const startDayIndex = Math.max( @@ -724,6 +722,7 @@ const addRecord = (date: dayjs.Dayjs) => {