Sorting events by default and minor fixes
This commit is contained in:
@@ -54,7 +54,7 @@ import {
|
||||
import SearchList from './lists/SearchList.vue'
|
||||
|
||||
const { characters } = useCharacters()
|
||||
const { baseEvents } = useCalendarEvents()
|
||||
const { allEvents } = useCalendarEvents()
|
||||
|
||||
const modalOpen = defineModel({ default: false })
|
||||
|
||||
@@ -96,11 +96,11 @@ const searchResults = computed<(Character | CalendarEvent)[]>(() => {
|
||||
// Assign data to loop over and filter
|
||||
// They are assigned this way for readability
|
||||
if (selectedEntity.value === 'events') {
|
||||
dataToFilter = baseEvents
|
||||
dataToFilter = allEvents
|
||||
} else if (selectedEntity.value === 'characters') {
|
||||
dataToFilter = characters
|
||||
} else {
|
||||
dataToFilter = [...baseEvents, ...characters]
|
||||
dataToFilter = [...allEvents, ...characters]
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -306,7 +306,7 @@ function handleCategorySelect(e: any) {
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-1">
|
||||
<TagsInput class="px-0 gap-0 w-52" :model-value="selectedCategories">
|
||||
<TagsInput class="px-0 gap-0 w-72" :model-value="selectedCategories">
|
||||
<div class="flex gap-2 flex-wrap items-center px-3">
|
||||
<TagsInputItem v-for="item in selectedCategories" :key="item" :value="item">
|
||||
<TagsInputItemText class="capitalize" />
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { CalendarEvent } from '@/models/Events'
|
||||
|
||||
export const regularEvents: CalendarEvent[] = [
|
||||
export const initialEvents: CalendarEvent[] = [
|
||||
// Histoire Antique
|
||||
{
|
||||
title: "Laurdieu devient la première cité de l'empire de Kaliatos",
|
||||
|
||||
@@ -1,35 +1,37 @@
|
||||
import { regularEvents } from '@/data/Events'
|
||||
import { convertDateToDays, daysPerMonth } from '@/models/Date'
|
||||
import { initialEvents } from '@/data/Events'
|
||||
import { compareDates, convertDateToDays, daysPerMonth } from '@/models/Date'
|
||||
import type { CalendarEvent } from '@/models/Events'
|
||||
import { defineStore } from 'pinia'
|
||||
import { ref, watch, type Ref } from 'vue'
|
||||
import { useCalendar } from './CalendarStore'
|
||||
import { useCharacters } from './CharacterStore'
|
||||
// import { useCharacters } from './CharacterStore'
|
||||
|
||||
export const useCalendarEvents = defineStore('calendar-events', () => {
|
||||
const { currentDate, currentConfig } = useCalendar()
|
||||
const { charactersWithBirthData, charactersWithDeathData } = useCharacters()
|
||||
// const { charactersWithBirthData, charactersWithDeathData } = useCharacters()
|
||||
|
||||
const baseEvents: CalendarEvent[] = regularEvents
|
||||
const baseEvents: CalendarEvent[] = initialEvents
|
||||
|
||||
const characterBirthEvents = charactersWithBirthData.map((character) => {
|
||||
return {
|
||||
title: `Naissance de ${character.name}`,
|
||||
startDate: character.birth,
|
||||
category: 'naissance'
|
||||
} as CalendarEvent
|
||||
// const characterBirthEvents = charactersWithBirthData.map((character) => {
|
||||
// return {
|
||||
// title: `Naissance de ${character.name}`,
|
||||
// startDate: character.birth,
|
||||
// category: 'naissance'
|
||||
// } as CalendarEvent
|
||||
// })
|
||||
|
||||
// const characterDeathEvents = charactersWithDeathData.map((character) => {
|
||||
// return {
|
||||
// title: `Décès de ${character.name}`,
|
||||
// startDate: character.death,
|
||||
// category: 'mort'
|
||||
// } as CalendarEvent
|
||||
// })
|
||||
|
||||
const allEvents = [...baseEvents].sort((a, b) => {
|
||||
return compareDates(a.startDate, b.startDate, 'desc')
|
||||
})
|
||||
|
||||
const characterDeathEvents = charactersWithDeathData.map((character) => {
|
||||
return {
|
||||
title: `Décès de ${character.name}`,
|
||||
startDate: character.death,
|
||||
category: 'mort'
|
||||
} as CalendarEvent
|
||||
})
|
||||
|
||||
const allEvents = [...characterBirthEvents, ...characterDeathEvents, ...baseEvents]
|
||||
|
||||
// Gets all current event in its default state
|
||||
const currentEvents: Ref<CalendarEvent[]> = ref(computeCurrentEvents())
|
||||
|
||||
@@ -106,5 +108,5 @@ export const useCalendarEvents = defineStore('calendar-events', () => {
|
||||
return allEvents.filter((event) => shouldEventBeDisplayed(event))
|
||||
}
|
||||
|
||||
return { baseEvents, allEvents, currentEvents }
|
||||
return { allEvents, currentEvents }
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user