Browse Source

fix(nc-gui): day view not functioning

pull/7611/head
DarkPhoenix2704 10 months ago
parent
commit
2c7e0f2a25
  1. 8
      packages/nc-gui/components/nc/DateWeekSelector.vue
  2. 4
      packages/nc-gui/components/smartsheet/calendar/DayView.vue
  3. 6
      packages/nc-gui/composables/useCalendarViewStore.ts
  4. 2
      packages/nc-gui/plugins/a.dayjs.ts

8
packages/nc-gui/components/nc/DateWeekSelector.vue

@ -23,7 +23,7 @@ const props = withDefaults(defineProps<Props>(), {
activeDates: [],
selectedWeek: null,
})
const emit = defineEmits(['change', 'update:selected-date', 'update:page-date', 'update:selected-week'])
const emit = defineEmits(['change', 'update:selectedDate', 'update:pageDate', 'update:selectedWeek'])
// Page date is the date we use to manage which month/date that is currently being displayed
const pageDate = useVModel(props, 'pageDate', emit)
const selectedDate = useVModel(props, 'selectedDate', emit)
@ -102,10 +102,10 @@ const handleSelectDate = (date: Date) => {
} else {
if (!isDayInPagedMonth(date)) {
pageDate.value = new Date(date)
emit('update:page-date', date)
emit('update:pageDate', date)
}
selectedDate.value = date
emit('update:selected-date', date)
emit('update:selectedDate', date)
}
}
@ -128,7 +128,7 @@ const paginate = (action: 'next' | 'prev') => {
newDate.setMonth(newDate.getMonth() - 1)
}
pageDate.value = newDate
emit('update:page-date', newDate)
emit('update:pageDate', newDate)
}
</script>

4
packages/nc-gui/components/smartsheet/calendar/DayView.vue

@ -49,7 +49,7 @@ const renderData = computed(() => {
}"
class="flex flex-col pt-3 gap-2 h-full w-full px-1"
>
<LazySmartSheetRow v-for="(record, rowIndex) in renderData" :row="record">
<LazySmartsheetRow v-for="(record, rowIndex) in renderData" :row="record">
<LazySmartsheetCalendarRecordCard
:key="rowIndex"
:date="record.row[calendarRange[0].fk_from_col.title]"
@ -58,7 +58,7 @@ const renderData = computed(() => {
size="small"
@click="emit('expand-record', record)"
/>
</LazySmartSheetRow>
</LazySmartsheetRow>
</div>
<div
v-else-if="calDataType === UITypes.DateTime"

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

@ -298,18 +298,18 @@ const [useProvideCalendarViewStore, useCalendarViewStore] = useInjectionState(
const filteredData = computed(() => {
if (!formattedData.value) return []
if (activeCalendarView === 'week') {
if (activeCalendarView.value === 'week') {
return formattedData.value.filter((row) => {
const startDate = dayjs(row.row[calendarRange.value[0].fk_from_col.title])
const endDate = dayjs(row.row[calendarRange.value[0].fk_to_col.title])
return startDate.isSameOrBefore(selectedDateRange.value.end) && endDate.isSameOrAfter(selectedDateRange.value.start)
})
} else if (activeCalendarView === 'day') {
} else if (activeCalendarView.value === 'day') {
return formattedData.value.filter((row) => {
const startDate = dayjs(row.row[calendarRange.value[0].fk_from_col.title])
return startDate.isSame(selectedDate.value)
})
} else if (activeCalendarView === 'month') {
} else if (activeCalendarView.value === 'month') {
return formattedData.value.filter((row) => {
const startDate = dayjs(row.row[calendarRange.value[0].fk_from_col.title])
const endDate = dayjs(row.row[calendarRange.value[0].fk_to_col.title])

2
packages/nc-gui/plugins/a.dayjs.ts

@ -7,6 +7,7 @@ import weekday from 'dayjs/plugin/weekday.js'
import timezone from 'dayjs/plugin/timezone.js'
import updateLocale from 'dayjs/plugin/updateLocale'
import isSameOrBefore from 'dayjs/plugin/isSameOrBefore'
import isSameOrAfter from 'dayjs/plugin/isSameOrAfter'
import { defineNuxtPlugin } from '#imports'
export default defineNuxtPlugin(() => {
@ -18,6 +19,7 @@ export default defineNuxtPlugin(() => {
extend(timezone)
extend(updateLocale)
extend(isSameOrBefore)
extend(isSameOrAfter)
dayjs.updateLocale('en', {
weekStart: 1,
})

Loading…
Cancel
Save