ff-admin/src/views/public/calendar/Calendar.vue

75 lines
2.3 KiB
Vue
Raw Normal View History

<template>
<MainTemplate :showBack="false">
<template #topBar>
2024-12-05 16:37:10 +01:00
<div class="flex flex-row items-center gap-4 pt-5 pb-3 px-7">
<h1 class="font-bold text-xl h-8">Kalender</h1>
2024-12-05 16:37:10 +01:00
<div class="grow"></div>
<LinkIcon class="text-gray-500 h-5 w-5 cursor-pointer" @click="openLinkModal" />
<RouterLink :to="{ name: 'public-calendar-explain' }">
<InformationCircleIcon class="text-gray-500 h-5 w-5 cursor-pointer" />
</RouterLink>
</div>
</template>
<template #diffMain>
<div class="flex flex-col w-full h-full gap-2 justify-between px-7 overflow-hidden">
2025-04-14 09:12:00 +02:00
<CustomCalendar :items="formattedItems" :allow-interaction="false" @event-select="eventClick" />
</div>
</template>
</MainTemplate>
</template>
<script setup lang="ts">
2024-12-05 16:37:10 +01:00
import { defineComponent, markRaw, defineAsyncComponent } from "vue";
import { mapActions, mapState } from "pinia";
import { useModalStore } from "@/stores/modal";
import MainTemplate from "@/templates/Main.vue";
2024-12-05 16:37:10 +01:00
import { InformationCircleIcon, LinkIcon } from "@heroicons/vue/24/outline";
2025-01-02 18:28:13 +01:00
import type { CalendarViewModel } from "@/viewmodels/admin/club/calendar.models";
2024-12-05 16:37:10 +01:00
import { RouterLink } from "vue-router";
2025-04-14 09:12:00 +02:00
import CustomCalendar from "@/components/CustomCalendar.vue";
</script>
<script lang="ts">
export default defineComponent({
data() {
return {
calendars: [] as Array<CalendarViewModel>,
};
},
computed: {
formattedItems() {
return this.calendars.map((c) => ({
id: c.id,
title: c.title,
start: c.starttime,
end: c.endtime,
backgroundColor: c.type.color,
}));
},
},
mounted() {
this.fetchCalendars();
},
methods: {
2024-12-05 16:37:10 +01:00
...mapActions(useModalStore, ["openModal"]),
fetchCalendars() {
this.$http
.get("/public/calendar?output=json")
.then((result) => {
this.calendars = result.data;
})
.catch((err) => {});
},
2024-12-05 16:37:10 +01:00
openLinkModal(e: any) {
this.openModal(markRaw(defineAsyncComponent(() => import("@/components/public/calendar/CalendarLinkModal.vue"))));
},
2025-04-14 09:12:00 +02:00
eventClick(id: string) {
this.openModal(
markRaw(defineAsyncComponent(() => import("@/components/public/calendar/ShowCalendarEntryModal.vue"))),
2025-04-14 09:12:00 +02:00
this.calendars.find((c) => c.id == id)
);
},
},
});
</script>