wip #VC
This commit is contained in:
		| @@ -142,22 +142,10 @@ import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue' | ||||
| import { ref, watch, computed, reactive } from 'vue' | ||||
| import { DateTime } from 'luxon' | ||||
| import useCurrentYearPeriodInfo from '@/Composables/yearPeriodInfo' | ||||
| import { useMonthInfo } from '@/Composables/monthInfo' | ||||
|  | ||||
| let days = ref([]) | ||||
| const months = [ | ||||
|   { id: 1, name: 'Styczeń' }, | ||||
|   { id: 2, name: 'Luty' }, | ||||
|   { id: 3, name: 'Marzec' }, | ||||
|   { id: 4, name: 'Kwiecień' }, | ||||
|   { id: 5, name: 'Maj' }, | ||||
|   { id: 6, name: 'Czerwiec' }, | ||||
|   { id: 7, name: 'Lipiec' }, | ||||
|   { id: 8, name: 'Sierpień' }, | ||||
|   { id: 9, name: 'Wrzesień' }, | ||||
|   { id: 10, name: 'Październik' }, | ||||
|   { id: 11, name: 'Listopad' }, | ||||
|   { id: 12, name: 'Grudzień' }, | ||||
| ] | ||||
| const months = useMonthInfo().getMonths() | ||||
| function getCurrentDate() { | ||||
|   const { year, month, weekNumber } = DateTime.now() | ||||
|   return { year, month, weekNumber } | ||||
| @@ -187,7 +175,7 @@ const viewMode = computed(() => { | ||||
|     name: viewModeOptions.find((obj) => obj.key === key)?.name, | ||||
|   } | ||||
| }) | ||||
| const monthName = computed(() => months.find(month => month.id === calendar.currents.month)?.name) | ||||
| const monthName = computed(() => months[calendar.currents.month - 1]?.name) | ||||
|  | ||||
| loadCalendar() | ||||
|  | ||||
| @@ -201,6 +189,8 @@ function loadCalendar() { | ||||
|   if (viewMode.value.key === 'week') { | ||||
|     if (currentDate.year === selectedYear) | ||||
|       focusDate = DateTime.fromObject({ weekNumber: calendar.currents.week }) | ||||
|     else | ||||
|       focusDate = focusDate.plus({ week: calendar.currents.week - 1 } ) | ||||
|     start = focusDate.startOf('week') | ||||
|     end = focusDate.endOf('week') | ||||
|   } else if (viewMode.value.key === 'month') { | ||||
| @@ -243,9 +233,9 @@ function toNext() { | ||||
| } | ||||
|  | ||||
| function resetCalendar() { | ||||
|   calendar.currents.year = currentDate.year | ||||
|   calendar.currents.month = currentDate.month | ||||
|   calendar.currents.week = currentDate.weekNumber | ||||
|   calendar.currents.year = selectedYear | ||||
|   calendar.currents.month = selectedYear === currentDate.year ? currentDate.month : 1 | ||||
|   calendar.currents.week = selectedYear === currentDate.year ? currentDate.weekNumber : 1 | ||||
| } | ||||
|  | ||||
| function addWeeks(howMany = 1) { | ||||
| @@ -257,6 +247,7 @@ function addMonths(howMany = 1) { | ||||
| } | ||||
|  | ||||
| function updateViewMode(type) { | ||||
|   resetCalendar() | ||||
|   calendar.viewMode.value = type | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user