diff --git a/packages/nc-gui/components/nc/DateWeekSelector.vue b/packages/nc-gui/components/nc/DateWeekSelector.vue index 7eb99b2d83..fbc3cd604e 100644 --- a/packages/nc-gui/components/nc/DateWeekSelector.vue +++ b/packages/nc-gui/components/nc/DateWeekSelector.vue @@ -180,7 +180,7 @@ const paginate = (action: 'next' | 'prev') => { 'text-gray-400': !isDateInCurrentMonth(date), 'nc-selected-week-start': isSameDate(date, selectedWeek?.start), 'nc-selected-week-end': isSameDate(date, selectedWeek?.end), - 'rounded-md bg-brand-50 text-brand-500': isSameDate(date, dayjs()) && isDateInCurrentMonth(date), + 'rounded-md bg-brand-50 nc-calendar-today text-brand-500': isSameDate(date, dayjs()) && isDateInCurrentMonth(date), }" class="h-9 w-9 px-1 py-2 relative font-medium flex items-center cursor-pointer justify-center" data-testid="nc-calendar-date" diff --git a/packages/nc-gui/components/smartsheet/calendar/Cell.vue b/packages/nc-gui/components/smartsheet/calendar/Cell.vue index 2f22680777..8a9c6a1db3 100644 --- a/packages/nc-gui/components/smartsheet/calendar/Cell.vue +++ b/packages/nc-gui/components/smartsheet/calendar/Cell.vue @@ -260,7 +260,6 @@ const getLookupValue = (modelValue: string | null | number | Array, col: Co } const getAttachmentValue = (modelValue: string | null | number | Array) => { - console.log(modelValue) if (Array.isArray(modelValue)) { return modelValue.map((v) => `${v.title} (${getPossibleAttachmentSrc(v).join(', ')})`).join(', ') } diff --git a/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue b/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue index 95621f28e6..a6e0be0c10 100644 --- a/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue +++ b/packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue @@ -56,7 +56,7 @@ const recordsAcrossAllRange = computed<{ record: Row[] count: { [key: string]: { - id: string + id: string[] overflow: boolean overflowCount: number } @@ -167,7 +167,7 @@ const recordsAcrossAllRange = computed<{ style.display = 'none' overlaps[timeKey].overflowCount += 1 } - _startDate = _startDate.add(15, 'minutes') + _startDate = _startDate.add(1, 'minutes') } // This property is used to determine which side the record should be rounded. It can be top, bottom, both or none @@ -205,16 +205,21 @@ const recordsAcrossAllRange = computed<{ const id = generateRandomNumber() const startDate = dayjs(record.row[fromCol.title!]) - const endDate = dayjs(record.row[fromCol.title!]).add(15, 'minutes') + + let endDate = dayjs(record.row[fromCol.title!]).add(1, 'hour') + + if (endDate.isAfter(scheduleEnd, 'minutes')) { + endDate = scheduleEnd + } const startHour = startDate.hour() let style: Partial = {} let _startDate = startDate.clone() - // We loop through every 15 minutes between the start and end date and keep track of the number of records that overlap at a given time + // We loop through every minute between the start and end date and keep track of the number of records that overlap at a given time while (_startDate.isBefore(endDate)) { - const timeKey = _startDate.startOf('hour').format('HH:mm') + const timeKey = _startDate.format('HH:mm') if (!overlaps[timeKey]) { overlaps[timeKey] = { @@ -234,15 +239,20 @@ const recordsAcrossAllRange = computed<{ display: 'none', } } - _startDate = _startDate.add(15, 'minutes') + _startDate = _startDate.add(1, 'minute') } - const topInPixels = (startDate.hour() + startDate.startOf('hour').minute() / 60) * 80 + // The top of the record is calculated based on the start hour + // Update such that it is also based on Minutes + + const minutes = startDate.minute() + startDate.hour() * 60 + + const updatedTopInPixels = (minutes * 80) / 60 // A minimum height of 80px is set for each record const heightInPixels = Math.max((endDate.diff(startDate, 'minute') / 60) * 80, perRecordHeight) - const finalTopInPixels = topInPixels + startHour * 2 + const finalTopInPixels = updatedTopInPixels + startHour * 2 style = { ...style, @@ -332,8 +342,9 @@ const calculateNewRow = (event: MouseEvent) => { // It can be between 0 and 23 (inclusive) const hour = Math.max(Math.floor(percentY * 23), 0) + const minutes = Math.min(Math.max(Math.round(Math.floor((percentY * 23 - hour) * 60) / 15) * 15, 0), 60) // We calculate the new startDate by adding the hour to the start of the selected date - const newStartDate = dayjs(selectedDate.value).startOf('day').add(hour, 'hour') + const newStartDate = dayjs(selectedDate.value).startOf('day').add(hour, 'hour').add(minutes, 'minute') if (!newStartDate || !fromCol) return { newRow: null, updateProperty: [] } let endDate @@ -570,6 +581,35 @@ const dragStart = (event: MouseEvent, record: Row) => { document.addEventListener('mouseup', onMouseUp) } +const isOverflowAcrossHourRange = (hour: dayjs.Dayjs) => { + let startOfHour = hour.startOf('hour') + const endOfHour = hour.endOf('hour') + + const ids: Array = [] + + let isOverflow = false + let overflowCount = 0 + + while (startOfHour.isBefore(endOfHour, 'minute')) { + const hourKey = startOfHour.format('HH:mm') + if (recordsAcrossAllRange.value?.count?.[hourKey]?.overflow) { + isOverflow = true + + recordsAcrossAllRange.value?.count?.[hourKey]?.id.forEach((id) => { + if (!ids.includes(id)) { + ids.push(id) + overflowCount += 1 + } + }) + } + startOfHour = startOfHour.add(1, 'minute') + } + + overflowCount = overflowCount > 8 ? overflowCount - 8 : 0 + + return { isOverflow, overflowCount } +} + const viewMore = (hour: dayjs.Dayjs) => { sideBarFilterOption.value = 'selectedHours' selectedTime.value = hour @@ -680,7 +720,7 @@ const viewMore = (hour: dayjs.Dayjs) => { { > + - {{ recordsAcrossAllRange?.count[hour.format('HH:mm')]?.overflowCount }} + {{ isOverflowAcrossHourRange(hour).overflowCount }} more @@ -709,7 +749,6 @@ const viewMore = (hour: dayjs.Dayjs) => { > { const onResizeStart = (direction: 'right' | 'left', event: MouseEvent, record: Row) => { if (!isUIAllowed('dataEdit') || draggingId.value) return - selectedDate.value = null + // selectedDate.value = null resizeInProgress.value = true resizeDirection.value = direction resizeRecord.value = record @@ -508,12 +508,8 @@ const onResizeStart = (direction: 'right' | 'left', event: MouseEvent, record: R const stopDrag = (event: MouseEvent) => { clearTimeout(dragTimeout.value) - - console.log('stopDrag') - console.log('stopDrag', dragRecord.value, isDragging.value) if (!isUIAllowed('dataEdit') || !dragRecord.value || !isDragging.value) return - console.log('stopDrag') event.preventDefault() dragElement.value!.style.boxShadow = 'none' @@ -560,7 +556,7 @@ const dragStart = (event: MouseEvent, record: Row) => { }) dragRecord.value = record - selectedDate.value = null + // selectedDate.value = null isDragging.value = true dragElement.value = target @@ -633,7 +629,7 @@ const isDateSelected = (date: dayjs.Dayjs) => {
{{ day }}
@@ -657,7 +653,7 @@ const isDateSelected = (date: dayjs.Dayjs) => { isDateSelected(day) || (focusedDate && dayjs(day).isSame(focusedDate, 'day')), '!text-gray-400': !isDayInPagedMonth(day), }" - class="text-right relative group last:border-r-0 text-sm h-full border-r-1 border-b-1 border-gray-200 font-medium hover:bg-gray-50 text-gray-800 bg-white" + class="text-right relative group last:border-r-0 text-sm h-full border-r-1 border-b-1 border-gray-100 font-medium hover:bg-gray-50 text-gray-800 bg-white" data-testid="nc-calendar-month-day" @click="selectDate(day)" > @@ -793,7 +789,6 @@ const isDateSelected = (date: dayjs.Dayjs) => { >