From e6bfb6d7b6ffce94eecc38fc0b0f16412ac91b5a Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 28 Aug 2020 12:11:39 -0400 Subject: [PATCH] LP1885767 Staff catalog exclude electronic option 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 Signed-off-by: Mary Llewellyn Signed-off-by: Galen Charlton --- .../src/app/share/catalog/catalog-url.service.ts | 8 ++++++++ .../src/eg2/src/app/share/catalog/search-context.ts | 6 ++++++ .../eg2/src/app/staff/catalog/catalog.service.ts | 3 +++ .../eg2/src/app/staff/catalog/prefs.component.html | 21 +++++++++++++++++++++ .../eg2/src/app/staff/catalog/prefs.component.ts | 12 +++++++++++- .../eg2/src/app/staff/catalog/resolver.service.ts | 5 ++++- .../app/staff/catalog/search-form.component.html | 13 ++++++++++--- .../src/app/staff/catalog/search-form.component.ts | 4 ++++ Open-ILS/src/sql/Pg/950.data.seed-values.sql | 10 ++++++++++ .../XXXX.data.staffcat-exclude-electronic.sql | 17 +++++++++++++++++ 10 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/XXXX.data.staffcat-exclude-electronic.sql diff --git a/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts b/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts index 7b9698f2d3..683947e441 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/catalog-url.service.ts @@ -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; + } } } } diff --git a/Open-ILS/src/eg2/src/app/share/catalog/search-context.ts b/Open-ILS/src/eg2/src/app/share/catalog/search-context.ts index f669ba0ad6..72683c1de8 100644 --- a/Open-ILS/src/eg2/src/app/share/catalog/search-context.ts +++ b/Open-ILS/src/eg2/src/app/share/catalog/search-context.ts @@ -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(/\./); diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts index 3b3268c4e3..a0652744f6 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/catalog.service.ts @@ -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; diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/prefs.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/prefs.component.html index b7ed34ed85..a3a595a7d0 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/prefs.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/prefs.component.html @@ -82,3 +82,24 @@ The number of search results to display per page. + +
+
+ +
+
+
+ +
+
+
+ Add the 'Exclude Electronic Resources' checkbox to the main search form. +
+
diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/prefs.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/prefs.component.ts index 7d81a07eb6..a186fc81ed 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/prefs.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/prefs.component.ts @@ -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 { const promise = (value === null) ? this.store.removeItem(setting) : diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/resolver.service.ts b/Open-ILS/src/eg2/src/app/staff/catalog/resolver.service.ts index f86a060653..78793730cb 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/resolver.service.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/resolver.service.ts @@ -54,7 +54,8 @@ export class CatalogResolver implements Resolve> { '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> { } this.staffCat.enableBookplates = settings['opac.search.enable_bookplate_search']; + this.staffCat.showExcludeElectronic = + settings['eg.staffcat.exclude_electronic'] === true; }); } } diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html index 5361992852..b3d5eb6aea 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html +++ b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.html @@ -117,25 +117,32 @@ -
+
-
+
-
+
+
+ +
diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts index c09da29785..9dcca68570 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/search-form.component.ts @@ -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; + } } diff --git a/Open-ILS/src/sql/Pg/950.data.seed-values.sql b/Open-ILS/src/sql/Pg/950.data.seed-values.sql index 6f0977db17..8f31296ed5 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -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 index 0000000000..ebc840f6a4 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.staffcat-exclude-electronic.sql @@ -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; + + -- 2.11.0