Reorder circuit groups
This commit is contained in:
@@ -52,6 +52,7 @@ import {
|
||||
buildCircuitSectionRenumberAssignments,
|
||||
} from "../utils/circuit-section-renumber-command";
|
||||
import {
|
||||
buildCircuitGroupReorderAssignments,
|
||||
buildNewCircuitGroupSnapshot,
|
||||
canDeleteCircuitGroup,
|
||||
renameCircuitGroupSnapshot,
|
||||
@@ -95,6 +96,7 @@ import {
|
||||
moveCircuitDeviceRowsToNewCircuitCommand,
|
||||
reorderCircuitSectionCommand,
|
||||
reorderCircuitSectionsCommand,
|
||||
reorderCircuitGroupsCommand,
|
||||
renumberCircuitSectionCommand,
|
||||
redoProjectCommand,
|
||||
updateCircuitById,
|
||||
@@ -1235,6 +1237,36 @@ export function CircuitTreeEditor(props: { projectId: string; circuitListId: str
|
||||
});
|
||||
}
|
||||
|
||||
async function handleMoveCircuitGroup(
|
||||
groupId: string,
|
||||
direction: -1 | 1
|
||||
) {
|
||||
if (!data) {
|
||||
return;
|
||||
}
|
||||
const assignments = buildCircuitGroupReorderAssignments(
|
||||
data.sections,
|
||||
groupId,
|
||||
direction
|
||||
);
|
||||
if (!assignments) {
|
||||
return;
|
||||
}
|
||||
await runCommand({
|
||||
label: "Stromkreisgruppen sortieren",
|
||||
redo: async () => {
|
||||
const result = await reorderCircuitGroupsCommand(
|
||||
projectId,
|
||||
getExpectedProjectRevision(),
|
||||
circuitListId,
|
||||
assignments
|
||||
);
|
||||
applyProjectCommandResult(result);
|
||||
return null;
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async function handleSaveCircuitProtection(
|
||||
protection: CircuitTreeProtectionDeviceDto
|
||||
) {
|
||||
@@ -3477,6 +3509,40 @@ export function CircuitTreeEditor(props: { projectId: string; circuitListId: str
|
||||
>
|
||||
Gruppe bearbeiten
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
tabIndex={-1}
|
||||
disabled={
|
||||
!buildCircuitGroupReorderAssignments(
|
||||
data.sections,
|
||||
section.id,
|
||||
-1
|
||||
)
|
||||
}
|
||||
onClick={() =>
|
||||
void handleMoveCircuitGroup(section.id, -1)
|
||||
}
|
||||
title="Innerhalb derselben Kategorie nach oben verschieben"
|
||||
>
|
||||
Gruppe nach oben
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
tabIndex={-1}
|
||||
disabled={
|
||||
!buildCircuitGroupReorderAssignments(
|
||||
data.sections,
|
||||
section.id,
|
||||
1
|
||||
)
|
||||
}
|
||||
onClick={() =>
|
||||
void handleMoveCircuitGroup(section.id, 1)
|
||||
}
|
||||
title="Innerhalb derselben Kategorie nach unten verschieben"
|
||||
>
|
||||
Gruppe nach unten
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
tabIndex={-1}
|
||||
|
||||
Reference in New Issue
Block a user