From 25c6dc159740adc574dfa33892852b58e73871b9 Mon Sep 17 00:00:00 2001 From: Jane Sandberg <sandbej@linnbenton.edu> Date: Wed, 23 Jun 2021 16:59:51 -0700 Subject: [PATCH] LP1905068: Add org-family-select to course list To test: 1) Apply this patch 2) Admin > Local admin > Course reserves list 3) Check that the list defaults to courses available at your workstation org unit 4) Check that, when you select ancestors, descendants, or a different org unit, the course list updates accordingly 5) Check that the list only displays org units for which you have the MANAGE_RESERVES permission Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu> Signed-off-by: Galen Charlton <gmc@equinoxOLI.org> --- .../local/course-reserves/course-list.component.html | 12 ++++++++++++ .../admin/local/course-reserves/course-list.component.ts | 16 ++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.html b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.html index 2031ee946f..6fb0972429 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.html +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.html @@ -13,6 +13,18 @@ <li ngbNavItem> <a ngbNavLink i18n>Course list</a> <ng-template ngbNavContent> + <div class="row"> + <div class="col-lg-6"> + <eg-org-family-select + [limitPerms]="['MANAGE_RESERVES']" + [selectedOrgId]="defaultOuId" + [(ngModel)]="searchOrgs" + (ngModelChange)="grid.reload()"> + </eg-org-family-select> + </div> + </div> + <hr/> + <div class="w-100 mt-2 mb-2"> <eg-grid #grid idlClass={{idlClass}} [dataSource]="grid_source" diff --git a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.ts b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.ts index a2e73289a6..5884c8a619 100644 --- a/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.ts @@ -11,6 +11,8 @@ import {StringComponent} from '@eg/share/string/string.component'; import {ToastService} from '@eg/share/toast/toast.service'; import {LocaleService} from '@eg/core/locale.service'; import {AuthService} from '@eg/core/auth.service'; +import {OrgService} from '@eg/core/org.service'; +import {OrgFamily} from '@eg/share/org-family-select/org-family-select.component'; import {CourseAssociateMaterialComponent } from './course-associate-material.component'; @@ -46,6 +48,8 @@ export class CourseListComponent implements OnInit, AfterViewInit { grid_source: GridDataSource = new GridDataSource(); currentMaterials: any[] = []; search_value = ''; + defaultOuId = 1; + searchOrgs: OrgFamily; defaultTerm: IdlObject; @@ -54,6 +58,7 @@ export class CourseListComponent implements OnInit, AfterViewInit { private locale: LocaleService, private auth: AuthService, private idl: IdlService, + private org: OrgService, private pcrud: PcrudService, private router: Router, private toast: ToastService @@ -62,7 +67,9 @@ export class CourseListComponent implements OnInit, AfterViewInit { ngOnInit() { this.getSource(); this.defaultTerm = this.idl.create('acmt'); - this.defaultTerm.owning_lib(this.auth.user().ws_ou()); + this.defaultOuId = this.auth.user().ws_ou() || this.org.root().id(); + this.defaultTerm.owning_lib(this.defaultOuId); + this.searchOrgs = {primaryOrgId: this.defaultOuId}; } ngAfterViewInit() { @@ -91,12 +98,17 @@ export class CourseListComponent implements OnInit, AfterViewInit { // Default sort field orderBy[this.idlClass] = this.sortField; } + const search: any = new Array(); + const orgFilter: any = {}; + orgFilter['owning_lib'] = + this.searchOrgs.orgIds || [this.defaultOuId]; + search.push(orgFilter); const searchOps = { offset: pager.offset, limit: pager.limit, order_by: orderBy }; - return this.pcrud.retrieveAll(this.idlClass, searchOps, {fleshSelectors: true}); + return this.pcrud.search(this.idlClass, search, searchOps, {fleshSelectors: true}); }; } -- 2.11.0