From b755aa4c34fa3e1ed0317d078a155d4ef8ee40a8 Mon Sep 17 00:00:00 2001 From: Dan Briem Date: Fri, 13 Aug 2021 11:18:11 -0400 Subject: [PATCH] LP#1759382 Setting: staff placed holds default to workstation New org unit setting for always using the staff's workstation as the default pickup location for staff placed holds, even if the user has a preferred pickup location set in their account. The setting applies on staff placed holds in the Angular and Traditional/Bootstrap catalog. This includes hold group holds. If this helps when testing, this is the priority order for determining the default pickup location: 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 --- .../eg2/src/app/staff/catalog/resolver.service.ts | 3 ++- .../perlmods/lib/OpenILS/Application/Circ/Holds.pm | 17 ++++++++++++++- 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 | 1 + .../web/js/ui/default/staff/services/eframe.js | 11 +++++++--- 6 files changed, 71 insertions(+), 5 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/resolver.service.ts b/Open-ILS/src/eg2/src/app/staff/catalog/resolver.service.ts index f7e956224d..95b496a2dd 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 @@ -58,7 +58,8 @@ export class CatalogResolver implements Resolve> { 'eg.staffcat.exclude_electronic', 'eg.catalog.search.form.open', 'eg.staff.catalog.results.show_more', - 'circ.staff_placed_holds_fallback_to_ws_ou' + 'circ.staff_placed_holds_fallback_to_ws_ou', + 'circ.staff_placed_holds_default_to_ws_ou' ]).then(settings => { this.staffCat.defaultSearchOrg = this.org.get(settings['eg.search.search_lib']); diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm index d0b5136640..8b44345b67 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm @@ -223,6 +223,13 @@ sub test_and_create_batch_hold_event { my $rand_setting = $U->ou_ancestor_setting_value($org, 'holds.subscription.randomize'); $randomize = $rand_setting if (defined $rand_setting); + my $default_to_workstation = $U->is_true( + $U->ou_ancestor_setting_value($org, 'circ.staff_placed_holds_default_to_ws_ou') + ); + my $fallback_to_workstation = $U->is_true( + $U->ou_ancestor_setting_value($org, 'circ.staff_placed_holds_fallback_to_ws_ou') + ); + my $target_field; if ($$params{'hold_type'} eq 'T') { $target_field = 'titleid'; } elsif ($$params{'hold_type'} eq 'C') { $target_field = 'copy_id'; } @@ -283,7 +290,15 @@ sub test_and_create_batch_hold_event { @{ $usr->settings } }; - $$params{pickup_lib} = $$user_setting_map{'opac.default_pickup_location'} || $usr->home_ou; + if ($default_to_workstation) { + $params->{pickup_lib} = $org; + } elsif ($user_setting_map->{'opac.default_pickup_location'}) { + $params->{pickup_lib} = $user_setting_map->{'opac.default_pickup_location'}; + } elsif ($fallback_to_workstation) { + $params->{pickup_lib} = $org; + } else { + $params->{pickup_lib} = $usr->home_ou; + } if ($user_setting_map->{'opac.hold_notify'} =~ /email/) { $$params{email_notify} = 1; 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 528ed563e6..cfb1fc5de8 100644 --- a/Open-ILS/src/sql/Pg/950.data.seed-values.sql +++ b/Open-ILS/src/sql/Pg/950.data.seed-values.sql @@ -21673,3 +21673,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..9b4d170aa9 100644 --- a/Open-ILS/web/js/ui/default/opac/staff.js +++ b/Open-ILS/web/js/ui/default/opac/staff.js @@ -179,6 +179,7 @@ function staff_hold_usr_barcode_changed2( // Patron preferred pickup loc always overrides the default pickup lib 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..b05c8e0538 100644 --- a/Open-ILS/web/js/ui/default/staff/services/eframe.js +++ b/Open-ILS/web/js/ui/default/staff/services/eframe.js @@ -259,8 +259,10 @@ angular.module('egCoreMod') return null; } - egCore.org.settings(['circ.staff_placed_holds_fallback_to_ws_ou']) - .then(function(auth_usr_aous){ + egCore.org.settings([ + 'circ.staff_placed_holds_fallback_to_ws_ou', + 'circ.staff_placed_holds_default_to_ws_ou' + ]).then(function(auth_usr_aous) { // copied more or less directly from XUL menu.js var settings = {}; @@ -268,13 +270,16 @@ angular.module('egCoreMod') settings[user.settings()[i].name()] = JSON2js(user.settings()[i].value()); } + settings['circ.staff_placed_holds_default_to_ws_ou'] = + auth_usr_aous['circ.staff_placed_holds_default_to_ws_ou']; // 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['circ.staff_placed_holds_fallback_to_ws_ou'] + || auth_usr_aous['circ.staff_placed_holds_default_to_ws_ou']) { pickup_lib = requestor.ws_ou(); } } -- 2.11.0