Bug 41604: Hide column if the feature is disabled
Example: supplier_report on the basket page 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>
This commit is contained in:
parent
8a5555238d
commit
e616be2e42
|
|
@ -1530,13 +1530,27 @@ function update_search_description(
|
|||
options
|
||||
);
|
||||
|
||||
settings["buttons"] = _dt_buttons({ settings, table_settings });
|
||||
|
||||
if (add_filters) {
|
||||
settings["orderCellsTop"] = true;
|
||||
}
|
||||
|
||||
if (table_settings) {
|
||||
// Deal with visibility_condition
|
||||
// Column must be hidden and cannot be toggled if condition is false
|
||||
table_settings.columns = table_settings.columns.map(c => {
|
||||
if (
|
||||
c.visibility_condition !== undefined &&
|
||||
!c.visibility_condition
|
||||
) {
|
||||
return {
|
||||
...c,
|
||||
is_hidden: true,
|
||||
cannot_be_toggled: true,
|
||||
};
|
||||
}
|
||||
return c;
|
||||
});
|
||||
|
||||
let state_settings = _dt_save_restore_state(
|
||||
table_settings,
|
||||
external_filter_nodes
|
||||
|
|
@ -1562,6 +1576,8 @@ function update_search_description(
|
|||
}
|
||||
}
|
||||
|
||||
settings["buttons"] = _dt_buttons({ settings, table_settings });
|
||||
|
||||
var default_column_defs = [
|
||||
{ targets: ["string-sort"], type: "string" },
|
||||
{ targets: ["anti-the"], type: "anti-the" },
|
||||
|
|
|
|||
|
|
@ -206,6 +206,38 @@ describe("kohaTable (using REST API)", () => {
|
|||
});
|
||||
});
|
||||
|
||||
it("One column hidden, feature is off {visibility_condition: false} - Save state is ON", () => {
|
||||
build_libraries().then(() => {
|
||||
cy.visit("/cgi-bin/koha/admin/branches.pl");
|
||||
|
||||
cy.mock_table_settings({
|
||||
default_save_state: 1,
|
||||
columns: {
|
||||
library_code: {
|
||||
is_hidden: true,
|
||||
visibility_condition: false,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
cy.get("@columns").then(columns => {
|
||||
cy.get(`#${table_id} th`).should(
|
||||
"have.length",
|
||||
columns.length - 1
|
||||
);
|
||||
cy.get(`#${table_id} th`).contains("Name");
|
||||
cy.get(`#${table_id} th`)
|
||||
.contains("Code")
|
||||
.should("not.exist");
|
||||
cy.get(`#${table_id}_wrapper .buttons-colvis`).click();
|
||||
// The feature is off, the column cannot be displayed
|
||||
cy.get(`#${table_id}_wrapper .dt-button-collection`)
|
||||
.contains("Code")
|
||||
.should("not.exist");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("Force visibility of one column", () => {
|
||||
build_libraries().then(() => {
|
||||
cy.visit("/cgi-bin/koha/admin/branches.pl");
|
||||
|
|
|
|||
Loading…
Reference in New Issue