diff --git a/src/components/admin/unit/equipment/CreateEquipmentModal.vue b/src/components/admin/unit/equipment/CreateEquipmentModal.vue deleted file mode 100644 index 6690d9a..0000000 --- a/src/components/admin/unit/equipment/CreateEquipmentModal.vue +++ /dev/null @@ -1,155 +0,0 @@ - - - - - diff --git a/src/components/admin/unit/equipmentType/CreateEquipmentTypeModal.vue b/src/components/admin/unit/equipmentType/CreateEquipmentTypeModal.vue index 372ec7f..bbe3a80 100644 --- a/src/components/admin/unit/equipmentType/CreateEquipmentTypeModal.vue +++ b/src/components/admin/unit/equipmentType/CreateEquipmentTypeModal.vue @@ -13,10 +13,6 @@ -
- - -
@@ -68,7 +64,6 @@ export default defineComponent({ let createEquipmentType: CreateEquipmentTypeViewModel = { type: formData.type.value, description: formData.description.value, - inspectionInterval: formData.interval.value || null, }; this.status = "loading"; this.createEquipmentType(createEquipmentType) diff --git a/src/components/admin/unit/inspectionPlan/InspectionPlanListItem.vue b/src/components/admin/unit/inspectionPlan/InspectionPlanListItem.vue new file mode 100644 index 0000000..fc653d1 --- /dev/null +++ b/src/components/admin/unit/inspectionPlan/InspectionPlanListItem.vue @@ -0,0 +1,33 @@ + + + + + diff --git a/src/components/admin/unit/vehicleType/CreateVehicleTypeModal.vue b/src/components/admin/unit/vehicleType/CreateVehicleTypeModal.vue new file mode 100644 index 0000000..79dfd38 --- /dev/null +++ b/src/components/admin/unit/vehicleType/CreateVehicleTypeModal.vue @@ -0,0 +1,82 @@ + + + + + diff --git a/src/components/admin/unit/vehicleType/DeleteVehicleTypeModal.vue b/src/components/admin/unit/vehicleType/DeleteVehicleTypeModal.vue new file mode 100644 index 0000000..25217eb --- /dev/null +++ b/src/components/admin/unit/vehicleType/DeleteVehicleTypeModal.vue @@ -0,0 +1,83 @@ + + + + + diff --git a/src/components/admin/unit/vehicleType/VehicleTypeListItem.vue b/src/components/admin/unit/vehicleType/VehicleTypeListItem.vue new file mode 100644 index 0000000..4ade7a4 --- /dev/null +++ b/src/components/admin/unit/vehicleType/VehicleTypeListItem.vue @@ -0,0 +1,30 @@ + + + + + diff --git a/src/demodata/equipmentType.ts b/src/demodata/equipmentType.ts index 90ba97b..0c2195c 100644 --- a/src/demodata/equipmentType.ts +++ b/src/demodata/equipmentType.ts @@ -5,6 +5,5 @@ export const equipmentTypeDemoData: Array = [ id: "xyz", type: "B-Schlauch", description: "Shläuche vom Typ B", - inspectionInterval: "1-m", }, ]; diff --git a/src/demodata/inspectionPlan.ts b/src/demodata/inspectionPlan.ts new file mode 100644 index 0000000..c95260e --- /dev/null +++ b/src/demodata/inspectionPlan.ts @@ -0,0 +1,12 @@ +import type { InspectionPlanViewModel } from "../viewmodels/admin/unit/inspectionPlan/inspectionPlan.models"; +import { equipmentTypeDemoData } from "./equipmentType"; + +export const inspectionPlanDemoData: Array = [ + { + id: "abc", + title: "Sichtprüfung", + inspectionInterval: "1-m", + equipmentTypeId: equipmentTypeDemoData[0].id, + equipmentType: equipmentTypeDemoData[0], + }, +]; diff --git a/src/demodata/vehicleType.ts b/src/demodata/vehicleType.ts new file mode 100644 index 0000000..81db560 --- /dev/null +++ b/src/demodata/vehicleType.ts @@ -0,0 +1,9 @@ +import type { VehicleTypeViewModel } from "../viewmodels/admin/unit/vehicleType/vehicleType.models"; + +export const vehicleTypeDemoData: Array = [ + { + id: "xyz", + type: "HLF", + description: "HLF", + }, +]; diff --git a/src/demodata/wearableType.ts b/src/demodata/wearableType.ts index 44cff0c..2619655 100644 --- a/src/demodata/wearableType.ts +++ b/src/demodata/wearableType.ts @@ -3,7 +3,7 @@ import type { WearableTypeViewModel } from "../viewmodels/admin/unit/wearableTyp export const wearableTypeDemoData: Array = [ { id: "xyz", - type: "B-Schlauch", - description: "Shläuche vom Typ B", + type: "Jacke", + description: "Bayern 2000", }, ]; diff --git a/src/router/index.ts b/src/router/index.ts index 61b8b92..7f38280 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -18,6 +18,7 @@ import { resetRespiratoryGearStores, setRespiratoryGearId } from "./unit/respira import { resetRespiratoryWearerStores, setRespiratoryWearerId } from "./unit/respiratoryWearer"; import { resetRespiratoryMissionStores, setRespiratoryMissionId } from "./unit/respiratoryMission"; import { resetWearableStores, setWearableId } from "./unit/wearable"; +import { resetInspectionPlanStores, setInspectionPlanId } from "./unit/inspectionPlan"; const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), @@ -739,6 +740,49 @@ const router = createRouter({ }, ], }, + { + path: "vehicle-type", + name: "admin-unit-vehicle_type-route", + component: () => import("@/views/RouterView.vue"), + meta: { type: "read", section: "unit", module: "vehicle_type" }, + beforeEnter: [abilityAndNavUpdate], + children: [ + { + path: "", + name: "admin-unit-vehicle_type", + component: () => import("@/views/admin/unit/vehicleType/VehicleType.vue"), + }, + { + path: ":vehicleTypeId", + name: "admin-unit-vehicle_type-routing", + component: () => import("@/views/admin/unit/vehicleType/VehicleTypeRouting.vue"), + beforeEnter: [setEquipmentTypeId], + props: true, + children: [ + { + path: "overview", + name: "admin-unit-vehicle_type-overview", + component: () => import("@/views/admin/unit/vehicleType/Overview.vue"), + props: true, + }, + { + path: "inspection-plan", + name: "admin-unit-vehicle_type-inspection_plan", + component: () => import("@/views/admin/unit/vehicleType/InspectionPlans.vue"), + props: true, + }, + { + path: "edit", + name: "admin-unit-vehicle_type-edit", + component: () => import("@/views/admin/ViewSelect.vue"), + meta: { type: "update", section: "unit", module: "equipment_type" }, + beforeEnter: [abilityAndNavUpdate], + props: true, + }, + ], + }, + ], + }, { path: "wearable-type", name: "admin-unit-wearable_type-route", @@ -761,6 +805,51 @@ const router = createRouter({ }, ], }, + { + path: "inspection-plan", + name: "admin-unit-inspection_plan-route", + component: () => import("@/views/RouterView.vue"), + meta: { type: "read", section: "unit", module: "inspection_plan" }, + beforeEnter: [abilityAndNavUpdate], + children: [ + { + path: "", + name: "admin-unit-inspection_plan", + component: () => import("@/views/admin/unit/inspectionPlan/InspectionPlan.vue"), + beforeEnter: [resetInspectionPlanStores], + }, + { + path: "create", + name: "admin-unit-inspection_plan-create", + component: () => import("@/views/admin/unit/inspectionPlan/CreateInspectionPlan.vue"), + meta: { type: "create", section: "unit", module: "equipment" }, + beforeEnter: [abilityAndNavUpdate], + }, + { + path: ":inspectionPlanId", + name: "admin-unit-inspection_plan-routing", + component: () => import("@/views/admin/unit/inspectionPlan/InspectionPlanRouting.vue"), + beforeEnter: [setInspectionPlanId], + props: true, + children: [ + { + path: "", + name: "admin-unit-inspection_plan-overview", + component: () => import("@/views/admin/unit/inspectionPlan/Overview.vue"), + props: true, + }, + { + path: "edit", + name: "admin-unit-inspection_plan-edit", + component: () => import("@/views/admin/ViewSelect.vue"), + meta: { type: "update", section: "unit", module: "inspection_plan" }, + beforeEnter: [abilityAndNavUpdate], + props: true, + }, + ], + }, + ], + }, ], }, { diff --git a/src/router/unit/inspectionPlan.ts b/src/router/unit/inspectionPlan.ts new file mode 100644 index 0000000..7bd43a3 --- /dev/null +++ b/src/router/unit/inspectionPlan.ts @@ -0,0 +1,20 @@ +import { useInspectionPlanStore } from "@/stores/admin/unit/inspectionPlan/inspectionPlan"; + +export async function setInspectionPlanId(to: any, from: any, next: any) { + const InspectionPlanStore = useInspectionPlanStore(); + InspectionPlanStore.activeInspectionPlan = to.params?.inspectionPlanId ?? null; + + //useXYStore().$reset(); + + next(); +} + +export async function resetInspectionPlanStores(to: any, from: any, next: any) { + const InspectionPlanStore = useInspectionPlanStore(); + InspectionPlanStore.activeInspectionPlan = null; + InspectionPlanStore.activeInspectionPlanObj = null; + + //useXYStore().$reset(); + + next(); +} diff --git a/src/router/unit/vehicleType.ts b/src/router/unit/vehicleType.ts new file mode 100644 index 0000000..8b7cb5f --- /dev/null +++ b/src/router/unit/vehicleType.ts @@ -0,0 +1,20 @@ +import { useVehicleTypeStore } from "@/stores/admin/unit/vehicleType/vehicleType"; + +export async function setVehicleTypeId(to: any, from: any, next: any) { + const vehicleTypeStore = useVehicleTypeStore(); + vehicleTypeStore.activeVehicleType = to.params?.vehicleTypeId ?? null; + + //useXYStore().$reset(); + + next(); +} + +export async function resetVehicleTypeStores(to: any, from: any, next: any) { + const vehicleTypeStore = useVehicleTypeStore(); + vehicleTypeStore.activeVehicleType = null; + vehicleTypeStore.activeVehicleTypeObj = null; + + //useXYStore().$reset(); + + next(); +} diff --git a/src/stores/admin/navigation.ts b/src/stores/admin/navigation.ts index fd5e108..60505db 100644 --- a/src/stores/admin/navigation.ts +++ b/src/stores/admin/navigation.ts @@ -126,9 +126,15 @@ export const useNavigationStore = defineStore("navigation", { ...(abilityStore.can("read", "unit", "equipment_type") ? [{ key: "equipment_type", title: "Geräte-Typen" }] : []), + ...(abilityStore.can("read", "unit", "vehicle_type") + ? [{ key: "vehicle_type", title: "Fahrzeug-Arten" }] + : []), ...(abilityStore.can("read", "unit", "wearable_type") ? [{ key: "wearable_type", title: "Kleidungs-Arten" }] : []), + ...(abilityStore.can("read", "unit", "inspection_plan") + ? [{ key: "inspection_plan", title: "Prüfpläne" }] + : []), ], }, configuration: { diff --git a/src/stores/admin/unit/inspectionPlan/inspectionPlan.ts b/src/stores/admin/unit/inspectionPlan/inspectionPlan.ts new file mode 100644 index 0000000..dd5b04c --- /dev/null +++ b/src/stores/admin/unit/inspectionPlan/inspectionPlan.ts @@ -0,0 +1,110 @@ +import { defineStore } from "pinia"; +import type { + InspectionPlanViewModel, + CreateInspectionPlanViewModel, + UpdateInspectionPlanViewModel, +} from "@/viewmodels/admin/unit/inspectionPlan/inspectionPlan.models"; +import { http } from "@/serverCom"; +import type { AxiosResponse } from "axios"; +import { inspectionPlanDemoData } from "@/demodata/inspectionPlan"; + +export const useInspectionPlanStore = defineStore("inspectionPlan", { + state: () => { + return { + inspectionPlans: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + activeInspectionPlan: null as string | null, + activeInspectionPlanObj: null as InspectionPlanViewModel | null, + loadingActive: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchInspectionPlans(offset = 0, count = 25, search = "", clear = false) { + this.inspectionPlans = inspectionPlanDemoData.map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.inspectionPlans.length; + this.loading = "fetched"; + return; + if (clear) this.inspectionPlans = []; + this.loading = "loading"; + http + .get(`/admin/inspectionPlan?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`) + .then((result) => { + this.totalCount = result.data.total; + result.data.inspectionPlans + .filter((elem: InspectionPlanViewModel) => this.inspectionPlans.findIndex((m) => m.id == elem.id) == -1) + .map((elem: InspectionPlanViewModel, index: number): InspectionPlanViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + }) + .forEach((elem: InspectionPlanViewModel & { tab_pos: number }) => { + this.inspectionPlans.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + async getAllInspectionPlans(): Promise> { + return await http.get(`/admin/inspectionPlan?noLimit=true`).then((res) => { + return { ...res, data: res.data.inspectionPlans }; + }); + }, + async getInspectionPlansByIds(ids: Array): Promise> { + return await http + .post(`/admin/inspectionPlan/ids`, { + ids, + }) + .then((res) => { + return { ...res, data: res.data.inspectionPlans }; + }); + }, + async searchInspectionPlans(search: string): Promise> { + return await http.get(`/admin/inspectionPlan?search=${search}&noLimit=true`).then((res) => { + return { ...res, data: res.data.inspectionPlans }; + }); + }, + fetchInspectionPlanByActiveId() { + this.activeInspectionPlanObj = inspectionPlanDemoData.find( + (e) => e.id == this.activeInspectionPlan + ) as InspectionPlanViewModel; + this.loading = "fetched"; + return; + this.loadingActive = "loading"; + http + .get(`/admin/inspectionPlan/${this.activeInspectionPlan}`) + .then((res) => { + this.activeInspectionPlanObj = res.data; + this.loadingActive = "fetched"; + }) + .catch((err) => { + this.loadingActive = "failed"; + }); + }, + fetchInspectionPlanById(id: string) { + return http.get(`/admin/inspectionPlan/${id}`); + }, + async createInspectionPlan(inspectionPlan: CreateInspectionPlanViewModel): Promise> { + const result = await http.post(`/admin/inspectionPlan`, { + // TODO: data + }); + this.fetchInspectionPlans(); + return result; + }, + async updateActiveInspectionPlan(inspectionPlan: UpdateInspectionPlanViewModel): Promise> { + const result = await http.patch(`/admin/inspectionPlan/${inspectionPlan.id}`, { + // TODO: data + }); + this.fetchInspectionPlans(); + return result; + }, + async deleteInspectionPlan(inspectionPlan: number): Promise> { + const result = await http.delete(`/admin/inspectionPlan/${inspectionPlan}`); + this.fetchInspectionPlans(); + return result; + }, + }, +}); diff --git a/src/stores/admin/unit/vehicleType/vehicleType.ts b/src/stores/admin/unit/vehicleType/vehicleType.ts new file mode 100644 index 0000000..28eac02 --- /dev/null +++ b/src/stores/admin/unit/vehicleType/vehicleType.ts @@ -0,0 +1,101 @@ +import { defineStore } from "pinia"; +import type { + VehicleTypeViewModel, + CreateVehicleTypeViewModel, + UpdateVehicleTypeViewModel, +} from "@/viewmodels/admin/unit/vehicleType/vehicleType.models"; +import { http } from "@/serverCom"; +import type { AxiosResponse } from "axios"; +import { vehicleTypeDemoData } from "../../../../demodata/vehicleType"; + +export const useVehicleTypeStore = defineStore("vehicleType", { + state: () => { + return { + vehicleTypes: [] as Array, + totalCount: 0 as number, + loading: "loading" as "loading" | "fetched" | "failed", + activeVehicleType: null as string | null, + activeVehicleTypeObj: null as VehicleTypeViewModel | null, + loadingActive: "loading" as "loading" | "fetched" | "failed", + }; + }, + actions: { + fetchVehicleTypes(offset = 0, count = 25, search = "", clear = false) { + this.vehicleTypes = vehicleTypeDemoData.map((e, i) => ({ ...e, tab_pos: i })); + this.totalCount = this.vehicleTypes.length; + this.loading = "fetched"; + return; + if (clear) this.vehicleTypes = []; + this.loading = "loading"; + http + .get(`/admin/vehicleType?offset=${offset}&count=${count}${search != "" ? "&search=" + search : ""}`) + .then((result) => { + this.totalCount = result.data.total; + result.data.vehicles + .filter((elem: VehicleTypeViewModel) => this.vehicleTypes.findIndex((m) => m.id == elem.id) == -1) + .map((elem: VehicleTypeViewModel, index: number): VehicleTypeViewModel & { tab_pos: number } => { + return { + ...elem, + tab_pos: index + offset, + }; + }) + .forEach((elem: VehicleTypeViewModel & { tab_pos: number }) => { + this.vehicleTypes.push(elem); + }); + this.loading = "fetched"; + }) + .catch((err) => { + this.loading = "failed"; + }); + }, + async getAllVehicleTypes(): Promise> { + return await http.get(`/admin/vehicleType?noLimit=true`).then((res) => { + return { ...res, data: res.data.vehicles }; + }); + }, + async searchVehicleTypes(search: string): Promise> { + return await http.get(`/admin/vehicleType?search=${search}&noLimit=true`).then((res) => { + return { ...res, data: res.data.vehicles }; + }); + }, + fetchVehicleTypeByActiveId() { + this.activeVehicleTypeObj = vehicleTypeDemoData.find( + (e) => e.id == this.activeVehicleType + ) as VehicleTypeViewModel; + this.loadingActive = "fetched"; + return; + this.loadingActive = "loading"; + http + .get(`/admin/vehicleType/${this.activeVehicleType}`) + .then((res) => { + this.activeVehicleTypeObj = res.data; + this.loadingActive = "fetched"; + }) + .catch((err) => { + this.loadingActive = "failed"; + }); + }, + fetchVehicleTypeById(id: string) { + return http.get(`/admin/vehicleType/${id}`); + }, + async createVehicleType(vehicleType: CreateVehicleTypeViewModel): Promise> { + const result = await http.post(`/admin/vehicleType`, { + // TODO: data + }); + this.fetchVehicleTypes(); + return result; + }, + async updateActiveVehicleType(vehicleType: UpdateVehicleTypeViewModel): Promise> { + const result = await http.patch(`/admin/vehicleType/${vehicleType.id}`, { + // TODO: data + }); + this.fetchVehicleTypes(); + return result; + }, + async deleteVehicleType(vehicleType: number): Promise> { + const result = await http.delete(`/admin/vehicleType/${vehicleType}`); + this.fetchVehicleTypes(); + return result; + }, + }, +}); diff --git a/src/types/permissionTypes.ts b/src/types/permissionTypes.ts index 9c6a354..55b38ad 100644 --- a/src/types/permissionTypes.ts +++ b/src/types/permissionTypes.ts @@ -12,6 +12,8 @@ export type PermissionModule = | "equipment" | "equipment_type" | "vehicle" + | "vehicle_type" + | "inspection_plan" | "respiratory_gear" | "respiratory_wearer" | "respiratory_mission" @@ -70,6 +72,8 @@ export const permissionModules: Array = [ "equipment", "equipment_type", "vehicle", + "vehicle_type", + "inspection_plan", "respiratory_gear", "respiratory_wearer", "respiratory_mission", @@ -101,6 +105,8 @@ export const sectionsAndModules: SectionsAndModulesObject = { "equipment", "equipment_type", "vehicle", + "vehicle_type", + "inspection_plan", "respiratory_gear", "respiratory_wearer", "respiratory_mission", diff --git a/src/viewmodels/admin/unit/equipmentType/equipmentType.models.ts b/src/viewmodels/admin/unit/equipmentType/equipmentType.models.ts index b2479dd..7524494 100644 --- a/src/viewmodels/admin/unit/equipmentType/equipmentType.models.ts +++ b/src/viewmodels/admin/unit/equipmentType/equipmentType.models.ts @@ -2,19 +2,16 @@ export interface EquipmentTypeViewModel { id: string; type: string; description: string; - inspectionInterval?: `${number}-${"d" | "m" | "y"}` | `${number}/${number}`; // attached inspection plans } export interface CreateEquipmentTypeViewModel { type: string; description: string; - inspectionInterval?: `${number}-${"d" | "m" | "y"}` | `${number}/${number}`; } export interface UpdateEquipmentTypeViewModel { id: string; type: string; description: string; - inspectionInterval?: `${number}-${"d" | "m" | "y"}` | `${number}/${number}`; } diff --git a/src/viewmodels/admin/unit/inspectionPlan/inspectionPlan.models.ts b/src/viewmodels/admin/unit/inspectionPlan/inspectionPlan.models.ts new file mode 100644 index 0000000..4227414 --- /dev/null +++ b/src/viewmodels/admin/unit/inspectionPlan/inspectionPlan.models.ts @@ -0,0 +1,21 @@ +import type { EquipmentTypeViewModel } from "../equipmentType/equipmentType.models"; + +export interface InspectionPlanViewModel { + id: string; + title: string; + inspectionInterval?: `${number}-${"d" | "m" | "y"}` | `${number}/${number}`; + equipmentTypeId: string; + equipmentType: EquipmentTypeViewModel; +} + +export interface CreateInspectionPlanViewModel { + title: string; + inspectionInterval?: `${number}-${"d" | "m" | "y"}` | `${number}/${number}`; + equipmentTypeId: string; +} + +export interface UpdateInspectionPlanViewModel { + id: string; + title: string; + inspectionInterval?: `${number}-${"d" | "m" | "y"}` | `${number}/${number}`; +} diff --git a/src/viewmodels/admin/unit/vehicleType/vehicleType.models.ts b/src/viewmodels/admin/unit/vehicleType/vehicleType.models.ts new file mode 100644 index 0000000..ea6c7cf --- /dev/null +++ b/src/viewmodels/admin/unit/vehicleType/vehicleType.models.ts @@ -0,0 +1,16 @@ +export interface VehicleTypeViewModel { + id: string; + type: string; + description: string; +} + +export interface CreateVehicleTypeViewModel { + type: string; + description: string; +} + +export interface UpdateVehicleTypeViewModel { + id: string; + type: string; + description: string; +} diff --git a/src/views/admin/unit/equipmentType/EquipmentTypeRouting.vue b/src/views/admin/unit/equipmentType/EquipmentTypeRouting.vue index da22317..f7287d0 100644 --- a/src/views/admin/unit/equipmentType/EquipmentTypeRouting.vue +++ b/src/views/admin/unit/equipmentType/EquipmentTypeRouting.vue @@ -1,7 +1,7 @@