equipmenttype form
This commit is contained in:
parent
8be88a5245
commit
5641dbb57f
9 changed files with 114 additions and 52 deletions
|
@ -1,30 +1,23 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="w-full md:max-w-md">
|
<div class="w-full md:max-w-md">
|
||||||
<div class="flex flex-col items-center">
|
<div class="flex flex-col items-center">
|
||||||
<p class="text-xl font-medium">Mitglied erstellen</p>
|
<p class="text-xl font-medium">Typ erstellen</p>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
<form class="flex flex-col gap-4 py-2" @submit.prevent="triggerCreate">
|
<form class="flex flex-col gap-4 py-2" @submit.prevent="triggerCreate">
|
||||||
<div>
|
<div>
|
||||||
<label for="firstname">Vorname</label>
|
<label for="type">Typ</label>
|
||||||
<input type="text" id="firstname" required />
|
<input type="text" id="type" required />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label for="lastname">Nachname</label>
|
<label for="description">Beschreibung (optional)</label>
|
||||||
<input type="text" id="lastname" required />
|
<textarea id="description" class="h-18"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label for="nameaffix">Nameaffix (optional)</label>
|
<label for="interval">Intervall (optional)</label>
|
||||||
<input type="text" id="nameaffix" />
|
<input type="text" id="interval" placeholder="<number>-(d|m|y) oder DD/MM" />
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="birthdate">Geburtsdatum</label>
|
|
||||||
<input type="date" id="birthdate" required />
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="internalId">Interne ID (optional)</label>
|
|
||||||
<input type="text" id="internalId" />
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-row gap-2">
|
<div class="flex flex-row gap-2">
|
||||||
<button primary type="submit" :disabled="status == 'loading' || status?.status == 'success'">erstellen</button>
|
<button primary type="submit" :disabled="status == 'loading' || status?.status == 'success'">erstellen</button>
|
||||||
<Spinner v-if="status == 'loading'" class="my-auto" />
|
<Spinner v-if="status == 'loading'" class="my-auto" />
|
||||||
|
@ -50,12 +43,8 @@ import { useModalStore } from "@/stores/modal";
|
||||||
import Spinner from "@/components/Spinner.vue";
|
import Spinner from "@/components/Spinner.vue";
|
||||||
import SuccessCheckmark from "@/components/SuccessCheckmark.vue";
|
import SuccessCheckmark from "@/components/SuccessCheckmark.vue";
|
||||||
import FailureXMark from "@/components/FailureXMark.vue";
|
import FailureXMark from "@/components/FailureXMark.vue";
|
||||||
import { Listbox, ListboxButton, ListboxOptions, ListboxOption, ListboxLabel } from "@headlessui/vue";
|
import { useEquipmentTypeStore } from "@/stores/admin/unit/equipmentType/equipmentType";
|
||||||
import { CheckIcon, ChevronUpDownIcon } from "@heroicons/vue/20/solid";
|
import type { CreateEquipmentTypeViewModel } from "@/viewmodels/admin/unit/equipmentType/equipmentType.models";
|
||||||
import { useEquipmentStore } from "@/stores/admin/unit/equipment/equipment";
|
|
||||||
import type { CreateEquipmentViewModel } from "@/viewmodels/admin/unit/equipment/equipment.models";
|
|
||||||
import { useSalutationStore } from "../../../../stores/admin/configuration/salutation";
|
|
||||||
import type { SalutationViewModel } from "../../../../viewmodels/admin/configuration/salutation.models";
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
@ -66,12 +55,6 @@ export default defineComponent({
|
||||||
timeout: undefined as any,
|
timeout: undefined as any,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
|
||||||
...mapState(useSalutationStore, ["salutations"]),
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.fetchSalutations();
|
|
||||||
},
|
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
try {
|
try {
|
||||||
clearTimeout(this.timeout);
|
clearTimeout(this.timeout);
|
||||||
|
@ -79,18 +62,16 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(useModalStore, ["closeModal"]),
|
...mapActions(useModalStore, ["closeModal"]),
|
||||||
...mapActions(useEquipmentStore, ["createEquipment"]),
|
...mapActions(useEquipmentTypeStore, ["createEquipmentType"]),
|
||||||
...mapActions(useSalutationStore, ["fetchSalutations"]),
|
|
||||||
triggerCreate(e: any) {
|
triggerCreate(e: any) {
|
||||||
let formData = e.target.elements;
|
let formData = e.target.elements;
|
||||||
let createEquipment: CreateEquipmentViewModel = {
|
let createEquipmentType: CreateEquipmentTypeViewModel = {
|
||||||
code: "",
|
type: formData.type.value,
|
||||||
name: "",
|
description: formData.description.value,
|
||||||
location: "",
|
inspectionInterval: formData.interval.value || null,
|
||||||
equipmentTypeId: "",
|
|
||||||
};
|
};
|
||||||
this.status = "loading";
|
this.status = "loading";
|
||||||
this.createEquipment(createEquipment)
|
this.createEquipmentType(createEquipmentType)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.status = { status: "success" };
|
this.status = { status: "success" };
|
||||||
this.timeout = setTimeout(() => {
|
this.timeout = setTimeout(() => {
|
||||||
|
|
|
@ -5,6 +5,6 @@ export const equipmentTypeDemoData: Array<EquipmentTypeViewModel> = [
|
||||||
id: "xyz",
|
id: "xyz",
|
||||||
type: "B-Schlauch",
|
type: "B-Schlauch",
|
||||||
description: "Shläuche vom Typ B",
|
description: "Shläuche vom Typ B",
|
||||||
inspectionInterval: "1m",
|
inspectionInterval: "1-m",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
|
@ -666,13 +666,13 @@ const router = createRouter({
|
||||||
{
|
{
|
||||||
path: "overview",
|
path: "overview",
|
||||||
name: "admin-unit-equipment_type-overview",
|
name: "admin-unit-equipment_type-overview",
|
||||||
component: () => import("@/views/admin/ViewSelect.vue"),
|
component: () => import("@/views/admin/unit/equipmentType/Overview.vue"),
|
||||||
props: true,
|
props: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: "inspection-plan",
|
path: "inspection-plan",
|
||||||
name: "admin-unit-equipment_type-inspection_plan",
|
name: "admin-unit-equipment_type-inspection_plan",
|
||||||
component: () => import("@/views/admin/ViewSelect.vue"),
|
component: () => import("@/views/admin/unit/equipmentType/InspectionPlans.vue"),
|
||||||
props: true,
|
props: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -62,7 +62,7 @@ export const useEquipmentTypeStore = defineStore("equipmentType", {
|
||||||
this.activeEquipmentTypeObj = equipmentTypeDemoData.find(
|
this.activeEquipmentTypeObj = equipmentTypeDemoData.find(
|
||||||
(e) => e.id == this.activeEquipmentType
|
(e) => e.id == this.activeEquipmentType
|
||||||
) as EquipmentTypeViewModel;
|
) as EquipmentTypeViewModel;
|
||||||
this.loading = "fetched";
|
this.loadingActive = "fetched";
|
||||||
return;
|
return;
|
||||||
this.loadingActive = "loading";
|
this.loadingActive = "loading";
|
||||||
http
|
http
|
||||||
|
|
|
@ -2,19 +2,19 @@ export interface EquipmentTypeViewModel {
|
||||||
id: string;
|
id: string;
|
||||||
type: string;
|
type: string;
|
||||||
description: string;
|
description: string;
|
||||||
inspectionInterval: `${number}${"d" | "m" | "y"}`;
|
inspectionInterval?: `${number}-${"d" | "m" | "y"}` | `${number}/${number}`;
|
||||||
// attached inspection plans
|
// attached inspection plans
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CreateEquipmentTypeViewModel {
|
export interface CreateEquipmentTypeViewModel {
|
||||||
type: string;
|
type: string;
|
||||||
description: string;
|
description: string;
|
||||||
inspectionInterval: `${number}${"d" | "m" | "y"}`;
|
inspectionInterval?: `${number}-${"d" | "m" | "y"}` | `${number}/${number}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UpdateEquipmentTypeViewModel {
|
export interface UpdateEquipmentTypeViewModel {
|
||||||
id: string;
|
id: string;
|
||||||
type: string;
|
type: string;
|
||||||
description: string;
|
description: string;
|
||||||
inspectionInterval: `${number}${"d" | "m" | "y"}`;
|
inspectionInterval?: `${number}-${"d" | "m" | "y"}` | `${number}/${number}`;
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import { useAbilityStore } from "@/stores/ability";
|
||||||
import { useDamageReportStore } from "@/stores/admin/unit/damageReport/damageReport";
|
import { useDamageReportStore } from "@/stores/admin/unit/damageReport/damageReport";
|
||||||
import type { DamageReportViewModel } from "@/viewmodels/admin/unit/damageReport/damageReport.models";
|
import type { DamageReportViewModel } from "@/viewmodels/admin/unit/damageReport/damageReport.models";
|
||||||
import Pagination from "@/components/Pagination.vue";
|
import Pagination from "@/components/Pagination.vue";
|
||||||
import DamageReportListItem from "@components/admin/unit/damageReport/DamageReportListItem.vue";
|
import DamageReportListItem from "@/components/admin/unit/damageReport/DamageReportListItem.vue";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
|
@ -34,11 +34,10 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineAsyncComponent, defineComponent, markRaw } from "vue";
|
import { defineComponent } from "vue";
|
||||||
import { mapActions, mapState } from "pinia";
|
import { mapActions, mapState } from "pinia";
|
||||||
import MainTemplate from "@/templates/Main.vue";
|
import MainTemplate from "@/templates/Main.vue";
|
||||||
import { RouterLink, RouterView } from "vue-router";
|
import { RouterLink, RouterView } from "vue-router";
|
||||||
import { useModalStore } from "@/stores/modal";
|
|
||||||
import { useAbilityStore } from "@/stores/ability";
|
import { useAbilityStore } from "@/stores/ability";
|
||||||
import { useEquipmentStore } from "@/stores/admin/unit/equipment/equipment";
|
import { useEquipmentStore } from "@/stores/admin/unit/equipment/equipment";
|
||||||
</script>
|
</script>
|
||||||
|
@ -65,13 +64,6 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions(useEquipmentStore, ["fetchEquipmentByActiveId"]),
|
...mapActions(useEquipmentStore, ["fetchEquipmentByActiveId"]),
|
||||||
...mapActions(useModalStore, ["openModal"]),
|
|
||||||
openDeleteModal() {
|
|
||||||
this.openModal(
|
|
||||||
markRaw(defineAsyncComponent(() => import("@/components/admin/unit/member/DeleteMemberModal.vue"))),
|
|
||||||
this.equipmentId ?? ""
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
42
src/views/admin/unit/equipmentType/InspectionPlans.vue
Normal file
42
src/views/admin/unit/equipmentType/InspectionPlans.vue
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<template>
|
||||||
|
<div class="flex flex-col gap-2 h-full w-full overflow-y-auto">
|
||||||
|
<Pagination
|
||||||
|
:items="[]"
|
||||||
|
:totalCount="0"
|
||||||
|
:indicateLoading="false"
|
||||||
|
@load-data="(offset, count, search) => {}"
|
||||||
|
@search="(search) => {}"
|
||||||
|
>
|
||||||
|
<template #pageRow="{ row }: { row: { id: string } }">
|
||||||
|
<p>{{ row }}</p>
|
||||||
|
</template>
|
||||||
|
</Pagination>
|
||||||
|
|
||||||
|
<div class="flex flex-row gap-4">
|
||||||
|
<button v-if="can('create', 'unit', 'equipment_type')" primary class="!w-fit" @click="">
|
||||||
|
Prüfplan erstellen
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { defineComponent } from "vue";
|
||||||
|
import { mapActions, mapState } from "pinia";
|
||||||
|
import Pagination from "@/components/Pagination.vue";
|
||||||
|
import { useAbilityStore } from "@/stores/ability";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export default defineComponent({
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
currentPage: 0,
|
||||||
|
maxEntriesPerPage: 25,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState(useAbilityStore, ["can"]),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
47
src/views/admin/unit/equipmentType/Overview.vue
Normal file
47
src/views/admin/unit/equipmentType/Overview.vue
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
<template>
|
||||||
|
<div class="flex flex-col gap-2 h-full w-full overflow-y-auto">
|
||||||
|
<div v-if="activeEquipmentTypeObj != null" class="flex flex-col gap-2 w-full">
|
||||||
|
<div>
|
||||||
|
<label for="type">Typ</label>
|
||||||
|
<input type="text" id="type" :value="activeEquipmentTypeObj.type" readonly />
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="description">Beschreibung</label>
|
||||||
|
<textarea id="description" :value="activeEquipmentTypeObj.description" class="h-18" readonly></textarea>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="interval">Intervall</label>
|
||||||
|
<input type="text" id="interval" :value="activeEquipmentTypeObj.inspectionInterval" reaonly />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Spinner v-if="loadingActive == 'loading'" class="mx-auto" />
|
||||||
|
<p v-else-if="loadingActive == 'failed'" @click="fetchEquipmentTypeByActiveId" class="cursor-pointer">
|
||||||
|
↺ laden fehlgeschlagen
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { defineComponent } from "vue";
|
||||||
|
import { mapActions, mapState } from "pinia";
|
||||||
|
import Spinner from "@/components/Spinner.vue";
|
||||||
|
import { useEquipmentTypeStore } from "@/stores/admin/unit/equipmentType/equipmentType";
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts">
|
||||||
|
export default defineComponent({
|
||||||
|
props: {
|
||||||
|
equipmentTypeId: String,
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
...mapState(useEquipmentTypeStore, ["activeEquipmentTypeObj", "loadingActive"]),
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.fetchEquipmentTypeByActiveId();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapActions(useEquipmentTypeStore, ["fetchEquipmentTypeByActiveId"]),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
</script>
|
Loading…
Add table
Reference in a new issue