}
}
- async loadCustomTree(purpose: string): Promise<any> {
- const flesh = ['children', 'org_unit'];
-
- let tree_type: IdlObject;
- tree_type = await firstValueFrom(
- this.pcrud.search('aouct', { purpose: purpose })
- .pipe(
- take(1),
- defaultIfEmpty(undefined),
- catchError(err => {
- console.warn('caught from pcrud (aouct): 1', err);
- return of(undefined);
- })
- )
- );
-
- let tree_id: number;
- if (tree_type) {
- tree_id = tree_type.id();
- } else {
- tree_id = null;
- }
-
- let tree: IdlObject;
+ async loadCustomTree(purpose: string): Promise<any> {
+ const flesh = ['children', 'org_unit'];
+
+ let tree_type: IdlObject;
+ tree_type = await firstValueFrom(
+ this.pcrud.search('aouct', { purpose: purpose })
+ .pipe(
+ take(1),
+ defaultIfEmpty(undefined),
+ catchError(err => {
+ console.warn('caught from pcrud (aouct): 1', err);
+ return of(undefined);
+ })
+ )
+ );
+
+ let tree_id: number;
+ if (tree_type) {
+ tree_id = tree_type.id();
+ } else {
+ tree_id = null;
+ }
+
+ let tree: IdlObject;
if (tree_id) {
tree = await firstValueFrom(
this.pcrud.search('aouctn', {tree: tree_id, parent_node: null},
- {flesh: -1, flesh_fields: {aouctn: flesh}}, {authoritative: true})
- .pipe(
- take(1),
- defaultIfEmpty(undefined),
- catchError(err => {
- console.warn('phasefx: caught from pcrud (aouctn): 2', err);
- return of(undefined);
- })
- )
+ {flesh: -1, flesh_fields: {aouctn: flesh}}, {authoritative: true})
+ .pipe(
+ take(1),
+ defaultIfEmpty(undefined),
+ catchError(err => {
+ console.warn('phasefx: caught from pcrud (aouctn): 2', err);
+ return of(undefined);
+ })
+ )
);
this.ingestCustomTree(tree); // sets this.custom_tree as a side-effect
} else {
this.custom_tree = this.tree.clone(); // need to remember to create the aouct if needed upon saving
}
return this.custom_tree;
- }
+ }
// Translate the org unt type tree into a structure EgTree can use.
ingestAouTree(aouTree: IdlObject) {