From 1cd2bcb999818917e198d61d539fb6c6f81f033d Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Tue, 20 Feb 2024 07:15:43 +0000 Subject: [PATCH] feat(nc-gui): year selector fix: refactored month selector to support year selector fix: renamed DateSelector.vue to DateWeekSelector.vue --- ...{DateSelector.vue => DateWeekSelector.vue} | 11 +- .../components/nc/MonthYearSelector.vue | 176 ++++++++++++++++++ .../smartsheet/calendar/SideMenu.vue | 20 +- .../components/smartsheet/calendar/index.vue | 2 +- 4 files changed, 195 insertions(+), 14 deletions(-) rename packages/nc-gui/components/nc/{DateSelector.vue => DateWeekSelector.vue} (95%) create mode 100644 packages/nc-gui/components/nc/MonthYearSelector.vue diff --git a/packages/nc-gui/components/nc/DateSelector.vue b/packages/nc-gui/components/nc/DateWeekSelector.vue similarity index 95% rename from packages/nc-gui/components/nc/DateSelector.vue rename to packages/nc-gui/components/nc/DateWeekSelector.vue index 3a59ede345..7751280868 100644 --- a/packages/nc-gui/components/nc/DateSelector.vue +++ b/packages/nc-gui/components/nc/DateWeekSelector.vue @@ -45,7 +45,7 @@ const currentMonth = computed(() => { }); const selectWeek = (date: Date) => { - if(!date) return; + if (!date) return; const dayOffset = props.isMondayFirst ? 1 : 0; const dayOfWeek = (date.getDay() - dayOffset + 7) % 7; const startDate = new Date(date); @@ -101,7 +101,7 @@ const isDateInCurrentMonth = (date: Date) => { // Used to check if two dates are the same const isSameDate = (date1: Date, date2: Date) => { - if(!date1 || !date2) return false; + if (!date1 || !date2) return false; return date1.getDate() === date2.getDate() && date1.getMonth() === date2.getMonth() && date1.getFullYear() === date2.getFullYear(); @@ -154,7 +154,8 @@ const paginate = (action: 'next' | 'prev') => { }" class="h-9 w-9 px-1 py-2 relative font-medium flex items-center cursor-pointer justify-center" @click="handleSelectDate(date)" > - + {{ date.getDate() }} @@ -179,11 +180,11 @@ const paginate = (action: 'next' | 'prev') => { height: 100%; } -.nc-selected-week-start:before{ +.nc-selected-week-start:before { @apply !border-l-2 !rounded-l-lg; } -.nc-selected-week-end:before{ +.nc-selected-week-end:before { width: 100%; @apply !border-r-2 !rounded-r-lg; } diff --git a/packages/nc-gui/components/nc/MonthYearSelector.vue b/packages/nc-gui/components/nc/MonthYearSelector.vue new file mode 100644 index 0000000000..aec139a800 --- /dev/null +++ b/packages/nc-gui/components/nc/MonthYearSelector.vue @@ -0,0 +1,176 @@ + + + + + \ No newline at end of file diff --git a/packages/nc-gui/components/smartsheet/calendar/SideMenu.vue b/packages/nc-gui/components/smartsheet/calendar/SideMenu.vue index a35e7f07aa..17450a08f8 100644 --- a/packages/nc-gui/components/smartsheet/calendar/SideMenu.vue +++ b/packages/nc-gui/components/smartsheet/calendar/SideMenu.vue @@ -6,7 +6,7 @@ const props = defineProps<{ visible: boolean }>() -const activeCalendarView = inject(CalendarViewTypeInj, ref<'month' | 'day' | 'year' | 'week'>('day' as const)) +const activeCalendarView = inject(CalendarViewTypeInj, ref<'month' | 'day' | 'year' | 'week'>('month' as const)) const {t} = useI18n() @@ -60,8 +60,11 @@ const selectedDate = ref(null); 'w-1/4 min-w-[22.1rem]': props.visible, 'transition-all': true, }" class="h-full border-l-1 border-gray-200"> - - + + + + +
{{ t('objects.Records') }} @@ -73,8 +76,11 @@ const selectedDate = ref(null); -
- +
@@ -82,7 +88,5 @@ const selectedDate = ref(null); \ No newline at end of file diff --git a/packages/nc-gui/components/smartsheet/calendar/index.vue b/packages/nc-gui/components/smartsheet/calendar/index.vue index 6df3d13843..cad3ac7773 100644 --- a/packages/nc-gui/components/smartsheet/calendar/index.vue +++ b/packages/nc-gui/components/smartsheet/calendar/index.vue @@ -33,7 +33,7 @@ provide(IsKanbanInj, ref(false)) provide(IsCalendarInj, ref(true)) -provide(CalendarViewTypeInj, ref('day' as const)) +provide(CalendarViewTypeInj, ref('year' as const)) const showSideMenu = ref(true)