forked from jappel/leistungsbilanz-ts
Persist circuit structure edits
This commit is contained in:
parent
76d8d59391
commit
2eba4ea75e
19 changed files with 809 additions and 964 deletions
73
src/frontend/utils/circuit-structure-command.ts
Normal file
73
src/frontend/utils/circuit-structure-command.ts
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
import type {
|
||||
CircuitDeviceRowSnapshot,
|
||||
} from "../../domain/models/circuit-device-row-structure-project-command.model.js";
|
||||
import type {
|
||||
CircuitSnapshot,
|
||||
} from "../../domain/models/circuit-structure-project-command.model.js";
|
||||
import type {
|
||||
CreateCircuitDeviceRowInputDto,
|
||||
CreateCircuitInputDto,
|
||||
} from "../types.js";
|
||||
|
||||
export function buildCircuitDeviceRowInsertSnapshot(input: {
|
||||
id: string;
|
||||
circuitId: string;
|
||||
values: CreateCircuitDeviceRowInputDto;
|
||||
defaultSortOrder: number;
|
||||
}): CircuitDeviceRowSnapshot {
|
||||
const { id, circuitId, values, defaultSortOrder } = input;
|
||||
return {
|
||||
id,
|
||||
circuitId,
|
||||
linkedProjectDeviceId: values.linkedProjectDeviceId ?? null,
|
||||
legacyConsumerId: null,
|
||||
sortOrder: values.sortOrder ?? defaultSortOrder,
|
||||
name: values.name,
|
||||
displayName: values.displayName,
|
||||
phaseType: values.phaseType ?? null,
|
||||
connectionKind: values.connectionKind ?? null,
|
||||
costGroup: values.costGroup ?? null,
|
||||
category: values.category ?? null,
|
||||
level: values.level ?? null,
|
||||
roomId: values.roomId ?? null,
|
||||
roomNumberSnapshot: values.roomNumberSnapshot ?? null,
|
||||
roomNameSnapshot: values.roomNameSnapshot ?? null,
|
||||
quantity: values.quantity,
|
||||
powerPerUnit: values.powerPerUnit,
|
||||
simultaneityFactor: values.simultaneityFactor,
|
||||
cosPhi: values.cosPhi ?? null,
|
||||
remark: values.remark ?? null,
|
||||
overriddenFields: values.overriddenFields ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
export function buildCircuitInsertSnapshot(input: {
|
||||
id: string;
|
||||
circuitListId: string;
|
||||
values: CreateCircuitInputDto;
|
||||
deviceRows: CircuitDeviceRowSnapshot[];
|
||||
}): CircuitSnapshot {
|
||||
const { id, circuitListId, values, deviceRows } = input;
|
||||
return {
|
||||
id,
|
||||
circuitListId,
|
||||
sectionId: values.sectionId,
|
||||
equipmentIdentifier: values.equipmentIdentifier,
|
||||
displayName: values.displayName ?? null,
|
||||
sortOrder: values.sortOrder,
|
||||
protectionType: values.protectionType ?? null,
|
||||
protectionRatedCurrent: values.protectionRatedCurrent ?? null,
|
||||
protectionCharacteristic: values.protectionCharacteristic ?? null,
|
||||
cableType: values.cableType ?? null,
|
||||
cableCrossSection: values.cableCrossSection ?? null,
|
||||
cableLength: values.cableLength ?? null,
|
||||
rcdAssignment: values.rcdAssignment ?? null,
|
||||
terminalDesignation: values.terminalDesignation ?? null,
|
||||
voltage: values.voltage ?? null,
|
||||
controlRequirement: values.controlRequirement ?? null,
|
||||
status: values.status ?? null,
|
||||
isReserve: deviceRows.length === 0,
|
||||
remark: values.remark ?? null,
|
||||
deviceRows,
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue