Bug 41604: Centralize visibility condition in datatables.js
We want to hide column if: * the feature is not accessible (pref disabled or insufficient permissions) or * the column is hidden in the settings or * the column has been hidden by the user Signed-off-by: Jason Robb <jrobb@sekls.org> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Jason Robb <jrobb@sekls.org> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Pedro Amorim <pedro.amorim@openfifth.co.uk>
This commit is contained in:
parent
306ebc18ea
commit
7c688774f1
|
|
@ -36,36 +36,29 @@ function LoadIssuesTable() {
|
|||
$("#issues-table").show();
|
||||
$("#issues-table-actions").show();
|
||||
var msg_loading = __("Loading... you may continue scanning.");
|
||||
|
||||
let renew_column = table_settings_issues_table.columns.find(
|
||||
c => c.columnname == "renew"
|
||||
);
|
||||
|
||||
if (!AllowCirculate) {
|
||||
renew_column.is_hidden = 1;
|
||||
renew_column.force_visibility = 1;
|
||||
} else {
|
||||
renew_column.is_hidden = 0;
|
||||
}
|
||||
renew_column.visibility_condition = AllowCirculate;
|
||||
renew_column.force_visibility = 1;
|
||||
|
||||
let checkin_column = table_settings_issues_table.columns.find(
|
||||
c => c.columnname == "checkin"
|
||||
);
|
||||
checkin_column.visibility_condition = AllowCirculate;
|
||||
checkin_column.force_visibility = 1;
|
||||
|
||||
let claims_returned_column = table_settings_issues_table.columns.find(
|
||||
c => c.columnname == "claims_returned"
|
||||
);
|
||||
if (!ClaimReturnedLostValue) {
|
||||
claims_returned_column.is_hidden = 1;
|
||||
} else {
|
||||
claims_returned_column.is_hidden = 0;
|
||||
}
|
||||
claims_returned_column.visibility_condition = ClaimReturnedLostValue;
|
||||
claims_returned_column.force_visibility = 1;
|
||||
|
||||
let export_column = table_settings_issues_table.columns.find(
|
||||
c => c.columnname == "export"
|
||||
);
|
||||
if (!exports_enabled) {
|
||||
export_column.is_hidden = 1;
|
||||
} else {
|
||||
export_column.is_hidden = 0;
|
||||
}
|
||||
export_column.visibility_condition = exports_enabled;
|
||||
export_column.force_visibility = 1;
|
||||
|
||||
issuesTable = $("#issues-table").kohaTable(
|
||||
|
|
|
|||
|
|
@ -1000,14 +1000,18 @@ function _dt_force_visibility(table_settings, table_dt, state) {
|
|||
.join(",")
|
||||
)
|
||||
.every(function () {
|
||||
state.columns[this.index()].visible =
|
||||
table_settings.columns.find(
|
||||
c =>
|
||||
c.columnname ==
|
||||
this.header().getAttribute("data-colname")
|
||||
).is_hidden
|
||||
? false
|
||||
: true;
|
||||
let column = table_settings.columns.find(
|
||||
c =>
|
||||
c.columnname ==
|
||||
this.header().getAttribute("data-colname")
|
||||
);
|
||||
if (
|
||||
!column.visibility_condition ||
|
||||
(column.is_hidden && column.cannot_be_toggled)
|
||||
) {
|
||||
state.columns[this.index()].visible = false;
|
||||
state.columns[this.index()].cannot_be_toggled = true;
|
||||
}
|
||||
});
|
||||
} else {
|
||||
throw new Error(
|
||||
|
|
|
|||
Loading…
Reference in New Issue