From fb856e816e865bc8e81ec9734f6e863f99606fce Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 6 Jul 2022 16:35:28 -0400 Subject: [PATCH] LP1884950 Org service loads all ou types Explicitly load all org unit types at page startup so that we fetch org types that may not have an org unit attached. Signed-off-by: Bill Erickson Signed-off-by: Dawn Dale Signed-off-by: Chris Sharp --- Open-ILS/src/eg2/src/app/core/org.service.ts | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/core/org.service.ts b/Open-ILS/src/eg2/src/app/core/org.service.ts index bf98630829..cc8e4cd7b2 100644 --- a/Open-ILS/src/eg2/src/app/core/org.service.ts +++ b/Open-ILS/src/eg2/src/app/core/org.service.ts @@ -175,17 +175,10 @@ export class OrgService { if (!node) { node = this.orgTree; this.orgMap = {}; - this.orgList = []; - this.orgTypeMap = {}; } this.orgMap[node.id()] = node; this.orgList.push(node); - this.orgTypeMap[node.ou_type().id()] = node.ou_type(); - if (!this.orgTypeList.filter(t => t.id() === node.ou_type().id())[0]) { - this.orgTypeList.push(node.ou_type()); - } - node.children().forEach(c => this.absorbTree(c)); } @@ -194,10 +187,22 @@ export class OrgService { * various shapes, then returns an "all done" promise. */ fetchOrgs(): Promise { - return this.pcrud.search('aou', {parent_ou : null}, - {flesh : -1, flesh_fields : {aou : ['children', 'ou_type']}}, - {anonymous : true} - ).toPromise().then(tree => { + + // Grab org types separately so we are guaranteed to fetch types + // that are not yet in use by an org unit. + return this.pcrud.retrieveAll( + 'aout', {}, {anonymous: true, atomic: true}).toPromise() + .then(types => { + this.orgTypeList = types; + types.forEach(t => this.orgTypeMap[Number(t.id())] = t); + + return this.pcrud.search('aou', {parent_ou : null}, + {flesh : -1, flesh_fields : {aou : ['children', 'ou_type']}}, + {anonymous : true} + ).toPromise() + }) + + .then(tree => { // ingest tree, etc. this.orgTree = tree; this.absorbTree(); -- 2.11.0