From 7cad3c56d065daa7cb6538b49b2fd4b59f48496d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 17 Dec 2021 10:19:35 +0100 Subject: [PATCH] Bug 29723: Add a "Configure table" button for KohaTable tables This patch suggests to have a "Configure table" button when a table can be configured in the "Table settings" administraition area. Test plan: Go to different views where the table can be configured (you an exhaustive list on bug 29648), notice the "Configure table" button (if you have the 'manage_column_config' subpermission. Note that the link is correct but the scrollbar is not adjusted at the correct position. Maybe we could improve that switching to the bootstrap accordion plugin? Signed-off-by: Martin Renvoize --- Koha/Template/Plugin/TablesSettings.pm | 8 +++++++- .../prog/en/includes/columns_settings.inc | 11 +++++++++++ .../intranet-tmpl/prog/en/includes/doc-head-close.inc | 5 +++++ koha-tmpl/intranet-tmpl/prog/js/datatables.js | 11 +++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Koha/Template/Plugin/TablesSettings.pm b/Koha/Template/Plugin/TablesSettings.pm index 720b67445a..2eb443f74e 100644 --- a/Koha/Template/Plugin/TablesSettings.pm +++ b/Koha/Template/Plugin/TablesSettings.pm @@ -134,7 +134,13 @@ sub GetTableSettings { my $settings = C4::Utils::DataTables::TablesSettings::get_table_settings( $module, $page, $table ); my $columns = C4::Utils::DataTables::TablesSettings::get_columns( $module, $page, $table ); - $settings->{columns} = $columns; + $settings = { + %$settings, + columns => $columns, + module => $module, + page => $page, + table => $table, + }; return $format eq 'json' ? to_json( $settings || {} ) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc index ea3d2d2888..27a7cbba69 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc @@ -161,6 +161,17 @@ function KohaTable(id_selector, dt_parameters, table_settings, add_filters) { } ); + if ( CAN_user_parameters_manage_column_config ) { + dt_parameters[ "buttons" ].push( + { + text: 'Configure this table', + action: function() { + window.location = '/cgi-bin/koha/admin/columns_settings.pl?module=' + table_settings['module'] + '#' + table_settings['page'] + '#' + table_settings['table']; + }, + } + ); + } + var table = $(selector); if ( add_filters ) { // Duplicate the table header row for columnFilter diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc index b35c001820..e4be83f166 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/doc-head-close.inc @@ -29,6 +29,11 @@ [% IF lang && lang != 'en' %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index 21dfe52636..c5f346f60e 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -813,6 +813,17 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { } ); + if ( CAN_user_parameters_manage_column_config ) { + settings[ "buttons" ].push( + { + text: 'Configure this table', + action: function() { + window.location = '/cgi-bin/koha/admin/columns_settings.pl?module=' + table_settings['module'] + '#' + table_settings['page'] + '#' + table_settings['table']; + }, + } + ); + } + $(".dt_button_clear_filter, .columns_controls, .export_controls").tooltip(); if ( add_filters ) { -- 2.20.1