Projects with several buildings could not be structured: floors and rooms hung directly off the project. Floors can now belong to a building (migration 0009: table buildings, nullable floors.building_id). Rooms and distribution boards keep their floor; their building follows from it. Existing floors stay without a building. Buildings use the location-structure command store with project-building.insert/.update/.delete, inverses and persistent Undo/Redo; deleting a building with assigned floors is rejected. Floor commands carry buildingId since command version 2. Version 1 floor commands from existing history predate buildings and are upgraded with buildingId = null before they are executed and persisted, so forward and inverse keep one version. Project snapshot schema 7 stores buildings and floor.buildingId; versions 1-6 are upgraded without buildings. Restore and portable transfer include buildings, and the transfer remaps building ids. Buildings, floors and rooms move from the project overview to their own page /projects/:id/struktur with three columns (Gebäude -> Etagen -> Räume) that filter each other, and a sidebar entry. Floor selects in the board and room dialogs are grouped by building. Unchanged dialogs close without a command. Details in docs/building-structure.md; see issue #6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
120 lines
4.7 KiB
TypeScript
120 lines
4.7 KiB
TypeScript
import { Router } from "express";
|
|
import {
|
|
createProject,
|
|
getProject,
|
|
listProjects,
|
|
updateProjectSettings,
|
|
} from "../controllers/project.controller.js";
|
|
import {
|
|
copyDistributionBoard,
|
|
createDistributionBoard,
|
|
deleteDistributionBoard,
|
|
listDistributionBoardsByProject,
|
|
updateDistributionBoard,
|
|
} from "../controllers/distribution-board.controller.js";
|
|
import { listCircuitListsByProject } from "../controllers/circuit-list.controller.js";
|
|
import {
|
|
createBuilding,
|
|
deleteBuilding,
|
|
listBuildingsByProject,
|
|
updateBuilding,
|
|
} from "../controllers/building.controller.js";
|
|
import { createFloor, deleteFloor, listFloorsByProject, updateFloor } from "../controllers/floor.controller.js";
|
|
import { createRoom, deleteRoom, listRoomsByProject, updateRoom } from "../controllers/room.controller.js";
|
|
import { getCircuitTree } from "../controllers/circuit-tree.controller.js";
|
|
import { getNextCircuitIdentifier } from "../controllers/circuit.controller.js";
|
|
import {
|
|
getProjectHistory,
|
|
listProjectRevisions,
|
|
} from "../controllers/project-history.controller.js";
|
|
import {
|
|
executeProjectCommand,
|
|
redoProjectCommand,
|
|
undoProjectCommand,
|
|
} from "../controllers/project-command.controller.js";
|
|
import {
|
|
createNamedProjectSnapshot,
|
|
listProjectSnapshots,
|
|
restoreProjectSnapshot,
|
|
} from "../controllers/project-snapshot.controller.js";
|
|
import {
|
|
exportProjectTransfer,
|
|
importProjectTransfer,
|
|
importProjectTransferAsNewProject,
|
|
} from "../controllers/project-transfer.controller.js";
|
|
import {
|
|
getExternalCsvConfiguration,
|
|
applyExternalInitialImport,
|
|
previewExternalCsv,
|
|
planExternalInitialImport,
|
|
updateExternalCsvConfiguration,
|
|
getExternalCircuitListObjects,
|
|
} from "../controllers/external-csv.controller.js";
|
|
|
|
export const projectRouter = Router();
|
|
|
|
projectRouter.get("/", listProjects);
|
|
projectRouter.post("/", createProject);
|
|
projectRouter.post("/import", importProjectTransferAsNewProject);
|
|
projectRouter.get("/:projectId", getProject);
|
|
projectRouter.get("/:projectId/export", exportProjectTransfer);
|
|
projectRouter.post("/:projectId/import", importProjectTransfer);
|
|
projectRouter.get("/:projectId/external-csv/configuration", getExternalCsvConfiguration);
|
|
projectRouter.put("/:projectId/external-csv/configuration", updateExternalCsvConfiguration);
|
|
projectRouter.post("/:projectId/external-csv/preview", previewExternalCsv);
|
|
projectRouter.post(
|
|
"/:projectId/external-csv/initial-import/plan",
|
|
planExternalInitialImport
|
|
);
|
|
projectRouter.get(
|
|
"/:projectId/circuit-lists/:circuitListId/external-objects",
|
|
getExternalCircuitListObjects
|
|
);
|
|
projectRouter.post(
|
|
"/:projectId/external-csv/initial-import/apply",
|
|
applyExternalInitialImport
|
|
);
|
|
projectRouter.get("/:projectId/history", getProjectHistory);
|
|
projectRouter.get("/:projectId/history/revisions", listProjectRevisions);
|
|
projectRouter.post("/:projectId/commands", executeProjectCommand);
|
|
projectRouter.post("/:projectId/history/undo", undoProjectCommand);
|
|
projectRouter.post("/:projectId/history/redo", redoProjectCommand);
|
|
projectRouter.get("/:projectId/snapshots", listProjectSnapshots);
|
|
projectRouter.post("/:projectId/snapshots", createNamedProjectSnapshot);
|
|
projectRouter.post(
|
|
"/:projectId/snapshots/:snapshotId/restore",
|
|
restoreProjectSnapshot
|
|
);
|
|
projectRouter.put("/:projectId", updateProjectSettings);
|
|
projectRouter.get("/:projectId/distribution-boards", listDistributionBoardsByProject);
|
|
projectRouter.post("/:projectId/distribution-boards", createDistributionBoard);
|
|
projectRouter.post(
|
|
"/:projectId/distribution-boards/:distributionBoardId/copy",
|
|
copyDistributionBoard
|
|
);
|
|
projectRouter.put(
|
|
"/:projectId/distribution-boards/:distributionBoardId",
|
|
updateDistributionBoard
|
|
);
|
|
projectRouter.delete(
|
|
"/:projectId/distribution-boards/:distributionBoardId",
|
|
deleteDistributionBoard
|
|
);
|
|
projectRouter.get("/:projectId/circuit-lists", listCircuitListsByProject);
|
|
projectRouter.get("/:projectId/circuit-lists/:circuitListId/tree", getCircuitTree);
|
|
projectRouter.get(
|
|
"/:projectId/circuit-sections/:sectionId/next-identifier",
|
|
getNextCircuitIdentifier
|
|
);
|
|
projectRouter.get("/:projectId/buildings", listBuildingsByProject);
|
|
projectRouter.post("/:projectId/buildings", createBuilding);
|
|
projectRouter.put("/:projectId/buildings/:buildingId", updateBuilding);
|
|
projectRouter.delete("/:projectId/buildings/:buildingId", deleteBuilding);
|
|
projectRouter.get("/:projectId/floors", listFloorsByProject);
|
|
projectRouter.post("/:projectId/floors", createFloor);
|
|
projectRouter.put("/:projectId/floors/:floorId", updateFloor);
|
|
projectRouter.delete("/:projectId/floors/:floorId", deleteFloor);
|
|
projectRouter.get("/:projectId/rooms", listRoomsByProject);
|
|
projectRouter.post("/:projectId/rooms", createRoom);
|
|
projectRouter.put("/:projectId/rooms/:roomId", updateRoom);
|
|
projectRouter.delete("/:projectId/rooms/:roomId", deleteRoom);
|