From 82fc579d20755771e9e11cde17cde9b905a38bd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9=20Zermatten?= Date: Fri, 12 Jul 2024 16:22:20 +0100 Subject: [PATCH 1/8] feat: Location class has showInSearchFacet property --- code/web/sys/LibraryLocation/Location.php | 1 + 1 file changed, 1 insertion(+) diff --git a/code/web/sys/LibraryLocation/Location.php b/code/web/sys/LibraryLocation/Location.php index a83a224a0a..a5dcb5b202 100644 --- a/code/web/sys/LibraryLocation/Location.php +++ b/code/web/sys/LibraryLocation/Location.php @@ -45,6 +45,7 @@ class Location extends DataObject { public $createSearchInterface; public $showInSelectInterface; public $showOnDonationsPage; + public $showInSearchFacet; public $enableAppAccess; public $appReleaseChannel; public $theme; From 307f2f64357e55aafadbf98c3a4730574bf1a91a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9=20Zermatten?= Date: Fri, 26 Jul 2024 14:07:47 +0100 Subject: [PATCH 2/8] complete merge --- .../version_updates/24.08.00.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/code/web/sys/DBMaintenance/version_updates/24.08.00.php b/code/web/sys/DBMaintenance/version_updates/24.08.00.php index 6061b179f1..10d0cc9c05 100644 --- a/code/web/sys/DBMaintenance/version_updates/24.08.00.php +++ b/code/web/sys/DBMaintenance/version_updates/24.08.00.php @@ -100,6 +100,25 @@ function getUpdates24_08_00(): array { ] ], //web_builder_custom_form_increase_email + //James Staub - Nashville Public Library + 'web_builder_custom_form_increase_email' => [ + 'title' => 'Increase Web Builder Custom Form "Email Results To" field character limit.', + 'description' => 'Increase Web Builder Custom Form "Email Results To" field character limit.', + 'continueOnError' => true, + 'sql' => [ + "ALTER TABLE web_builder_custom_form MODIFY COLUMN emailResultsTo VARCHAR(150)", + ] + ], //web_builder_custom_form_increase_email + + //chloe - PTFS-Europe + 'show_in_search_facet_column' => [ + 'title' => 'Show In Search Facet Column', + 'description' => 'Adds the showInSearchFacet column to the Location table', + // 'continueOnError' => false, + 'sql' => [ + 'ALTER TABLE location ADD COLUMN showInSearchFacet TINYINT(1) DEFAULT 1' + ] + ], //show_in_search_facet_column //other ]; From 9abd660f569fd43b149e9b3850bcff95b88a60e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9=20Zermatten?= Date: Mon, 15 Jul 2024 13:37:17 +0100 Subject: [PATCH 3/8] feat: toggle showInSearchFacet setting in branch editor --- code/web/sys/LibraryLocation/Location.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/code/web/sys/LibraryLocation/Location.php b/code/web/sys/LibraryLocation/Location.php index a5dcb5b202..cf7ca86526 100644 --- a/code/web/sys/LibraryLocation/Location.php +++ b/code/web/sys/LibraryLocation/Location.php @@ -892,6 +892,15 @@ static function getObjectStructure($context = ''): array { 'default' => true, 'forcesReindex' => true, ], + [ + 'property' => 'showInSearchFacet', + 'type' => 'checkbox', + 'label' => 'Show This Branch In Search Facet', + 'description' => 'Whether or not the library should appear as a location that can be selected to filter search results by.', + 'hideInLists' => true, + 'default' => true, + 'forcesReindex' => true, + ], [ 'property' => 'additionalLocationsToShowAvailabilityFor', 'type' => 'text', From 5c4ccf9d4c3c68fa28717c3a1f9c918340927d43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9=20Zermatten?= Date: Thu, 18 Jul 2024 18:34:22 +0100 Subject: [PATCH 4/8] feat: fetch a list of branches related to main Get the list of branches related to the main branch, and swap the original keys (integers) for the names of the branches, so that the branches can easily be accessed in the list later on by doing $branchlist[$branchName]. --- code/web/sys/SearchObject/GroupedWorkSearcher2.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/code/web/sys/SearchObject/GroupedWorkSearcher2.php b/code/web/sys/SearchObject/GroupedWorkSearcher2.php index 6cb309e921..d476d163cf 100644 --- a/code/web/sys/SearchObject/GroupedWorkSearcher2.php +++ b/code/web/sys/SearchObject/GroupedWorkSearcher2.php @@ -785,6 +785,19 @@ public function getFacetList($filter = null) { $numValidLibraries = 0; // Loop through values: $isScopedField = $this->isScopedField($field); + + // Get a list of branches so we can access their 'showInSearchFacet' value + // Also rename the keys to the branches' names so they can easily be accessed later + $branchList = null; + if ($field == 'available_at') { + $mainBranch = new Location(); + $branchList = $mainBranch->getLocationListAsObjects(false); + // may need to be optimised / unsure how heavy this is + foreach ($branchList as $key=>$value) { + $branchList[$value->displayName] = $value; + unset($branchList[$key]); + } + } foreach ($data as $facet) { // Initialize the array of data about the current facet: $currentSettings = []; From 7985d9ec69c53a43696722d389c2d7c5f01a9c56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9=20Zermatten?= Date: Thu, 18 Jul 2024 18:38:53 +0100 Subject: [PATCH 5/8] feat: filter out branches for which showInSearchFacet="0" This ensures that, when a user runs a search, the list of branches displaying under 'Available At' in the 'Narrow Your Results' facet list is filtered, and only includes branches for which the 'Show This Branch In Search Facet' setting has not been disabled by an admin. --- code/web/sys/SearchObject/GroupedWorkSearcher2.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/code/web/sys/SearchObject/GroupedWorkSearcher2.php b/code/web/sys/SearchObject/GroupedWorkSearcher2.php index d476d163cf..7bf8d84f36 100644 --- a/code/web/sys/SearchObject/GroupedWorkSearcher2.php +++ b/code/web/sys/SearchObject/GroupedWorkSearcher2.php @@ -802,6 +802,17 @@ public function getFacetList($filter = null) { // Initialize the array of data about the current facet: $currentSettings = []; $facetValue = $facet[0]; + + // if populating the array of facet options for 'available at' + // then filter out any branch (location) for which showInSearchFacet has been set to "0" + // thus preventing these branches from being displayed as search by options + if ($field == 'available_at') { + $branchName = substr($facetValue, 5); + if (empty($branchList[$branchName]->showInSearchFacet)) { + continue; + } + } + if ($isScopedField && strpos($facetValue, '#') !== false) { $facetValue = substr($facetValue, strpos($facetValue, '#') + 1); } From 7b1270701d2e9bd6206b2d88a2b25e723c59cc05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9=20Zermatten?= Date: Fri, 19 Jul 2024 08:05:42 +0100 Subject: [PATCH 6/8] docs: update changelog --- code/web/release_notes/24.08.00.MD | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/code/web/release_notes/24.08.00.MD b/code/web/release_notes/24.08.00.MD index e2901017ab..ed5fbafae8 100644 --- a/code/web/release_notes/24.08.00.MD +++ b/code/web/release_notes/24.08.00.MD @@ -100,6 +100,10 @@ To generate the passkey file, the following command should be run (as root): // other +// chloe +### Other Updates +- Adds a new setting to Location(branch) which enables admins to toggle the visibility of specific branches under the 'Available At' search facet. + ## This release includes code contributions from - ByWater Solutions - Mark Noble (MDN) @@ -113,6 +117,7 @@ To generate the passkey file, the following command should be run (as root): - PTFS-Europe - Pedro Amorim (PA) - Alexander Blanchard (AB) + - Chloe Zermatten (CZ) - Jacob O'Mara (JOM) - Theke Solutions From 909f2c506cf809a6795f08338ae36d1c15a63ea4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9=20Zermatten?= Date: Thu, 25 Jul 2024 17:56:21 +0100 Subject: [PATCH 7/8] fix: hide causes reindex message With this search facet location options filter occuring at runtime, the 'Updating this setting causes a nightly reindex' message should not be displayed. --- code/web/sys/LibraryLocation/Location.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/web/sys/LibraryLocation/Location.php b/code/web/sys/LibraryLocation/Location.php index cf7ca86526..2b0199f5bd 100644 --- a/code/web/sys/LibraryLocation/Location.php +++ b/code/web/sys/LibraryLocation/Location.php @@ -899,7 +899,7 @@ static function getObjectStructure($context = ''): array { 'description' => 'Whether or not the library should appear as a location that can be selected to filter search results by.', 'hideInLists' => true, 'default' => true, - 'forcesReindex' => true, + 'forcesReindex' => false, ], [ 'property' => 'additionalLocationsToShowAvailabilityFor', From f15c6a7ba7ef9fed62b3290b98a420b0d2f30e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chlo=C3=A9=20Zermatten?= Date: Fri, 26 Jul 2024 15:08:55 +0100 Subject: [PATCH 8/8] feat: also hide selected location from branch search facet The 'branch' facet, which can be added to the list of search facets to be displayed, also contains locations (library branches) and therefore must also be affected by the filter, which is what this commit implements. --- code/web/sys/SearchObject/GroupedWorkSearcher2.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/web/sys/SearchObject/GroupedWorkSearcher2.php b/code/web/sys/SearchObject/GroupedWorkSearcher2.php index 7bf8d84f36..d53d9ec783 100644 --- a/code/web/sys/SearchObject/GroupedWorkSearcher2.php +++ b/code/web/sys/SearchObject/GroupedWorkSearcher2.php @@ -789,7 +789,7 @@ public function getFacetList($filter = null) { // Get a list of branches so we can access their 'showInSearchFacet' value // Also rename the keys to the branches' names so they can easily be accessed later $branchList = null; - if ($field == 'available_at') { + if ($field == 'available_at' || $field == 'owning_location') { $mainBranch = new Location(); $branchList = $mainBranch->getLocationListAsObjects(false); // may need to be optimised / unsure how heavy this is @@ -806,7 +806,7 @@ public function getFacetList($filter = null) { // if populating the array of facet options for 'available at' // then filter out any branch (location) for which showInSearchFacet has been set to "0" // thus preventing these branches from being displayed as search by options - if ($field == 'available_at') { + if ($field == 'available_at' || $field == 'owning_location') { $branchName = substr($facetValue, 5); if (empty($branchList[$branchName]->showInSearchFacet)) { continue;