From: Jason Etheridge Date: Sun, 30 Apr 2023 20:10:01 +0000 (-0400) Subject: tree X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=73b6b7ada14ffcf4cae5537f46c4b0b9d05cbb58;p=working%2FEvergreen.git tree --- diff --git a/Open-ILS/src/eg2/src/app/share/tree/tree.component.html b/Open-ILS/src/eg2/src/app/share/tree/tree.component.html index 525fece16a..0ac2c5720a 100644 --- a/Open-ILS/src/eg2/src/app/share/tree/tree.component.html +++ b/Open-ILS/src/eg2/src/app/share/tree/tree.component.html @@ -1,8 +1,13 @@ - - + + +
+
@@ -18,3 +23,5 @@
+ + diff --git a/Open-ILS/src/eg2/src/app/share/tree/tree.component.ts b/Open-ILS/src/eg2/src/app/share/tree/tree.component.ts index 2a60270128..5709e58dd1 100644 --- a/Open-ILS/src/eg2/src/app/share/tree/tree.component.ts +++ b/Open-ILS/src/eg2/src/app/share/tree/tree.component.ts @@ -49,6 +49,10 @@ export class TreeComponent { return this._tree; } + @Input() showTogglers: boolean = false; // expand all / collapse all + @Input() showSelectors: boolean = false; // the checkboxes, etc. + @Input() disableRootSelector: boolean = false; // checkbox at the top of the tree + @Output() nodeClicked: EventEmitter; constructor() { @@ -64,6 +68,44 @@ export class TreeComponent { this.tree.selectNode(node); this.nodeClicked.emit(node); } + + expandAll() { + if (this.tree) { + this.tree.expandAll(); + } + } + + collapseAll() { + if (this.tree) { + this.tree.collapseAll(); + } + } + + selectAll() { + if (this.tree) { + this.tree.nodeList().forEach(node => { + if (!(this.disableRootSelector && node === this.tree.rootNode)) { + node.selected = true; + } + }); + } + } + + deselectAll() { + if (this.tree) { + this.tree.nodeList().forEach(node => { + if (!(this.disableRootSelector && node === this.tree.rootNode)) { + node.selected = false; + } + }); + } + } + + handleNodeCheck(node: TreeNode) { + // If needed, add logic here to handle the case where + // a node's checkbox was clicked. + } + } diff --git a/Open-ILS/src/eg2/src/app/share/tree/tree.ts b/Open-ILS/src/eg2/src/app/share/tree/tree.ts index 68e01fee9f..6d72d30fd3 100644 --- a/Open-ILS/src/eg2/src/app/share/tree/tree.ts +++ b/Open-ILS/src/eg2/src/app/share/tree/tree.ts @@ -113,20 +113,39 @@ export class Tree { } expandAll() { - this.nodeList().forEach(node => node.expanded = true); + if (this.rootNode) { + this.nodeList().forEach(node => node.expanded = true); + } } collapseAll() { - this.nodeList().forEach(node => node.expanded = false); + if (this.rootNode) { + this.nodeList().forEach(node => node.expanded = false); + } } selectedNode(): TreeNode { return this.nodeList().filter(node => node.selected)[0]; } + selectedNodes(): TreeNode[] { + return this.nodeList().filter(node => node.selected); + } + selectNode(node: TreeNode) { this.nodeList().forEach(n => n.selected = false); node.selected = true; } + + selectNodes(nodes: TreeNode[]) { + this.nodeList().forEach(n => n.selected = false); + nodes.forEach(node => { + let foundNode = this.findNode(node.id); + if (foundNode) { + foundNode.selected = true; + } + }); + } + }