From cea65e3827b455d0fa839ddfafcbcd6d0a5f5e42 Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 23 May 2019 12:47:56 -0400 Subject: [PATCH] LP#1823393: various usability improvements - display the number of org units associated with the selected type - disable the Delete button if a type either has children types or org units linked to it - ensure that the type name and label fields are required - ensure that the tree is fully refreshed after an update Signed-off-by: Galen Charlton Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg --- .../admin/server/org-unit-type.component.html | 25 +++++++++++++------ .../staff/admin/server/org-unit-type.component.ts | 29 ++++++++++++++++------ 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit-type.component.html b/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit-type.component.html index d812d124ff..3c0af3b95c 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit-type.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit-type.component.html @@ -16,7 +16,9 @@ dialogBody="Delete Org Unit Type {{selected ? selected.label : ''}}?"> - +
@@ -39,7 +41,8 @@
- +
@@ -48,7 +51,7 @@
- {{selected.callerData.name()}} + {{selected.callerData.aout.name()}}
@@ -56,7 +59,7 @@
- {{selected.callerData.opac_label()}} + {{selected.callerData.aout.opac_label()}}
@@ -65,7 +68,7 @@
- {{selected.callerData.can_have_users() == 't'}} + {{selected.callerData.aout.can_have_users() == 't'}}
@@ -74,7 +77,7 @@
- {{selected.callerData.can_have_vols() == 't'}} + {{selected.callerData.aout.can_have_vols() == 't'}}
@@ -82,7 +85,15 @@
- {{selected.callerData.depth()}} + {{selected.callerData.aout.depth()}} +
+ +
+
+ +
+
+ {{selected.callerData.orgCount}}
diff --git a/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit-type.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit-type.component.ts index 1820cc8e4e..978b46f19a 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit-type.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/server/org-unit-type.component.ts @@ -38,7 +38,7 @@ export class OrgUnitTypeComponent implements OnInit { loadAoutTree() { this.pcrud.search('aout', {depth: 0}, - {flesh: -1, flesh_fields: {aout: ['children']}}, + {flesh: -1, flesh_fields: {aout: ['children','org_units']}}, {anonymous: true} ).subscribe(aoutTree => this.ingestAoutTree(aoutTree)); } @@ -49,10 +49,16 @@ export class OrgUnitTypeComponent implements OnInit { const handleNode = (aoutNode: IdlObject): TreeNode => { if (!aoutNode) { return; } + // grab number of associated org units, then + // clear it so that FmRecordEditor doesn't try + // to render the list + const orgCount = aoutNode.org_units().length; + aoutNode.org_units(null); + const treeNode = new TreeNode({ id: aoutNode.id(), label: aoutNode.name(), - callerData: aoutNode + callerData: { aout: aoutNode, orgCount: orgCount }, }); aoutNode.children().forEach(childNode => @@ -83,11 +89,14 @@ export class OrgUnitTypeComponent implements OnInit { edit() { this.editDialog.mode = 'update'; - this.editDialog.setRecord(this.selected.callerData); + this.editDialog.setRecord(this.selected.callerData.aout); this.editDialog.open().then( success => { this.postUpdate(this.editString); + this.loadAoutTree(); // since the tree is never going to + // be large, just reload the whole + // thing }, rejected => { if (rejected && rejected.dismissed) { @@ -102,7 +111,7 @@ export class OrgUnitTypeComponent implements OnInit { remove() { this.delConfirm.open().then( ok => { - this.pcrud.remove(this.selected.callerData) + this.pcrud.remove(this.selected.callerData.aout) .subscribe( ok2 => {}, err => { @@ -112,7 +121,9 @@ export class OrgUnitTypeComponent implements OnInit { () => { // Avoid updating until we know the entire // pcrud action/transaction completed. - this.tree.removeNode(this.selected); + this.loadAoutTree(); // since the tree is never going to + // be large, just reload the whole + // thing this.selected = null; this.postUpdate(this.editString); } @@ -124,7 +135,7 @@ export class OrgUnitTypeComponent implements OnInit { addChild() { const parentTreeNode = this.selected; - const parentType = parentTreeNode.callerData; + const parentType = parentTreeNode.callerData.aout; const newType = this.idl.create('aout'); newType.parent(parentType.id()); @@ -140,9 +151,11 @@ export class OrgUnitTypeComponent implements OnInit { const newNode = new TreeNode({ id: result.id(), label: result.name(), - callerData: result + callerData: { aout: result, orgCount: 0 } }); - parentTreeNode.children.push(newNode); + this.loadAoutTree(); // since the tree is never going to + // be large, just reload the whole + // thing this.postUpdate(this.createString); }, -- 2.11.0