Browse Source

fix(nc-gui): some issues

pull/7611/head
DarkPhoenix2704 7 months ago
parent
commit
0b05332a81
  1. 25
      packages/nc-gui/components/smartsheet/calendar/DayView/DateTimeField.vue
  2. 9
      packages/nc-gui/components/smartsheet/calendar/MonthView.vue
  3. 8
      packages/nc-gui/components/smartsheet/calendar/WeekView/DateTimeField.vue

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

@ -55,14 +55,33 @@ const recordsAcrossAllRange = computed<Row[]>(() => {
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<Row[]>(() => {
})
}
} 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()

9
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<Array<Date>> = []
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')
}
}
})

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

@ -114,7 +114,7 @@ const recordsAcrossAllRange = computed(() => {
const style: Partial<CSSStyleDeclaration> = {
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

Loading…
Cancel
Save