From 2d85be5411e153766fe9383a69392f3fc9324d37 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Mon, 23 Jul 2018 17:43:09 -0400 Subject: [PATCH] LP#1775466 Tree widget minor tweaks Signed-off-by: Bill Erickson --- .../src/eg2/src/app/share/tree/tree.component.html | 2 +- .../src/eg2/src/app/share/tree/tree.component.ts | 2 +- Open-ILS/src/eg2/src/app/share/tree/tree.ts | 46 +++++++++++++++------- 3 files changed, 33 insertions(+), 17 deletions(-) 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 80125b3ec2..525fece16a 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 @@ -13,7 +13,7 @@   - 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 d933957000..d02238dfd6 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 @@ -51,7 +51,7 @@ export class TreeComponent implements OnInit { } handleNodeClick(node: TreeNode) { - this.tree.activateNode(node); + this.tree.selectNode(node); this.nodeClicked.emit(node); } } 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 f230780d28..2eb500e1d6 100644 --- a/Open-ILS/src/eg2/src/app/share/tree/tree.ts +++ b/Open-ILS/src/eg2/src/app/share/tree/tree.ts @@ -1,23 +1,39 @@ export class TreeNode { + // Unique identifier id: any; + + // Display label label: string; + + // True if child nodes should be visible expanded: boolean; + children: TreeNode[]; + + // Set by the tree. depth: number; - active: boolean; + + // Set by the tree. + selected: boolean; + + // Optional link to user-provided stuff. + // This field is ignored by the tree. + callerData: any; constructor(values: {[key: string]: any}) { this.children = []; this.expanded = false; this.depth = 0; - this.active = false; - if (values) { - if ('id' in values) { this.id = values.id; } - if ('label' in values) { this.label = values.label; } - if ('children' in values) { this.children = values.children; } - if ('expanded' in values) { this.expanded = values.expanded; } - } + this.selected = false; + + if (!values) { return; } + + if ('id' in values) { this.id = values.id; } + if ('label' in values) { this.label = values.label; } + if ('children' in values) { this.children = values.children; } + if ('expanded' in values) { this.expanded = values.expanded; } + if ('callerData' in values) { this.callerData = values.callerData; } } toggleExpand() { @@ -49,8 +65,8 @@ export class Tree { this.idMap[node.id + ''] = node; if (hidden) { - // it could be confusing for a hidden node to be active. - node.active = false; + // it could be confusing for a hidden node to be selected. + node.selected = false; } if (hidden && filterHidden) { @@ -105,13 +121,13 @@ export class Tree { this.nodeList().forEach(node => node.expanded = false); } - activeNode(): TreeNode { - return this.nodeList().filter(node => node.active)[0]; + selectedNode(): TreeNode { + return this.nodeList().filter(node => node.selected)[0]; } - activateNode(node: TreeNode) { - this.nodeList().forEach(n => n.active = false); - node.active = true; + selectNode(node: TreeNode) { + this.nodeList().forEach(n => n.selected = false); + node.selected = true; } } -- 2.11.0