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
9 months ago
|
<script lang="ts" setup>
|
||
6 months ago
|
import type dayjs from 'dayjs'
|
||
|
|
||
|
const { selectedDate, activeDates, activeCalendarView } = useCalendarViewStoreOrThrow()
|
||
9 months ago
|
|
||
|
const months = computed(() => {
|
||
|
const months = []
|
||
|
for (let i = 0; i < 12; i++) {
|
||
9 months ago
|
months.push(selectedDate.value.set('month', i).set('date', 1))
|
||
9 months ago
|
}
|
||
|
return months
|
||
|
})
|
||
9 months ago
|
|
||
9 months ago
|
const calendarContainer = ref<HTMLElement | null>(null)
|
||
|
|
||
6 months ago
|
const { width } = useElementSize(calendarContainer)
|
||
9 months ago
|
|
||
6 months ago
|
const size = ref<'small' | 'medium'>('small')
|
||
|
const cols = ref(4)
|
||
9 months ago
|
|
||
|
const handleResize = () => {
|
||
6 months ago
|
if (width.value > 1250) {
|
||
|
size.value = 'medium'
|
||
|
cols.value = 4
|
||
|
} else if (width.value > 850) {
|
||
9 months ago
|
size.value = 'medium'
|
||
6 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
|
||
9 months ago
|
} else {
|
||
6 months ago
|
size.value = 'medium'
|
||
|
cols.value = 1
|
||
9 months ago
|
}
|
||
|
}
|
||
|
|
||
6 months ago
|
const changeView = (date: dayjs.Dayjs) => {
|
||
|
selectedDate.value = date
|
||
|
activeCalendarView.value = 'day'
|
||
|
}
|
||
|
|
||
9 months ago
|
onMounted(() => {
|
||
|
handleResize()
|
||
|
})
|
||
|
|
||
|
watch(width, handleResize)
|
||
9 months ago
|
</script>
|
||
|
|
||
|
<template>
|
||
6 months ago
|
<div ref="calendarContainer" class="overflow-auto flex my-2 transition-all justify-center nc-scrollbar-md">
|
||
6 months ago
|
<div
|
||
|
:class="{
|
||
6 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',
|
||
6 months ago
|
}"
|
||
6 months ago
|
class="grid justify-items-center gap-8"
|
||
6 months ago
|
data-testid="nc-calendar-year-view"
|
||
|
>
|
||
6 months ago
|
<LazySmartsheetCalendarYearViewMonth
|
||
9 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"
|
||
6 months ago
|
class="nc-year-view-calendar"
|
||
9 months ago
|
data-testid="nc-calendar-year-view-month-selector"
|
||
6 months ago
|
@dbl-click="changeView"
|
||
9 months ago
|
/>
|
||
|
</div>
|
||
9 months ago
|
</div>
|
||
|
</template>
|
||
|
|
||
7 months ago
|
<style lang="scss" scoped>
|
||
|
.nc-year-view-calendar {
|
||
|
:deep(.nc-date-week-header) {
|
||
6 months ago
|
@apply border-gray-200 h-8 py-2;
|
||
7 months ago
|
}
|
||
|
}
|
||
|
</style>
|