From: Bill Erickson Date: Fri, 28 Aug 2020 16:11:39 +0000 (-0400) Subject: LP1885767 Staff catalog exclude electronic option X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=refs%2Fheads%2Fuser%2Fberick%2Flp1885767-staffcat-exclude-electronic;p=working%2FEvergreen.git 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 to control the behavior and an option to toggle the preference in the staff catalog preferences page. Signed-off-by: Bill Erickson --- 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 57d9db6573..97a560a934 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']; @@ -563,6 +565,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 95912a4285..bf5b86e228 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 842893cf11..3cd5fe33ee 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 @@ -53,6 +53,7 @@ export class CatalogResolver implements Resolve> { 'cat.holdings_show_vols', 'opac.staff_saved_search.size', 'eg.catalog.search_templates', + 'eg.staffcat.exclude_electronic', 'opac.staff_saved_search.size' ]).then(settings => { this.staffCat.defaultSearchOrg = @@ -64,6 +65,8 @@ export class CatalogResolver implements Resolve> { this.staffCat.defaultSearchLimit = Number(settings['eg.catalog.results.count']); } + 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 4468d38bd3..4c016c6255 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 @@ -115,25 +115,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 043adb0ed1..d8d657a854 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'; @@ -279,6 +280,10 @@ export class SearchFormComponent implements OnInit, AfterViewInit { } } } + + 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 36e655d460..9e48e67703 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -20456,3 +20456,14 @@ VALUES ( ) ); +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; + +