71 lines
2.7 KiB
Vue
71 lines
2.7 KiB
Vue
|
<template>
|
||
|
<MainTemplate>
|
||
|
<template #headerInsert>
|
||
|
<RouterLink to="../" class="text-primary">zurück zur Liste</RouterLink>
|
||
|
</template>
|
||
|
<template #topBar>
|
||
|
<div class="flex flex-row items-center justify-between pt-5 pb-3 px-7">
|
||
|
<h1 class="font-bold text-xl h-8">Vereinsamt {{ executivePosition?.position }} - Daten bearbeiten</h1>
|
||
|
</div>
|
||
|
</template>
|
||
|
<template #main>
|
||
|
<Spinner v-if="loadingSingle == 'loading'" class="mx-auto" />
|
||
|
<p v-else-if="loadingSingle == 'failed'">laden fehlgeschlagen</p>
|
||
|
<form v-else class="flex flex-col gap-4 py-2 w-full max-w-xl mx-auto" @submit.prevent="triggerUpdate">
|
||
|
<div>
|
||
|
<label for="executivePosition">Bezeichnung</label>
|
||
|
<input type="text" id="executivePosition" required :value="executivePosition?.position" />
|
||
|
</div>
|
||
|
<div class="flex flex-row justify-end gap-2">
|
||
|
<RouterLink button primary-outline to="../" class="!w-fit">abbrechen</RouterLink>
|
||
|
<button primary type="submit" class="!w-fit" :disabled="updateStatus == 'loading'">speichern</button>
|
||
|
<Spinner v-if="updateStatus == 'loading'" class="my-auto" />
|
||
|
<SuccessCheckmark v-else-if="updateStatus?.status == 'success'" />
|
||
|
<FailureXMark v-else-if="updateStatus?.status == 'failed'" />
|
||
|
</div>
|
||
|
</form>
|
||
|
</template>
|
||
|
</MainTemplate>
|
||
|
</template>
|
||
|
|
||
|
<script setup lang="ts">
|
||
|
import { defineComponent } from "vue";
|
||
|
import { mapState, mapActions } from "pinia";
|
||
|
import MainTemplate from "@/templates/Main.vue";
|
||
|
import { useExecutivePositionStore } from "@/stores/admin/executivePosition";
|
||
|
import Spinner from "@/components/Spinner.vue";
|
||
|
import SuccessCheckmark from "@/components/SuccessCheckmark.vue";
|
||
|
import FailureXMark from "@/components/FailureXMark.vue";
|
||
|
import { RouterLink } from "vue-router";
|
||
|
import type { CreateOrUpdateExecutivePositionViewModel } from "@/viewmodels/admin/executivePosition.models";
|
||
|
</script>
|
||
|
|
||
|
<script lang="ts">
|
||
|
export default defineComponent({
|
||
|
props: {
|
||
|
id: String,
|
||
|
},
|
||
|
computed: {
|
||
|
...mapState(useExecutivePositionStore, ["executivePosition", "updateStatus", "loadingSingle"]),
|
||
|
},
|
||
|
mounted() {
|
||
|
this.resetStatus();
|
||
|
this.fetchExecutivePositionById(parseInt(this.id ?? ""));
|
||
|
},
|
||
|
methods: {
|
||
|
...mapActions(useExecutivePositionStore, [
|
||
|
"fetchExecutivePositionById",
|
||
|
"updateActiveExecutivePosition",
|
||
|
"resetStatus",
|
||
|
]),
|
||
|
triggerUpdate(e: any) {
|
||
|
let formData = e.target.elements;
|
||
|
let updateExecutivePosition: CreateOrUpdateExecutivePositionViewModel = {
|
||
|
position: formData.executivePosition.value,
|
||
|
};
|
||
|
this.updateActiveExecutivePosition(updateExecutivePosition);
|
||
|
},
|
||
|
},
|
||
|
});
|
||
|
</script>
|