forked from jappel/leistungsbilanz-ts
Add buildings above floors and a building structure page
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>
This commit is contained in:
parent
7692699ee2
commit
cd89c4a499
42 changed files with 5883 additions and 373 deletions
|
|
@ -41,6 +41,7 @@ import { projectChangeSets } from "../src/db/schema/project-change-sets.js";
|
|||
import { projectDevices } from "../src/db/schema/project-devices.js";
|
||||
import { projectRevisions } from "../src/db/schema/project-revisions.js";
|
||||
import { projects } from "../src/db/schema/projects.js";
|
||||
import { buildings } from "../src/db/schema/buildings.js";
|
||||
import { floors } from "../src/db/schema/floors.js";
|
||||
import { rooms } from "../src/db/schema/rooms.js";
|
||||
import { externalCsvConfigurations } from "../src/db/schema/external-csv-configurations.js";
|
||||
|
|
@ -78,6 +79,8 @@ import {
|
|||
createDistributionBoardComponentUpdateProjectCommand,
|
||||
} from "../src/domain/models/distribution-board-component-structure-project-command.model.js";
|
||||
import {
|
||||
createProjectBuildingInsertProjectCommand,
|
||||
createProjectBuildingSnapshot,
|
||||
createProjectFloorInsertProjectCommand,
|
||||
createProjectFloorSnapshot,
|
||||
createProjectRoomInsertProjectCommand,
|
||||
|
|
@ -1610,6 +1613,43 @@ describe("project command service", () => {
|
|||
}
|
||||
});
|
||||
|
||||
it("dispatches building commands and floor assignments with persisted inverses", () => {
|
||||
const context = createTestDatabase();
|
||||
try {
|
||||
const service = createService(context);
|
||||
const building = createProjectBuildingSnapshot("project-1", "Haus A", 0);
|
||||
service.executeUser({
|
||||
projectId: "project-1",
|
||||
expectedRevision: 0,
|
||||
command: createProjectBuildingInsertProjectCommand(building),
|
||||
});
|
||||
const floor = createProjectFloorSnapshot("project-1", "EG", 0, building.id);
|
||||
const created = service.executeUser({
|
||||
projectId: "project-1",
|
||||
expectedRevision: 1,
|
||||
command: createProjectFloorInsertProjectCommand(floor),
|
||||
});
|
||||
assert.equal(created.history.currentRevision, 2);
|
||||
assert.equal(
|
||||
context.db.select().from(floors).where(eq(floors.id, floor.id)).get()
|
||||
?.buildingId,
|
||||
building.id
|
||||
);
|
||||
|
||||
createService(context).undo({ projectId: "project-1", expectedRevision: 2 });
|
||||
createService(context).undo({ projectId: "project-1", expectedRevision: 3 });
|
||||
assert.equal(context.db.select().from(buildings).all().length, 0);
|
||||
createService(context).redo({ projectId: "project-1", expectedRevision: 4 });
|
||||
createService(context).redo({ projectId: "project-1", expectedRevision: 5 });
|
||||
assert.deepEqual(
|
||||
context.db.select().from(floors).where(eq(floors.id, floor.id)).get(),
|
||||
floor
|
||||
);
|
||||
} finally {
|
||||
context.close();
|
||||
}
|
||||
});
|
||||
|
||||
it("dispatches floor and room setup with their persisted inverses", () => {
|
||||
const context = createTestDatabase();
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue