Bug 20350: Add column configuration to table of saved reports
authorOwen Leonard <oleonard@myacpl.org>
Wed, 7 Mar 2018 15:39:49 +0000 (15:39 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 5 Apr 2018 17:17:36 +0000 (14:17 -0300)
This patch makes changes to the saved reports template to enable a
columns configuration button. Settings for the table have been added to
columns_settings.yml.

To test, apply the patch and go to Reports -> Use saved.

 - Confirm that there is a "Column visibility" button in the
   table's pagination toolbar.
 - Confirm that showing and hiding columns via the button is working
   correctly.
 - Confirm that the first, second, and last columns cannot be toggled.

Go to Administration -> Columns settings.

- Expand the "Reports" section.
- Find "id=table_reports."
- Make some selections to configure default settings of the reports
  table.
- Return to reports and confirm that these defaults are applied.

Signed-off-by: Jesse Maseto <jesse@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
admin/columns_settings.yml
koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt

index f56a745..d1a5920 100644 (file)
@@ -317,6 +317,49 @@ modules:
         -
           columnname: notes
 
+    saved-sql:
+      table_reports:
+        -
+          columnname: selection
+          cannot_be_toggled: 1
+          cannot_be_modified: 1
+        -
+          columnname: report_id
+          cannot_be_toggled: 1
+          cannot_be_modified: 1
+        -
+          columnname: report_name
+        -
+          columnname: type
+        -
+          columnname: group
+        -
+          columnname: subgroup
+        -
+          columnname: notes
+        -
+          columnname: author
+        -
+          columnname: creation_date
+        -
+          columnname: last_edit
+        -
+          columnname: last_run
+        -
+          columnname: public
+        -
+          columnname: json_url
+        -
+          columnname: cache_expiry
+        -
+          columnname: saved_results
+        -
+          columnname: update
+        -
+          columnname: actions
+          cannot_be_toggled: 1
+          cannot_be_modified: 1
+
   circ:
     circulation:
       issues-table:
index 28e0c17..7f5d368 100644 (file)
@@ -1,5 +1,6 @@
 [% USE KohaDates %]
 [% USE Koha %]
+[% USE ColumnsSettings %]
 [% SET footerjs = 1 %]
 [%- BLOCK area_name -%]
     [%- SWITCH area -%]
@@ -178,7 +179,7 @@ canned reports and writing custom SQL reports.</p>
                     [% IF (usecache) %] <th>Cache expiry (seconds)</th> [% END %]
                     <th>Saved results</th>
                     [% IF has_obsolete_reports %]<th>Update</th>[% END %]
-                    <th>&nbsp;</th>
+                    <th>Actions</th>
                 </tr>
             </thead>
             <tbody>
@@ -953,8 +954,9 @@ Sub report:<select name="subreport">
     [% INCLUDE 'calendar.inc' %]
     [% IF ( saved1 ) %]
         [% INCLUDE 'datatables.inc' %]
+        [% INCLUDE 'columns_settings.inc' %]
     [% END %]
-    <script type="text/javascript">
+    <script>
         var MSG_CONFIRM_DELETE = _("Are you sure you want to delete this report? This cannot be undone.");
         var group_subgroups = {};
         [% FOREACH group IN groups_with_subgroups %]
@@ -986,6 +988,7 @@ Sub report:<select name="subreport">
         $(document).ready(function(){
 
             $('[data-toggle="tooltip"]').tooltip();
+            var columns_settings = [% ColumnsSettings.GetColumns( 'reports', 'saved-sql', 'table_reports', 'json' ) %];
 
             $('#limit').change(function() {
                 $('#limitselect').submit();
@@ -1009,7 +1012,7 @@ Sub report:<select name="subreport">
             });
 
             [% IF (saved1) %]
-                var rtable = $("#table_reports").dataTable($.extend(true, {}, dataTablesDefaults, {
+                var rtable = KohaTable("table_reports", {
                     'iDisplayLength': [% Koha.Preference('NumSavedReports') %],
                     'bAutoWidth': false,
                     'sPaginationType': 'four_button',
@@ -1022,8 +1025,8 @@ Sub report:<select name="subreport">
                     ],
                     'oLanguage': {
                         'sZeroRecords': _("No matching reports found")
-                    }
-                }));
+                    },
+                }, columns_settings);
 
                 var rtabs = $("#tabs").tabs();
                 rtabs.on("tabsactivate", function(e, ui) {