From fb526fb155143a62ea24a8433f58c1c79c1a0179 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Sun, 12 Jan 2020 20:28:16 +0000 Subject: [PATCH] Bug 16784: Add table configuration on suggestions table This patch adds DataTables column configuration and export options to the suggestions management tables in the staff interface. The columns settings made via the administrative interface will affect tables under each tab in the interface whether it be organized by status, library, etc. However because of the way the KohaTable function is currently written, changes made via the "Columns" button will only affect the visible table. To test, apply the patch and go to Acquisitions -> Suggestions. - Under each tab, the table of suggestions should have a DataTables toolbar with export and columns buttons. These controls should work correctly: - Showing and hiding columns should work as expected - Exports should work, excluding the first and last columns - Test the tables when using the various "Organize by" settings. - Test changing the settings in Administration -> Columns settings. - Verify that the changes you make to that configuration are reflected in the suggestions tables. Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize --- admin/columns_settings.yml | 27 ++++++++++++ .../prog/en/modules/suggestion/suggestion.tt | 42 ++++++++++--------- 2 files changed, 50 insertions(+), 19 deletions(-) diff --git a/admin/columns_settings.yml b/admin/columns_settings.yml index c1fdf398ca..e4353226a1 100644 --- a/admin/columns_settings.yml +++ b/admin/columns_settings.yml @@ -101,6 +101,33 @@ modules: cannot_be_toggled: 1 cannot_be_modified: 1 + suggestions: + suggestions: + - + columnname: selections + cannot_be_toggled: 1 + cannot_be_modified: 1 + - + columnname: suggestion + - + columnname: suggested_by + - + columnname: suggested_on + - + columnname: managed_by + - + columnname: managed_on + - + columnname: library + - + columnname: library_fund + - + columnname: suggestion_status + - + columnname: actions + cannot_be_toggled: 1 + cannot_be_modified: 1 + admin: currency: currencies-table: diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt index b896da541d..397dcb2f6c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt @@ -4,6 +4,7 @@ [% USE AuthorisedValues %] [% USE KohaDates %] [% USE Price %] +[% USE ColumnsSettings %] [% SET footerjs = 1 %] [% INCLUDE 'doc-head-open.inc' %] Koha › Acquisitions › @@ -501,7 +502,7 @@ <table id="[% suggestion.suggestiontype | html %]t" class="sorted"> <thead> <tr> - <th class="NoSort"> </th> + <th class="NoSort noExport"> </th> <th class="anti-the">Suggestion</th> <th>Suggested by</th> <th>Suggested on</th> @@ -510,7 +511,7 @@ <th>Library</th> <th>Fund</th> <th>Status</th> - <th class="NoSort"> </th> + <th class="NoSort noExport"> </th> </tr> </thead> <tbody> @@ -810,7 +811,7 @@ [% MACRO jsinclude BLOCK %] [% INCLUDE 'calendar.inc' %] [% IF ( op == 'show' || op_else ) %] - <script type="text/javascript"> + <script> $(document).ready(function(){ $(".deletesuggestion").on("click",function(){ return confirm(_("Are you sure you want to delete this suggestion?")); @@ -820,8 +821,9 @@ [% END %] [% IF ( op_else ) %] [% INCLUDE 'datatables.inc' %] + [% INCLUDE 'columns_settings.inc' %] [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %] - <script type="text/javascript"> + <script> /** * displayOther. * This function display the select or an textaera to write a reason. @@ -831,20 +833,22 @@ $("#"+show+id).show(); } $(document).ready(function() { - $('#suggestiontabs').tabs({ - // Correct table sizing for tables hidden in tabs - // http://www.datatables.net/examples/api/tabs_and_scrolling.html - "activate": function(event, ui) { - $( $.fn.dataTable.tables( true ) ).DataTable().columns.adjust(); - } - }); - $(".sorted").dataTable($.extend(true, {}, dataTablesDefaults, { - "aoColumnDefs": [ - { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] }, - { "sType": "anti-the", "aTargets" : [ "anti-the" ] } - ], - "sPaginationType": "full" - })); + $('#suggestiontabs').tabs(); + + columns_settings = [% ColumnsSettings.GetColumns( 'acqui', 'suggestions', 'suggestions', 'json' ) | $raw %] + [% FOREACH suggestion IN suggestions %] + [% IF ( suggestion.suggestions_loop ) %] + KohaTable("[% suggestion.suggestiontype %]t", { + "sorting": [[ 1, "asc" ]], + "autoWidth": false, + "columnDefs": [ + { "sortable": false, "searchable": false, 'targets': [ 'NoSort' ] }, + { "sType": "anti-the", "aTargets" : [ "anti-the" ] }, + ] + }, columns_settings ); + [% END %] + [% END %] + [% FOREACH suggestion IN suggestions %] // functions for [% suggestion.suggestiontype | html %] interactions $("#CheckAll[% suggestion.suggestiontype | html %]").click(function(e){ @@ -948,7 +952,7 @@ </script> [% END %] [% IF ( op_save ) %] - <script type="text/javascript"> + <script> $(document).ready(function(){ calcNewsuggTotal(); $("#quantity,#price,#currency").on("change",function(){ -- 2.39.5