From bccced0be68c41b09638a423f9d5768ac8411998 Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Tue, 10 Sep 2024 20:34:04 +0000 Subject: [PATCH 01/16] FOLIO: Support delivery fulfillment preference for requests --- config/vufind/Folio.ini | 12 ++ module/VuFind/src/VuFind/ILS/Driver/Folio.php | 125 +++++++++++++++++- 2 files changed, 135 insertions(+), 2 deletions(-) diff --git a/config/vufind/Folio.ini b/config/vufind/Folio.ini index 6ab52375900..e1725d78724 100644 --- a/config/vufind/Folio.ini +++ b/config/vufind/Folio.ini @@ -121,6 +121,18 @@ extraHoldFields = requiredByDate:pickUpLocation ; requested item's effective location. Only applicable to item-level requests. ;limitPickupLocations = itemEffectiveLocation +; When the extra hold field requestGroup is used, the request group Delivery is offered +; whenever the FOLIO user's Request Preferences have delivery enabled. This setting +; overrides every user's FOLIO seetting if it's necessary to globally disable delivery +; for backwards compatibility. +;allowDelivery = false + +; When the extra hold fields pickupLocation and requestGroup are used, and requestGroup +; is Delivery, the request form's list of "pickup locations" is actually a list of +; address types matching the addresses defined for the current user. In that context, +; this setting optionally further limits which FOLIO address types are offered. +;limitDeliveryAddressTypes[] = "Campus" + ; By default, a "Hold" type request is placed when an item is unavailable and a Page ; when an item is available. This setting overrides the default behavior for ; unavailable items and for all title-level requests. Legal values: "Page", "Hold" or diff --git a/module/VuFind/src/VuFind/ILS/Driver/Folio.php b/module/VuFind/src/VuFind/ILS/Driver/Folio.php index 23a4c359a5b..e7160a1acfb 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Folio.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Folio.php @@ -129,6 +129,9 @@ class Folio extends AbstractAPI implements */ protected $courseCache = null; + protected $fulfillmentTypeHoldShelf = 'Hold Shelf'; + protected $fulfillmentTypeDelivery = 'Delivery'; + /** * Constructor * @@ -1180,6 +1183,7 @@ public function patronLogin($username, $password) 'firstname' => $profile->personal->firstName ?? null, 'lastname' => $profile->personal->lastName ?? null, 'email' => $profile->personal->email ?? null, + 'addressTypeIds' => array_map(fn($address) => $address->addressTypeId, $profile->personal->addresses), ]; } @@ -1411,6 +1415,22 @@ public function renewMyItems($renewDetails) */ public function getPickupLocations($patron, $holdInfo = null) { + if ($this->fulfillmentTypeDelivery == ($holdInfo['requestGroupId'] ?? null)) { + $addressTypes = $this->getAddressTypes(); + $limitDeliveryAddressTypes = $this->config['Holds']['limitDeliveryAddressTypes'] ?? []; + $deliveryPickupLocations = []; + foreach($patron['addressTypeIds'] as $addressTypeId) { + $addressType = $addressTypes[$addressTypeId]; + if (empty($limitDeliveryAddressTypes) || in_array($addressType, $limitDeliveryAddressTypes)) { + $deliveryPickupLocations[] = [ + 'locationID' => $addressTypeId, + 'locationDisplay' => $addressType, + ]; + } + } + return $deliveryPickupLocations; + } + $limitedServicePoints = null; if ( str_contains($this->config['Holds']['limitPickupLocations'] ?? '', 'itemEffectiveLocation') @@ -1444,6 +1464,101 @@ public function getPickupLocations($patron, $holdInfo = null) return $locations; } + /** + * Get Default Pick Up Location + * + * Returns the default pick up location set in HorizonXMLAPI.ini + * + * @param array $patron Patron information returned by the patronLogin + * method. + * @param array $holdDetails Optional array, only passed in when getting a list + * in the context of placing a hold; contains most of the same values passed to + * placeHold, minus the patron data. May be used to limit the pickup options + * or may be ignored. + * + * @return false|string The default pickup location for the patron or false + * if the user has to choose. + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function getDefaultPickUpLocation($patron = false, $holdDetails = null) + { + if ($this->fulfillmentTypeDelivery == ($holdInfo['requestGroupId'] ?? null)) { + $deliveryPickupLocations = $this->getPickupLocations($patron, $holdDetails); + if (count($deliveryPickupLocations) == 1) { + return $deliveryPickupLocations[0]['locationDisplay']; + } + } + return false; + } + + + /** + * Get request groups + * + * @param int $bibId BIB ID + * @param array $patron Patron information returned by the patronLogin + * method. + * @param array $holdDetails Optional array, only passed in when getting a list + * in the context of placing a hold; contains most of the same values passed to + * placeHold, minus the patron data. May be used to limit the request group + * options or may be ignored. + * + * @return array False if request groups not in use or an array of + * associative arrays with id and name keys + * + * @SuppressWarnings(PHPMD.UnusedFormalParameter) + */ + public function getRequestGroups( + $bibId = null, + $patron = null, + $holdDetails = null + ) { + // circulation-storage.request-preferences.collection.get + $response = $this->makeRequest( + 'GET', + '/request-preference-storage/request-preference?query=userId==' . $patron['id'] + ); + $requestPreferencesResponse = json_decode($response->getBody()); + $requestPreferences = $requestPreferencesResponse->requestPreferences[0]; + $allowHoldShelf = $requestPreferences->holdShelf; + $allowDelivery = $requestPreferences->delivery && ($this->config['Holds']['allowDelivery'] ?? true); + if ($allowHoldShelf && $allowDelivery) { + return [ + [ + 'id' => $this->fulfillmentTypeHoldShelf, + 'name' => 'Hold Shelf', + ], + [ + 'id' => $this->fulfillmentTypeDelivery, + 'name' => 'Delivery', + ], + ]; + } + return false; + } + + protected function getAddressTypes() + { + $cacheKey = 'addressTypes'; + $addressTypes = $this->getCachedData($cacheKey); + if (null == $addressTypes) { + $addressTypes = []; + // addresstypes.collection.get + foreach ( + $this->getPagedResults( + 'addressTypes', + '/addresstypes' + ) as $addressType + ) { + $addressTypes[$addressType->id] = $addressType->addressType; + } + $this->putCachedData($cacheKey, $addressTypes); + + } + return $addressTypes; + } + /** * This method queries the ILS for a patron's current holds * @@ -1692,13 +1807,19 @@ public function placeHold($holdDetails) // Account for an API spelling change introduced in mod-circulation v24: $fulfillmentKey = $this->getModuleMajorVersion('mod-circulation') >= 24 ? 'fulfillmentPreference' : 'fulfilmentPreference'; + $fulfillmentValue = $holdDetails['requestGroupId'] ?? $this->fulfillmentTypeHoldShelf; $requestBody = $baseParams + [ 'requesterId' => $holdDetails['patron']['id'], 'requestDate' => date('c'), - $fulfillmentKey => 'Hold Shelf', + $fulfillmentKey => $fulfillmentValue, 'requestExpirationDate' => $requiredBy, - 'pickupServicePointId' => $holdDetails['pickUpLocation'], ]; + if ($this->fulfillmentTypeHoldShelf == $fulfillmentValue) { + $requestBody['pickupServicePointId'] = $holdDetails['pickUpLocation']; + } + elseif ($this->fulfillmentTypeDelivery == $fulfillmentValue) { + $requestBody['deliveryAddressTypeId'] = $holdDetails['pickUpLocation']; + } if (!empty($holdDetails['proxiedUser'])) { $requestBody['requesterId'] = $holdDetails['proxiedUser']; $requestBody['proxyUserId'] = $holdDetails['patron']['id']; From 8d93ffdd2ea3d33e77e15ce09b4377e5231ffc81 Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Tue, 10 Sep 2024 21:10:52 +0000 Subject: [PATCH 02/16] Fix style issues --- module/VuFind/src/VuFind/ILS/Driver/Folio.php | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/module/VuFind/src/VuFind/ILS/Driver/Folio.php b/module/VuFind/src/VuFind/ILS/Driver/Folio.php index e7160a1acfb..59bf4903789 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Folio.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Folio.php @@ -129,9 +129,6 @@ class Folio extends AbstractAPI implements */ protected $courseCache = null; - protected $fulfillmentTypeHoldShelf = 'Hold Shelf'; - protected $fulfillmentTypeDelivery = 'Delivery'; - /** * Constructor * @@ -1183,7 +1180,7 @@ public function patronLogin($username, $password) 'firstname' => $profile->personal->firstName ?? null, 'lastname' => $profile->personal->lastName ?? null, 'email' => $profile->personal->email ?? null, - 'addressTypeIds' => array_map(fn($address) => $address->addressTypeId, $profile->personal->addresses), + 'addressTypeIds' => array_map(fn ($address) => $address->addressTypeId, $profile->personal->addresses), ]; } @@ -1415,11 +1412,11 @@ public function renewMyItems($renewDetails) */ public function getPickupLocations($patron, $holdInfo = null) { - if ($this->fulfillmentTypeDelivery == ($holdInfo['requestGroupId'] ?? null)) { + if ('Delivery' == ($holdInfo['requestGroupId'] ?? null)) { $addressTypes = $this->getAddressTypes(); $limitDeliveryAddressTypes = $this->config['Holds']['limitDeliveryAddressTypes'] ?? []; $deliveryPickupLocations = []; - foreach($patron['addressTypeIds'] as $addressTypeId) { + foreach ($patron['addressTypeIds'] as $addressTypeId) { $addressType = $addressTypes[$addressTypeId]; if (empty($limitDeliveryAddressTypes) || in_array($addressType, $limitDeliveryAddressTypes)) { $deliveryPickupLocations[] = [ @@ -1483,7 +1480,7 @@ public function getPickupLocations($patron, $holdInfo = null) */ public function getDefaultPickUpLocation($patron = false, $holdDetails = null) { - if ($this->fulfillmentTypeDelivery == ($holdInfo['requestGroupId'] ?? null)) { + if ('Delivery' == ($holdDetails['requestGroupId'] ?? null)) { $deliveryPickupLocations = $this->getPickupLocations($patron, $holdDetails); if (count($deliveryPickupLocations) == 1) { return $deliveryPickupLocations[0]['locationDisplay']; @@ -1492,7 +1489,6 @@ public function getDefaultPickUpLocation($patron = false, $holdDetails = null) return false; } - /** * Get request groups * @@ -1526,11 +1522,11 @@ public function getRequestGroups( if ($allowHoldShelf && $allowDelivery) { return [ [ - 'id' => $this->fulfillmentTypeHoldShelf, + 'id' => 'Hold Shelf', 'name' => 'Hold Shelf', ], [ - 'id' => $this->fulfillmentTypeDelivery, + 'id' => 'Delivery', 'name' => 'Delivery', ], ]; @@ -1538,6 +1534,11 @@ public function getRequestGroups( return false; } + /** + * Get list of address types from FOLIO. Cache as needed. + * + * @return array An array mapping an address type id to its name. + */ protected function getAddressTypes() { $cacheKey = 'addressTypes'; @@ -1554,7 +1555,6 @@ protected function getAddressTypes() $addressTypes[$addressType->id] = $addressType->addressType; } $this->putCachedData($cacheKey, $addressTypes); - } return $addressTypes; } @@ -1807,17 +1807,16 @@ public function placeHold($holdDetails) // Account for an API spelling change introduced in mod-circulation v24: $fulfillmentKey = $this->getModuleMajorVersion('mod-circulation') >= 24 ? 'fulfillmentPreference' : 'fulfilmentPreference'; - $fulfillmentValue = $holdDetails['requestGroupId'] ?? $this->fulfillmentTypeHoldShelf; + $fulfillmentValue = $holdDetails['requestGroupId'] ?? 'Hold Shelf'; $requestBody = $baseParams + [ 'requesterId' => $holdDetails['patron']['id'], 'requestDate' => date('c'), $fulfillmentKey => $fulfillmentValue, 'requestExpirationDate' => $requiredBy, ]; - if ($this->fulfillmentTypeHoldShelf == $fulfillmentValue) { + if ('Hold Shelf' == $fulfillmentValue) { $requestBody['pickupServicePointId'] = $holdDetails['pickUpLocation']; - } - elseif ($this->fulfillmentTypeDelivery == $fulfillmentValue) { + } elseif ('Delivery' == $fulfillmentValue) { $requestBody['deliveryAddressTypeId'] = $holdDetails['pickUpLocation']; } if (!empty($holdDetails['proxiedUser'])) { From f66113f814f1938fcd5cc9677d3df7f1f6abb88e Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Wed, 11 Sep 2024 12:11:38 +0000 Subject: [PATCH 03/16] Fix unit tests --- .../responses/successful-patron-login-with-okapi-legacy.json | 2 +- .../folio/responses/successful-patron-login-with-okapi.json | 2 +- .../tests/unit-tests/src/VuFindTest/ILS/Driver/FolioTest.php | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/module/VuFind/tests/fixtures/folio/responses/successful-patron-login-with-okapi-legacy.json b/module/VuFind/tests/fixtures/folio/responses/successful-patron-login-with-okapi-legacy.json index fade83cc077..be24136947b 100644 --- a/module/VuFind/tests/fixtures/folio/responses/successful-patron-login-with-okapi-legacy.json +++ b/module/VuFind/tests/fixtures/folio/responses/successful-patron-login-with-okapi-legacy.json @@ -14,6 +14,6 @@ "expectedParams": { "query": "username == foo" }, - "body": "{ \"users\": [ { \"id\": \"fake-id\", \"personal\": { \"firstName\": \"first\", \"lastName\": \"last\", \"email\": \"fake@fake.com\" } } ] }" + "body": "{ \"users\": [ { \"id\": \"fake-id\", \"personal\": { \"firstName\": \"first\", \"lastName\": \"last\", \"email\": \"fake@fake.com\", \"addresses\": [] } } ] }" } ] diff --git a/module/VuFind/tests/fixtures/folio/responses/successful-patron-login-with-okapi.json b/module/VuFind/tests/fixtures/folio/responses/successful-patron-login-with-okapi.json index 717c7f64540..789020bb68d 100644 --- a/module/VuFind/tests/fixtures/folio/responses/successful-patron-login-with-okapi.json +++ b/module/VuFind/tests/fixtures/folio/responses/successful-patron-login-with-okapi.json @@ -14,6 +14,6 @@ "expectedParams": { "query": "username == foo" }, - "body": "{ \"users\": [ { \"id\": \"fake-id\", \"personal\": { \"firstName\": \"first\", \"lastName\": \"last\", \"email\": \"fake@fake.com\" } } ] }" + "body": "{ \"users\": [ { \"id\": \"fake-id\", \"personal\": { \"firstName\": \"first\", \"lastName\": \"last\", \"email\": \"fake@fake.com\", \"addresses\": [] } } ] }" } ] diff --git a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/FolioTest.php b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/FolioTest.php index 5853232e1bf..e05e0bdc799 100644 --- a/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/FolioTest.php +++ b/module/VuFind/tests/unit-tests/src/VuFindTest/ILS/Driver/FolioTest.php @@ -332,6 +332,7 @@ public function testSuccessfulPatronLoginWithOkapi(): void 'firstname' => 'first', 'lastname' => 'last', 'email' => 'fake@fake.com', + 'addressTypeIds' => [], ]; $this->assertEquals($expected, $result); } @@ -361,6 +362,7 @@ public function testSuccessfulPatronLoginWithOkapiLegacyAuth(): void 'firstname' => 'first', 'lastname' => 'last', 'email' => 'fake@fake.com', + 'addressTypeIds' => [], ]; $this->assertEquals($expected, $result); } From 5c79c2bffb410b1dc579dadc34505d8b2868aa9a Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Tue, 1 Oct 2024 17:49:00 +0000 Subject: [PATCH 04/16] Fix typo --- config/vufind/Folio.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/vufind/Folio.ini b/config/vufind/Folio.ini index e1725d78724..4eefc15775c 100644 --- a/config/vufind/Folio.ini +++ b/config/vufind/Folio.ini @@ -123,7 +123,7 @@ extraHoldFields = requiredByDate:pickUpLocation ; When the extra hold field requestGroup is used, the request group Delivery is offered ; whenever the FOLIO user's Request Preferences have delivery enabled. This setting -; overrides every user's FOLIO seetting if it's necessary to globally disable delivery +; overrides every user's FOLIO setting if it's necessary to globally disable delivery ; for backwards compatibility. ;allowDelivery = false From 321cc9e87e05d21b1ff1145521400c079e2227a8 Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Tue, 1 Oct 2024 18:28:51 +0000 Subject: [PATCH 05/16] Protect against no addresses --- module/VuFind/src/VuFind/ILS/Driver/Folio.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/VuFind/src/VuFind/ILS/Driver/Folio.php b/module/VuFind/src/VuFind/ILS/Driver/Folio.php index 59bf4903789..e20b6565527 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Folio.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Folio.php @@ -1180,7 +1180,7 @@ public function patronLogin($username, $password) 'firstname' => $profile->personal->firstName ?? null, 'lastname' => $profile->personal->lastName ?? null, 'email' => $profile->personal->email ?? null, - 'addressTypeIds' => array_map(fn ($address) => $address->addressTypeId, $profile->personal->addresses), + 'addressTypeIds' => array_map(fn ($address) => $address->addressTypeId, $profile->personal->addresses ?? []), ]; } From 1d28e9b42546117216de399a03792ff7e1893900 Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Tue, 1 Oct 2024 18:52:08 +0000 Subject: [PATCH 06/16] Use match statement for $fulfillmentLocationKey --- module/VuFind/src/VuFind/ILS/Driver/Folio.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/module/VuFind/src/VuFind/ILS/Driver/Folio.php b/module/VuFind/src/VuFind/ILS/Driver/Folio.php index e20b6565527..cb163cca890 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Folio.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Folio.php @@ -1808,17 +1808,17 @@ public function placeHold($holdDetails) $fulfillmentKey = $this->getModuleMajorVersion('mod-circulation') >= 24 ? 'fulfillmentPreference' : 'fulfilmentPreference'; $fulfillmentValue = $holdDetails['requestGroupId'] ?? 'Hold Shelf'; + $fulfillmentLocationKey = match ($fulfillmentValue) { + 'Hold Shelf' => 'pickupServicePointId', + 'Delivery' => 'deliveryAddressTypeId', + }; $requestBody = $baseParams + [ 'requesterId' => $holdDetails['patron']['id'], 'requestDate' => date('c'), $fulfillmentKey => $fulfillmentValue, 'requestExpirationDate' => $requiredBy, + $fulfillmentLocationKey => $holdDetails['pickUpLocation'], ]; - if ('Hold Shelf' == $fulfillmentValue) { - $requestBody['pickupServicePointId'] = $holdDetails['pickUpLocation']; - } elseif ('Delivery' == $fulfillmentValue) { - $requestBody['deliveryAddressTypeId'] = $holdDetails['pickUpLocation']; - } if (!empty($holdDetails['proxiedUser'])) { $requestBody['requesterId'] = $holdDetails['proxiedUser']; $requestBody['proxyUserId'] = $holdDetails['patron']['id']; From 2242720c4d5ef357ae09bade5e3c40cb6dd0a880 Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Tue, 1 Oct 2024 18:55:14 +0000 Subject: [PATCH 07/16] Fix styles --- module/VuFind/src/VuFind/ILS/Driver/Folio.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/module/VuFind/src/VuFind/ILS/Driver/Folio.php b/module/VuFind/src/VuFind/ILS/Driver/Folio.php index cb163cca890..5ed0420d7c5 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Folio.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Folio.php @@ -1180,7 +1180,10 @@ public function patronLogin($username, $password) 'firstname' => $profile->personal->firstName ?? null, 'lastname' => $profile->personal->lastName ?? null, 'email' => $profile->personal->email ?? null, - 'addressTypeIds' => array_map(fn ($address) => $address->addressTypeId, $profile->personal->addresses ?? []), + 'addressTypeIds' => array_map( + fn ($address) => $address->addressTypeId, + $profile->personal->addresses ?? [] + ), ]; } From 74375c623e6b20daa80c2107d131fc52f1c8998c Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Tue, 1 Oct 2024 19:07:03 +0000 Subject: [PATCH 08/16] Allow translation of fulfillment method display names --- languages/en.ini | 2 ++ module/VuFind/src/VuFind/ILS/Driver/Folio.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/languages/en.ini b/languages/en.ini index 56ec648c798..4796a736bfa 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -1221,6 +1221,8 @@ renew_success = "Renewal Successful" renew_success_summary = "Successfully renewed {count, plural, =1 {1 item} other {# items}}." Renewed = "Renewed" Request full text = "Request full text" +request_group_fulfillment_method_hold_shelf = "Pick up at the library" +request_group_fulfillment_method_delivery = "Delivery to your location" request_in_transit = "In Transit to Pickup Location" request_place_text = "Place a Request" request_submit_text = "Submit Request" diff --git a/module/VuFind/src/VuFind/ILS/Driver/Folio.php b/module/VuFind/src/VuFind/ILS/Driver/Folio.php index 5ed0420d7c5..ba04b289af8 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Folio.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Folio.php @@ -1526,11 +1526,11 @@ public function getRequestGroups( return [ [ 'id' => 'Hold Shelf', - 'name' => 'Hold Shelf', + 'name' => 'fulfillment_method_hold_shelf', ], [ 'id' => 'Delivery', - 'name' => 'Delivery', + 'name' => 'fulfillment_method_delivery', ], ]; } From 48f12f6460b06e26f6aeaa7daa4c4930b1c8fdf9 Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Tue, 1 Oct 2024 19:17:53 +0000 Subject: [PATCH 09/16] Fix en.ini sort order --- languages/en.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/languages/en.ini b/languages/en.ini index 4796a736bfa..b08a1bc2733 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -1221,8 +1221,8 @@ renew_success = "Renewal Successful" renew_success_summary = "Successfully renewed {count, plural, =1 {1 item} other {# items}}." Renewed = "Renewed" Request full text = "Request full text" -request_group_fulfillment_method_hold_shelf = "Pick up at the library" request_group_fulfillment_method_delivery = "Delivery to your location" +request_group_fulfillment_method_hold_shelf = "Pick up at the library" request_in_transit = "In Transit to Pickup Location" request_place_text = "Place a Request" request_submit_text = "Submit Request" From dfd7740a92bfdcf29dd923ec85f18b8612e5701a Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Tue, 1 Oct 2024 20:04:37 +0000 Subject: [PATCH 10/16] Change hold form pickup location label based on request group --- languages/en.ini | 2 ++ themes/bootstrap3/js/hold.js | 1 + themes/bootstrap3/templates/record/hold.phtml | 6 +++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/languages/en.ini b/languages/en.ini index b08a1bc2733..d6f483c5dd7 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -1086,6 +1086,8 @@ Photo = "Photo" Physical Description = "Physical Description" Physical Object = "Physical Object" pick_up_location = "Pickup Location" +pick_up_location_label_Delivery = "Delivery Address" +pick_up_location_label_Hold Shelf = "Pickup Location" Place a Hold = "Place a Hold" Place of birth = "Place of birth" Place of death = "Place of death" diff --git a/themes/bootstrap3/js/hold.js b/themes/bootstrap3/js/hold.js index 2cf2c7c7eac..b0284ad7f02 100644 --- a/themes/bootstrap3/js/hold.js +++ b/themes/bootstrap3/js/hold.js @@ -40,6 +40,7 @@ function setUpHoldRequestForm(recordId) { $select.append(option); }); $select.show(); + $('#pickUpLocationLabel').text($self.find(':selected').data('locations-label')); } else { $select.hide(); $noResults.show(); diff --git a/themes/bootstrap3/templates/record/hold.phtml b/themes/bootstrap3/templates/record/hold.phtml index fc9adf8327d..55a16192418 100644 --- a/themes/bootstrap3/templates/record/hold.phtml +++ b/themes/bootstrap3/templates/record/hold.phtml @@ -56,7 +56,11 @@ requestGroups as $group): ?> - From dec14d301615e6dfa069a225a308f5a6dc63c0ee Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Tue, 1 Oct 2024 20:07:39 +0000 Subject: [PATCH 11/16] Update bootstrap5 --- themes/bootstrap5/js/hold.js | 1 + themes/bootstrap5/templates/record/hold.phtml | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/themes/bootstrap5/js/hold.js b/themes/bootstrap5/js/hold.js index 2cf2c7c7eac..b0284ad7f02 100644 --- a/themes/bootstrap5/js/hold.js +++ b/themes/bootstrap5/js/hold.js @@ -40,6 +40,7 @@ function setUpHoldRequestForm(recordId) { $select.append(option); }); $select.show(); + $('#pickUpLocationLabel').text($self.find(':selected').data('locations-label')); } else { $select.hide(); $noResults.show(); diff --git a/themes/bootstrap5/templates/record/hold.phtml b/themes/bootstrap5/templates/record/hold.phtml index fc9adf8327d..55a16192418 100644 --- a/themes/bootstrap5/templates/record/hold.phtml +++ b/themes/bootstrap5/templates/record/hold.phtml @@ -56,7 +56,11 @@ requestGroups as $group): ?> - From ec93804c6e9f8978cafa925af99449c6d1f43b41 Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Mon, 7 Oct 2024 19:59:34 +0000 Subject: [PATCH 12/16] Shorten fulfillment method display strings --- languages/en.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/languages/en.ini b/languages/en.ini index d6f483c5dd7..4cee2936678 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -1223,8 +1223,8 @@ renew_success = "Renewal Successful" renew_success_summary = "Successfully renewed {count, plural, =1 {1 item} other {# items}}." Renewed = "Renewed" Request full text = "Request full text" -request_group_fulfillment_method_delivery = "Delivery to your location" -request_group_fulfillment_method_hold_shelf = "Pick up at the library" +request_group_fulfillment_method_delivery = "Delivery" +request_group_fulfillment_method_hold_shelf = "Pick up" request_in_transit = "In Transit to Pickup Location" request_place_text = "Place a Request" request_submit_text = "Submit Request" From e658a5cf03d8b9703605f987f537db7f4a8f7b80 Mon Sep 17 00:00:00 2001 From: Maccabee Levine Date: Tue, 8 Oct 2024 13:01:46 +0000 Subject: [PATCH 13/16] Move locations field label into config --- config/vufind/Folio.ini | 7 +++++++ languages/en.ini | 4 ++-- module/VuFind/src/VuFind/ILS/Driver/Folio.php | 3 +++ themes/bootstrap3/templates/record/hold.phtml | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/config/vufind/Folio.ini b/config/vufind/Folio.ini index 27bf4c7ff30..cb69d43dd2b 100644 --- a/config/vufind/Folio.ini +++ b/config/vufind/Folio.ini @@ -135,6 +135,13 @@ extraHoldFields = requiredByDate:pickUpLocation ; this setting optionally further limits which FOLIO address types are offered. ;limitDeliveryAddressTypes[] = "Campus" +; When the extra hold fields pickupLocation and requestGroup are used, and the user +; selects a request group, the pickup locations field label is adjusted to be more +; appropriate to that group. This setting defines translation keys used for the label. +; Disabling these settings stops customization of the pickup locations field label. +locationsLabelByRequestGroup["Delivery"] = "pick_up_location_label_delivery" +locationsLabelByRequestGroup["Hold Shelf"] = "pick_up_location_label_hold_shelf" + ; By default, a "Hold" type request is placed when an item is unavailable and a Page ; when an item is available. This setting overrides the default behavior for ; unavailable items and for all title-level requests. Legal values: "Page", "Hold" or diff --git a/languages/en.ini b/languages/en.ini index d997f3de3f1..0affb62da8f 100644 --- a/languages/en.ini +++ b/languages/en.ini @@ -1089,8 +1089,8 @@ Photo = "Photo" Physical Description = "Physical Description" Physical Object = "Physical Object" pick_up_location = "Pickup Location" -pick_up_location_label_Delivery = "Delivery Address" -pick_up_location_label_Hold Shelf = "Pickup Location" +pick_up_location_label_delivery = "Delivery Address" +pick_up_location_label_hold_shelf = "Pickup Location" Place a Hold = "Place a Hold" Place of birth = "Place of birth" Place of death = "Place of death" diff --git a/module/VuFind/src/VuFind/ILS/Driver/Folio.php b/module/VuFind/src/VuFind/ILS/Driver/Folio.php index 9f0f0185641..e5a0f1743ef 100644 --- a/module/VuFind/src/VuFind/ILS/Driver/Folio.php +++ b/module/VuFind/src/VuFind/ILS/Driver/Folio.php @@ -1619,15 +1619,18 @@ public function getRequestGroups( $requestPreferences = $requestPreferencesResponse->requestPreferences[0]; $allowHoldShelf = $requestPreferences->holdShelf; $allowDelivery = $requestPreferences->delivery && ($this->config['Holds']['allowDelivery'] ?? true); + $locationsLabels = $this->config['Holds']['locationsLabelByRequestGroup'] ?? []; if ($allowHoldShelf && $allowDelivery) { return [ [ 'id' => 'Hold Shelf', 'name' => 'fulfillment_method_hold_shelf', + 'locationsLabel' => $locationsLabels['Hold Shelf'] ?? '', ], [ 'id' => 'Delivery', 'name' => 'fulfillment_method_delivery', + 'locationsLabel' => $locationsLabels['Delivery'] ?? '', ], ]; } diff --git a/themes/bootstrap3/templates/record/hold.phtml b/themes/bootstrap3/templates/record/hold.phtml index 55a16192418..193d27af8f1 100644 --- a/themes/bootstrap3/templates/record/hold.phtml +++ b/themes/bootstrap3/templates/record/hold.phtml @@ -58,7 +58,7 @@ requestGroups as $group): ?>