added marking for affected nodes in hierarchy suggestions

This commit is contained in:
2026-10-25 19:26:28 +01:00
parent 686f6e05fb
commit 2baa01846f
3 changed files with 63 additions and 8 deletions
@@ -1,4 +1,7 @@
<div class="hte-toolbar">
@if (editorStatus === 'in-progress') {
<span class="hte-status-label">In Bearbeitung</span>
}
<button mat-icon-button (click)="rollback()" matTooltip="Zurücksetzen">
<mat-icon>refresh</mat-icon>
</button>
@@ -22,7 +25,11 @@
<div mat-dialog-actions class="hte-actions">
<span class="hte-spacer"></span>
@if (!isManager && numberOfSuggestions <= 0) {
@if (readOnly) {
<span>Nur Ansicht</span>
} @else if (
!isManager && numberOfSuggestions <= 0 && editorStatus !== 'in-progress'
) {
<div
[matTooltip]="
'Sie haben keine Vorschläge mehr übrig, um Änderungen zu speichern.'
@@ -39,9 +46,7 @@
[matTooltip]="
isManager
? 'Diese Änderungen werden direkt in der Hierarchie gespeichert.'
: 'Sie haben noch ' +
numberOfSuggestions +
' Vorschläge übrig, um Änderungen zu speichern.'
: 'Einen Hierarchie-Vorschlag erstellen.'
">
{{
isSuggestion && isManager
@@ -84,12 +89,17 @@
} @else {
<span class="hte-toggle-spacer"></span>
}
<div class="hte-node-label">
<span
class="hte-node-name"
[class.hte-node-name--bold]="hasChild(0, node)">
{{ node.name_de }}
@if (node.affected || node.modified) {
<span
matTooltip="Dieser Knoten wurde von einer Änderung betroffen."
class="affected-indicator"
title="This node was affected"></span>
}
</span>
@if (node.link_de) {
<span class="hte-node-link">{{ node.link_de }}</span>
@@ -111,7 +121,7 @@
</div>
<div class="hte-node-actions">
@if (node.modified !== 'deleted') {
@if (!readOnly && node.modified !== 'deleted') {
<app-add-organization
[item]="node"
(addOrg)="addOrganization($event, node)"
@@ -120,6 +130,7 @@
}
@if (
!readOnly &&
node.type === 'leaf' &&
node.modified !== 'deleted' &&
node.modified !== 'created'
@@ -130,7 +141,7 @@
</app-edit-organization>
}
@if (node.type === 'leaf' || node.modified) {
@if (!readOnly && (node.type === 'leaf' || node.modified)) {
@if (node.modified === 'deleted') {
<button
mat-icon-button
@@ -14,6 +14,11 @@
flex: 1 1 auto;
}
.hte-status-label {
color: var(--sg-text-muted);
font-weight: 600;
}
.hte-content {
max-height: 70vh;
overflow: auto;
@@ -53,7 +58,6 @@
width: 40px;
height: 40px;
}
.hte-node-label {
flex: 1 1 auto;
min-width: 0;
@@ -106,3 +110,12 @@
.created_node {
background-color: rgba(0, 255, 0, 0.1);
}
.affected-indicator {
display: inline-block;
width: 8px;
height: 8px;
background-color: #2196f3;
border-radius: 50%;
margin-left: 6px;
vertical-align: middle;
}
@@ -49,7 +49,9 @@ export class HierarchyTreeEditorComponent {
readonly numberOfSuggestions: number;
readonly isManager: boolean;
readonly isSuggestion: boolean;
readonly readOnly: boolean;
readonly suggestionStatus: HierarchyEditorDialogData['suggestionStatus'];
readonly editorStatus: HierarchyEditorDialogData['editorStatus'];
readonly expanded = new Set<RawNode['id']>();
@@ -81,7 +83,9 @@ export class HierarchyTreeEditorComponent {
this.numberOfSuggestions = data.numberOfSuggestions;
this.isManager = data.isManager;
this.isSuggestion = data.isSuggestion ?? false;
this.readOnly = data.readOnly ?? false;
this.suggestionStatus = data.suggestionStatus;
this.editorStatus = data.editorStatus;
this.originalData = JSON.parse(JSON.stringify(data.tree));
this.initHierarchy();
}
@@ -90,10 +94,29 @@ export class HierarchyTreeEditorComponent {
private initHierarchy(): void {
this.hierarchy = JSON.parse(JSON.stringify(this.originalData));
this.updateAffectedMarkers();
this.expanded.clear();
this.previousStatus.clear();
}
private markAffectedParents(node: RawNode): boolean {
const childAffected = (node.children ?? []).some((child) =>
this.markAffectedParents(child),
);
const affected = childAffected && !node.modified;
if (affected) node['affected'] = true;
return affected || !!node.modified;
}
private updateAffectedMarkers(): void {
const clear = (node: RawNode): void => {
delete node['affected'];
node.children?.forEach(clear);
};
clear(this.hierarchy);
this.markAffectedParents(this.hierarchy);
}
rollback(): void {
this.initHierarchy();
}
@@ -117,6 +140,7 @@ export class HierarchyTreeEditorComponent {
target.value = 0;
}
target.children.unshift(newOrg);
this.updateAffectedMarkers();
}
addAggregator(newAgg: RawNode, target: RawNode): void {
@@ -129,6 +153,7 @@ export class HierarchyTreeEditorComponent {
target.value = 0;
}
target.children.unshift(newAgg);
this.updateAffectedMarkers();
}
editItem(result: OrganizationEditResult, target: RawNode): void {
@@ -143,6 +168,7 @@ export class HierarchyTreeEditorComponent {
target.name_de = result.name_de;
target.link_de = result.link_de;
target.modified = 'updated';
this.updateAffectedMarkers();
}
/* ---------------------------------- structure ---------------------------------- */
@@ -172,12 +198,14 @@ export class HierarchyTreeEditorComponent {
item.children = item.children.filter((c) => c.modified !== 'created');
item.children.forEach((c) => this.markAsDeleted(c));
}
this.updateAffectedMarkers();
}
restoreElement(item: RawNode): void {
this.restoreAncestors(item);
this.restoreOne(item);
this.restoreDescendants(item);
this.updateAffectedMarkers();
}
private restoreOne(item: RawNode): void {
@@ -206,12 +234,14 @@ export class HierarchyTreeEditorComponent {
const index = parent.children.indexOf(item);
if (index !== -1) {
parent.children.splice(index, 1);
this.updateAffectedMarkers();
}
}
/* ----------------------------------- dialog ------------------------------------ */
async save(): Promise<void> {
if (this.readOnly) return;
const cleaned = this.cleanHierarchy(
JSON.parse(JSON.stringify(this.hierarchy)),
);
@@ -223,6 +253,7 @@ export class HierarchyTreeEditorComponent {
}
rejectSuggestion(): void {
if (this.readOnly) return;
if (this.suggestionStatus === 'accepted') return;
this.dialogRef.close({ action: 'reject' } as HierarchyEditorResult);
}