diff --git a/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue b/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue index 787639d8b4..57f2112d98 100644 --- a/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue +++ b/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue @@ -55,14 +55,33 @@ const recordsAcrossAllRange = computed(() => { calendarRange.value.forEach((range) => { const fromCol = range.fk_from_col const endCol = range.fk_to_col + + const sortedFormattedData = [...formattedData.value].filter((record) => { + const fromDate = record.row[fromCol!.title!] ? dayjs(record.row[fromCol!.title!]) : null + + if (fromCol && endCol) { + const fromDate = record.row[fromCol.title!] ? dayjs(record.row[fromCol.title!]) : null + const toDate = record.row[endCol.title!] ? dayjs(record.row[endCol.title!]) : null + + return fromDate && toDate?.isValid() ? fromDate.isBefore(toDate) : true + } else if (fromCol && !endCol) { + return !!fromDate + } + return false + }) + if (fromCol && endCol) { - for (const record of formattedData.value) { + for (const record of sortedFormattedData) { const id = getRandomNumbers() let startDate = dayjs(record.row[fromCol.title!]) let endDate = dayjs(record.row[endCol.title!]) if (!startDate.isValid() || startDate.isAfter(endDate)) continue + if (!endDate.isValid()) { + endDate = startDate.clone().add(30, 'minutes') + } + if (startDate.isBefore(scheduleStart, 'minutes')) { startDate = scheduleStart } @@ -124,11 +143,11 @@ const recordsAcrossAllRange = computed(() => { }) } } else if (fromCol) { - for (const record of formattedData.value) { + for (const record of sortedFormattedData) { const id = getRandomNumbers() const startDate = dayjs(record.row[fromCol.title!]) - const endDate = dayjs(record.row[fromCol.title!]).add(1, 'hour') + const endDate = dayjs(record.row[fromCol.title!]).add(30, 'minutes') const startHour = startDate.hour() const endHour = endDate.hour() diff --git a/packages/nc-gui/components/smartsheet/calendar/MonthView.vue b/packages/nc-gui/components/smartsheet/calendar/MonthView.vue index be0ef6ed59..f2c6ab4c0e 100644 --- a/packages/nc-gui/components/smartsheet/calendar/MonthView.vue +++ b/packages/nc-gui/components/smartsheet/calendar/MonthView.vue @@ -66,7 +66,7 @@ const dates = computed(() => { let numberOfRows = Math.ceil(daysToDisplay / 7) numberOfRows = Math.max(numberOfRows, 5) - const weeksArray = [] + const weeksArray: Array> = [] let currentDay = firstDayToDisplay for (let week = 0; week < numberOfRows; week++) { const weekArray = [] @@ -237,8 +237,9 @@ const recordsToDisplay = computed(() => { const heightRequired = perRecordHeight * maxRecordCount + spaceBetweenRecords let position = 'rounded' - - const isStartMonthBeforeCurrentWeek = startDate.isBefore(selectedMonth.value, 'month') + const isStartMonthBeforeCurrentWeek = dates.value[weekIndex - 1] + ? dayjs(dates.value[weekIndex - 1][0]).isBefore(startDate, 'month') + : false if (startDate.isSame(currentWeekStart, 'week') && endDate.isSame(currentWeekEnd, 'week')) { position = 'rounded' @@ -277,7 +278,7 @@ const recordsToDisplay = computed(() => { id, }, }) - currentWeekStart = currentWeekStart.add(1, 'week') + currentWeekStart = currentWeekStart.add(1, 'week').endOf('week') } } }) diff --git a/packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue b/packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue index 92158d261c..c6c9e9b030 100644 --- a/packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue +++ b/packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue @@ -114,7 +114,7 @@ const recordsAcrossAllRange = computed(() => { const style: Partial = { top: `${hourIndex * perHeight}px`, - height: `${perHeight - 30}px`, + height: `${perHeight / 2 - 30}px`, } recordsToDisplay.push({ @@ -134,7 +134,11 @@ const recordsAcrossAllRange = computed(() => { let startDate = record.row[fromCol.title!] ? dayjs(record.row[fromCol.title!]) : null let endDate = record.row[toCol.title!] ? dayjs(record.row[toCol.title!]) : null - if (!startDate?.isValid() || !endDate?.isValid()) return + if (!startDate?.isValid()) return + + if (!endDate?.isValid()) { + endDate = startDate.clone().add(30, 'minutes') + } if (startDate.isBefore(scheduleStart, 'minutes')) { startDate = scheduleStart