extend wearable and enable maintenance
This commit is contained in:
parent
aeb1ccbc42
commit
b8b2186c58
20 changed files with 457 additions and 93 deletions
|
@ -1,9 +1,13 @@
|
|||
import { inspectionPlan } from "../../../../entity/unit/inspection/inspectionPlan";
|
||||
import { InspectionPlanViewModel } from "../../../../viewmodel/admin/unit/inspection/inspectionPlan.models";
|
||||
import {
|
||||
InspectionPlanRelated,
|
||||
InspectionPlanViewModel,
|
||||
} from "../../../../viewmodel/admin/unit/inspection/inspectionPlan.models";
|
||||
import EquipmentFactory from "../equipment/equipment";
|
||||
import EquipmentTypeFactory from "../equipment/equipmentType";
|
||||
import VehicleFactory from "../vehicle/vehicle";
|
||||
import VehicleTypeFactory from "../vehicle/vehicleType";
|
||||
import WearableTypeFactory from "../wearable/wearableType";
|
||||
import InspectionPointFactory from "./inspectionPoint";
|
||||
|
||||
export default abstract class InspectionPlanFactory {
|
||||
|
@ -13,6 +17,27 @@ export default abstract class InspectionPlanFactory {
|
|||
* @returns {InspectionPlanViewModel}
|
||||
*/
|
||||
public static mapToSingle(record: inspectionPlan): InspectionPlanViewModel {
|
||||
let related: InspectionPlanRelated;
|
||||
if (record?.equipmentTypeId) {
|
||||
related = {
|
||||
relatedId: record.equipmentTypeId,
|
||||
assigned: "equipment",
|
||||
related: EquipmentTypeFactory.mapToSingle(record.equipmentType),
|
||||
};
|
||||
} else if (record?.vehicleTypeId) {
|
||||
related = {
|
||||
relatedId: record.vehicleTypeId,
|
||||
assigned: "vehicle",
|
||||
related: VehicleTypeFactory.mapToSingle(record.vehicleType),
|
||||
};
|
||||
} else {
|
||||
related = {
|
||||
relatedId: record.wearableTypeId,
|
||||
assigned: "wearable",
|
||||
related: WearableTypeFactory.mapToSingle(record.wearableType),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
id: record.id,
|
||||
title: record.title,
|
||||
|
@ -23,17 +48,7 @@ export default abstract class InspectionPlanFactory {
|
|||
inspectionPoints: record.latestVersionedPlan
|
||||
? InspectionPointFactory.mapToBase(record.latestVersionedPlan.inspectionPoints)
|
||||
: [],
|
||||
...(record.equipmentTypeId
|
||||
? {
|
||||
relatedId: record.equipmentTypeId,
|
||||
assigned: "equipment",
|
||||
related: EquipmentTypeFactory.mapToSingle(record.equipmentType),
|
||||
}
|
||||
: {
|
||||
relatedId: record.vehicleTypeId,
|
||||
assigned: "vehicle",
|
||||
related: VehicleTypeFactory.mapToSingle(record.vehicleType),
|
||||
}),
|
||||
...related,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue