From c46093b378200a44a55f08dd9f34db87b4d8621f Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 13 Aug 2019 12:23:14 -0400 Subject: [PATCH] LP1840050 org unit admin UI WIP Signed-off-by: Bill Erickson --- .../app/share/org-select/org-select.component.ts | 2 +- .../app/staff/admin/server/org-unit.component.html | 62 +++++++++++++++++--- .../app/staff/admin/server/org-unit.component.ts | 66 +++++++++++++++------- 3 files changed, 100 insertions(+), 30 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts b/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts index dee3248939..dc14debcbf 100644 --- a/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts +++ b/Open-ILS/src/eg2/src/app/share/org-select/org-select.component.ts @@ -182,7 +182,7 @@ export class OrgSelectComponent implements OnInit { } // Remove the tree-padding spaces when matching. - formatter = (result: OrgDisplay) => result.label.trim(); + formatter = (result: OrgDisplay) => result ? result.label.trim() : ''; // reset the state of the component reset() { 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 a1ef44a3c8..22ae883593 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 @@ -13,7 +13,7 @@ + dialogBody="Delete Org Unit {{selected ? selected.label : ''}}?">
@@ -22,15 +22,61 @@
- + - - +
+ + +
+
+
+ + +
+
+
Open Time
+
Close Time
+
+
+
Monday
+
+ +
+
+ +
+
+ +
+
+
+
+
+ + +
+ + + + + + + + + + +
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 65b21d0cb1..0446ecf62f 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 @@ -12,7 +12,6 @@ import {FmRecordEditorComponent} from '@eg/share/fm-editor/fm-editor.component'; @Component({ templateUrl: './org-unit.component.html' }) - export class OrgUnitComponent implements OnInit { tree: Tree; @@ -33,14 +32,21 @@ export class OrgUnitComponent implements OnInit { ngOnInit() { - // On initial page load, use the existing org tree data and - // select the root node. - this.ingestAouTree(this.org.tree()); - this.selected = this.tree.rootNode; + this.loadAouTree(this.org.root().id()); } - loadAouTree() { - this.org.fetchOrgs().then(() => this.ingestAouTree(this.org.tree())); + loadAouTree(selectNodeId?: number): Promise { + return this.pcrud.search('aou', {parent_ou : null}, + {flesh : -1, flesh_fields : {aou : [ + 'children', 'ou_type', 'hours_of_operation', 'ill_address', + 'holds_address', 'mailing_address', 'billing_address' + ]}}, {authoritative: true} + ).toPromise().then(tree => { + this.ingestAouTree(tree); + if (selectNodeId) { + this.selected = this.tree.findNode(selectNodeId); + } + }); } // Translate the org unt type tree into a structure EgTree can use. @@ -49,17 +55,26 @@ export class OrgUnitComponent implements OnInit { const handleNode = (orgNode: IdlObject): TreeNode => { if (!orgNode) { return; } - // Clone to avoid modifying the shared org tree - const node = this.idl.clone(orgNode); - node.ou_type(node.ou_type().id()); + if (!orgNode.hours_of_operation()) { + const hours = this.idl.create('aouhoo'); + hours.org_unit(orgNode.id()); + hours.isnew(true); + [0, 1, 2, 3, 4, 5, 6].forEach(dow => { + hours[`dow_${dow}_open`]('09:00:00'); + hours[`dow_${dow}_close`]('17:00:00'); + }); + orgNode.hours_of_operation(hours); + } + + // TODO addresses const treeNode = new TreeNode({ - id: node.id(), - label: node.name(), - callerData: {orgUnit: node} + id: orgNode.id(), + label: orgNode.name(), + callerData: {orgUnit: orgNode} }); - node.children().forEach(childNode => + orgNode.children().forEach(childNode => treeNode.children.push(handleNode(childNode)) ); @@ -74,6 +89,16 @@ export class OrgUnitComponent implements OnInit { this.selected = $event; } + hours(): IdlObject { + if (this.selected) { + console.log('we have org ', this.selected.callerData.orgUnit); + console.log('we have hours ', this.selected.callerData.orgUnit.hours_of_operation()); + return this.selected.callerData.orgUnit.hours_of_operation(); + } + return this.selected ? + this.selected.callerData.orgUnit.hours_of_operation() : null; + } + postUpdate(message: StringComponent) { // Modifying org unit types means refetching the org unit // data normally fetched on page load, since it includes @@ -97,13 +122,12 @@ export class OrgUnitComponent implements OnInit { () => { // Avoid updating until we know the entire // pcrud action/transaction completed. - this.loadAouTree(); - // After removal, select the parent org if available // otherwise the root org. - const orgId = org.parent_ou() ? org.parent_ou() : this.org.root().id(); - this.selected = this.tree.findNode(orgId); - this.postUpdate(this.editString); + const orgId = org.parent_ou() ? + org.parent_ou() : this.org.root().id(); + this.loadAouTree(orgId).then(_ => + this.postUpdate(this.editString)); } ); }); @@ -125,8 +149,8 @@ export class OrgUnitComponent implements OnInit { label: result.name(), callerData: {orgUnit: result} }); - this.loadAouTree(); - this.postUpdate(this.createString); + this.loadAouTree(result.id()).then(_ => + this.postUpdate(this.createString)); }); // TODO subscribe / unsub error events -- 2.11.0