TSK-601 Bug Fix tree component filtering

This commit is contained in:
Martin Rojas Miguel Angel 2018-06-27 18:35:03 +02:00 committed by Holger Hagen
parent 14aa61bd7c
commit baaf53ec1c
1 changed files with 16 additions and 14 deletions

View File

@ -64,17 +64,13 @@ export class TaskanaTreeComponent implements OnInit, AfterViewChecked {
this.unSelectActiveNode();
}
if (this.filterTextOld !== this.filterText) {
this.filterTextOld = this.filterText;
this.filterNodes(this.filterText);
this.manageTreeState();
}
if (this.filterIconOld !== this.filterIcon) {
if (this.filterTextOld !== this.filterText ||
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();
}
}
onActivate(treeNode: any) {
@ -118,20 +114,26 @@ export class TaskanaTreeComponent implements OnInit, AfterViewChecked {
this.expandParent(node.parent);
}
private filterNodes(text) {
private filterNodes(text, iconText) {
this.tree.treeModel.filterNodes((node) => {
return (node.data.name.toUpperCase().includes(text.toUpperCase())
|| node.data.key.toUpperCase().includes(text.toUpperCase())
|| node.data.category.toUpperCase().includes(text.toUpperCase()));
return this.checkNameAndKey(node, text) &&
this.checkIcon(node, iconText);
});
}
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() {
if (this.filterText === '') {
this.tree.treeModel.collapseAll();
}
}
}