LP#1922273: use a setting to determine which advanced search filters are displayed...
authorJeff Davis <jdavis@sitka.bclibraries.ca>
Mon, 3 May 2021 22:21:02 +0000 (15:21 -0700)
committerGalen Charlton <gmc@equinoxOLI.org>
Mon, 20 Sep 2021 15:56:58 +0000 (11:56 -0400)
The TPAC allows admins to customize which search filters are available
in advanced search.  This commit adds an org unit setting,
eg.staffcat.search_filters, which lets you customize search filters in
the staff catalog.  The setting value should be an array of filter
types, e.g. ["item_lang","audience","lit_form"].  The standard set of
search filters is used when the settings are not set.

Signed-off-by: Jeff Davis <jdavis@sitka.bclibraries.ca>
Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts
Open-ILS/src/eg2/src/app/staff/catalog/resolver.service.ts
Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html
Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.staffcat-search-filters.sql [new file with mode: 0644]

index 04eb852..76b75ca 100644 (file)
@@ -25,6 +25,10 @@ export class StaffCatalogService {
     // Display the Exclude Electronic checkbox
     showExcludeElectronic = false;
 
+    // Advanced search filters to display
+    searchFilters: string[];
+
+    // TODO: does unapi support pref-lib for result-page copy counts?
     prefOrg: IdlObject;
 
     // Default search tab
index 11c46ff..6780c2d 100644 (file)
@@ -8,6 +8,7 @@ import {AuthService} from '@eg/core/auth.service';
 import {CatalogService} from '@eg/share/catalog/catalog.service';
 import {StaffCatalogService} from './catalog.service';
 import {BasketService} from '@eg/share/catalog/basket.service';
+import {CATALOG_CCVM_FILTERS} from '@eg/share/catalog/search-context';
 
 
 @Injectable()
@@ -60,6 +61,7 @@ export class CatalogResolver implements Resolve<Promise<any[]>> {
             'eg.staff.catalog.results.show_more',
             'circ.staff_placed_holds_fallback_to_ws_ou',
             'opac.staff.jump_to_details_on_single_hit',
+            'eg.staffcat.search_filters'
         ]).then(settings => {
             this.staffCat.defaultSearchOrg =
                 this.org.get(settings['eg.search.search_lib']);
@@ -76,6 +78,8 @@ export class CatalogResolver implements Resolve<Promise<any[]>> {
                 settings['eg.staffcat.exclude_electronic'] === true;
             this.staffCat.jumpOnSingleHit =
                 settings['opac.staff.jump_to_details_on_single_hit'] === true;
+            this.staffCat.searchFilters =
+                settings['eg.staffcat.search_filters'] || CATALOG_CCVM_FILTERS;
         });
     }
 }
index 0911b8f..8f3ed84 100644 (file)
               </div>
           </div>
           <div class="row mt-3" *ngIf="showFilters()">
-            <div class="col-lg-3">
+            <div class="col-lg-3" *ngIf="searchFilters().includes('item_type')">
               <select class="form-control"  multiple="true"
                 [(ngModel)]="context.termSearch.ccvmFilters.item_type">
                 <option value='' i18n>All Item Types</option>
                 </ng-container> 
               </select>
             </div>
-            <div class="col-lg-3">
+            <div class="col-lg-3" *ngIf="searchFilters().includes('item_form')">
               <select class="form-control" multiple="true"
                 [(ngModel)]="context.termSearch.ccvmFilters.item_form">
                 <option value='' i18n>All Item Forms</option>
                 </ng-container> 
               </select>
             </div>
-            <div class="col-lg-3">
+            <div class="col-lg-3" *ngIf="searchFilters().includes('item_lang')">
               <select class="form-control" 
                 [(ngModel)]="context.termSearch.ccvmFilters.item_lang" multiple="true">
                 <option value='' i18n>All Languages</option>
                 </ng-container> 
               </select>
             </div>
-            <div class="col-lg-3">
+            <div class="col-lg-3" *ngIf="searchFilters().includes('audience')">
               <select class="form-control" 
                 [(ngModel)]="context.termSearch.ccvmFilters.audience" multiple="true">
                 <option value='' i18n>All Audiences</option>
             </div>
           </div>
           <div class="row mt-3" *ngIf="showFilters()">
-            <div class="col-lg-3">
+            <div class="col-lg-3" *ngIf="searchFilters().includes('vr_format')">
               <select class="form-control" 
                 [(ngModel)]="context.termSearch.ccvmFilters.vr_format" multiple="true">
                 <option value='' i18n>All Video Formats</option>
                 </ng-container> 
               </select>
             </div>
-            <div class="col-lg-3">
+            <div class="col-lg-3" *ngIf="searchFilters().includes('bib_level')">
               <select class="form-control" 
                 [(ngModel)]="context.termSearch.ccvmFilters.bib_level" multiple="true">
                 <option value='' i18n>All Bib Levels</option>
                 </ng-container> 
               </select>
             </div>
-            <div class="col-lg-3">
+            <div class="col-lg-3" *ngIf="searchFilters().includes('lit_form')">
               <select class="form-control" 
                 [(ngModel)]="context.termSearch.ccvmFilters.lit_form" multiple="true">
                 <option value='' i18n>All Literary Forms</option>
index d416f16..c7d9898 100644 (file)
@@ -309,6 +309,9 @@ export class SearchFormComponent implements OnInit, AfterViewInit {
     showExcludeElectronic(): boolean {
         return this.staffCat.showExcludeElectronic;
     }
+    searchFilters(): string[] {
+        return this.staffCat.searchFilters;
+    }
 }
 
 
index 4d5c730..ab4ada2 100644 (file)
@@ -21862,3 +21862,18 @@ INSERT into config.org_unit_setting_type
         'string'
     );
 
+INSERT INTO config.org_unit_setting_type
+( name, grp, label, description, datatype )
+VALUES
+( 'eg.staffcat.search_filters', 'gui',
+  oils_i18n_gettext(
+    'eg.staffcat.search_filters',
+    'Staff Catalog Search Filters',
+    'coust', 'label'),
+  oils_i18n_gettext(
+    'eg.staffcat.search_filters',
+    'Array of advanced search filters to display, e.g. ["item_lang","audience","lit_form"]',
+    'coust', 'description'),
+  'array' );
+
+
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.staffcat-search-filters.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.staffcat-search-filters.sql
new file mode 100644 (file)
index 0000000..ef17694
--- /dev/null
@@ -0,0 +1,22 @@
+BEGIN;
+
+--SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+INSERT INTO config.org_unit_setting_type
+( name, grp, label, description, datatype )
+VALUES
+( 'eg.staffcat.search_filters', 'gui',
+  oils_i18n_gettext(
+    'eg.staffcat.search_filters',
+    'Staff Catalog Search Filters',
+    'coust', 'label'),
+  oils_i18n_gettext(
+    'eg.staffcat.search_filters',
+    'Array of advanced search filters to display, e.g. ["item_lang","audience","lit_form"]',
+    'coust', 'description'),
+  'array' );
+
+COMMIT;
+
+
+