From: Galen Charlton Date: Tue, 3 Aug 2021 17:58:50 +0000 (-0400) Subject: staff portal: implement looking for the relevant set of portal entries X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=267be0244646e7c663f312cc14660d7bf32eef72;p=working%2FEvergreen.git staff portal: implement looking for the relevant set of portal entries Signed-off-by: Galen Charlton --- diff --git a/Open-ILS/src/eg2/src/app/staff/splash.component.ts b/Open-ILS/src/eg2/src/app/staff/splash.component.ts index 82e395b197..987a3e3aa1 100644 --- a/Open-ILS/src/eg2/src/app/staff/splash.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/splash.component.ts @@ -1,4 +1,6 @@ import {Component, OnInit, AfterViewInit, Directive, ElementRef, Renderer2} from '@angular/core'; +import {OrgService} from '@eg/core/org.service'; +import {AuthService} from '@eg/core/auth.service'; import {PcrudService} from '@eg/core/pcrud.service'; import {Router} from '@angular/router'; @@ -15,12 +17,15 @@ export class StaffSplashComponent implements OnInit { constructor( private renderer: Renderer2, private pcrud: PcrudService, + private auth: AuthService, + private org: OrgService, private router: Router ) {} ngOnInit() { const tmpPortalEntries: any[][] = []; - this.pcrud.search('cusppe', {owner: 1}).subscribe( + const wsAncestors = this.org.ancestors(this.auth.user().ws_ou(), true); + this.pcrud.search('cusppe', {owner: wsAncestors}).subscribe( item => { const page_col = item.page_col(); if (tmpPortalEntries[page_col] === undefined) { @@ -30,10 +35,32 @@ export class StaffSplashComponent implements OnInit { }, err => {}, () => { + // find the first set of entries belonging to the + // workstation OU or one of its ancestors + var filteredPortalEntries: any[][] = []; + var foundMatch = false; + for (let ou of wsAncestors) { + tmpPortalEntries.forEach((col) => { + if (col !== undefined) { + const filtered = col.filter(x => x !== undefined) + .filter(x => ou === x.owner()); + if (filtered.length) { + foundMatch = true; + filteredPortalEntries.push(filtered); + } + } + }); + if (foundMatch) { + break; + } else { + filteredPortalEntries = []; + } + } + // munge the results so that we don't need to // care if there are gaps in the page_col or col_pos // sequences - tmpPortalEntries.forEach((col) => { + filteredPortalEntries.forEach((col) => { if (col !== undefined) { const filtered = col.filter(x => x !== undefined); this.portalEntries.push(filtered);