From b52dc2f08faf1a7ebeb5b1d8ef4e9a9c5821326c Mon Sep 17 00:00:00 2001 From: Dan Briem Date: Wed, 25 Aug 2021 10:24:12 -0400 Subject: [PATCH] LP#1759382 Setting: staff placed holds default to workstation New org unit setting to always default the pickup location to the workstation when placing holds as staff, regardless of the patron's preferred pickup location. The setting applies to staff placed holds in the Angular and traditional catalogs. Priority for determining the default pickup location when placing holds as staff: 1. workstation if circ.staff_placed_holds_default_to_ws_ou 2. user preferred location if opac.default_pickup_location 3. workstation if circ.staff_placed_holds_fallback_to_ws_ou 4. user home org unit Signed-off-by: Dan Briem Signed-off-by: Gina Monti Signed-off-by: Galen Charlton --- .../src/app/staff/catalog/hold/hold.component.ts | 24 +++++++++++++++------ .../eg2/src/app/staff/catalog/resolver.service.ts | 1 + Open-ILS/src/sql/Pg/950.data.seed-values.sql | 19 ++++++++++++++++ ...xx.data.staff_placed_holds_default_to_ws_ou.sql | 25 ++++++++++++++++++++++ Open-ILS/web/js/ui/default/opac/staff.js | 4 +++- .../web/js/ui/default/staff/services/eframe.js | 8 +++++-- 6 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 Open-ILS/src/sql/Pg/upgrade/xxxx.data.staff_placed_holds_default_to_ws_ou.sql diff --git a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts index 25943b9e69..b4d24430f9 100644 --- a/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/catalog/hold/hold.component.ts @@ -88,6 +88,7 @@ export class HoldComponent implements OnInit { badBarcode: string = null; puLibWsFallback = false; + puLibWsDefault = false; // Orgs which are not valid pickup locations disableOrgs: number[] = []; @@ -137,8 +138,15 @@ export class HoldComponent implements OnInit { this.userBarcode = this.staffCat.holdForBarcode; } - this.store.getItem('circ.staff_placed_holds_fallback_to_ws_ou') - .then(setting => this.puLibWsFallback = setting === true); + this.store.getItemBatch([ + 'circ.staff_placed_holds_fallback_to_ws_ou', + 'circ.staff_placed_holds_default_to_ws_ou' + ]).then(settings => { + this.puLibWsFallback = + settings['circ.staff_placed_holds_fallback_to_ws_ou'] === true; + this.puLibWsDefault = + settings['circ.staff_placed_holds_default_to_ws_ou'] === true; + }); this.org.list().forEach(org => { if (org.ou_type().can_have_vols() === 'f') { @@ -429,9 +437,13 @@ export class HoldComponent implements OnInit { this.phoneValue = this.user.day_phone() || this.user.evening_phone(); // Default to work org if placing holds for staff. - if (this.user.id() !== this.requestor.id() && !this.puLibWsFallback) { - // This value may be superseded below by user settings. - this.pickupLib = this.user.home_ou(); + // Default to home org if placing holds for patrons unless + // settings default or fallback to the workstation. + if (this.user.id() !== this.requestor.id()) { + if (!this.puLibWsFallback && !this.puLibWsDefault) { + // This value may be superseded below by user settings. + this.pickupLib = this.user.home_ou(); + } } if (!this.user.settings()) { return; } @@ -454,7 +466,7 @@ export class HoldComponent implements OnInit { break; case 'opac.default_pickup_location': - if (value) { + if (!this.puLibWsDefault && value) { this.pickupLib = Number(value); } break; 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 6780c2dc8c..b8e38b3ba3 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 @@ -60,6 +60,7 @@ export class CatalogResolver implements Resolve> { 'eg.catalog.search.form.open', 'eg.staff.catalog.results.show_more', 'circ.staff_placed_holds_fallback_to_ws_ou', + 'circ.staff_placed_holds_default_to_ws_ou', 'opac.staff.jump_to_details_on_single_hit', 'eg.staffcat.search_filters' ]).then(settings => { 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 f7fc6862ca..143584f91a 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -21937,3 +21937,22 @@ VALUES ( ) ); +INSERT INTO config.org_unit_setting_type ( + name, grp, label, description, datatype +) VALUES ( + 'circ.staff_placed_holds_default_to_ws_ou', + 'circ', + oils_i18n_gettext( + 'circ.staff_placed_holds_default_to_ws_ou', + 'Workstation OU is the default for staff-placed holds', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.staff_placed_holds_default_to_ws_ou', + 'For staff-placed holds, regardless of the patron preferred pickup location, the staff workstation OU is the default pickup location', + 'coust', + 'description' + ), + 'bool' +); diff --git a/Open-ILS/src/sql/Pg/upgrade/xxxx.data.staff_placed_holds_default_to_ws_ou.sql b/Open-ILS/src/sql/Pg/upgrade/xxxx.data.staff_placed_holds_default_to_ws_ou.sql new file mode 100644 index 0000000000..86196f85c2 --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/xxxx.data.staff_placed_holds_default_to_ws_ou.sql @@ -0,0 +1,25 @@ +BEGIN; + +SELECT evergreen.upgrade_deps_block_check('xxxx', :eg_version); + +INSERT INTO config.org_unit_setting_type ( + name, grp, label, description, datatype +) VALUES ( + 'circ.staff_placed_holds_default_to_ws_ou', + 'circ', + oils_i18n_gettext( + 'circ.staff_placed_holds_default_to_ws_ou', + 'Workstation OU is the default for staff-placed holds', + 'coust', + 'label' + ), + oils_i18n_gettext( + 'circ.staff_placed_holds_default_to_ws_ou', + 'For staff-placed holds, regardless of the patron preferred pickup location, the staff workstation OU is the default pickup location', + 'coust', + 'description' + ), + 'bool' +); + +COMMIT; diff --git a/Open-ILS/web/js/ui/default/opac/staff.js b/Open-ILS/web/js/ui/default/opac/staff.js index 525b8d5a57..f0679df751 100644 --- a/Open-ILS/web/js/ui/default/opac/staff.js +++ b/Open-ILS/web/js/ui/default/opac/staff.js @@ -177,8 +177,10 @@ function staff_hold_usr_barcode_changed2( // Safe at this point as we already set cur_hold_barcode document.getElementById('hold_usr_input').value = load_info.barcode; - // Patron preferred pickup loc always overrides the default pickup lib + // Patron preferred pickup loc overrides the default pickup lib + // unless the default to workstation setting is enabled document.getElementById('pickup_lib').value = + !load_info.settings['circ.staff_placed_holds_default_to_ws_ou'] && load_info.settings['opac.default_pickup_location'] ? load_info.settings['opac.default_pickup_location'] : load_info.pickup_lib; } diff --git a/Open-ILS/web/js/ui/default/staff/services/eframe.js b/Open-ILS/web/js/ui/default/staff/services/eframe.js index bf27b88c20..c4defe5fa7 100644 --- a/Open-ILS/web/js/ui/default/staff/services/eframe.js +++ b/Open-ILS/web/js/ui/default/staff/services/eframe.js @@ -259,7 +259,10 @@ angular.module('egCoreMod') return null; } - egCore.org.settings(['circ.staff_placed_holds_fallback_to_ws_ou']) + var wsFallback = 'circ.staff_placed_holds_fallback_to_ws_ou'; + var wsDefault = 'circ.staff_placed_holds_default_to_ws_ou'; + + egCore.org.settings([wsFallback, wsDefault]) .then(function(auth_usr_aous){ // copied more or less directly from XUL menu.js @@ -268,13 +271,14 @@ angular.module('egCoreMod') settings[user.settings()[i].name()] = JSON2js(user.settings()[i].value()); } + settings[wsDefault] = auth_usr_aous[wsDefault]; // find applicable YAOUSes for staff-placed holds var requestor = egCore.auth.user(); var pickup_lib = user.home_ou(); // default to home ou if (requestor.id() !== user.id()){ // this is a staff-placed hold, optionally default to ws ou - if (auth_usr_aous['circ.staff_placed_holds_fallback_to_ws_ou']){ + if (auth_usr_aous[wsFallback] || auth_usr_aous[wsDefault]) { pickup_lib = requestor.ws_ou(); } } -- 2.11.0