Add cell copy/paste, multi-row edits and a context menu to the circuit grid
Ctrl+C/Ctrl+V copy and paste grid cells without opening an editor, using the document copy/paste events so it also works over plain HTTP in the LAN. Protection and cable summaries copy the complete circuit record; tab-separated blocks from Excel spread over visible rows and columns. With a Ctrl/Shift multi-selection, typing, pasting and the protection dialog apply to every selected row that can take the value, including device power and GZF; other cells are skipped and reported. All of these writes use the new circuit-list.bulk-update command. It carries complete circuit.update, circuit-device-row.update and circuit-protection.update commands, applies them with the single-command rules in one transaction and stores the reversed inverses, so each edit is one undo step. The single-command apply logic is extracted for reuse. A right-click menu (also context-menu key / Shift+F10) offers copy, paste, edit, protection, cable sizing, insert circuit below, add device and delete. The protection summary is now selected by click and opened by double click, Enter or F2. Existing numbers open in the inline editor with a decimal comma, so confirming an unchanged decimal no longer fails. Refs #26 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
07bc52a134
commit
17a3945813
18 changed files with 2548 additions and 391 deletions
|
|
@ -0,0 +1,69 @@
|
|||
import { circuitDeviceRowUpdateCommandType } from "../../domain/models/circuit-device-row-project-command.model.js";
|
||||
import {
|
||||
assertCircuitListBulkUpdateProjectCommand,
|
||||
createCircuitListBulkUpdateProjectCommand,
|
||||
type CircuitListBulkUpdateEntry,
|
||||
} from "../../domain/models/circuit-list-bulk-update-project-command.model.js";
|
||||
import { circuitUpdateCommandType } from "../../domain/models/circuit-project-command.model.js";
|
||||
import type {
|
||||
CircuitListBulkUpdateProjectCommandStore,
|
||||
ExecuteCircuitListBulkUpdateCommandInput,
|
||||
} from "../../domain/ports/circuit-list-bulk-update-project-command.store.js";
|
||||
import type { AppDatabase } from "../database-context.js";
|
||||
import { applyCircuitDeviceRowUpdateCommand } from "./circuit-device-row-project-command.repository.js";
|
||||
import { applyCircuitUpdateCommand } from "./circuit-project-command.repository.js";
|
||||
import { applyCircuitProtectionUpdateCommand } from "./circuit-protection-project-command.repository.js";
|
||||
import { executeProjectCommandTransactionWithAppliedForward } from "./project-command-transaction.persistence.js";
|
||||
|
||||
export class CircuitListBulkUpdateProjectCommandRepository
|
||||
implements CircuitListBulkUpdateProjectCommandStore
|
||||
{
|
||||
constructor(private readonly database: AppDatabase) {}
|
||||
|
||||
// Applies every update with the same rules as its single command inside
|
||||
// one transaction. Any rejected update rolls the whole edit back.
|
||||
execute(input: ExecuteCircuitListBulkUpdateCommandInput) {
|
||||
assertCircuitListBulkUpdateProjectCommand(input.command);
|
||||
return executeProjectCommandTransactionWithAppliedForward(
|
||||
this.database,
|
||||
input,
|
||||
(tx) => {
|
||||
const forward: CircuitListBulkUpdateEntry[] = [];
|
||||
const inverse: CircuitListBulkUpdateEntry[] = [];
|
||||
for (const update of input.command.payload.updates) {
|
||||
const applied = applyBulkUpdateEntry(tx, input, update);
|
||||
forward.push(applied.forward);
|
||||
inverse.unshift(applied.inverse);
|
||||
}
|
||||
return {
|
||||
forward: createCircuitListBulkUpdateProjectCommand(forward),
|
||||
inverse: createCircuitListBulkUpdateProjectCommand(inverse),
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function applyBulkUpdateEntry(
|
||||
tx: AppDatabase,
|
||||
input: ExecuteCircuitListBulkUpdateCommandInput,
|
||||
update: CircuitListBulkUpdateEntry
|
||||
): { forward: CircuitListBulkUpdateEntry; inverse: CircuitListBulkUpdateEntry } {
|
||||
const context = { projectId: input.projectId, source: input.source };
|
||||
if (update.type === circuitUpdateCommandType) {
|
||||
return applyCircuitUpdateCommand(tx, { ...context, command: update });
|
||||
}
|
||||
if (update.type === circuitDeviceRowUpdateCommandType) {
|
||||
return applyCircuitDeviceRowUpdateCommand(tx, {
|
||||
...context,
|
||||
command: update,
|
||||
});
|
||||
}
|
||||
return {
|
||||
forward: update,
|
||||
inverse: applyCircuitProtectionUpdateCommand(tx, {
|
||||
...context,
|
||||
command: update,
|
||||
}),
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue