From 1e0442b847d372c8f46a41c2ca8af3dd58aa1b48 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 1 Jul 2026 13:51:13 +0100 Subject: [PATCH] Bug 41105: (QA follow-up) DRY out gender label rendering The gender-code-to-label mapping (F/M/O -> Female/Male/Other) was duplicated between the results table cell and the edit-form select options in modborrowers.tt. Extract it into a shared patron-sex-label.inc so there is a single place defining the mapping, and drop the now-unused "lib" values from the sex options in tools/modborrowers.pl (labels are supplied by the include, keyed on the option value, rather than by Perl). Test plan: 1. Navigate to Patrons and click Search, to display a list of patrons. 2. Select all results and click "Batch patron modification". 3. Verify the "Gender" column displays Female/Male/Other correctly. 4. Verify the "Gender" edit dropdown still offers Female/Male/Other and saves correctly. Signed-off-by: Pedro Amorim --- .../prog/en/includes/patron-sex-label.inc | 8 ++++++++ .../prog/en/modules/tools/modborrowers.tt | 18 +++--------------- tools/modborrowers.pl | 8 ++++---- 3 files changed, 15 insertions(+), 19 deletions(-) create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/patron-sex-label.inc diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-sex-label.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-sex-label.inc new file mode 100644 index 0000000000..e32ec12fd5 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-sex-label.inc @@ -0,0 +1,8 @@ +[%# The variable sex must be passed, containing a patron's gender code (F, M, O, or blank) -%] +[%- IF sex == 'F' -%] + Female +[%- ELSIF sex == 'M' -%] + Male +[%- ELSIF sex == 'O' -%] + [% tp('gender', 'Other') | html %] +[%- END -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt index 9867a8e63d..3781659fbf 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/modborrowers.tt @@ -258,15 +258,7 @@ [% borrower.cardnumber | html %] [% borrower.surname | html %] [% borrower.firstname | html %] - - [% IF borrower.sex == 'F' %] - Female - [% ELSIF borrower.sex == 'M' %] - Male - [% ELSIF borrower.sex == 'O' %] - [% tp('gender', 'Other') | html %] - [% END %] - + [% INCLUDE 'patron-sex-label.inc' sex = borrower.sex %] [% Branches.GetName( borrower.branchcode ) | html %] [% Categories.GetName(borrower.categorycode) | html %] [% borrower.streetnumber | html %] @@ -422,12 +414,8 @@