Bugzilla – Attachment 184502 Details for
Bug 40245
Support option to display firstname in memberresultst
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), 7.96 KB, created by
CJ Lynce
on 2025-07-22 18:57:26 UTC
(
hide
)
Description:
Bug 40245: Show firstname in patron search results when different than preferred_name
Filename:
MIME Type:
Creator:
CJ Lynce
Created:
2025-07-22 18:57:26 UTC
Size:
7.96 KB
patch
obsolete
>From f613710361b46bdfe9d5a5e4eee162dac8b4ab2e Mon Sep 17 00:00:00 2001 >From: CJ Lynce <cj.lynce@westlakelibrary.org> >Date: Tue, 22 Jul 2025 14:05:08 +0000 >Subject: [PATCH] Bug 40245: Show firstname in patron search results when > different than preferred_name > >This patch shows the patron's firstname in search results and autosuggestions when > thier preferred_name is different than their first name. Requires that sysprep > ShowFirstIfDifferentThanPreferred is enabled. When disabled, only the preferred > name shows in results. > >Test plan: >0. Apply patches and login to the staff interface. >1. Edit a patron to give a different preferred name than first. >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> >--- > .../intranet-tmpl/prog/en/includes/js-patron-format.inc | 8 ++++++-- > koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc | 1 + > .../intranet-tmpl/prog/en/includes/patron-search.inc | 8 ++++---- > koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 8 ++++++-- > 4 files changed, 17 insertions(+), 8 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format.inc >index 682d109b46..94fe2a6dd1 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-format.inc >@@ -5,7 +5,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 `showlegal`. > * @return {string} The formatted HTML string > */ > window.$patron_to_html = function (patron, config) { >@@ -22,13 +23,16 @@ > var firstname = escape_str(patron.firstname); > var preferred_name = escape_str(patron.preferred_name); > var surname = escape_str(patron.surname); >+ var showFirstIfDifferentThanPreferred = [% Koha.Preference('ShowFirstIfDifferentThanPreferred') | html %]; > > if (patron.middle_name != null && patron.middle_name != "") { > firstname += " " + escape_str(patron.middle_name); > preferred_name += " " + escape_str(patron.middle_name); > } > >- if (patron.other_name != null && patron.other_name != "") { >+ if (showFirstIfDifferentThanPreferred && config && config.showlegal && patron.preferred_name != patron.firstname) { >+ preferred_name += " [" + escape_str(patron.firstname) + "]"; >+ } else if (patron.other_name != null && patron.other_name != "") { > firstname += " (" + escape_str(patron.other_name) + ")"; > preferred_name += " (" + escape_str(patron.other_name) + ")"; > } >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 d968eb8286..f83cdfb927 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js_includes.inc >@@ -74,6 +74,7 @@ > var extendedPatronAttributes = "[% Koha.Preference('ExtendedPatronAttributes') | html %]"; > var loggedInLibrary = '[% Branches.GetLoggedInBranchcode | html %]'; > var singleBranchMode = '[% singleBranchMode | html %]'; >+ var showFirstIfDifferentThanPreferred = [% Koha.Preference('ShowFirstIfDifferentThanPreferred') | 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 85184bdc6a..52eeaddbfb 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-search.inc >@@ -595,9 +595,9 @@ > 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, showlegal: 1 }) + "</a>"; > [% ELSE %] >- r += $patron_to_html(row, { invert_name: 1 }); >+ r += $patron_to_html(row, { invert_name: 1, showlegal: 1 }); > [% END %] > r += '<br/>'; > r += '<div class="address"><ul>'; >@@ -619,9 +619,9 @@ > "render": function( data, type, row, meta ) { > let patron_id = encodeURIComponent(row.patron_id); > [% IF ! open_on_row_click %] >- return "<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>"; >+ return "<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, showlegal: 1 }) + "</a>"; > [% ELSE %] >- return $patron_to_html(row, { invert_name: 1 }); >+ return $patron_to_html(row, { invert_name: 1, showlegal: 1 }); > [% END %] > } > } >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index 5c4e2f6315..d7fd0c4363 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -790,8 +790,12 @@ function patron_autocomplete(node, options) { > " " + > (item.middle_name ? item.middle_name.escapeHtml() : "") + > " " + >- (item.other_name >- ? "(" + item.other_name.escapeHtml() + ")" >+ (showFirstIfDifferentThanPreferred >+ ? item.preferred_name != item.firstname >+ ? "[" + item.firstname + "]" >+ : item.other_name >+ ? "(" + item.other_name.escapeHtml() + ")" >+ : "" > : "") + > cardnumber.escapeHtml() + > " " + >-- >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