[66] Merge: Präsentationsplan mit einem Klick (site_and_shadow mit Massstab und Baurecht-Schalter)
This commit is contained in:
28 files changed
+1184
-39
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import { COMMANDS, ALIASES } from "../registry";
|
||||
import { setPresentationDialogOpener } from "../../state/presentationSheetHook";
|
||||
import { createPresentationSheet } from "../../state/presentationSheet";
|
||||
import { getState } from "../../state/appStore";
|
||||
import { buildComplexSampleProject } from "../../model/sampleProjectComplex";
|
||||
import { presentationDefaults } from "../../core";
|
||||
|
||||
describe("[66] Befehl praesentation", () => {
|
||||
beforeEach(() => {
|
||||
getState().loadProject(buildComplexSampleProject());
|
||||
getState().clearHistory();
|
||||
});
|
||||
|
||||
it("Aliase führen auf den Befehl, der den Dialog öffnet", () => {
|
||||
expect(ALIASES.praesentationsplan).toBe("praesentation");
|
||||
expect(ALIASES.presentation).toBe("praesentation");
|
||||
let opened = 0;
|
||||
setPresentationDialogOpener(() => opened++);
|
||||
const res = COMMANDS.praesentation.autoRun!({} as never);
|
||||
expect(res.done).toBe(true);
|
||||
expect(opened).toBe(1);
|
||||
setPresentationDialogOpener(null);
|
||||
});
|
||||
|
||||
it("Bestätigen legt das Blatt in EINEM Undo-Schritt an", () => {
|
||||
const before = getState().project;
|
||||
const o = presentationDefaults(before);
|
||||
const id = createPresentationSheet({ ...o, sketch: true });
|
||||
expect(id).toBeTruthy();
|
||||
const p = getState().project;
|
||||
const lay = p.layouts!.find((l) => l.id === id)!;
|
||||
expect(lay.viewports.length).toBeGreaterThanOrEqual(o.floors.length);
|
||||
expect(p.drawingLevels.some((l) => l.sketch)).toBe(true);
|
||||
expect(getState().undoDepth).toBe(1);
|
||||
getState().undo();
|
||||
const q = getState().project;
|
||||
expect(q.layouts?.some((l) => l.id === id)).toBe(false);
|
||||
expect(q.drawingLevels.some((l) => l.sketch)).toBe(false);
|
||||
expect(q.drawingLevels.length).toBe(before.drawingLevels.length);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
// [66] Präsentationsplan — öffnet den Dialog (in App montiert) und endet sofort; das Blatt entsteht beim
|
||||
// Bestätigen in einem Undo-Schritt (`state/presentationSheet.ts`). Muster wie `import`.
|
||||
|
||||
import { openPresentationDialog } from "../../state/presentationSheetHook";
|
||||
import type { Command, CommandResult, CommandState } from "../types";
|
||||
|
||||
const IDLE: CommandState = { phase: "idle", lastPoint: null };
|
||||
|
||||
function open(): [CommandState, CommandResult] {
|
||||
openPresentationDialog();
|
||||
return [{ ...IDLE }, { draft: null, done: true }];
|
||||
}
|
||||
|
||||
export const presentationCommand: Command = {
|
||||
name: "praesentation",
|
||||
labelKey: "cmd.praesentation.label",
|
||||
prompt: () => "cmd.praesentation.prompt",
|
||||
accepts: () => [],
|
||||
options: () => [],
|
||||
init: () => ({ ...IDLE }),
|
||||
autoRun: (): CommandResult => {
|
||||
openPresentationDialog();
|
||||
return { draft: null, done: true };
|
||||
},
|
||||
onInput: () => open(),
|
||||
onMove: (state): [CommandState, CommandResult] => [state, { draft: null }],
|
||||
onConfirm: () => open(),
|
||||
onCancel: (): [CommandState, CommandResult] => [{ ...IDLE }, { draft: null, done: true }],
|
||||
};
|
||||
@@ -71,6 +71,7 @@ import { sectionLineCommand, viewLineCommand } from "./cmds/sectionline";
|
||||
import { georefCommand } from "./cmds/georef";
|
||||
import { blockCommand } from "./cmds/block";
|
||||
import { defblockCommand } from "./cmds/defblock";
|
||||
import { presentationCommand } from "./cmds/presentation";
|
||||
|
||||
/** Alle bekannten Befehle, Schlüssel = Befehlsname (lowercase). */
|
||||
export const COMMANDS: Record<string, Command> = {
|
||||
@@ -140,6 +141,7 @@ export const COMMANDS: Record<string, Command> = {
|
||||
chamfer: chamferCommand,
|
||||
multiline: multilineCommand,
|
||||
import: importCommand,
|
||||
praesentation: presentationCommand,
|
||||
terrain: terrainCommand,
|
||||
excavation: excavationCommand,
|
||||
measure: measureCommand,
|
||||
@@ -184,6 +186,9 @@ export const ALIASES: Record<string, string> = {
|
||||
dachfenster: "roofwindow",
|
||||
oberlicht: "roofwindow",
|
||||
gaube: "dormer",
|
||||
praesentationsplan: "praesentation",
|
||||
präsentation: "praesentation",
|
||||
presentation: "praesentation",
|
||||
lukarne: "dormer",
|
||||
dachhof: "roofhole",
|
||||
lichthof: "roofhole",
|
||||
|
||||
Reference in new issue
Block a user