ff-admin/src/views/admin/club/protocol/ProtocolRouting.vue

138 lines
4.8 KiB
Vue
Raw Normal View History

2024-10-03 13:43:13 +02:00
<template>
<MainTemplate>
<template #headerInsert>
2024-10-15 16:24:29 +02:00
<RouterLink to="../" class="text-primary w-fit">zurück zur Liste</RouterLink>
2024-10-03 13:43:13 +02:00
</template>
<template #topBar>
<div class="flex flex-row gap-2 items-center justify-between pt-5 pb-3 px-7">
2024-10-14 17:03:48 +02:00
<h1 class="font-bold text-xl h-8 min-h-fit grow">{{ origin?.title }}, {{ origin?.date }}</h1>
<ProtocolSyncing
:executeSyncAll="executeSyncAll"
@syncState="
(state) => {
syncState = state;
}
"
/>
2024-10-03 13:43:13 +02:00
</div>
</template>
<template #diffMain>
<div class="flex flex-col gap-2 grow px-7 overflow-hidden">
<div class="flex flex-col grow gap-2 overflow-hidden">
<div class="w-full flex flex-row max-lg:flex-wrap justify-center">
<RouterLink
v-for="tab in tabs"
:key="tab.route"
v-slot="{ isActive }"
:to="{ name: tab.route }"
class="w-1/2 md:w-1/3 lg:w-full p-0.5 first:pl-0 last:pr-0"
>
<p
:class="[
2025-04-12 15:17:44 +02:00
'w-full rounded-lg py-2.5 text-sm text-center font-medium leading-5 focus:ring-0 outline-hidden',
isActive ? 'bg-red-200 shadow-sm border-b-2 border-primary rounded-b-none' : ' hover:bg-red-200',
2024-10-03 13:43:13 +02:00
]"
>
{{ tab.title }}
</p>
</RouterLink>
</div>
<RouterView />
</div>
</div>
</template>
</MainTemplate>
</template>
<script setup lang="ts">
import { defineAsyncComponent, defineComponent, markRaw } from "vue";
import { mapActions, mapState } from "pinia";
import MainTemplate from "@/templates/Main.vue";
import { RouterLink, RouterView } from "vue-router";
2025-01-02 18:28:13 +01:00
import { useProtocolStore } from "@/stores/admin/club/protocol/protocol";
2024-10-03 13:43:13 +02:00
import { useModalStore } from "@/stores/modal";
2024-10-14 17:03:48 +02:00
import ProtocolSyncing from "@/components/admin/club/protocol/ProtocolSyncing.vue";
2024-10-18 15:23:37 +02:00
import { PrinterIcon } from "@heroicons/vue/24/outline";
import { useProtocolAgendaStore } from "@/stores/admin/club/protocol/protocolAgenda";
import { useProtocolDecisionStore } from "@/stores/admin/club/protocol/protocolDecision";
import { useProtocolPresenceStore } from "@/stores/admin/club/protocol/protocolPresence";
import { useProtocolVotingStore } from "@/stores/admin/club/protocol/protocolVoting";
2024-10-03 13:43:13 +02:00
</script>
<script lang="ts">
export default defineComponent({
props: {
protocolId: String,
},
2024-10-14 17:03:48 +02:00
watch: {
syncState() {
if (this.wantToClose && this.syncState == "synced") {
this.wantToClose = false;
this.closeModal();
}
},
},
2024-10-03 13:43:13 +02:00
data() {
return {
2024-10-04 12:47:04 +02:00
tabs: [
{ route: "admin-club-protocol-overview", title: "Übersicht" },
2024-10-11 14:43:56 +02:00
{ route: "admin-club-protocol-presence", title: "Anwesenheit" },
2024-10-04 12:47:04 +02:00
{ route: "admin-club-protocol-voting", title: "Abstimmungen" },
2024-10-08 10:43:16 +02:00
{ route: "admin-club-protocol-decisions", title: "Beschlüsse" },
2024-10-11 14:43:56 +02:00
{ route: "admin-club-protocol-agenda", title: "Protokoll" },
2024-10-19 16:24:33 +02:00
{ route: "admin-club-protocol-printout", title: "Druck" },
2024-10-04 12:47:04 +02:00
],
2024-10-14 17:03:48 +02:00
wantToClose: false as boolean,
executeSyncAll: undefined as any,
syncState: "synced" as "synced" | "syncing" | "detectedChanges" | "failed",
2024-10-03 13:43:13 +02:00
};
},
computed: {
2024-10-14 17:03:48 +02:00
...mapState(useProtocolStore, ["origin"]),
2024-10-03 13:43:13 +02:00
},
mounted() {
this.fetchProtocolByActiveId();
this.fetchProtocolAgenda()
this.fetchProtocolDecision()
this.fetchProtocolPresence()
this.fetchProtocolVoting()
2024-10-03 13:43:13 +02:00
},
2024-10-14 17:03:48 +02:00
// this.syncState is undefined, so it will never work
// beforeRouteLeave(to, from, next) {
2024-12-12 15:04:05 +01:00
// const answer = window.confirm('Do you really want to leave? you have unsaved changes!')
// if (answer) {
// next()
// } else {
// next(false)
// }
2024-10-14 17:03:48 +02:00
// if (this.syncState != "synced") {
// this.executeSyncAll = Date.now();
// this.wantToClose = true;
// this.openInfoModal();
// next(false);
// } else {
// next();
// }
// },
2024-10-03 13:43:13 +02:00
methods: {
2024-10-19 16:24:33 +02:00
...mapActions(useProtocolStore, ["fetchProtocolByActiveId"]),
...mapActions(useProtocolAgendaStore, ["fetchProtocolAgenda"]),
...mapActions(useProtocolDecisionStore, ["fetchProtocolDecision"]),
...mapActions(useProtocolPresenceStore,["fetchProtocolPresence"]),
...mapActions(useProtocolVotingStore,["fetchProtocolVoting"]),
2024-10-03 13:43:13 +02:00
...mapActions(useModalStore, ["openModal"]),
2024-10-14 17:03:48 +02:00
openInfoModal() {
this.openModal(
markRaw(defineAsyncComponent(() => import("@/components/admin/club/protocol/CurrentlySyncingModal.vue")))
);
},
2024-10-03 13:43:13 +02:00
openDeleteModal() {
// this.openModal(
// markRaw(defineAsyncComponent(() => import("@/components/admin/club/protocol/DeleteProtocolModal.vue"))),
// parseInt(this.protocolId ?? "")
// );
},
},
});
</script>