UI: Refactoring

This commit is contained in:
Artem Dzhereleiko 2025-03-12 12:03:15 +02:00
parent 492ae5dece
commit fdfb9264ad
2 changed files with 3 additions and 6 deletions

View File

@ -52,10 +52,6 @@ export interface NavTreeEditCallbacks {
clearSearch?: () => void; clearSearch?: () => void;
} }
interface JSTreeEventDataWithAction extends JSTreeEventData {
action: string;
}
export type NodesCallback = (nodes: NavTreeNode[]) => void; export type NodesCallback = (nodes: NavTreeNode[]) => void;
export type LoadNodesCallback = (node: NavTreeNode, cb: NodesCallback) => void; export type LoadNodesCallback = (node: NavTreeNode, cb: NodesCallback) => void;
export type NodeSearchCallback = (searchText: string, node: NavTreeNode) => boolean; export type NodeSearchCallback = (searchText: string, node: NavTreeNode) => boolean;
@ -153,9 +149,9 @@ export class NavTreeComponent implements OnInit {
this.treeElement = $('.tb-nav-tree-container', this.elementRef.nativeElement).jstree(config); this.treeElement = $('.tb-nav-tree-container', this.elementRef.nativeElement).jstree(config);
this.treeElement.on('changed.jstree', (e: any, data: JSTreeEventDataWithAction) => { this.treeElement.on('changed.jstree', (e: any, data) => {
const node: NavTreeNode = data.instance.get_selected(true)[0];
if (this.onNodeSelected && data.action !== 'ready') { if (this.onNodeSelected && data.action !== 'ready') {
const node: NavTreeNode = data.instance.get_selected(true)[0];
this.ngZone.run(() => this.onNodeSelected(node, e as Event)); this.ngZone.run(() => this.onNodeSelected(node, e as Event));
} }
}); });

View File

@ -27,6 +27,7 @@ interface JQuery {
interface JSTreeEventData { interface JSTreeEventData {
instance: JSTree; instance: JSTree;
action: string;
} }
interface JSTreeModelEventData extends JSTreeEventData { interface JSTreeModelEventData extends JSTreeEventData {