Bugzilla – Attachment 169494 Details for
Bug 37442
Add customizable dropdown selections for the advanced search filters
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37442: Add customizable dropdown selections for the advanced search filters
Bug-37442-Add-customizable-dropdown-selections-for.patch (text/plain), 13.78 KB, created by
Eric Garcia
on 2024-07-24 14:31:37 UTC
(
hide
)
Description:
Bug 37442: Add customizable dropdown selections for the advanced search filters
Filename:
MIME Type:
Creator:
Eric Garcia
Created:
2024-07-24 14:31:37 UTC
Size:
13.78 KB
patch
obsolete
>From 3a691d4581ef68659661fb38b6c945ad8d4ba612 Mon Sep 17 00:00:00 2001 >From: Sam Lau <samalau@gmail.com> >Date: Tue, 23 Jul 2024 19:59:57 +0000 >Subject: [PATCH] Bug 37442: Add customizable dropdown selections for the > advanced search filters > >To test: >1) Apply patch, restart_all >2) Visit Tools->HTML customizations >3) Click 'New entry using text editor' >4) For 'Display location', select "StaffAdvancedSearchList" >5) Make the publication date today. >6) For the content, put some dropdown options... you can paste in this block for example: > ><option value="au">Author</option> ><option value="ti">Title</option> ><option value="bc">Barcode</option> > >7) Visit the Advanced search page >8) In the search dropdowns, notice that there are only the options that you provided (Author, Title, Barcode) >9) In the top search dropdown, select 'Title' and type in "the" >10) Press 'Search'. The search completes succesfully. Now press 'Edit this search' >11) You should be brought back to the 'Advanced search' page and the top dropdown should be selected as 'Title' and have "the" prefilled. >12) In the second search dropdown, select "Author" and type in "John" >13) Now press search. Once again press "Edit this search" and note the items are prefilled correctly. >14) Go back to Tools->HTML customizations and delete the 'StaffAdvancedSearchList' we initially created. >15) Back at the 'Advanced search' page, the dropdown options should be back to the default. Do some searches to ensure the searches work, and when editing, the options are correctly prefilled. > >Signed-off-by: Eric Garcia <cubingguy714@gmail.com> >--- > .../prog/en/includes/search_indexes.inc | 170 ++---------------- > .../prog/en/modules/catalogue/advsearch.tt | 20 ++- > .../en/modules/tools/additional-contents.tt | 2 +- > 3 files changed, 32 insertions(+), 160 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc >index f668fdcc9b..c0dfc00947 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/search_indexes.inc >@@ -1,189 +1,45 @@ > [% USE Koha %] >+[% USE AdditionalContents %] >+[% USE raw %] >+ > [% IF refiner %] >- <select class="advsearch" name="idx" id="refiner_idx"> >+ <select class="advsearch" name="idx" id="refiner_idx_[% index | html %]" data-preselect="[% preselect | html %]"> > [% ELSE %] >- <select class="advsearch" name="idx" id="idx"> >+ <select class="advsearch" name="idx" id="idx_[% index | html %]" data-preselect="[% preselect | html %]"> > [% END %] >- [% IF ms_kw %] >- <option selected="selected" value="kw">Keyword</option> >+ [% SET StaffAdvancedSearchList = AdditionalContents.get( location => "StaffAdvancedSearchList", lang => lang, library => logged_in_user.branchcode ) -%] >+ [% IF StaffAdvancedSearchList.content %] >+ [% FOREACH block IN StaffAdvancedSearchList.content %] >+ [%- block.content | $raw -%] >+ [% END %] > [% ELSE %] > <option value="kw">Keyword</option> >- [% END %] >- [% IF ms_kwcommaphr %] >- <option selected="selected" value="kw,phr"> Keyword as phrase</option> >- [% ELSE %] > <option value="kw,phr"> Keyword as phrase</option> >- [% END %] >- [% IF ms_au %] >- <option selected="selected" value="au">Author</option> >- [% ELSE %] > <option value="au">Author</option> >- [% END %] >- [% IF ms_aucommaphr %] >- <option selected="selected" value="au,phr"> Author as phrase</option> >- [% ELSE %] > <option value="au,phr"> Author as phrase</option> >- [% END %] >- [% IF ms_cpn %] >- <option selected="selected" value="cpn"> Corporate name</option> >- [% ELSE %] > <option value="cpn"> Corporate name</option> >- [% END %] >- [% IF ms_cfn %] >- <option selected="selected" value="cfn"> Conference name</option> >- [% ELSE %] > <option value="cfn"> Conference name</option> >- [% END %] >- [% IF ms_cpncommaphr %] >- <option selected="selected" value="cpn,phr"> Corporate name as phrase</option> >- [% ELSE %] > <option value="cpn,phr"> Corporate name as phrase</option> >- [% END %] >- [% IF ms_cfncommaphr %] >- <option selected="selected" value="cfn,phr"> Conference name as phrase</option> >- [% ELSE %] > <option value="cfn,phr"> Conference name as phrase</option> >- [% END %] >- [% IF ms_pn %] >- <option selected="selected" value="pn"> Personal name</option> >- [% ELSE %] > <option value="pn"> Personal name</option> >- [% END %] >- [% IF ms_pncommaphr %] >- <option selected="selected" value="pn,phr"> Personal name as phrase</option> >- [% ELSE %] > <option value="pn,phr"> Personal name as phrase</option> >- [% END %] >- [% IF ms_ti %] >- <option selected="selected" value="ti">Title</option> >- [% ELSE %] > <option value="ti">Title</option> >- [% END %] >- [% IF ms_ticommaphr %] >- <option selected="selected" value="ti,phr"> Title as phrase</option> >- [% ELSE %] > <option value="ti,phr"> Title as phrase</option> >- [% END %] >- [% IF ms_se %] >- <option selected="seleced" value="se"> Series title</option> >- [% ELSE %] > <option value="se"> Series title</option> >- [% END %] >- [% IF ms_su %] >- <option selected="selected" value="su">Subject</option> >- [% ELSE %] > <option value="su">Subject</option> >- [% END %] >- [% IF ms_sucommaphr %] >- <option selected="selected" value="su,phr"> Subject as phrase</option> >- [% ELSE %] > <option value="su,phr"> Subject as phrase</option> >- [% END %] >- [% IF ( expanded_options ) %] >- [% IF ms_sudashbr %] >- <option selected="selected" value="su-br"> Subject and broader terms</option> >- [% ELSE %] >- <option value="su-br"> Subject and broader terms</option> >- [% END %] >- [% IF ms_sudashna %] >- <option selected="selected" value="su-na"> Subject and narrower terms</option> >- [% ELSE %] >- <option value="su-na"> Subject and narrower terms</option> >- [% END %] >- [% IF ms_sudashrl %] >- <option selected="selected" value="su-rl"> Subject and related terms</option> >- [% ELSE %] >- <option value="su-rl"> Subject and related terms</option> >- [% END %] >- [% END %] >- [% IF ms_bc %] >- <option selected="selected" value="bc">Barcode</option> >- [% ELSE %] > <option value="bc">Barcode</option> >- [% END %] >- [% IF ms_locationcommawrdl %] >- <option selected="selected" value="location,wrdl" title="Enter location code value for search">Shelving location (code)</option> >- [% ELSE %] > <option value="location,wrdl" title="Enter location code value for search">Shelving location (code)</option> >- [% END %] >- [% IF ( Koha.Preference('IntranetNumbersPreferPhrase') ) %] >- [% IF ms_identcommaphr %] >- <option selected="selected" value="ident,phr">Standard number</option> >- [% ELSE %] >- <option value="ident,phr">Standard number</option> >- [% END %] >- [% ELSE %] >- [% IF ms_ident %] >- <option selected="selected" value="ident">Standard number</option> >- [% ELSE %] >- <option value="ident">Standard number</option> >- [% END %] >- [% END %] >- [% IF ms_nb %] >- <option selected="selected" value="nb"> ISBN</option> >- [% ELSE %] >+ <option value="ident">Standard number</option> > <option value="nb"> ISBN</option> >- [% END %] >- [% IF ms_ns %] >- <option selected="selected" value="ns"> ISSN</option> >- [% ELSE %] > <option value="ns"> ISSN</option> >- [% END %] >- [% IF ( Koha.Preference('IntranetNumbersPreferPhrase') ) %] >- [% IF ms_callnumcommaphr %] >- <option selected="selected" value="callnum,phr"> Call number</option> >- [% ELSE %] >- <option value="callnum,phr"> Call number</option> >- [% END %] >- [% ELSE %] >- [% IF ms_callnum %] >- <option selected="selected" value="callnum"> Call number</option> >- [% ELSE %] >- <option value="callnum"> Call number</option> >- [% END %] >- [% END %] >- [% IF ms_lncommartrn %] >- <option selected="selected" value="ln,rtrn">Language</option> >- [% ELSE %] >+ <option value="callnum"> Call number</option> > <option value="ln,rtrn">Language</option> >- [% END %] >- [% IF ms_nt %] >- <option selected="selected" value="nt">Notes/Comments</option> >- [% ELSE %] > <option value="nt">Notes/Comments</option> >- [% END %] >- [% IF (marcflavour != 'UNIMARC' ) %] >- [% IF ms_curriculum %] >- <option selected="selected" value="curriculum">Curriculum</option> >- [% ELSE %] >- <option value="curriculum">Curriculum</option> >- [% END %] >- [% END %] >- [% IF ms_pb %] >- <option selected="selected" value="pb">Publisher</option> >- [% ELSE %] >+ <option value="curriculum">Curriculum</option> > <option value="pb">Publisher</option> >- [% END %] >- [% IF ms_pl %] >- <option selected="selected" value="pl">Publisher location</option> >- [% ELSE %] > <option value="pl">Publisher location</option> >- [% END %] >- >- [%# Use non-normalized st-year instead of st-numeric, %] >- [%# since pubdate can include 'u' to signify unknown %] >- [%# dates. See "Legal Characters" at: %] >- [%# http://www.loc.gov/marc/bibliographic/bd008a.html %] >- [%# This search is also for date ranges due to the %] >- [%# special Zebra r=r CCL mapping for 'yr' %] >- [% IF ms_yrcommastdashyear %] >- <option selected="selected" value="yr,st-year">Publication date (yyyy-yyyy)</option> >- [% ELSE %] > <option value="yr,st-year">Publication date (yyyy-yyyy)</option> >- [% END %] >- [% IF ms_acqdatecommastdashdatedashnormalized %] >- <option selected="selected" value="acqdate,st-date-normalized">Acquisition date (yyyy-mm-dd)</option> >- [% ELSE %] > <option value="acqdate,st-date-normalized">Acquisition date (yyyy-mm-dd)</option> > [% END %] > </select> >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 0d0ec4ce3f..3a4bfe55f2 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/advsearch.tt >@@ -174,8 +174,8 @@ > [% ELSE %] > <div> > [% END %] >- [% SET preselect = 'ms_' _ indexes.${loop.index}.replace(',','comma') %] >- [% INCLUDE 'search_indexes.inc' ${preselect} = 1 %] >+ [% SET preselect = indexes.${loop.index} %] >+ [% INCLUDE 'search_indexes.inc' ${preselect} = preselect index = loop.index %] > <input type="text" size="30" name="q" title="Enter search terms" value="[% query | html %]" /> > [% IF ( expanded_options ) %] > [% IF ( loop.last ) %] >@@ -516,6 +516,22 @@ > }); > [% END %] > >+ function preselectOptions() { >+ const dropdowns = document.querySelectorAll('.advsearch'); >+ dropdowns.forEach(dropdown => { >+ const preselectValue = dropdown.dataset.preselect; >+ if (preselectValue) { >+ const options = dropdown.querySelectorAll('option'); >+ for (let i = 0; i < options.length; i++) { >+ if (options[i].value === preselectValue) { >+ options[i].selected = true; >+ break; >+ } >+ } >+ } >+ }); >+ } >+ preselectOptions(); > > }); > </script> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt >index bdf8a0a089..470ae82a2c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/additional-contents.tt >@@ -536,7 +536,7 @@ > [% END %] > [% END %] > </optgroup> >- [% SET staff_available_options = [ 'IntranetmainUserblock', 'StaffAcquisitionsHome', 'StaffAuthoritiesHome', 'StaffCataloguingHome', 'StaffListsHome', 'StaffPatronsHome', 'StaffPOSHome', 'StaffSerialsHome' ] %] >+ [% SET staff_available_options = [ 'IntranetmainUserblock', 'StaffAcquisitionsHome', 'StaffAdvancedSearchList', 'StaffAuthoritiesHome', 'StaffCataloguingHome', 'StaffListsHome', 'StaffPatronsHome', 'StaffPOSHome', 'StaffSerialsHome' ] %] > <optgroup label="Staff"> > [% FOREACH l IN staff_available_options.sort %] > [% IF l == location %] >-- >2.30.2
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 37442
:
169448
| 169494