Browse Source

fix(nc-gui): handle date pagination

pull/7611/head
DarkPhoenix2704 9 months ago
parent
commit
aa6e28cb8a
  1. 13
      packages/nc-gui/composables/useCalendarViewStore.ts

13
packages/nc-gui/composables/useCalendarViewStore.ts

@ -33,7 +33,7 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
const selectedDateRange = ref<{
start: Date | null
end: Date | null
}>({start: null, end: null})
}>({start: new Date(), end: null})
const defaultPageSize = 1000
@ -102,12 +102,23 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
switch (activeCalendarView.value) {
case 'month':
selectedDate.value = action === 'next' ? addMonths(selectedDate.value, 1) : addMonths(selectedDate.value, -1)
if(pageDate.value.getFullYear() !== selectedDate.value.getFullYear()) {
pageDate.value = selectedDate.value
}
break
case 'year':
selectedDate.value = action === 'next' ? addYears(selectedDate.value, 1) : addYears(selectedDate.value, -1)
if(pageDate.value.getFullYear() !== selectedDate.value.getFullYear()) {
pageDate.value = selectedDate.value
}
break
case 'day':
selectedDate.value = action === 'next' ? addDays(selectedDate.value, 1) : addDays(selectedDate.value, -1)
if(pageDate.value.getFullYear() !== selectedDate.value.getFullYear()) {
pageDate.value = selectedDate.value
} else if(pageDate.value.getMonth() !== selectedDate.value.getMonth()) {
pageDate.value = selectedDate.value
}
break
case 'week':
selectedDateRange.value = action === 'next' ? {

Loading…
Cancel
Save