TSK-601 Bug Fix tree component filtering
This commit is contained in:
parent
14aa61bd7c
commit
baaf53ec1c
|
|
@ -64,17 +64,13 @@ export class TaskanaTreeComponent implements OnInit, AfterViewChecked {
|
||||||
this.unSelectActiveNode();
|
this.unSelectActiveNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.filterTextOld !== this.filterText) {
|
if (this.filterTextOld !== this.filterText ||
|
||||||
this.filterTextOld = this.filterText;
|
this.filterIconOld !== this.filterIcon) {
|
||||||
this.filterNodes(this.filterText);
|
|
||||||
this.manageTreeState();
|
|
||||||
}
|
|
||||||
if (this.filterIconOld !== this.filterIcon) {
|
|
||||||
this.filterIconOld = this.filterIcon;
|
this.filterIconOld = this.filterIcon;
|
||||||
this.filterNodes(this.filterIcon);
|
this.filterTextOld = this.filterText;
|
||||||
|
this.filterNodes(this.filterText ? this.filterText : '', this.filterIcon);
|
||||||
this.manageTreeState();
|
this.manageTreeState();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onActivate(treeNode: any) {
|
onActivate(treeNode: any) {
|
||||||
|
|
@ -118,20 +114,26 @@ export class TaskanaTreeComponent implements OnInit, AfterViewChecked {
|
||||||
this.expandParent(node.parent);
|
this.expandParent(node.parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
private filterNodes(text) {
|
private filterNodes(text, iconText) {
|
||||||
this.tree.treeModel.filterNodes((node) => {
|
this.tree.treeModel.filterNodes((node) => {
|
||||||
return (node.data.name.toUpperCase().includes(text.toUpperCase())
|
return this.checkNameAndKey(node, text) &&
|
||||||
|| node.data.key.toUpperCase().includes(text.toUpperCase())
|
this.checkIcon(node, iconText);
|
||||||
|| node.data.category.toUpperCase().includes(text.toUpperCase()));
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private checkNameAndKey(node: any, text: string): boolean {
|
||||||
|
return (node.data.name.toUpperCase().includes(text.toUpperCase())
|
||||||
|
|| node.data.key.toUpperCase().includes(text.toUpperCase()))
|
||||||
|
}
|
||||||
|
private checkIcon(node: any, iconText: string): boolean {
|
||||||
|
return (node.data.category.toUpperCase() === iconText.toUpperCase()
|
||||||
|
|| iconText === '')
|
||||||
|
}
|
||||||
|
|
||||||
private manageTreeState() {
|
private manageTreeState() {
|
||||||
if (this.filterText === '') {
|
if (this.filterText === '') {
|
||||||
this.tree.treeModel.collapseAll();
|
this.tree.treeModel.collapseAll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue