From: Bill Erickson Date: Thu, 15 Aug 2019 15:40:23 +0000 (-0400) Subject: LP1840050 org unit admin UI WIP X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=6ec44c4ffedce15accd4e19d9794fdeb6c6b90ad;p=working%2FEvergreen.git LP1840050 org unit admin UI WIP Signed-off-by: Bill Erickson --- diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.html b/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.html index 4389217eb8..8b600a92b7 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.html @@ -14,7 +14,7 @@ - {{org.name()}} ({{org.shortname()}}) + {{org.name()}} -- {{org.shortname()}} @@ -26,31 +26,39 @@
-
- {{currentOrg().name()}} ({{currentOrg().shortname()}}) +
+ + {{currentOrg().name()}} ({{currentOrg().shortname()}}) + + + Add Name +
- +
- +
@@ -93,7 +101,8 @@
- +
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.ts index e2ade99955..6c86587921 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit.component.ts @@ -42,11 +42,20 @@ export class OrgUnitComponent implements OnInit { // stubbing out in case we need it. } - orgSaved(orgId: number) { - if (!orgId && this.currentOrg()) { - orgId = this.currentOrg().id(); + orgSaved(orgId: number | IdlObject) { + let id; + + if (orgId) { // new org created, focus it. + id = typeof orgId === 'object' ? orgId.id() : orgId; + } else if (this.currentOrg()) { + id = this.currentOrg().id(); } - this.loadAouTree(orgId).then(_ => this.postUpdate(this.editString)); + + this.loadAouTree(id).then(_ => this.postUpdate(this.editString)); + } + + orgDeleted() { + this.loadAouTree(); } loadAouTree(selectNodeId?: number): Promise { @@ -57,11 +66,10 @@ export class OrgUnitComponent implements OnInit { ]}}, {authoritative: true} ).toPromise().then(tree => { this.ingestAouTree(tree); - if (selectNodeId) { - const node = this.tree.findNode(selectNodeId); - this.selected = node; - this.tree.selectNode(node); - } + if (!selectNodeId) { selectNodeId = this.org.root().id(); } + const node = this.tree.findNode(selectNodeId); + this.selected = node; + this.tree.selectNode(node); }); } @@ -179,6 +187,11 @@ export class OrgUnitComponent implements OnInit { return this.selected ? this.selected.callerData.orgUnit : null; } + orgHasChildren(): boolean { + const org = this.currentOrg(); + return (org && org.children().length > 0); + } + postUpdate(message: StringComponent) { // Modifying org unit types means refetching the org unit // data normally fetched on page load, since it includes @@ -242,13 +255,14 @@ export class OrgUnitComponent implements OnInit { addChild() { const parentTreeNode = this.selected; - const parentOrg = parentTreeNode.callerData.orgUnit; + const parentOrg = this.currentOrg(); const newType = this.orgChildTypes()[0]; const org = this.idl.create('aou'); org.isnew(true); org.parent_ou(parentOrg.id()); org.ou_type(newType.id()); + org.children([]); // Create a dummy, detached org node to keep the UI happy. this.selected = new TreeNode({