[33] Overrides auf Bauteilschichten: Kriterien Bauteilart/Schichtfunktion/Lage/Baustoff/Kategorie, Aktionen Füllung/Schraffur/Umriss mit Vorrang vor 1:100 schwarz; Baustein „Deckenaufbau weiss“, Vorlagen-Dialog, CLI --template/--rule
This commit is contained in:
23 files changed
+1316
-406
No files matched your search
@@ -1083,7 +1083,7 @@ export function createProjectSlice(
|
||||
// Rückmeldung, was hinzukam ([101]); ein Undo-Schritt.
|
||||
const ops = standardsMergeOps(get().project);
|
||||
const c = standardsMergeCounts(ops);
|
||||
const parts = (["components", "wallTypes", "ceilingTypes", "roofTypes", "hatches", "lineStyles", "viewTemplates", "blockDefs"] as const)
|
||||
const parts = (["components", "wallTypes", "ceilingTypes", "roofTypes", "hatches", "lineStyles", "viewTemplates", "blockDefs", "overrideRules"] as const)
|
||||
.filter((k) => c[k] > 0)
|
||||
.map((k) => t(`resources.loadStandards.n.${k}`, { n: c[k] }));
|
||||
if (ops.length) applyChange(ops);
|
||||
|
||||
@@ -16,6 +16,7 @@ import type { DisplayMode } from "../panels/types";
|
||||
import type { ViewTemplateHandlers, ViewTemplateTarget } from "../ui/resourceManager/ViewTemplatesTab";
|
||||
import type { PlanViewHandle } from "../views/plan/PlanView";
|
||||
import {
|
||||
addRuleBlockOps,
|
||||
addTemplateOps,
|
||||
applyToLevelOps,
|
||||
applyToSnapshotOps,
|
||||
@@ -120,5 +121,7 @@ export function useViewTemplateHandlers(d: Deps): ViewTemplateHandlers {
|
||||
},
|
||||
onDeleteViewTemplate: (id) => applyChange((p) => deleteTemplateOps(p, id)),
|
||||
onApplyViewTemplate: onApply,
|
||||
// [33] Override-Baustein (z. B. „Deckenaufbau weiss“) übernehmen: ein Undo-Schritt.
|
||||
onAddRuleBlock: (id, rule) => applyChange((p) => addRuleBlockOps(p, id, rule)),
|
||||
};
|
||||
}
|
||||
@@ -12,10 +12,12 @@ import {
|
||||
deleteTemplateOps,
|
||||
duplicateTemplateOps,
|
||||
linkedTemplate,
|
||||
addRuleBlockOps,
|
||||
patchTemplateOps,
|
||||
uiPatch,
|
||||
type ViewTemplateUi,
|
||||
} from "./viewTemplates";
|
||||
import { standardOverrideRules } from "../model/standards";
|
||||
|
||||
const ui: ViewTemplateUi = { detail: "mittel", scaleDenominator: 100, layerVisibility: { "20": true, "30": true }, enabledOverrideRuleIds: [], displayMode: "all", mono: false, scaleLineWeights: false };
|
||||
|
||||
@@ -100,4 +102,21 @@ describe("viewTemplates", () => {
|
||||
expect(uiPatch(t, ui)).toEqual({ layerVisibility: { "30": false } });
|
||||
expect(uiPatch(t, { ...ui, layerVisibility: { "20": true } })).toEqual({});
|
||||
});
|
||||
|
||||
it("[33] Baustein „Deckenaufbau weiss“: Regel aus den Standards ins Projekt (aus), in der Vorlage eingeschaltet", () => {
|
||||
let p = withTemplate(base());
|
||||
const blocks = standardOverrideRules(p);
|
||||
const block = blocks.find((r) => r.id === "std-or-deckenaufbau-weiss")!;
|
||||
expect(block).toMatchObject({ name: "Deckenaufbau weiss", enabled: false, actions: { fillColor: "#ffffff", hatch: "none", outline: true } });
|
||||
p = applyOps(p, addRuleBlockOps(p, "t1", block));
|
||||
expect(p.overrideRules!.find((r) => r.id === block.id)).toMatchObject({ enabled: false });
|
||||
expect(p.viewTemplates![0].enabledOverrideRuleIds).toEqual([block.id]);
|
||||
// Zweimal: nichts doppelt; Baustein bleibt in der Liste (jetzt aus dem Projekt).
|
||||
p = applyOps(p, addRuleBlockOps(p, "t1", block));
|
||||
expect(p.overrideRules!.filter((r) => r.id === block.id)).toHaveLength(1);
|
||||
expect(p.viewTemplates![0].enabledOverrideRuleIds).toEqual([block.id]);
|
||||
expect(standardOverrideRules(p).map((r) => r.id)).toContain(block.id);
|
||||
// Vorlage anwenden schaltet die Regel ein (Anzeigezustand).
|
||||
expect(uiPatch(p.viewTemplates![0], ui).enabledOverrideRuleIds).toEqual([block.id]);
|
||||
});
|
||||
});
|
||||
@@ -10,9 +10,9 @@
|
||||
// (`patchTemplateOps` schreibt sie in einem Schritt in alle verknüpften Ansichten/Ausschnitte).
|
||||
// Alles liefert Ops (`applyChange`); eine Änderung = ein Undo-Schritt.
|
||||
|
||||
import { addItems, findItem, itemsOf, patchItem, removeItems } from "../core";
|
||||
import { addItems, fieldOps, findItem, itemsOf, patchItem, removeItems } from "../core";
|
||||
import type { CoreOp } from "../core";
|
||||
import type { DrawingLevel, Project, ViewSnapshot, ViewTemplate } from "../model/types";
|
||||
import type { DrawingLevel, OverrideRule, Project, ViewSnapshot, ViewTemplate } from "../model/types";
|
||||
import type { DetailLevel } from "../model/viewTypes";
|
||||
|
||||
/** Anzeigezustand, den Vorlagen zusätzlich steuern (liegt nicht am Geschoss). */
|
||||
@@ -125,6 +125,21 @@ export function patchTemplateOps(p: Project, id: string, patch: Partial<ViewTemp
|
||||
return ops;
|
||||
}
|
||||
|
||||
/**
|
||||
* [33] Override-Baustein (z. B. Standardregel „Deckenaufbau weiss") in eine Vorlage übernehmen: fehlt die
|
||||
* Regel im Projekt, wird sie (ausgeschaltet) angehängt; die Vorlage schaltet sie ein (`enabledOverrideRuleIds`,
|
||||
* ohne festgelegte Liste ausgehend von den heute aktiven Regeln). Ein Undo-Schritt.
|
||||
*/
|
||||
export function addRuleBlockOps(p: Project, templateId: string, rule: OverrideRule): CoreOp[] {
|
||||
const t = findItem(p, "viewTemplates", templateId);
|
||||
if (!t) return [];
|
||||
const rules = p.overrideRules ?? [];
|
||||
const ops = rules.some((r) => r.id === rule.id) ? [] : fieldOps(p, "overrideRules", [...rules, { ...rule, enabled: false }]);
|
||||
const ids = t.enabledOverrideRuleIds ?? rules.filter((r) => r.enabled).map((r) => r.id);
|
||||
if (!ids.includes(rule.id)) ops.push(...patchTemplateOps(p, templateId, { enabledOverrideRuleIds: [...ids, rule.id] }));
|
||||
return ops;
|
||||
}
|
||||
|
||||
/** Die verknüpfte Vorlage einer Ansicht/eines Ausschnitts (nur bei `templateLinked`). */
|
||||
export function linkedTemplate(p: Project, target: { templateId?: string; templateLinked?: boolean } | undefined): ViewTemplate | undefined {
|
||||
if (!target?.templateId || !target.templateLinked) return undefined;
|
||||
|
||||
Reference in new issue
Block a user