Bug 33568: Fix patron_to_html display

Take HidePatronName into account
Display cardnumber
Remove parenthesis around cardnumber if the name is hidden

Signed-off-by: Laurence Rault <laurence.rault@biblibre.com>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2023-10-31 08:45:56 +01:00 committed by Katrin Fischer
parent ce216aaa82
commit 59a7a68fea
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
2 changed files with 18 additions and 9 deletions

View File

@ -76,6 +76,7 @@
[% BLOCK build_items_table_js %]
<script>
let hide_patron_name = [% !Koha.Preference('HidePatronName') ? 'false' : 'true' %];
[% IF StaffDetailItemSelection %]
let items_selection = {};
@ -454,11 +455,11 @@
nodes += '<span>';
if ( row.checkout.onsite_checkout ) {
let patron_to_html = $patron_to_html(row.checkout.patron, { url: true });
let patron_to_html = $patron_to_html(row.checkout.patron, { url: true, display_cardnumber: true, hide_patron_name });
nodes += _("Currently in local use by %s").format(patron_to_html);
} else {
nodes += '<span class="datedue">';
let patron_to_html = $patron_to_html(row.checkout.patron, { url: true });
let patron_to_html = $patron_to_html(row.checkout.patron, { url: true, display_cardnumber: true, hide_patron_name });
nodes += _("Checked out to %s").format(patron_to_html);
}
nodes += ': ';
@ -504,7 +505,7 @@
[%# Hacky for patron_to_html in case we simply want to display the patron's library name %]
row.first_hold.patron.library = { name: libraries_names.get(row.first_hold.patron.library_id) };
let patron_to_html = $patron_to_html(row.first_hold.patron, { url: true });
let patron_to_html = $patron_to_html(row.first_hold.patron, { url: true, display_cardnumber: true, hide_patron_name });
nodes += ' <span class="heldfor">%s</span>'.format(_("Hold for: %s").format(patron_to_html));
}
[% END %]
@ -521,7 +522,7 @@
[%# Hacky for patron_to_html in case we simply want to display the patron's library name %]
row.recall.patron.library = { name: libraries_names.get(row.recall.patron.library_id) };
let patron_to_html = $patron_to_html(row.recall.patron, {url: true });
let patron_to_html = $patron_to_html(row.recall.patron, {url: true, display_cardnumber: true, hide_patron_name });
nodes += '<span>%s</span>'.format(_("recalled by %s on %s").format(patron_to_html, $date(row.recall.created_date)))
}
}

View File

@ -36,8 +36,20 @@
name = firstname + ' ' + surname;
}
if ( name.replace(' ', '').length == 0 ) {
return _("A patron from library %s".format(patron.library.name));
}
if ( config && config.hide_patron_name ) {
name = '';
}
if ( config && config.display_cardnumber ) {
name = name + ' (' + escape_str(patron.cardnumber) + ')';
if ( name.length > 0 ) {
name = name + ' (' + escape_str(patron.cardnumber) + ')';
} else {
name = escape_str(patron.cardnumber);
}
}
if (config && config.url) {
@ -49,10 +61,6 @@
}
}
if ( name.replace(' ', '').length == 0 ) {
name = _("A patron from library %s".format(patron.library.name));
}
return name;
};
})();