From 59e574339735e11e634a0e92e058d51c15f8229f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= Date: Tue, 7 Oct 2025 15:31:39 -0300 Subject: [PATCH] Bug 40968: Make 'Edit this search' aware of 'whole_records' and 'weighted_fields' This patch makes the advanced search page that gets pre-filled with previous searches (a.k.a 'Edit this search') behave like this: * 'More options' is preselected if any of 'whole_records' or 'weighted_fields' query parameters are passed * In Edit-mode, the checkboxes for those are pre-filled with the passed values * In normal mode, the current behavior is preserved to avoid changing it. To test: 1. Apply bug 40966 2. Perform an adv search as in that bug. Using the 'More options' tab. 3. Include any of the following options (or both): * Search entire MARC record * Apply field weights to search 4. Notice the facets include 'whole_records=1' and/or 'weighted_fields=1' (this is the bug 40966 patch in action) 5. hover the 'Edit this search' link => SUCCESS: It gets the query parameters passed through 6. Click on the link => FAIL: None is really set, we lost search information. 7. Go back to the search results 8. Apply this patch 9. Refresh the page 10. Click on the 'Edit this search' link => SUCCESS: The page is pre-loaded with the right values for 'Search entire MARC record' and 'Apply field weights to search' 11. Sign off :-D --- catalogue/search.pl | 5 ++++- .../intranet-tmpl/prog/en/modules/catalogue/advsearch.tt | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/catalogue/search.pl b/catalogue/search.pl index b723855d066..d62d14cb4f5 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -277,7 +277,9 @@ if ( $template_type eq 'advsearch' ) { @operators = $cgi->multi_param('op'); @indexes = $cgi->multi_param('idx'); $template->param( - sort => scalar $cgi->param('sort_by'), + sort => scalar $cgi->param('sort_by'), + whole_record => scalar $cgi->param('whole_record'), + weighted_fields => scalar $cgi->param('weighted_fields'), ); # determine what to display next to the search boxes @@ -340,6 +342,7 @@ if ( $template_type eq 'advsearch' ) { { $expanded = C4::Context->preference("expandedSearchOption") || 0 if !defined($expanded) || $expanded !~ /^0|1$/; + $expanded = 1 if ( $cgi->param('whole_record') || $cgi->param('weighted_fields') ); $template->param( expanded_options => $expanded ); } diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt index ab6b53aac6d..5d403484b35 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt @@ -153,10 +153,12 @@ [% IF ( expanded_options ) %]

[% IF Koha.Preference('ElasticsearchMARCFormat') == 'ARRAY' %] - + [% END %] - +

[% ELSE %] -- 2.51.0