Bladeren bron

Inspector - Filter can now work on children

Temechon 8 jaren geleden
bovenliggende
commit
cb8ff850a1
2 gewijzigde bestanden met toevoegingen van 15 en 10 verwijderingen
  1. 5 0
      inspector/src/tabs/PropertyTab.ts
  2. 10 10
      inspector/src/tree/TreeItem.ts

+ 5 - 0
inspector/src/tabs/PropertyTab.ts

@@ -136,6 +136,11 @@ module INSPECTOR{
                 if (item.id.toLowerCase().indexOf(filter.toLowerCase()) != -1) {
                     items.push(item);
                 }
+                for (let child of item.children) {
+                    if (child.id.toLowerCase().indexOf(filter.toLowerCase()) != -1) {
+                        items.push(item);
+                    }
+                }
             }    
             this.update(items);
         }

+ 10 - 10
inspector/src/tree/TreeItem.ts

@@ -7,7 +7,7 @@
         // The object this item is linked to (should be a primitive or a canvas) TODO should be superclass of all primitives
         private _adapter    : Adapter;
         private _tools      : Array<AbstractTreeTool>;
-        private _children   : Array<TreeItem> = [];
+        public children     : Array<TreeItem> = [];
         // Div element that contains all children of this node.
         private _lineContent: HTMLElement;  
 
@@ -29,7 +29,7 @@
 
         /** Add the given item as a child of this one */
         public add(child:TreeItem) {
-            this._children.push(child);
+            this.children.push(child);
             this.update();
         }
 
@@ -51,8 +51,8 @@
         /** hide all children of this item */
         public fold() {
             // Do nothing id no children
-            if (this._children.length > 0) {
-                for (let elem of this._children) {
+            if (this.children.length > 0) {
+                for (let elem of this.children) {
                     elem.toHtml().style.display = 'none';
                 }
                 this._div.classList.add('folded');
@@ -62,8 +62,8 @@
         /** Show all children of this item */
         public unfold() {
             // Do nothing id no children
-            if (this._children.length > 0) {
-                for (let elem of this._children) {
+            if (this.children.length > 0) {
+                for (let elem of this.children) {
                     elem.toHtml().style.display = 'block';
                 }
                 this._div.classList.add('unfolded');
@@ -110,11 +110,11 @@
             // Clean division holding all children
             Helpers.CleanDiv(this._lineContent);
 
-            for (let child of this._children) {
+            for (let child of this.children) {
                 let elem = child.toHtml();
                 this._lineContent.appendChild(elem);
             }
-            if (this._children.length > 0) {
+            if (this.children.length > 0) {
                 // Check if folded or not
                 if (!this._div.classList.contains('folded') && !this._div.classList.contains('unfolded')) {
                     this._div.classList.add('folded');
@@ -155,7 +155,7 @@
         public highlight(b:boolean) {
             // Remove highlight for all children 
             if (!b) {
-                for (let child of this._children) {
+                for (let child of this.children) {
                     child._adapter.highlight(b);
                 }
             }
@@ -171,7 +171,7 @@
         /** Set this item as active (background lighter) in the tree panel */
         public active(b:boolean) {
             this._div.classList.remove('active');
-            for (let child of this._children) {
+            for (let child of this.children) {
                 child.active(false);
             }
             if (b) {