LP1905068: Add org-family-select to course list
authorJane Sandberg <sandbej@linnbenton.edu>
Wed, 23 Jun 2021 23:59:51 +0000 (16:59 -0700)
committerGalen Charlton <gmc@equinoxOLI.org>
Sun, 15 Aug 2021 15:31:41 +0000 (11:31 -0400)
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>
Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.html
Open-ILS/src/eg2/src/app/staff/admin/local/course-reserves/course-list.component.ts

index 2031ee9..6fb0972 100644 (file)
   <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"
index a2e7328..5884c8a 100644 (file)
@@ -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});
         };
     }