LP1885767 Staff catalog exclude electronic option
authorBill Erickson <berickxx@gmail.com>
Fri, 28 Aug 2020 16:11:39 +0000 (12:11 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 22 Sep 2020 14:19:06 +0000 (10:19 -0400)
Adds support for the 'Exclude Electronic Resources' checkbox in the
staff catalog, consistent with the TPAC option.

Adds a workstation setting, 'Staff Catalog "Exclude Electronic
Resources" Option' to control the behavior and an option to
toggle the preference in the staff catalog preferences page.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Mary Llewellyn <mllewell@biblio.org>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>

Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts
Open-ILS/src/eg2/src/app/share/catalog/search-context.ts
Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts
Open-ILS/src/eg2/src/app/staff/catalog/prefs.component.html
Open-ILS/src/eg2/src/app/staff/catalog/prefs.component.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-exclude-electronic.sql [new file with mode: 0644]

index 7b9698f..683947e 100644 (file)
@@ -121,6 +121,10 @@ export class CatalogUrlService {
             if (ts.copyLocations.length && ts.copyLocations[0] !== '') {
                 params.copyLocations = ts.copyLocations.join(',');
             }
+
+            if (ts.excludeElectronic) {
+                params.excludeElectronic = true;
+            }
         }
 
         if (context.cnBrowseSearch.isSearchable()) {
@@ -245,6 +249,10 @@ export class CatalogUrlService {
             if (params.get('copyLocations')) {
                 ts.copyLocations = params.get('copyLocations').split(/,/);
             }
+
+            if (params.get('excludeElectronic')) {
+                ts.excludeElectronic = true;
+            }
         }
     }
 }
index f669ba0..72683c1 100644 (file)
@@ -208,6 +208,8 @@ export class CatalogTermContext {
     date2: number;
     dateOp: string; // before, after, between, is
 
+    excludeElectronic = false;
+
     reset() {
         this.query = [''];
         this.fieldClass  = ['keyword'];
@@ -567,6 +569,10 @@ export class CatalogSearchContext {
             str += '#available';
         }
 
+        if (ts.excludeElectronic) {
+            str += '-search_format(electronic)';
+        }
+
         if (this.sort) {
             // e.g. title, title.descending
             const parts = this.sort.split(/\./);
index 3b3268c..a065274 100644 (file)
@@ -22,6 +22,9 @@ export class StaffCatalogService {
     // Track the current template through route changes.
     selectedTemplate: string;
 
+    // Display the Exclude Electronic checkbox
+    showExcludeElectronic = false;
+
     // TODO: does unapi support pref-lib for result-page copy counts?
     prefOrg: IdlObject;
 
index b7ed34e..a3a595a 100644 (file)
     The number of search results to display per page.
   </div>
 </div>
+
+<div class="row border-bottom border-secondary p-2 m-2">
+  <div class="col-lg-2 offset-lg-1">
+    <label for="pref-lib-selector" class="font-weight-bold" i18n>
+      Exclude Electronic Resources
+    </label>
+  </div>
+  <div class="col-lg-2">
+    <div class="checkbox pl-3 pt-2">
+      <label>
+        <input type="checkbox" 
+          (change)="checkboxChanged('eg.staffcat.exclude_electronic')"
+          [(ngModel)]="settings['eg.staffcat.exclude_electronic']">
+        <span class="pl-1" i18n></span>
+      </label>
+    </div>
+  </div>
+  <div class="col-lg-6" i18n>
+    Add the 'Exclude Electronic Resources' checkbox to the main search form.
+  </div>
+</div>
index 7d81a07..a186fc8 100644 (file)
@@ -12,7 +12,8 @@ const CATALOG_PREFS = [
     'eg.search.search_lib',
     'eg.search.pref_lib',
     'eg.search.adv_pane',
-    'eg.catalog.results.count'
+    'eg.catalog.results.count',
+    'eg.staffcat.exclude_electronic'
 ];
 
 @Component({
@@ -60,6 +61,15 @@ export class PreferencesComponent implements OnInit {
         });
     }
 
+    checkboxChanged(setting: string) {
+        const value = this.settings[setting];
+        this.updateValue(setting, value || null);
+
+        if (setting === 'eg.staffcat.exclude_electronic') {
+            this.staffCat.showExcludeElectronic = value;
+        }
+    }
+
     updateValue(setting: string, value: any): Promise<any> {
         const promise = (value === null) ?
             this.store.removeItem(setting) :
index f86a060..7879373 100644 (file)
@@ -54,7 +54,8 @@ export class CatalogResolver implements Resolve<Promise<any[]>> {
             'opac.staff_saved_search.size',
             'eg.catalog.search_templates',
             'opac.staff_saved_search.size',
-            'opac.search.enable_bookplate_search'
+            'opac.search.enable_bookplate_search',
+            'eg.staffcat.exclude_electronic'
         ]).then(settings => {
             this.staffCat.defaultSearchOrg =
                 this.org.get(settings['eg.search.search_lib']);
@@ -67,6 +68,8 @@ export class CatalogResolver implements Resolve<Promise<any[]>> {
             }
             this.staffCat.enableBookplates =
                 settings['opac.search.enable_bookplate_search'];
+            this.staffCat.showExcludeElectronic =
+                settings['eg.staffcat.exclude_electronic'] === true;
         });
     }
 }
index 5361992..b3d5eb6 100644 (file)
                     <option value='poprel' i18n>Popularity Adjusted Relevance</option>
                   </optgroup>
                 </select>
-                <div class="checkbox pl-2 ml-2">
+                <div class="checkbox pl-2 ml-2 pt-2">
                   <label>
                     <input type="checkbox" [(ngModel)]="context.termSearch.available"/>
                     <span class="pl-1" i18n>Limit to Available</span>
                   </label>
                 </div>
-                <div class="checkbox pl-3">
+                <div class="checkbox pl-3 pt-2">
                   <label>
                     <input type="checkbox"
                       [(ngModel)]="context.termSearch.groupByMetarecord"/>
                     <span class="pl-1" i18n>Group Formats/Editions</span>
                   </label>
                 </div>
-                <div class="checkbox pl-3">
+                <div class="checkbox pl-3 pt-2">
                   <label>
                     <input type="checkbox" [(ngModel)]="context.global"/>
                     <span class="pl-1" i18n>Results from All Libraries</span>
                   </label>
                 </div>
+                <div class="checkbox pl-3 pt-2" *ngIf="showExcludeElectronic()">
+                  <label>
+                    <input type="checkbox" 
+                      [(ngModel)]="context.termSearch.excludeElectronic"/>
+                    <span class="pl-1" i18n>Exclude Electronic Resources</span>
+                  </label>
+                </div>
               </div>
           </div>
           <div class="row mt-3" *ngIf="showFilters()">
index c09da29..9dcca68 100644 (file)
@@ -2,6 +2,7 @@ import {Component, OnInit, AfterViewInit, Renderer2} from '@angular/core';
 import {Router, ActivatedRoute, NavigationEnd} from '@angular/router';
 import {IdlObject} from '@eg/core/idl.service';
 import {OrgService} from '@eg/core/org.service';
+import {ServerStoreService} from '@eg/core/server-store.service';
 import {CatalogService} from '@eg/share/catalog/catalog.service';
 import {CatalogSearchContext, CatalogSearchState} from '@eg/share/catalog/search-context';
 import {StaffCatalogService} from './catalog.service';
@@ -283,6 +284,9 @@ export class SearchFormComponent implements OnInit, AfterViewInit {
     showBookplate(): boolean {
         return this.staffCat.enableBookplates;
     }
+    showExcludeElectronic(): boolean {
+        return this.staffCat.showExcludeElectronic;
+    }
 }
 
 
index 6f0977d..8f31296 100644 (file)
@@ -21215,3 +21215,13 @@ INSERT INTO action_trigger.environment (
 INSERT INTO action_trigger.event_params (event_def, param, value)
     VALUES (currval('action_trigger.event_definition_id_seq'), 'check_sms_notify', 1);
 */
+
+INSERT INTO config.workstation_setting_type (name, grp, datatype, label)
+VALUES (
+    'eg.staffcat.exclude_electronic', 'gui', 'bool',
+    oils_i18n_gettext(
+        'eg.staffcat.exclude_electronic',
+        'Staff Catalog "Exclude Electronic Resources" Option',
+        'cwst', 'label'
+    )
+);
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.staffcat-exclude-electronic.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.staffcat-exclude-electronic.sql
new file mode 100644 (file)
index 0000000..ebc840f
--- /dev/null
@@ -0,0 +1,17 @@
+BEGIN;
+
+-- SELECT evergreen.upgrade_deps_block_check('TODO', :eg_version);
+
+INSERT INTO config.workstation_setting_type (name, grp, datatype, label)
+VALUES (
+    'eg.staffcat.exclude_electronic', 'gui', 'bool',
+    oils_i18n_gettext(
+        'eg.staffcat.exclude_electronic',
+        'Staff Catalog "Exclude Electronic Resources" Option',
+        'cwst', 'label'
+    )
+);
+
+COMMIT;
+
+