Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Stepan Kiryakov <[email protected]>
  • Loading branch information
Stepan-Kirjakov committed Dec 30, 2024
1 parent 4793d46 commit 7d8fe0b
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class LabelConfig {
this.menu = NavMenu.from(item);
this.navigationTree = NavTree.from(item);
this.navigationTree.update();
this.updateSelected();
}

public setPolicy(relationships: any) {
Expand Down Expand Up @@ -119,6 +120,13 @@ export class LabelConfig {
this.selectedNavItem = node;
}

public updateSelected() {
if (this.selectedNavItem) {
const key = this.selectedNavItem.key;
this.selectedNavItem = this.navigationTree.getItem(key);
}
}

public ifNavSelected(node: NavItem) {
if (this.selectedNavItem) {
return this.selectedNavItem.key === node.key;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,21 @@ export class NavItem implements TreeNode {
}
return null;
}

public getItem(key: string): NavItem | null {
if (this.key === key) {
return this;
}
if (Array.isArray(this.children)) {
for (const node of this.children) {
const result = node.getItem(key);
if (result) {
return result;
}
}
}
return null;
}
}

export class NavTree {
Expand All @@ -323,6 +338,16 @@ export class NavTree {
this._deleteNode(this.data, node);
}

public getItem(key: string): NavItem | null {
for (const node of this.data) {
const result = node.getItem(key);
if (result) {
return result;
}
}
return null;
}

private _deleteNode(nodes: NavItem[] | undefined, node: NavItem): void {
if (!Array.isArray(nodes)) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,8 @@
<div class="navigation-toolbar-group-title">{{group.title}}</div>
</div>
<div *ngFor="let item of group.items" class="navigation-toolbar-group-item"
pDraggable="navigationTree" (onDragStart)="labelConfig.dragMenuStart(item)"
pDraggable="navigationTree"
(onDragStart)="labelConfig.dragMenuStart(item)"
(onDragEnd)="labelConfig.dragMenuEnd()">
<div class="navigation-toolbar-group-item-icon">
<svg-icon class="icon-btn svg-icon-16"
Expand All @@ -247,9 +248,13 @@
<div *ngIf="labelConfig.draggedMenuItem" class="navigation-drop-area" pDroppable="navigationTree"
(onDrop)="labelConfig.onDrop()"></div>
<div class="navigation-tree-area">
<p-tree class="navigation-tree guardian-tree" [value]="labelConfig.navigationTree.data"
[draggableNodes]="true" [droppableNodes]="true" draggableScope="navigationTree"
droppableScope="navigationTree" [validateDrop]="true"
<p-tree class="navigation-tree guardian-tree"
[value]="labelConfig.navigationTree.data"
[draggableNodes]="true"
[droppableNodes]="true"
draggableScope="navigationTree"
droppableScope="navigationTree"
[validateDrop]="true"
[selectionMode]="labelConfig.navigationTree.mode"
(onNodeDrop)="labelConfig.onDropValidator($event)">
<ng-template let-expanded pTemplate="togglericon">
Expand Down

0 comments on commit 7d8fe0b

Please sign in to comment.