From be9c6f0d523e1a57f93a389c787f4db637e833cb Mon Sep 17 00:00:00 2001 From: Julian Appel Date: Fri, 31 Jul 2026 07:53:07 +0200 Subject: [PATCH] Renumber circuit groups explicitly --- docs/current-architecture.md | 5 + docs/spec/08-current-product-backlog.md | 3 + .../components/circuit-tree-editor.tsx | 72 ++++++++- src/frontend/utils/api.ts | 21 +++ src/frontend/utils/circuit-group-editing.ts | 146 ++++++++++++++++++ tests/circuit-group-numbering.test.ts | 101 ++++++++++++ 6 files changed, 347 insertions(+), 1 deletion(-) diff --git a/docs/current-architecture.md b/docs/current-architecture.md index 0fd4c14..45d3977 100644 --- a/docs/current-architecture.md +++ b/docs/current-architecture.md @@ -390,6 +390,11 @@ Gruppen lassen sich im Editor schrittweise nur gegenüber einer benachbarten Gruppe derselben Kategorie verschieben. Der Client sendet dabei immer die vollständige erwartete und gewünschte Sortierreihenfolge über `circuit-group.reorder`; Gruppennummer, Präfix und Kind-BMK bleiben unverändert. +Eine separate, ausdrücklich bestätigte Editoraktion erzeugt dagegen einen +vollständigen `circuit-group.renumber`-Plan für genau eine Kategorie. Sie +nummeriert deren Gruppen gemäß aktueller Reihenfolge ab eins und ändert +Gruppenpräfixe, optionale Gruppen-Schutz-BMK und Stromkreis-BMK gemeinsam; +die Stromkreisnummer hinter dem letzten Punkt bleibt erhalten. `distribution-board.update` versioniert Etage, Netzart und den verteilerweiten Gleichzeitigkeitsfaktor gemeinsam und stellt alle Werte über dauerhaftes Undo/Redo wieder her. Der Faktor liegt zwischen `0` und `1` und diff --git a/docs/spec/08-current-product-backlog.md b/docs/spec/08-current-product-backlog.md index b8db24d..5d2f48b 100644 --- a/docs/spec/08-current-product-backlog.md +++ b/docs/spec/08-current-product-backlog.md @@ -40,6 +40,9 @@ requirements and intended sequencing, not proof of implementation. - [x] Phase E3b2b: circuit-protection defaults on insert and editor modal. - [x] Phase E4a: persistent same-category group reorder controls. - [ ] Phase E4b: explicit group renumber, circuit moves and populated-delete warning. + - [x] Explicit same-category group renumbering updates prefixes and all child BMK atomically. + - [ ] Circuit moves between same-category groups. + - [ ] Populated-group delete warning and explicit subtree deletion. - [ ] Phase E: editor projection and editing. - [ ] Phase F: documentation and full GUI verification. - [ ] Keep full electrical sizing and cable-dimensioning rules separate until diff --git a/src/frontend/components/circuit-tree-editor.tsx b/src/frontend/components/circuit-tree-editor.tsx index 2869c86..6480857 100644 --- a/src/frontend/components/circuit-tree-editor.tsx +++ b/src/frontend/components/circuit-tree-editor.tsx @@ -52,8 +52,10 @@ import { buildCircuitSectionRenumberAssignments, } from "../utils/circuit-section-renumber-command"; import { + buildCircuitGroupRenumberPlan, buildCircuitGroupReorderAssignments, buildNewCircuitGroupSnapshot, + canRenumberCircuitGroups, canDeleteCircuitGroup, renameCircuitGroupSnapshot, toCircuitGroupSnapshot, @@ -97,6 +99,7 @@ import { reorderCircuitSectionCommand, reorderCircuitSectionsCommand, reorderCircuitGroupsCommand, + renumberCircuitGroupsCommand, renumberCircuitSectionCommand, redoProjectCommand, updateCircuitById, @@ -126,7 +129,10 @@ import type { import { DistributionBoardComponentModal } from "./distribution-board-component-modal"; import { CircuitGroupModal } from "./circuit-group-modal"; import { CircuitProtectionModal } from "./circuit-protection-modal"; -import type { CircuitGroupCategory } from "../../shared/constants/circuit-group"; +import { + circuitGroupCategoryLabels, + type CircuitGroupCategory, +} from "../../shared/constants/circuit-group"; type SaveDirection = "stay" | "next" | "prev"; type StartEditMode = "selectExisting" | "replaceWithTypedChar"; @@ -1267,6 +1273,44 @@ export function CircuitTreeEditor(props: { projectId: string; circuitListId: str }); } + async function handleRenumberCircuitGroups( + category: CircuitGroupCategory + ) { + if (!data) { + return; + } + let plan: ReturnType; + try { + plan = buildCircuitGroupRenumberPlan(data.sections, category); + } catch (err) { + setError(normalizeUiError(err)); + return; + } + if (!plan) { + return; + } + if ( + !confirm( + `Alle Gruppen der Kategorie „${circuitGroupCategoryLabels[category]}“ gemäß ihrer aktuellen Reihenfolge neu nummerieren? Gruppennummern, Präfixe und zugehörige BMK werden dabei gemeinsam geändert.` + ) + ) { + return; + } + await runCommand({ + label: "Stromkreisgruppen neu nummerieren", + redo: async () => { + const result = await renumberCircuitGroupsCommand( + projectId, + getExpectedProjectRevision(), + circuitListId, + plan + ); + applyProjectCommandResult(result); + return null; + }, + }); + } + async function handleSaveCircuitProtection( protection: CircuitTreeProtectionDeviceDto ) { @@ -3543,6 +3587,32 @@ export function CircuitTreeEditor(props: { projectId: string; circuitListId: str > Gruppe nach unten +