Bug 23612 - If no columns in a table can be toggled, don't show columns button
Summary: If no columns in a table can be toggled, don't show columns button
Status: Pushed to master
Alias: None
Product: Koha
Classification: Unclassified
Component: System Administration (show other bugs)
Version: master
Hardware: All All
: P5 - low minor (vote)
Assignee: Owen Leonard
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 23611
  Show dependency treegraph
 
Reported: 2019-09-13 17:59 UTC by Owen Leonard
Modified: 2019-10-07 10:03 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:
19.11.00


Attachments
Bug 23612: If no columns in a table can be toggled, don't show columns button (2.80 KB, patch)
2019-09-13 18:20 UTC, Owen Leonard
Details | Diff | Splinter Review
Works well with all DataTables I tested. (2.85 KB, patch)
2019-09-17 02:20 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 23612: If no columns in a table can be toggled, don't show columns button (2.91 KB, patch)
2019-10-02 13:06 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 23612: (RM follow-up) Fix failing tests (2.26 KB, patch)
2019-10-07 10:03 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
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>