ff-admin/src/components/admin/unit/inspection/OkNotOk.vue

71 lines
1.9 KiB
Vue

<template>
<div class="flex flex-col h-fit w-full border border-primary rounded-md">
<div class="bg-primary p-2 text-white flex flex-row justify-between items-center">
<p>{{ inspectionPoint.title }}</p>
</div>
<div class="p-2">
<p v-if="inspectionPoint.description" class="pb-2">Beschreibung: {{ inspectionPoint.description }}</p>
<hr v-if="inspectionPoint.description" />
<div class="flex flex-row gap-2">
<button
v-for="option in options"
:key="option.key"
:primary="value == option.key"
:primary-outline="value != option.key"
:disabled="!editable"
:value="option.key"
@click="value = option.key"
>
{{ option.title }}
</button>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { defineComponent, type PropType } from "vue";
import { RadioGroup, RadioGroupOption } from "@headlessui/vue";
import type { InspectionPointViewModel } from "@/viewmodels/admin/unit/inspection/inspectionPlan.models";
</script>
<script lang="ts">
export default defineComponent({
props: {
inspectionPoint: {
type: Object as PropType<InspectionPointViewModel>,
required: true,
},
modelValue: {
type: String as PropType<"true" | "false" | "">,
default: "",
},
editable: {
type: Boolean,
default: true,
},
},
emits: ["update:model-value"],
data() {
return {
options: [
{ key: "true", title: "OK" },
{ key: "false", title: "nicht OK" },
] as Array<{ key: "true" | "false"; title: string }>,
};
},
computed: {
value: {
get() {
return this.modelValue;
},
set(val: string) {
this.$emit("update:model-value", val);
},
},
},
mounted() {
if (this.value == "") this.value = "false";
},
});
</script>