Bugzilla – Attachment 188113 Details for
Bug 40245
Support option to display firstname in patron search results when different than preferred_name
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40245: Show firstname in patron search results when different than preferred_name
Bug-40245-Show-firstname-in-patron-search-results-.patch (text/plain), 6.08 KB, created by
Andrew Fuerste-Henry
on 2025-10-17 17:59:51 UTC
(
hide
)
Description:
Bug 40245: Show firstname in patron search results when different than preferred_name
Filename:
MIME Type:
Creator:
Andrew Fuerste-Henry
Created:
2025-10-17 17:59:51 UTC
Size:
6.08 KB
patch
obsolete
>From 2d774ccad5e3a07c936e5ba38b42a3dc9a2ad484 Mon Sep 17 00:00:00 2001 >From: CJ Lynce <cj.lynce@westlakelibrary.org> >Date: Mon, 13 Oct 2025 22:20:35 +0000 >Subject: [PATCH] Bug 40245: Show firstname in patron search results when > different than preferred_name > >This patch shows the patron's firstname in patron search results and autosuggestions > when the patrons preferred_name is different than their first name. Requires that > the ShowPatronFirstnameIfDifferentThanPreferredname system preference is enabled. > >Test plan: >0. Apply patches and login to the staff interface. >1. Edit a patron to give a different preferred name than firstname. >2. Return to home page and search for the patron in the quick-search bar. >3. Verify patron shows up in autosuggest list, showing preferred name only. >4. Verify patron shows up in regular list (member.pl) with preferred name showing only. >5. Change syspref ShowFirstIfDifferentThanPreferred to "Show" and save. >6. Return to home page and search for the patron in the quick-search bar. >7. Verify patron shows up in autosuggest list, showing preferred name, and firstname in brackets. >8. Verify patron shows up in regular list (member.pl) with preferred name, and firstname in brackets. > >Sponsored-by: Westlake Porter Public Library <https://westlakelibrary.org> >Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com> >--- > .../intranet-tmpl/prog/en/includes/js_includes.inc | 1 + > .../intranet-tmpl/prog/en/includes/patron-search.inc | 5 +++-- > koha-tmpl/intranet-tmpl/prog/js/patron-format.js | 12 +++++++++++- > koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 2 ++ > 4 files changed, 17 insertions(+), 3 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >index 75ca87955c3..189a2687c9c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >@@ -75,6 +75,7 @@ > var extendedPatronAttributes = "[% Koha.Preference('ExtendedPatronAttributes') | html %]"; > var loggedInLibrary = '[% Branches.GetLoggedInBranchcode | html %]'; > var singleBranchMode = '[% singleBranchMode | html %]'; >+ var showPatronFirstnameIfDifferentThanPreferredname = [% Koha.Preference('ShowPatronFirstnameIfDifferentThanPreferredname') ? 1 : 0 | html %]; > </script> > [% IF ( PatronAutoComplete ) %] > <script> >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 384cf72157a..97226c5db88 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -594,9 +594,10 @@ > let patron_id = encodeURIComponent(row.patron_id); > let r = ''; > [% IF ! open_on_row_click %] >- r += "<a href=\"/cgi-bin/koha/members/moremember.pl?borrowernumber=" + patron_id + "\" class=\"patron_name\" data-borrowernumber=\"" + patron_id + "\" style=\"white-space:nowrap\">" + $patron_to_html(row, { invert_name: 1 }) + "</a>"; >+ r += "<a href=\"/cgi-bin/koha/members/moremember.pl?borrowernumber=" + patron_id + "\" class=\"patron_name\" data-borrowernumber=\"" + patron_id + "\" style=\"white-space:nowrap\">" >+ + $patron_to_html(row, { invert_name: 1, showDiffFirstname: [% Koha.Preference('ShowPatronFirstnameIfDifferentThanPreferredname') ? 1 : 0 | html %] }) + "</a>"; > [% ELSE %] >- r += $patron_to_html(row, { invert_name: 1 }); >+ r += $patron_to_html(row, { invert_name: 1, showDiffFirstname: [% Koha.Preference('ShowPatronFirstnameIfDifferentThanPreferredname') ? 1 : 0 | html %] }); > [% END %] > r += '<br/>'; > r += '<div class="address"><ul>'; >diff --git a/koha-tmpl/intranet-tmpl/prog/js/patron-format.js b/koha-tmpl/intranet-tmpl/prog/js/patron-format.js >index 10223b07472..3973703e5eb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/patron-format.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/patron-format.js >@@ -3,7 +3,8 @@ > * Format the patron response from a Koha RESTful API request. > * @param {Object} patron The patron json object as returned from the Koha RESTful API > * @param {Object} config A configuration object >- * Valid keys are: `invert_name`, `display_cardnumber` and `url` >+ * Valid keys are: `invert_name`, `display_cardnumber', `url` >+ * and `showDiffFirstname` > * @return {string} The formatted HTML string > */ > window.$patron_to_html = function (patron, config) { >@@ -33,6 +34,15 @@ > preferred_name += " (" + escape_str(patron.other_name) + ")"; > } > >+ if ( >+ config && >+ config.showDiffFirstname && >+ patron.preferred_name != patron.firstname >+ ) { >+ preferred_name += >+ " <em>[" + escape_str(patron.firstname) + "]</em>"; >+ } >+ > const nameParts = []; > if (config?.invert_name) { > // Invert: "Surname, Preferred" >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index 13eccbfbcf6..2ccbf99e342 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -804,6 +804,8 @@ function patron_autocomplete(node, options) { > $patron_to_html(item, { > display_cardnumber: true, > invert_name: true, >+ showDiffFirstname: >+ showPatronFirstnameIfDifferentThanPreferredname, > }) + > " " + > (item.date_of_birth >-- >2.39.5
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 40245
:
184501
|
184502
|
184637
|
184638
|
184639
|
185601
|
185602
|
185603
|
186732
|
186733
|
187891
|
187892
|
187893
|
187943
|
188112
|
188113
|
188114
|
188811
|
188812
|
188813