[256] Klassen-Füllung im Ebenen-Editor bearbeitbar (Farbwähler + keine, auch im macOS-Ebenenfenster)

This commit is contained in:
Claude committed 2026-11-14 07:01:45 +00:00
1 parent 9a796ac7d6
commit a1fb4fc134
9 files changed
+87 -4

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
// [256] Klassen-Füllung (`LayerCategory.fill`) über den Store setzen, entfernen, zurücknehmen; Ziehen im Farbwähler = ein Undo-Schritt.
import { beforeEach, describe, expect, it } from "vitest";
import { getState } from "./appStore";
import { findCategory } from "../model/layers";
import { sampleProject } from "../model/sampleProject";
const st = () => getState();
const code = () => st().project.layers[0].code;
const fill = () => findCategory(st().project.layers, code())?.fill;
beforeEach(() => {
st().loadProject(structuredClone(sampleProject));
st().clearHistory();
});
describe("Klassen-Füllung bearbeiten ([256])", () => {
it("setzt, entfernt und nimmt zurück", () => {
st().patchCategory(code(), { fill: "#d9d9d9" });
expect(fill()).toBe("#d9d9d9");
st().patchCategory(code(), { name: "X" }); // beendet die Zusammenfassung
st().patchCategory(code(), { fill: undefined });
expect(fill()).toBeUndefined();
expect(findCategory(st().project.layers, code())).not.toHaveProperty("fill", null);
st().undo();
st().undo();
expect(fill()).toBe("#d9d9d9");
st().undo();
expect(fill()).toBeUndefined();
});
it("Ziehen im Farbwähler ist ein Undo-Schritt", () => {
for (const c of ["#111111", "#222222", "#333333"]) st().patchCategory(code(), { fill: c });
expect(fill()).toBe("#333333");
st().undo();
expect(fill()).toBeUndefined();
});
});
+5 -1
View File
@@ -863,7 +863,11 @@ export function createProjectSlice(
}),
patchCategory: (code, patch) =>
applyChange((p) => fieldOps(p, "layers", patchCategoryByCode(p.layers, code, patch))),
applyChange(
(p) => fieldOps(p, "layers", patchCategoryByCode(p.layers, code, patch)),
// [256] Ziehen im Farbwähler der Klassen-Füllung = ein Undo-Schritt.
Object.keys(patch).length === 1 && "fill" in patch ? `layer-fill:${code}` : undefined,
),
addSubCategory: (parentCode) =>
applyChange((p) => {