From: Bill Erickson Date: Wed, 6 Jul 2022 20:35:28 +0000 (-0400) Subject: LP1884950 Org service loads all ou types X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d48751fa99e3c161af96f9252cf97b54ff0f5131;p=evergreen%2Fequinox.git 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 --- 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();