Bugzilla – Attachment 154578 Details for
Bug 34517
Add option to search patron attribute in standard search
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34517: Add option search patron attributes by default
Bug-34517-Add-option-search-patron-attributes-by-d.patch (text/plain), 7.80 KB, created by
Nick Clemens (kidclamp)
on 2023-08-17 20:03:47 UTC
(
hide
)
Description:
Bug 34517: Add option search patron attributes by default
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-08-17 20:03:47 UTC
Size:
7.80 KB
patch
obsolete
>From 5441c293a063eb4c99187a18a550214c677329ff Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 11 Aug 2023 19:31:57 +0000 >Subject: [PATCH] Bug 34517: Add option search patron attributes by default > >This patch moves form any staff_searchable attribute being automatically >included in the the Standard patron serch, to allowing the librarian to choose. >Current searchable attributes will be marked as 'searched_by_default' > >To test: >1 - Add a searchable patron attribute type >2 - Add some values >3 - Confirm they are searched in a 'Standard' patron search >4 - Apply patch >5 - Go to admin - >patron attribute types >6 - Note new 'Searching' column >7 - Confirm attribute is 'Searched by default' >8 - Confirm searches work as before >9 - Edit the attribute type >10 - Uncheck 'searched_by_default' >11 - Save >12 - Confirm attribute not searched in 'Standard' search >13 - Select the attribute in patron search dropdowns >14 - Confirm it is correctly searched >--- > admin/patron-attr-types.pl | 2 + > .../prog/en/includes/patron-search.inc | 2 +- > .../en/modules/admin/patron-attr-types.tt | 44 ++++++++++++++++++- > .../intranet-tmpl/prog/js/staff-global.js | 2 +- > 4 files changed, 47 insertions(+), 3 deletions(-) > >diff --git a/admin/patron-attr-types.pl b/admin/patron-attr-types.pl >index e89b8927765..ca5d2fca476 100755 >--- a/admin/patron-attr-types.pl >+++ b/admin/patron-attr-types.pl >@@ -117,6 +117,7 @@ sub add_update_attribute_type { > my $opac_display = $input->param('opac_display') ? 1 : 0; > my $opac_editable = $input->param('opac_editable') ? 1 : 0; > my $staff_searchable = $input->param('staff_searchable') ? 1 : 0; >+ my $searched_by_default = $input->param('searched_by_default') ? 1 : 0; > my $keep_for_pseudonymization = $input->param('keep_for_pseudonymization') ? 1 : 0; > my $mandatory = $input->param('mandatory') ? 1 : 0; > my $authorised_value_category = $input->param('authorised_value_category'); >@@ -152,6 +153,7 @@ sub add_update_attribute_type { > opac_display => $opac_display, > opac_editable => $opac_editable, > staff_searchable => $staff_searchable, >+ searched_by_default => $searched_by_default, > keep_for_pseudonymization => $keep_for_pseudonymization, > mandatory => $mandatory, > authorised_value_category => $authorised_value_category, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >index 8ea0b10db5a..feb02463277 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -233,7 +233,7 @@ > }, {}); > > [% IF Koha.Preference('ExtendedPatronAttributes') %] >- [% SET extended_attribute_types = [ ExtendedAttributeTypes.codes( staff_searchable => 1 ) ] %] >+ [% SET extended_attribute_types = [ ExtendedAttributeTypes.codes( staff_searchable => 1, searched_by_default => 1 ) ] %] > let extended_attribute_types = [% To.json(extended_attribute_types || []) | $raw %]; > [% END %] > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >index 2129798b317..7e5f4043d6a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/patron-attr-types.tt >@@ -169,7 +169,21 @@ > [% ELSE %] > <input type="checkbox" id="staff_searchable" name="staff_searchable" /> > [% END %] >- <span class="hint">Check to make this attribute staff_searchable in the staff patron search.</span> >+ <span class="hint"> >+ Check to make this attribute searchable in staff patron searches. If >+ checked, this attribute will appear in patron search dropdowns. >+ </span> >+ </li> >+ <li><label for="searched_by_default">Search by default: </label> >+ [% IF attribute_type AND attribute_type.searched_by_default %] >+ <input type="checkbox" id="searched_by_default" name="searched_by_default" checked="checked" /> >+ [% ELSE %] >+ <input type="checkbox" id="searched_by_default" name="searched_by_default" /> >+ [% END %] >+ <span class="hint"> >+ If checked, this field will be included in 'Standard' patron searches. Requires >+ field to be marked as searchable above >+ </span> > </li> > <li><label for="mandatory">Mandatory: </label> > [% IF attribute_type AND attribute_type.mandatory %] >@@ -299,6 +313,7 @@ > <th>Library limitation</th> > <th>Authorized value category</th> > <th>Mandatory</th> >+ <th>Searching</th> > <th class="NoSort noExport">Actions</th> > </tr> > </thead> >@@ -338,6 +353,17 @@ > <span>No</span> > [% END %] > </td> >+ <td> >+ [% IF ( item.staff_searchable ) %] >+ [% IF( item.searched_by_default ) %] >+ <span>Searched by default</span> >+ [% ELSE %] >+ <span>Searchable</span> >+ [% END %] >+ [% ELSE %] >+ <span>Not searchable</span> >+ [% END %] >+ </td> > <td class="actions"> > <a class="btn btn-default btn-xs" href="[% script_name | url %]?op=edit_attribute_type&code=[% item.code | uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a> > <a class="btn btn-default btn-xs" href="[% script_name | url %]?op=delete_attribute_type&code=[% item.code | uri %]"><i class="fa fa-trash-can"></i> Delete</a> >@@ -372,6 +398,22 @@ > [% INCLUDE 'columns_settings.inc' %] > <script> > $(document).ready(function() { >+ >+ function toggle_search_default(){ >+ if( $("#staff_searchable").is(":checked") ){ >+ $("#searched_by_default").prop('disabled', false); >+ } else { >+ >+ $("#searched_by_default").prop('disabled', true).prop('checked',false); >+ } >+ } >+ $("#staff_searchable").on('change',function(){ >+ toggle_search_default(); >+ }); >+ >+ toggle_search_default(); >+ >+ > if ( $("#branches option:selected").length < 1 ) { > $("#branches option:first").attr("selected", "selected"); > } >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index b254bd69a0a..48c0463958a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -613,7 +613,7 @@ function buildPatronSearchQuery(term, options) { > q.push({ "-or": term_subquery_or }); > > // Add each pattern for each extended patron attributes >- if ( typeof options !== 'undefined' && ( (options.search_fields == 'standard' && options.extended_attribute_types) || searched_attribute_fields ) && extendedPatronAttributes) { >+ if ( typeof options !== 'undefined' && ( (options.search_fields == 'standard' && options.extended_attribute_types) || ( searched_attribute_fields.length > 0 ) ) && extendedPatronAttributes) { > extended_attribute_codes_to_search = (searched_attribute_fields.length > 0) ? searched_attribute_fields : options.extended_attribute_types; > extended_attribute_subquery_and = []; > patterns.forEach(function (pattern, i) { >-- >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 34517
:
154389
|
154390
|
154391
|
154392
|
154575
|
154576
|
154577
|
154578
|
154608
|
154610
|
154611
|
154612
|
154613
|
154614
|
154615
|
154616
|
154617
|
154618
|
154619
|
154620
|
154622
|
154623
|
154624
|
154625
|
158429
|
158430
|
158431
|
158432
|
158433
|
158876
|
158878