ff-operation/src/views/admin/operation/mission/MissionOverview.vue

105 lines
3.1 KiB
Vue
Raw Normal View History

2025-02-20 12:01:12 +01:00
<template>
<MainTemplate :showBack="false">
<template #headerInsert>
2025-02-26 13:21:09 +01:00
<RouterLink :to="{ name: 'admin-operation-mission' }" class="text-primary !w-fit">zurück zur Liste</RouterLink>
2025-02-20 12:01:12 +01:00
</template>
<template #diffMain>
2025-02-24 11:46:02 +01:00
<div class="flex flex-col gap-2 grow px-2 overflow-hidden">
2025-02-20 12:01:12 +01:00
<div class="flex flex-col grow gap-2 overflow-hidden">
2025-02-24 11:46:02 +01:00
<div class="w-full flex flex-row justify-center">
2025-02-20 12:01:12 +01:00
<RouterLink
v-for="tab in tabs"
:key="tab.hash"
:to="{ hash: tab.hash }"
replace
2025-02-24 11:46:02 +01:00
class="w-full p-0.5 first:pl-0 last:pr-0"
2025-02-20 12:01:12 +01:00
>
<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>
2025-02-26 13:21:09 +01:00
<MissionDetail v-show="routeHash == '#edit'" />
2025-02-26 17:50:35 +01:00
<MissionPresence v-show="routeHash == '#presence'" />
2025-02-20 12:01:12 +01:00
</div>
</div>
</template>
</MainTemplate>
</template>
<script setup lang="ts">
import { defineComponent } from "vue";
import { mapActions, mapState } from "pinia";
import MainTemplate from "@/templates/Main.vue";
2025-02-21 11:55:49 +01:00
import { useConnectionStore } from "@/stores/admin/operation/connection";
2025-02-24 11:46:02 +01:00
import MissionDetail from "./MissionDetail.vue";
2025-02-26 17:50:35 +01:00
import MissionPresence from "./MissionPresence.vue";
2025-02-24 11:46:02 +01:00
import { useForceStore } from "@/stores/admin/configuration/force";
import type { ForceViewModel } from "@/viewmodels/admin/configuration/force.models";
2025-02-26 13:21:09 +01:00
import { useMissionDetailStore } from "../../../../stores/admin/operation/missionDetail";
2025-02-20 12:01:12 +01:00
</script>
<script lang="ts">
export default defineComponent({
2025-02-26 13:21:09 +01:00
props: {
id: {
type: String,
default: "",
},
},
2025-02-20 12:01:12 +01:00
data() {
return {
tabs: [
{ hash: "#edit", title: "Einträge" },
{ hash: "#presence", title: "Anwesenheit" },
{ hash: "#protocol", title: "Protokoll" },
],
2025-02-24 11:46:02 +01:00
forces: [] as Array<ForceViewModel>,
2025-02-20 12:01:12 +01:00
};
},
watch: {
"$route.hash"() {
this.manageHash();
},
2025-02-26 13:21:09 +01:00
connectionStatus() {
if (this.connectionStatus) {
this.init(this.id);
}
},
2025-02-20 12:01:12 +01:00
},
computed: {
2025-02-26 13:21:09 +01:00
...mapState(useConnectionStore, ["connectionStatus"]),
2025-02-20 12:01:12 +01:00
routeHash() {
return this.$route.hash;
},
},
mounted() {
this.manageHash();
2025-02-21 11:55:49 +01:00
this.connectClient();
2025-02-27 15:08:56 +01:00
this.init(this.id);
2025-02-24 11:46:02 +01:00
this.getAvailableForces();
2025-02-20 12:01:12 +01:00
},
2025-02-26 13:21:09 +01:00
beforeUnmount() {
this.destroy();
},
2025-02-20 12:01:12 +01:00
methods: {
2025-02-21 11:55:49 +01:00
...mapActions(useConnectionStore, ["connectClient"]),
2025-02-26 13:21:09 +01:00
...mapActions(useMissionDetailStore, ["init", "destroy"]),
2025-02-24 11:46:02 +01:00
...mapActions(useForceStore, ["getAvailableForces"]),
2025-02-20 12:01:12 +01:00
manageHash() {
if (!this.$route.hash || !this.tabs.map((t) => t.hash).includes(this.$route.hash)) {
this.$router.replace({ hash: this.tabs[0].hash });
}
},
},
});
</script>