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 <pedro.amorim@openfifth.co.uk>
This commit is contained in:
Martin Renvoize 2026-07-01 13:51:13 +01:00 committed by Pedro Amorim
parent b51a3f111a
commit 1e0442b847
No known key found for this signature in database
GPG Key ID: 06B75BA7F3894D55
3 changed files with 15 additions and 19 deletions

View File

@ -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 -%]

View File

@ -258,15 +258,7 @@
<td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber | uri %]">[% borrower.cardnumber | html %]</a></td>
<td>[% borrower.surname | html %]</td>
<td>[% borrower.firstname | html %]</td>
<td>
[% IF borrower.sex == 'F' %]
Female
[% ELSIF borrower.sex == 'M' %]
Male
[% ELSIF borrower.sex == 'O' %]
[% tp('gender', 'Other') | html %]
[% END %]
</td>
<td> [% INCLUDE 'patron-sex-label.inc' sex = borrower.sex %] </td>
<td>[% Branches.GetName( borrower.branchcode ) | html %]</td>
<td>[% Categories.GetName(borrower.categorycode) | html %]</td>
<td>[% borrower.streetnumber | html %]</td>
@ -422,12 +414,8 @@
<select id="[% field.name | html %]" name="[% field.name | html %]">
[% FOREACH opt IN field.option %]
<option value="[% opt.value | html %]">
[% IF field.name == 'sex' && opt.value == 'F' %]
Female
[% ELSIF field.name == 'sex' && opt.value == 'M' %]
Male
[% ELSIF field.name == 'sex' && opt.value == 'O' %]
[% tp('gender', 'Other') | html %]
[% IF field.name == 'sex' %]
[% INCLUDE 'patron-sex-label.inc' sex = opt.value %]
[% ELSE %]
[% opt.lib | html %]
[% END %]

View File

@ -226,10 +226,10 @@ if ( $op eq 'cud-show' || $op eq 'show' ) {
name => "sex",
type => "select",
option => [
{ value => "", lib => "" },
{ value => "F", lib => "Female" },
{ value => "M", lib => "Male" },
{ value => "O", lib => "Other" },
{ value => "" },
{ value => "F" },
{ value => "M" },
{ value => "O" },
],
mandatory => ( grep /sex/, @mandatoryFields ) ? 1 : 0,
},