Bugzilla – Attachment 188008 Details for
Bug 40968
'Edit this search' forgets about 'whole_records' and 'weighted_fields'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40968: Make 'Edit this search' aware of 'whole_records' and 'weighted_fields'
937ca08.patch (text/plain), 6.87 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-10-16 13:30:53 UTC
(
hide
)
Description:
Bug 40968: Make 'Edit this search' aware of 'whole_records' and 'weighted_fields'
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-10-16 13:30:53 UTC
Size:
6.87 KB
patch
obsolete
>From 937ca08b8cfb27d70014d8f723dfa6664b586df5 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= <tomascohen@theke.io> >Date: Tue, 7 Oct 2025 15:31:39 -0300 >Subject: [PATCH] Bug 40968: Make 'Edit this search' aware of 'whole_records' > and 'weighted_fields' >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >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 (as weighted_fields is >on by default, we rely on a new parameter to achieve this) >* 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 > >Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> >--- > catalogue/search.pl | 24 +++++++++++++------ > .../prog/en/modules/catalogue/advsearch.tt | 4 ++-- > .../bootstrap/en/modules/opac-advsearch.tt | 2 +- > opac/opac-search.pl | 2 +- > 4 files changed, 21 insertions(+), 11 deletions(-) > >diff --git a/catalogue/search.pl b/catalogue/search.pl >index 596c5d428a1..dc9930a11ee 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -277,7 +277,10 @@ 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'), >+ weight_search => scalar $cgi->param('weight_search'), >+ weight_search_submitted => scalar $cgi->param('weight_search_submitted'), > ); > > # determine what to display next to the search boxes >@@ -340,6 +343,10 @@ 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('weight_search') >+ || $cgi->param('weight_search_submitted') ); > $template->param( expanded_options => $expanded ); > } > >@@ -740,12 +747,15 @@ $template->param( > $template->param( > > #classlist => $classlist, >- total => $total, >- opacfacets => 1, >- facets_loop => $facets, >- displayFacetCount => C4::Context->preference('displayFacetCount') || 0, >- scan => $scan, >- search_error => $error, >+ total => $total, >+ opacfacets => 1, >+ facets_loop => $facets, >+ displayFacetCount => C4::Context->preference('displayFacetCount') || 0, >+ scan => $scan, >+ search_error => $error, >+ weight_search => $weight_search, >+ weight_search_submitted => $params->{'weight_search_submitted'}, >+ whole_record => $whole_record, > ); > > if ( $query_desc || $limit_desc ) { >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 8f28f329beb..6d6fa3bfd1f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt >@@ -153,11 +153,11 @@ > [% IF ( expanded_options ) %] > <p> > [% IF Koha.Preference('ElasticsearchMARCFormat') == 'ARRAY' %] >- <label><input type="checkbox" name="whole_record" /> Search entire MARC record</label> >+ <label><input type="checkbox" name="whole_record" [% IF whole_record %]checked="checked"[% END %] /> Search entire MARC record</label> > [% END %] > <span id="weight_search"> > <input type="hidden" name="weight_search_submitted" value="1" /> >- <label><input type="checkbox" name="weight_search" checked="checked" /> Apply field weights to search</label> >+ <label><input type="checkbox" name="weight_search" [% IF weight_search_submitted %][% IF weight_search %]checked="checked"[% END %][% ELSE %]checked="checked"[% END %] /> Apply field weights to search</label> > </span> > </p> > [% ELSE %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt >index 2df04d7e19f..217327176eb 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-advsearch.tt >@@ -153,7 +153,7 @@ > <div id="weight_search"> > <input type="hidden" name="weight_search_submitted" value="1" /> > <label> >- <input type="checkbox" name="weight_search" checked="checked" /> >+ <input type="checkbox" name="weight_search" [% IF weight_search_submitted %][% IF weight_search %]checked="checked"[% END %][% ELSE %]checked="checked"[% END %] /> > Apply field weights to search > </label> > </div> >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index dc7a86ae4d6..afb830100e7 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -527,7 +527,7 @@ if ( C4::Context->preference('OpacSuppression') ) { > { > suppress => $suppress, > is_opac => 1, >- weighted_fields => $weight_search, >+ weight_search => $weight_search, > weight_search_submitted => $cgi->param('weight_search_submitted') > } > ); >-- >2.51.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40968
:
187544
| 188008