Bug 23612

Summary: If no columns in a table can be toggled, don't show columns button
Product: Koha Reporter: Owen Leonard <oleonard>
Component: System AdministrationAssignee: Owen Leonard <oleonard>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: minor    
Priority: P5 - low CC: gmcharlt, lucas, martin.renvoize
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
19.11.00
Bug Depends on:    
Bug Blocks: 23611    
Attachments: Bug 23612: If no columns in a table can be toggled, don't show columns button
Works well with all DataTables I tested.
Bug 23612: If no columns in a table can be toggled, don't show columns button
Bug 23612: (RM follow-up) Fix failing tests

Description Owen Leonard 2019-09-13 17:59:04 UTC
If a library makes a change to a table's default columns settings and marks all table columns 'Cannot be toggled,' the columns button in the interface will show an empty menu.

If no columns can be changed the button shouldn't appear.
Comment 1 Owen Leonard 2019-09-13 18:20:15 UTC
Created attachment 92818 [details] [review]
Bug 23612: If no columns in a table can be toggled, don't show columns button

This patch makes a change to the JavaScript setup for DataTables button
controls so that if there are no toggle-able buttons (or there is no
columns configuration at all) the column selection menu button will not
appear.

To test, apply the patch and go to Administration -> Columns settings.

 - In the Administration section, find the section for the "libraries"
   table.
 - In the "Cannot be toggled" column, check all the checkboxes.
 - Save.
 - Go to Administration -> Libraries.
 - At the top of the table there should be no "Columns" button, only
   "Clear filter" and "Export" buttons.
Comment 2 Lucas Gass 2019-09-17 02:20:43 UTC
Created attachment 92865 [details] [review]
Works well with all DataTables I tested.

Bug 23612: If no columns in a table can be toggled, don't show columns button

This patch makes a change to the JavaScript setup for DataTables button
controls so that if there are no toggle-able buttons (or there is no
columns configuration at all) the column selection menu button will not
appear.

To test, apply the patch and go to Administration -> Columns settings.

 - In the Administration section, find the section for the "libraries"
   table.
 - In the "Cannot be toggled" column, check all the checkboxes.
 - Save.
 - Go to Administration -> Libraries.
 - At the top of the table there should be no "Columns" button, only
   "Clear filter" and "Export" buttons.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 3 Katrin Fischer 2019-10-02 13:06:20 UTC
Created attachment 93457 [details] [review]
Bug 23612: If no columns in a table can be toggled, don't show columns button

This patch makes a change to the JavaScript setup for DataTables button
controls so that if there are no toggle-able buttons (or there is no
columns configuration at all) the column selection menu button will not
appear.

To test, apply the patch and go to Administration -> Columns settings.

 - In the Administration section, find the section for the "libraries"
   table.
 - In the "Cannot be toggled" column, check all the checkboxes.
 - Save.
 - Go to Administration -> Libraries.
 - At the top of the table there should be no "Columns" button, only
   "Clear filter" and "Export" buttons.

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 4 Martin Renvoize 2019-10-03 10:02:18 UTC
Nice work!

Pushed to master for 19.11.00
Comment 5 Martin Renvoize 2019-10-07 10:03:48 UTC
Created attachment 93787 [details] [review]
Bug 23612: (RM follow-up) Fix failing tests

Trailing comma's were causing hidden javascript errors during selenium
tests.

Error was identified by adding a $s->capture($driver) line to the
relevant selenium test and using the following JS snippet to dump errors
to the screen.

   (function () {
       var ul = null;
       function createErrorList() {
           ul = document.createElement('ul');
           ul.setAttribute('id', 'js_error_list');
           //ul.style.display = 'none';
           document.body.appendChild(ul);
       }
       window.onerror = function(msg){
           if (ul === null)
               createErrorList();
           var li = document.createElement("li");
           li.appendChild(document.createTextNode(msg));
           ul.appendChild(li);
       };
   })();

Which clearly showed the following error.

    ReferenceError: KohaTable is not defined

Removing the trailing comma's introduced in this bug resolved the issue.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>