ff-operation/src/views/admin/operation/mission/MissionOverview.vue
2025-03-01 12:29:53 +01:00

108 lines
3.3 KiB
Vue

<template>
<MainTemplate :showBack="false">
<template #headerInsert>
<RouterLink :to="{ name: 'admin-operation-mission' }" class="text-primary !w-fit">zurück zur Liste</RouterLink>
</template>
<template #diffMain>
<div class="flex flex-col gap-2 grow px-2 overflow-hidden">
<div class="flex flex-col grow gap-2 overflow-hidden">
<div class="w-full flex flex-row justify-center">
<RouterLink
v-for="tab in tabs"
:key="tab.hash"
:to="{ hash: tab.hash }"
replace
class="w-full p-0.5 first:pl-0 last:pr-0"
>
<p
:class="[
'w-full rounded-lg py-2.5 text-sm text-center font-medium leading-5 focus:ring-0 outline-none',
routeHash == tab.hash
? 'bg-red-200 shadow border-b-2 border-primary rounded-b-none'
: ' hover:bg-red-200',
]"
>
{{ tab.title }}
</p>
</RouterLink>
</div>
<MissionDetail v-show="routeHash == '#edit'" :document="yDoc" :awareness="awareness" />
<MissionPresence v-show="routeHash == '#presence'" />
</div>
</div>
</template>
</MainTemplate>
</template>
<script setup lang="ts">
import { defineComponent } from "vue";
import { mapActions, mapState, mapWritableState } from "pinia";
import MainTemplate from "@/templates/Main.vue";
import { useConnectionStore } from "@/stores/admin/operation/connection";
import MissionDetail from "./MissionDetail.vue";
import MissionPresence from "./MissionPresence.vue";
import { useForceStore } from "@/stores/admin/configuration/force";
import type { ForceViewModel } from "@/viewmodels/admin/configuration/force.models";
import { useMissionDetailStore } from "../../../../stores/admin/operation/missionDetail";
</script>
<script lang="ts">
export default defineComponent({
props: {
id: {
type: String,
default: "",
},
},
data() {
return {
tabs: [
{ hash: "#edit", title: "Einträge" },
{ hash: "#presence", title: "Anwesenheit" },
{ hash: "#protocol", title: "Protokoll" },
],
forces: [] as Array<ForceViewModel>,
};
},
watch: {
"$route.hash"() {
this.manageHash();
},
connectionStatus() {
if (this.connectionStatus) {
this.setupSocketHandlers();
}
},
},
computed: {
...mapState(useConnectionStore, ["connectionStatus"]),
...mapWritableState(useMissionDetailStore, ["yDoc", "awareness"]),
routeHash() {
return this.$route.hash;
},
editors() {
return this.awareness?.getStates() ?? [];
},
},
mounted() {
this.manageHash();
this.connectClient();
this.initialize(this.id);
this.getAvailableForces();
},
beforeUnmount() {
this.cleanup();
},
methods: {
...mapActions(useConnectionStore, ["connectClient"]),
...mapActions(useMissionDetailStore, ["initialize", "setupSocketHandlers", "cleanup"]),
...mapActions(useForceStore, ["getAvailableForces"]),
manageHash() {
if (!this.$route.hash || !this.tabs.map((t) => t.hash).includes(this.$route.hash)) {
this.$router.replace({ hash: this.tabs[0].hash });
}
},
},
});
</script>