LP1840050 Anguar tree component realtime updates
authorBill Erickson <berickxx@gmail.com>
Fri, 16 Aug 2019 20:50:34 +0000 (16:50 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Fri, 6 Sep 2019 16:58:25 +0000 (12:58 -0400)
Teach the Angular tree component to re-render itself when its underyling
tree has been replaced.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/share/tree/tree.component.ts

index f519268..64dd298 100644 (file)
@@ -37,7 +37,18 @@ nodeClicked(node: TreeNode) {
 })
 export class TreeComponent implements OnInit {
 
-    @Input() tree: Tree;
+    _tree: Tree;
+    @Input() set tree(t: Tree) {
+        if (t) {
+            this._tree = t;
+            this._tree.nodeList(); // reindex nodes
+        }
+    }
+
+    get tree(): Tree {
+        return this._tree;
+    }
+
     @Output() nodeClicked: EventEmitter<TreeNode>;
 
     constructor() {