Refactored some stuff
This commit is contained in:
13
components/calendar/category/Item.vue
Normal file
13
components/calendar/category/Item.vue
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { Category } from "~/models/Category";
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
category: Category
|
||||||
|
}>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<UiButton variant="secondary" size="sm" class="w-full text-left">
|
||||||
|
{{ category }}
|
||||||
|
</UiButton>
|
||||||
|
</template>
|
||||||
15
components/calendar/category/List.vue
Normal file
15
components/calendar/category/List.vue
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import type { Category } from "~/models/Category";
|
||||||
|
|
||||||
|
defineProps<{
|
||||||
|
categories: Category[]
|
||||||
|
}>()
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<ul>
|
||||||
|
<li v-for="category in categories" :key="category.id">
|
||||||
|
<CalendarCategoryItem :category="category" />
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</template>
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { CalendarFormCategories } from "#components";
|
||||||
import { PhX } from "@phosphor-icons/vue";
|
import { PhX } from "@phosphor-icons/vue";
|
||||||
|
|
||||||
const { toggleCategoriesModal } = useCalendar()
|
const { toggleCategoriesModal } = useCalendar()
|
||||||
@@ -20,17 +21,23 @@ function handleClosing() {
|
|||||||
@interact-outside="handleClosing"
|
@interact-outside="handleClosing"
|
||||||
@close-auto-focus="(e) => e.preventDefault()"
|
@close-auto-focus="(e) => e.preventDefault()"
|
||||||
>
|
>
|
||||||
|
<header>
|
||||||
<UiAlertDialogTitle>
|
<UiAlertDialogTitle>
|
||||||
<span class="text-2xl">
|
<span class="text-2xl">
|
||||||
<strong class="font-bold">Gestion des catégories</strong>
|
{{ $t('entity.category.manageDialog.title') }}
|
||||||
</span>
|
</span>
|
||||||
</UiAlertDialogTitle>
|
</UiAlertDialogTitle>
|
||||||
|
|
||||||
|
<UiAlertDialogDescription>
|
||||||
|
{{ $t('entity.category.manageDialog.subtitle') }}
|
||||||
|
</UiAlertDialogDescription>
|
||||||
|
</header>
|
||||||
|
|
||||||
<UiButton size="icon" variant="ghost" class="absolute top-4 right-4" title="Fermer la fenêtre" @click="handleClosing">
|
<UiButton size="icon" variant="ghost" class="absolute top-4 right-4" title="Fermer la fenêtre" @click="handleClosing">
|
||||||
<PhX size="20" />
|
<PhX size="20" />
|
||||||
</UiButton>
|
</UiButton>
|
||||||
|
|
||||||
catégories là
|
<CalendarFormCategories />
|
||||||
</UiAlertDialogContent>
|
</UiAlertDialogContent>
|
||||||
</UiAlertDialog>
|
</UiAlertDialog>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
7
components/calendar/form/Categories.vue
Normal file
7
components/calendar/form/Categories.vue
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<script lang="ts" setup>
|
||||||
|
const { categories } = storeToRefs(useCalendar())
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<CalendarCategoryList :categories />
|
||||||
|
</template>
|
||||||
@@ -5,7 +5,7 @@ import { useElementBounding } from "@vueuse/core"
|
|||||||
import { storeToRefs } from "pinia"
|
import { storeToRefs } from "pinia"
|
||||||
import { computed, ref, type ComputedRef } from "vue"
|
import { computed, ref, type ComputedRef } from "vue"
|
||||||
|
|
||||||
import CalendarEventButton from "../../CalendarEvent.vue"
|
import CalendarEventButton from "../../event/Event.vue"
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
date: RPGDate
|
date: RPGDate
|
||||||
|
|||||||
@@ -93,7 +93,11 @@ export default defineI18nConfig(() => ({
|
|||||||
search: "Search categories",
|
search: "Search categories",
|
||||||
notFoundAny: "No categories found.",
|
notFoundAny: "No categories found.",
|
||||||
addPrimary: "Add a primary category",
|
addPrimary: "Add a primary category",
|
||||||
addSecondaries: "Add secondary categories"
|
addSecondaries: "Add secondary categories",
|
||||||
|
manageDialog: {
|
||||||
|
title: "Manage categories",
|
||||||
|
subtitle: "Add and change the categories of your calendar",
|
||||||
|
}
|
||||||
},
|
},
|
||||||
isLoading: "Loading in progress…",
|
isLoading: "Loading in progress…",
|
||||||
addDescription: "Add a description",
|
addDescription: "Add a description",
|
||||||
@@ -397,6 +401,10 @@ export default defineI18nConfig(() => ({
|
|||||||
notFoundAny: "Aucune catégorie trouvée.",
|
notFoundAny: "Aucune catégorie trouvée.",
|
||||||
addPrimary: "Ajouter une catégorie principale",
|
addPrimary: "Ajouter une catégorie principale",
|
||||||
addSecondaries: "Ajouter des catégories secondaires",
|
addSecondaries: "Ajouter des catégories secondaires",
|
||||||
|
manageDialog: {
|
||||||
|
title: "Gestion des catégories",
|
||||||
|
subtitle: "Créer et modifier les catégories de votre calendrier",
|
||||||
|
}
|
||||||
},
|
},
|
||||||
isLoading: "Chargement en cours…",
|
isLoading: "Chargement en cours…",
|
||||||
addDescription: "Ajouter une description",
|
addDescription: "Ajouter une description",
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const {
|
|||||||
refresh: calRefresh
|
refresh: calRefresh
|
||||||
} = await useLazyFetch<{ data: Calendar }>("/api/calendars/query",
|
} = await useLazyFetch<{ data: Calendar }>("/api/calendars/query",
|
||||||
{
|
{
|
||||||
key: `calendar-${shortId}`,
|
key: "active-calendar",
|
||||||
query: {
|
query: {
|
||||||
shortId,
|
shortId,
|
||||||
full: true
|
full: true
|
||||||
@@ -27,7 +27,7 @@ const {
|
|||||||
status: categoriesStatus,
|
status: categoriesStatus,
|
||||||
refresh: catRefresh
|
refresh: catRefresh
|
||||||
} = await useLazyFetch<{ data: Category[] }>("/api/calendars/categories/query",
|
} = await useLazyFetch<{ data: Category[] }>("/api/calendars/categories/query",
|
||||||
{ key: `categories-${shortId}` }
|
{ key: "active-categories" }
|
||||||
)
|
)
|
||||||
|
|
||||||
const isLoading = computed(() => calendarStatus.value === "pending" || categoriesStatus.value === "pending")
|
const isLoading = computed(() => calendarStatus.value === "pending" || categoriesStatus.value === "pending")
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const {
|
|||||||
status: calendarStatus
|
status: calendarStatus
|
||||||
} = await useLazyFetch<{ data: Calendar }>("/api/calendars/query",
|
} = await useLazyFetch<{ data: Calendar }>("/api/calendars/query",
|
||||||
{
|
{
|
||||||
key: `calendar-${id}`,
|
key: "active-calendar",
|
||||||
query: {
|
query: {
|
||||||
id,
|
id,
|
||||||
full: true
|
full: true
|
||||||
@@ -36,35 +36,10 @@ const {
|
|||||||
data: categories,
|
data: categories,
|
||||||
status: categoriesStatus
|
status: categoriesStatus
|
||||||
} = await useLazyFetch<{ data: Category[] }>("/api/calendars/categories/query",
|
} = await useLazyFetch<{ data: Category[] }>("/api/calendars/categories/query",
|
||||||
{ key: `categories-${id}` }
|
{ key: "active-categories" }
|
||||||
)
|
)
|
||||||
|
|
||||||
const isLoading = computed(() => calendarStatus.value === "pending" || categoriesStatus.value === "pending")
|
const isLoading = computed(() => calendarStatus.value === "pending" || categoriesStatus.value === "pending")
|
||||||
|
|
||||||
// Set custom menu
|
|
||||||
// This should be reserved for actions, not for breadcrumbs
|
|
||||||
//
|
|
||||||
// const { t } = useI18n()
|
|
||||||
// const { setCurrentMenu } = useUiStore()
|
|
||||||
|
|
||||||
// // Set menu once we have the calendar data
|
|
||||||
// watch(calendar, (n) => {
|
|
||||||
// if (n?.data) {
|
|
||||||
// setCurrentMenu([
|
|
||||||
// {
|
|
||||||
// tooltip: t("entity.world.backToMy"),
|
|
||||||
// to: "/my",
|
|
||||||
// phIcon: "universe",
|
|
||||||
// phIconWeight: "regular"
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// tooltip: t("entity.world.backToSingle", { world: calendar.value?.data.world?.name }),
|
|
||||||
// to: `/my/worlds/${calendar.value?.data.world?.id}`,
|
|
||||||
// phIcon: "world"
|
|
||||||
// },
|
|
||||||
// ])
|
|
||||||
// }
|
|
||||||
// }, { immediate: true })
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|||||||
@@ -16,12 +16,13 @@ export default defineEventHandler(async (event) => {
|
|||||||
.from("calendar_event_categories")
|
.from("calendar_event_categories")
|
||||||
.select(`
|
.select(`
|
||||||
id,
|
id,
|
||||||
name
|
name,
|
||||||
|
color
|
||||||
`)
|
`)
|
||||||
|
|
||||||
if (query.id) {
|
if (query.id) {
|
||||||
return output.eq("id", query.id).limit(1).single<Category>()
|
return output.eq("id", query.id).limit(1).single<Category>()
|
||||||
}
|
}
|
||||||
|
|
||||||
return output.returns<Category[]>()
|
return output.overrideTypes<Category[]>()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ export const useCalendar = defineStore("calendar", () => {
|
|||||||
const months = ref<CalendarMonth[]>([])
|
const months = ref<CalendarMonth[]>([])
|
||||||
|
|
||||||
function setActiveCalendar(calendarData: Calendar, categoryData: Category[]) {
|
function setActiveCalendar(calendarData: Calendar, categoryData: Category[]) {
|
||||||
|
console.log("proced")
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!calendarData.id) return
|
if (!calendarData.id) return
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user