Keep Revit and manual row quantities consistent

Editing "Anzahl" on a row with linked Revit objects set manualQuantity to
the new total, so the row no longer matched its objects and detaching
them failed with "row.manualQuantity must not exceed row.quantity".

Such rows now lock "Anzahl" in the editor. The new optional columns
"Anz. manuell" (editable) and "Anz. Revit" (read-only) show both shares;
stored column layouts get them hidden next to "Anzahl". The device-row
update derives the total from a manual-only edit and rejects any change
that breaks quantity = manual + Revit, for every source. Two history
fixtures inserted rows with quantity 1 and the column default
manualQuantity 0, a state no runtime path creates; they now insert 1/1.

Undoing "Revit-Objekte lösen" re-validated planning-value conflicts that
the user had confirmed on the original assignment and was rejected.
Undo/redo of row assignments now restores the accepted state without a
new confirmation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Julian Appel 2026-10-29 14:03:29 +01:00
parent 01312b89fe
commit 898be43ebc
12 changed files with 272 additions and 21 deletions

View file

@ -4,6 +4,7 @@ import {
allColumns,
buildCircuitEditPatch,
buildDeviceRowEditPatch,
defaultVisibleColumnKeys,
formatValue,
formatCellValue,
getCircuitSectionLabel,
@ -107,6 +108,34 @@ describe("circuit grid model", () => {
assert.equal(parseStoredColumnLayout("{invalid"), null);
});
it("adds new quantity columns hidden and next to Anzahl in stored layouts", () => {
const layout = parseStoredColumnLayout(
JSON.stringify({
order: ["equipmentIdentifier", "remark", "quantity", "displayName"],
visible: ["equipmentIdentifier", "quantity"],
})
);
assert.ok(layout);
const quantityIndex = layout.order.indexOf("quantity");
assert.deepEqual(
layout.order.slice(quantityIndex, quantityIndex + 3),
["quantity", "manualQuantity", "externalQuantity"]
);
assert.deepEqual(layout.visible, ["equipmentIdentifier", "quantity"]);
assert.equal(defaultVisibleColumnKeys.includes("manualQuantity"), false);
assert.equal(defaultVisibleColumnKeys.includes("externalQuantity"), false);
});
it("edits the manual share only on existing device rows", () => {
assert.equal(getCellKind("deviceRow", "manualQuantity"), "deviceField");
assert.equal(getCellKind("circuitCompact", "manualQuantity"), "deviceField");
assert.equal(getCellKind("placeholder", "manualQuantity"), "readonly");
assert.equal(getCellKind("reserveCircuit", "manualQuantity"), "readonly");
assert.equal(getCellKind("deviceRow", "externalQuantity"), "computed");
assert.deepEqual(buildDeviceRowEditPatch("manualQuantity", "2"), { manualQuantity: 2 });
assert.equal(formatCellValue(2, "externalQuantity"), "2 St.");
});
it("shows stable circuit sections with German labels", () => {
assert.equal(
getCircuitSectionLabel({