Bug 16784: Add table configuration on suggestions table
authorOwen Leonard <oleonard@myacpl.org>
Sun, 12 Jan 2020 20:28:16 +0000 (20:28 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 20 Jan 2020 16:37:21 +0000 (16:37 +0000)
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 <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

admin/columns_settings.yml
koha-tmpl/intranet-tmpl/prog/en/modules/suggestion/suggestion.tt

index c1fdf39..e435322 100644 (file)
@@ -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:
index b896da5..397dcb2 100644 (file)
@@ -4,6 +4,7 @@
 [% USE AuthorisedValues %]
 [% USE KohaDates %]
 [% USE Price %]
+[% USE ColumnsSettings %]
 [% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Acquisitions  &rsaquo;
     <table id="[% suggestion.suggestiontype | html %]t" class="sorted">
         <thead>
             <tr>
-                <th class="NoSort">&nbsp;</th>
+                <th class="NoSort noExport">&nbsp;</th>
                 <th class="anti-the">Suggestion</th>
                 <th>Suggested by</th>
                 <th>Suggested on</th>
                 <th>Library</th>
                 <th>Fund</th>
                 <th>Status</th>
-                <th class="NoSort">&nbsp;</th>
+                <th class="NoSort noExport">&nbsp;</th>
             </tr>
     </thead>
         <tbody>
 [% 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?"));
     [% 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.
                 $("#"+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){
         </script>
     [% END %]
     [% IF ( op_save )  %]
-        <script type="text/javascript">
+        <script>
             $(document).ready(function(){
                 calcNewsuggTotal();
                 $("#quantity,#price,#currency").on("change",function(){