Bug 41079: Force visibility for columns depending on sysprefs

If two sysprefs are disabled we must hide the two related columns.
We should also force the visibility of the checkboxes: on the first
screen (op=show/edition) they must be displayed, on the result screen
(op=show_results) the must be hidden.

Test plan:
1. Create a report to see some patrons:
    SELECT cardnumber FROM borrowers WHERE cardnumber LIKE '%2'
2. Run report and select 'Batch operations ...'
3. Batch patron modification
=> Notice that the table has the checkboxes in the first column
=> The table is sorted by cardnumber
4. Perform the modification
=> Notice that the result table does not have the checkboxes in the first column
=> The table is still sorted by cardnumber

Additional tests:
1. If the logged in user is superlibrarian then the columns "Password expiration date"
and "Protected" are displayed
2. Play with the table's settings and columns visibility to confirm that
they are working correctly (they were not before this patch set)

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 17a07dcc2a)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Jonathan Druart 2025-10-23 10:00:35 +02:00 committed by Paul Derscheid
parent a09945c29d
commit fc8b400a4c
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 39 additions and 10 deletions

View File

@ -251,7 +251,7 @@
<tbody>
[% FOREACH borrower IN borrowers %]
<tr>
<td [% IF op != 'show' %]class="NoVisible"[% END %]>
<td>
<input type="checkbox" name="borrowernumber" value="[% borrower.borrowernumber | html %]" checked="checked" />
</td>
<td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% borrower.borrowernumber | uri %]">[% borrower.cardnumber | html %]</a></td>
@ -484,18 +484,47 @@
<script>
var patron_attributes_lib = new Array();
var patron_attributes_values = new Array();
var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'batch_patron_modification', 'borrowerst', 'json' ) | $raw %];
[% FOREACH attrh IN attributes_header %]
table_settings["columns"].push({
columname: "[% attrh.attribute | html %]",
cannot_be_modified: 0,
cannot_be_toggled: 0,
is_hidden: 0
});
[% END %]
$(document).ready(function() {
[% IF borrowers %]
var table_settings = [% TablesSettings.GetTableSettings( 'tools', 'batch_patron_modification', 'borrowerst', 'json' ) | $raw %];
[% FOREACH attrh IN attributes_header %]
table_settings["columns"].push({
columname: "[% attrh.attribute | html %]",
cannot_be_modified: 0,
cannot_be_toggled: 0,
is_hidden: 0
});
[% END %]
let selections_column = table_settings.columns.find(c => c.columnname == 'batch_patron_edit_selections');
selections_column.cannot_be_modified = 1;
selections_column.cannot_be_toggled = 1;
selections_column.force_visibility = 1;
[% IF op == 'show' %]
selections_column.is_hidden = 0;
[% ELSE %]
selections_column.is_hidden = 1;
[% END %]
[% UNLESS CanUpdatePasswordExpiration %]
let password_expiration_date_column = table_settings.columns.find(c => c.columnname == 'batch_patron_edit_password_expiration_date');
password_expiration_date_column.is_hidden = 1;
password_expiration_date_column.cannot_be_modified = 1;
password_expiration_date_column.cannot_be_toggled = 1;
password_expiration_date_column.force_visibility = 1;
[% END %]
[% UNLESS CanUpdateProtectPatron %]
let protected_column = table_settings.columns.find(c => c.columnname == 'batch_patron_edit_protected');
protected_column.is_hidden = 1;
protected_column.cannot_be_modified = 1;
protected_column.cannot_be_toggled = 1;
protected_column.force_visibility = 1;
[% END %]
let patron_table = $("#borrowerst").kohaTable(
{
order: [[1, "asc"]],