mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
87 lines
2.0 KiB
87 lines
2.0 KiB
10 months ago
|
<script lang="ts" setup>
|
||
7 months ago
|
import type dayjs from 'dayjs'
|
||
|
|
||
|
const { selectedDate, activeDates, activeCalendarView } = useCalendarViewStoreOrThrow()
|
||
10 months ago
|
|
||
|
const months = computed(() => {
|
||
|
const months = []
|
||
|
for (let i = 0; i < 12; i++) {
|
||
10 months ago
|
months.push(selectedDate.value.set('month', i).set('date', 1))
|
||
10 months ago
|
}
|
||
|
return months
|
||
|
})
|
||
10 months ago
|
|
||
10 months ago
|
const calendarContainer = ref<HTMLElement | null>(null)
|
||
|
|
||
7 months ago
|
const { width } = useElementSize(calendarContainer)
|
||
10 months ago
|
|
||
7 months ago
|
const size = ref<'small' | 'medium'>('small')
|
||
|
const cols = ref(4)
|
||
10 months ago
|
|
||
|
const handleResize = () => {
|
||
7 months ago
|
if (width.value > 1250) {
|
||
|
size.value = 'medium'
|
||
|
cols.value = 4
|
||
|
} else if (width.value > 850) {
|
||
10 months ago
|
size.value = 'medium'
|
||
7 months ago
|
cols.value = 3
|
||
|
} else if (width.value > 680) {
|
||
|
size.value = 'small'
|
||
|
cols.value = 3
|
||
|
} else if (width.value > 375) {
|
||
|
size.value = 'small'
|
||
|
cols.value = 2
|
||
10 months ago
|
} else {
|
||
7 months ago
|
size.value = 'medium'
|
||
|
cols.value = 1
|
||
10 months ago
|
}
|
||
|
}
|
||
|
|
||
7 months ago
|
const changeView = (date: dayjs.Dayjs) => {
|
||
|
selectedDate.value = date
|
||
|
activeCalendarView.value = 'day'
|
||
|
}
|
||
|
|
||
10 months ago
|
onMounted(() => {
|
||
|
handleResize()
|
||
|
})
|
||
|
|
||
|
watch(width, handleResize)
|
||
10 months ago
|
</script>
|
||
|
|
||
|
<template>
|
||
7 months ago
|
<div ref="calendarContainer" class="overflow-auto flex my-2 transition-all justify-center nc-scrollbar-md">
|
||
7 months ago
|
<div
|
||
|
:class="{
|
||
7 months ago
|
'grid-cols-1': cols === 1,
|
||
|
'grid-cols-2': cols === 2,
|
||
|
'grid-cols-3': cols === 3,
|
||
|
'grid-cols-4': cols === 4,
|
||
|
'!gap-5': cols < 3 && size === 'small',
|
||
7 months ago
|
}"
|
||
7 months ago
|
class="grid justify-items-center gap-8"
|
||
7 months ago
|
data-testid="nc-calendar-year-view"
|
||
|
>
|
||
7 months ago
|
<LazySmartsheetCalendarYearViewMonth
|
||
10 months ago
|
v-for="(_, index) in months"
|
||
|
:key="index"
|
||
|
v-model:active-dates="activeDates"
|
||
|
v-model:page-date="months[index]"
|
||
|
v-model:selected-date="selectedDate"
|
||
|
:size="size"
|
||
7 months ago
|
class="nc-year-view-calendar"
|
||
10 months ago
|
data-testid="nc-calendar-year-view-month-selector"
|
||
7 months ago
|
@dbl-click="changeView"
|
||
10 months ago
|
/>
|
||
|
</div>
|
||
10 months ago
|
</div>
|
||
|
</template>
|
||
|
|
||
8 months ago
|
<style lang="scss" scoped>
|
||
|
.nc-year-view-calendar {
|
||
|
:deep(.nc-date-week-header) {
|
||
7 months ago
|
@apply border-gray-200 h-8 py-2;
|
||
8 months ago
|
}
|
||
|
}
|
||
|
</style>
|