Browse Source

fix: resizing in day DateTimeField.vue

pull/9831/head
DarkPhoenix2704 2 days ago
parent
commit
eb7e60a8c9
  1. 8
      packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue

8
packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue

@ -504,7 +504,6 @@ const calculateNewRow = (event: MouseEvent, skipChangeCheck?: boolean) => {
// We calculate the hour based on the percentage of the mouse position in the scroll container // We calculate the hour based on the percentage of the mouse position in the scroll container
// It can be between 0 and 23 (inclusive) // It can be between 0 and 23 (inclusive)
const hour = Math.max(Math.floor(percentY * 23), 0) 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) 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 // 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').add(minutes, 'minute') const newStartDate = dayjs(selectedDate.value).startOf('day').add(hour, 'hour').add(minutes, 'minute')
@ -601,15 +600,14 @@ const onResize = (event: MouseEvent) => {
const ogEndDate = dayjs(resizeRecord.value.row[toCol.title!]) const ogEndDate = dayjs(resizeRecord.value.row[toCol.title!])
const ogStartDate = dayjs(resizeRecord.value.row[fromCol.title!]) const ogStartDate = dayjs(resizeRecord.value.row[fromCol.title!])
const hour = Math.floor(percentY * 24) // Round down to the nearest hour const minutes = Math.round((percentY * 24 * 60) / 15) * 15 // Round to nearest 15 minutes
const minutes = Math.round((percentY * 24 * 60) % 60)
let newRow: Row | null = null let newRow: Row | null = null
let updateProperty: string[] = [] let updateProperty: string[] = []
if (resizeDirection.value === 'right') { if (resizeDirection.value === 'right') {
// If the user is resizing the record to the right, we calculate the new end date based on the mouse position // If the user is resizing the record to the right, we calculate the new end date based on the mouse position
let newEndDate = dayjs(selectedDate.value).add(hour, 'hour').add(minutes, 'minute') let newEndDate = dayjs(selectedDate.value).startOf('day').add(minutes, 'minute')
updateProperty = [toCol.title!] updateProperty = [toCol.title!]
@ -629,7 +627,7 @@ const onResize = (event: MouseEvent) => {
}, },
} }
} else if (resizeDirection.value === 'left') { } else if (resizeDirection.value === 'left') {
let newStartDate = dayjs(selectedDate.value).add(hour, 'hour').add(minutes, 'minute') let newStartDate = dayjs(selectedDate.value).startOf('day').add(minutes, 'minute')
updateProperty = [fromCol.title!] updateProperty = [fromCol.title!]

Loading…
Cancel
Save