From db96e66b7ad2adcdf1d6a12b03e8a0a6fc2fe976 Mon Sep 17 00:00:00 2001 From: Alexis <35.alexis.pele@gmail.com> Date: Wed, 21 Aug 2024 22:52:36 +0200 Subject: [PATCH] Changed loading and added spinner --- components/calendar/Calendar.vue | 12 ++++++++--- components/calendar/CalendarMenu.vue | 4 +++- pages/i/calendar/[id].vue | 21 ++++++++++++------- stores/CalendarStore.ts | 30 ++++++++++++++-------------- 4 files changed, 41 insertions(+), 26 deletions(-) diff --git a/components/calendar/Calendar.vue b/components/calendar/Calendar.vue index c5acd41..fe4c5a4 100644 --- a/components/calendar/Calendar.vue +++ b/components/calendar/Calendar.vue @@ -8,6 +8,12 @@ import CenturyLayout from './state/centennially/Layout.vue' import DecadeLayout from './state/decennially/Layout.vue' import YearLayout from './state/yearly/Layout.vue' +const route = useRoute() +const id = route.params.id +const calendarStore = useCalendar() + +await calendarStore.fetchCalendar(Number(id)) + const { currentConfig, jumpToDate, selectedDate } = useCalendar() // const { setCharacters } = useCharacters() @@ -41,9 +47,9 @@ onMounted(() => { - - - + + + diff --git a/components/calendar/CalendarMenu.vue b/components/calendar/CalendarMenu.vue index 4c84849..69f5a51 100644 --- a/components/calendar/CalendarMenu.vue +++ b/components/calendar/CalendarMenu.vue @@ -29,7 +29,9 @@ const { revealAdvancedSearch } = useCalendar()
  • - + + +
  • diff --git a/pages/i/calendar/[id].vue b/pages/i/calendar/[id].vue index 0c6a875..3611527 100644 --- a/pages/i/calendar/[id].vue +++ b/pages/i/calendar/[id].vue @@ -1,4 +1,6 @@ diff --git a/stores/CalendarStore.ts b/stores/CalendarStore.ts index d23b775..48f240d 100644 --- a/stores/CalendarStore.ts +++ b/stores/CalendarStore.ts @@ -4,7 +4,7 @@ import { } from '@/models/Date' import { useUrlSearchParams } from '@vueuse/core' import { defineStore } from 'pinia' -import { computed, ref, type ComputedRef, type Ref } from 'vue' +import { computed, ref, type ComputedRef } from 'vue' import type { Calendar } from '~/models/CalendarConfig' import type { CalendarEvent } from '~/models/CalendarEvent' import type { CalendarMonth } from '~/models/CalendarMonth' @@ -32,10 +32,10 @@ export const useCalendar = defineStore('calendar', () => { /** * Static calendar config */ - const currentConfig: Ref = ref({ + const currentConfig = ref({ viewType: 'month' }) - const viewTypeOptions: Set = new Set([ + const viewTypeOptions = new Set([ 'month', 'year' ]) @@ -45,7 +45,7 @@ export const useCalendar = defineStore('calendar', () => { /** * Month list (queried from API) */ - const months: Ref = ref([]) + const months = ref([]) async function fetchCalendar(id: number) { try { @@ -89,14 +89,14 @@ export const useCalendar = defineStore('calendar', () => { * Sorted month data using the raw months */ const sortedMonths = computed(() => months.value.sort((a, b) => a.position - b.position)) - const monthsPerYear = computed(() => months.value.length) - const daysPerYear = computed(() => months.value.reduce((acc, o) => acc + o.days, 0)) + const monthsPerYear = computed(() => months.value.length) + const daysPerYear = computed(() => months.value.reduce((acc, o) => acc + o.days, 0)) // Default date settings (current day in the world) // The base setting is the first day / month of year 0 - const defaultDay: Ref = ref(1) - const defaultMonth: Ref = ref(0) - const defaultYear: Ref = ref(0) + const defaultDay = ref(1) + const defaultMonth = ref(0) + const defaultYear = ref(0) // Object representation const defaultDate = computed(() => { @@ -305,7 +305,7 @@ export const useCalendar = defineStore('calendar', () => { /** * State for advanced search modal */ - const isAdvancedSearchOpen: Ref = ref(false) + const isAdvancedSearchOpen = ref(false) function revealAdvancedSearch() { isAdvancedSearchOpen.value = true @@ -623,7 +623,7 @@ export const useCalendar = defineStore('calendar', () => { const categories = ref([]) // Order base events by dates - const allEvents = computed(() => [...baseEvents.value].sort((a, b) => compareDates(a.startDate, b.startDate, 'desc'))) + const allEvents = computed(() => [...baseEvents.value].sort((a, b) => compareDates(a.startDate, b.startDate, 'desc'))) // Gets all current event in its default state const currentEvents = ref([]) @@ -774,7 +774,7 @@ export const useCalendar = defineStore('calendar', () => { /** * State for event modal edition */ - const isEditEventModalOpen: Ref = ref(false) + const isEditEventModalOpen = ref(false) function revealEditEventModal() { isEditEventModalOpen.value = true @@ -783,7 +783,7 @@ export const useCalendar = defineStore('calendar', () => { /** * State for event modal edition */ - const isDeleteEventModalOpen: Ref = ref(false) + const isDeleteEventModalOpen = ref(false) function revealDeleteEventModal() { isDeleteEventModalOpen.value = true @@ -796,13 +796,13 @@ export const useCalendar = defineStore('calendar', () => { const isCreatingEvent = ref(false) const isUpdatingEvent = ref(false) const isDeletingEvent = ref(false) - const operationInProgress = computed(() => isCreatingEvent.value || isUpdatingEvent.value || isDeletingEvent.value) + const operationInProgress = computed(() => isCreatingEvent.value || isUpdatingEvent.value || isDeletingEvent.value) let abortController: AbortController | null = null /** * Dummy event to hold creation data */ - const eventSkeleton: Ref = ref({ title: '', startDate: defaultDate.value }) + const eventSkeleton = ref({ title: '', startDate: defaultDate.value }) /** * Resets the dummy event data