Bug 18791 - Add the ability for librarians to easily copy, download or print DataTables based tables in Koha
Summary: Add the ability for librarians to easily copy, download or print DataTables b...
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Kyle M Hall
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on:
Blocks: 20583 19282
  Show dependency treegraph
 
Reported: 2017-06-12 18:23 UTC by Kyle M Hall
Modified: 2020-11-12 15:02 UTC (History)
9 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 18791 - Add the ability for librarians to easily copy, download or print DataTables based tables in Koha (166.91 KB, patch)
2017-06-12 18:30 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 18791 - Add the ability for librarians to easily copy, download or print DataTables based tables in Koha (166.59 KB, patch)
2018-03-09 16:22 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 18791 - Make buttons translatable (1.29 KB, patch)
2018-03-09 16:22 UTC, Kyle M Hall
Details | Diff | Splinter Review
Bug 18791 - Make buttons translatable (1.34 KB, patch)
2018-03-09 19:35 UTC, Roch D'Amour
Details | Diff | Splinter Review
Bug 18791 (follow up) Translation of copy messages (3.59 KB, patch)
2018-03-27 15:39 UTC, Owen Leonard
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 18791 - Add the ability for librarians to easily copy, download or print DataTables based tables in Koha (166.66 KB, patch)
2018-04-11 08:14 UTC, Claire Gravely
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 18791 - Make buttons translatable (1.41 KB, patch)
2018-04-11 08:16 UTC, Claire Gravely
Details | Diff | Splinter Review
[SIGNED-OFF] Bug 18791 (follow up) Translation of copy messages (3.66 KB, patch)
2018-04-11 08:16 UTC, Claire Gravely
Details | Diff | Splinter Review
Bug 18791: Add the ability for librarians to easily copy, download or print DataTables based tables in Koha (166.75 KB, patch)
2018-04-12 12:44 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 18791: (follow-up) Make buttons translatable (1.47 KB, patch)
2018-04-12 12:45 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 18791: (follow up) Fix translation of copy messages (3.72 KB, patch)
2018-04-12 12:45 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 18791: Export visible columns only (1.78 KB, patch)
2018-04-13 16:54 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle M Hall 2017-06-12 18:23:23 UTC
There are many tables in Koha where it would be useful for librarians to easily copy, download or print the table for various purposes. These functions are available via DataTables button plugins.
Comment 1 Kyle M Hall 2017-06-12 18:30:56 UTC Comment hidden (obsolete)
Comment 2 Katrin Fischer 2017-07-09 13:19:35 UTC
Hi Kyle,

this is fun - I like it!

Just 2 things:

1) The new buttons only appear for tables using the column configuration. Is that correct? I tried the administration tables (branches, itemtypes, patron categories) first, before taking a look at the code. If it's intended that's not a blocker.

2) The buttons don't appear to be translatable. It seems we did some work to make the other strings from datatables translatable. Can we apply the same technique here too?

Failing for the translation issue for now, waiting for Kyle to comment.
Comment 3 Caroline Cyr La Rose 2017-09-08 21:17:03 UTC
Works as mentioned.

I will add another bug for the functionality to be added to all tables (some reports don't use datatables). I suggest doing the same for the translation issue.
Comment 4 Katrin Fischer 2017-09-09 07:17:19 UTC
I'd really like to see the translation issue fixed the same version as this goes in as it will appear in quite a few spots.
Comment 5 Katrin Fischer 2017-12-28 07:22:39 UTC
Marking failed QA for my comments #2 and #4 - Kyle, can you please take a look?
Comment 6 Kyle M Hall 2018-03-09 16:22:30 UTC
Created attachment 72615 [details] [review]
Bug 18791 - Add the ability for librarians to easily copy, download or print DataTables based tables in Koha

There are many tables in Koha where it would be useful for librarians to easily copy, download or print the table for various purposes. These functions are available via DataTables button plugins.

Test Plan:
1) Clear your browser cache ( just in case )
2) Apply this patch
3) Browse to boraccount.pl ( or another page using DataTabes )
4) Note the new Excel, CSV, Copy and Print buttons
5) Test each button to ensure they work
Comment 7 Kyle M Hall 2018-03-09 16:22:38 UTC Comment hidden (obsolete)
Comment 8 Roch D'Amour 2018-03-09 19:35:51 UTC
Created attachment 72618 [details] [review]
Bug 18791 - Make buttons translatable

Signed-off-by: Roch D'Amour <roch.damour@inlibro.com>
Comment 9 Katrin Fischer 2018-03-25 10:14:15 UTC
Hi Kyle,

I'd really like to get this feature in. 2 things:

- Can you please double-check the about page for the Javascript libraries updated and introduced here? I see only one entry changed, but 4 were touched.

- One of the libraries contains another string that is not translatable this way. It is the "copy" modal text:

c.i18n("buttons.copySuccess",{1:"Copied one row to clipboard",_:"Copied %d rows to clipboard"},a.rows),2E3);
Comment 10 Kyle M Hall 2018-03-27 13:12:21 UTC
(In reply to Katrin Fischer from comment #9)
> Hi Kyle,
> 
> I'd really like to get this feature in. 2 things:
> 
> - Can you please double-check the about page for the Javascript libraries
> updated and introduced here? I see only one entry changed, but 4 were
> touched.
> 
> - One of the libraries contains another string that is not translatable this
> way. It is the "copy" modal text:
> 
> c.i18n("buttons.copySuccess",{1:"Copied one row to clipboard",_:"Copied %d
> rows to clipboard"},a.rows),2E3);

Try is I might, I simply cannot get that message to translate : \

It should be very simple to do:
Literal example of exactly this: https://datatables.net/extensions/buttons/examples/html5/copyi18n.html
https://datatables.net/reference/button/copyHtml5

Is there anyone in the community that might know how to translate datatables better than I?
Comment 11 Kyle M Hall 2018-03-27 13:53:11 UTC
(In reply to Katrin Fischer from comment #9)
> Hi Kyle,
> 
> I'd really like to get this feature in. 2 things:
> 
> - Can you please double-check the about page for the Javascript libraries
> updated and introduced here? I see only one entry changed, but 4 were
> touched.

Those are all part of DataTables so no new entries are needed!
Comment 12 Owen Leonard 2018-03-27 15:39:26 UTC
Created attachment 73325 [details] [review]
Bug 18791 (follow up) Translation of copy messages

This patch updates DataTables configuration so that more strings are
translatable:

https://datatables.net/extensions/buttons/examples/html5/copyi18n.html

To test, apply the patch and clear your browser cache.

- Open the account tab for a patron who has only one fine.
- Confirm that the new DataTables buttons appear.
- Click the 'Copy' button and confirm that a "Copied 1 row to clipboard"
  message appears.
- Test again with a patron who has multiple fines, confirm that the
  message reads "Copied X rows to clipboard."

To test the translation:

- Confirm that "Copied 1 row to clipboard" is missing from the language
  file you're testing with (misc/translator/po/xx-YY-staff-prog.po).
- Run 'translate update xx-YY'
- Check that the clipboard strings are now in the po file.
- Add translations for those strings.
- Run 'translate update xx-YY' and 'translate install xx-YY'
- Switch to the translated language and clear your browser cache.
- Test the 'Copy' button again. Your translated text should appear.
Comment 13 Katrin Fischer 2018-03-30 14:07:53 UTC
Thx Owen! Could we get another quick sign-off please?
Comment 14 Claire Gravely 2018-04-11 08:14:55 UTC
Created attachment 73995 [details] [review]
[SIGNED-OFF] Bug 18791 - Add the ability for librarians to easily copy, download or print DataTables based tables in Koha

There are many tables in Koha where it would be useful for librarians to easily copy, download or print the table for various purposes. These functions are available via DataTables button plugins.

Test Plan:
1) Clear your browser cache ( just in case )
2) Apply this patch
3) Browse to boraccount.pl ( or another page using DataTabes )
4) Note the new Excel, CSV, Copy and Print buttons
5) Test each button to ensure they work

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Comment 15 Claire Gravely 2018-04-11 08:16:26 UTC
Created attachment 73996 [details] [review]
[SIGNED-OFF] Bug 18791 - Make buttons translatable

Signed-off-by: Roch D'Amour <roch.damour@inlibro.com>

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Comment 16 Claire Gravely 2018-04-11 08:16:29 UTC
Created attachment 73997 [details] [review]
[SIGNED-OFF] Bug 18791 (follow up) Translation of copy messages

This patch updates DataTables configuration so that more strings are
translatable:

https://datatables.net/extensions/buttons/examples/html5/copyi18n.html

To test, apply the patch and clear your browser cache.

- Open the account tab for a patron who has only one fine.
- Confirm that the new DataTables buttons appear.
- Click the 'Copy' button and confirm that a "Copied 1 row to clipboard"
  message appears.
- Test again with a patron who has multiple fines, confirm that the
  message reads "Copied X rows to clipboard."

To test the translation:

- Confirm that "Copied 1 row to clipboard" is missing from the language
  file you're testing with (misc/translator/po/xx-YY-staff-prog.po).
- Run 'translate update xx-YY'
- Check that the clipboard strings are now in the po file.
- Add translations for those strings.
- Run 'translate update xx-YY' and 'translate install xx-YY'
- Switch to the translated language and clear your browser cache.
- Test the 'Copy' button again. Your translated text should appear.

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Comment 17 Katrin Fischer 2018-04-12 12:38:18 UTC
Working on this.
Comment 18 Katrin Fischer 2018-04-12 12:44:58 UTC
Created attachment 74085 [details] [review]
Bug 18791: Add the ability for librarians to easily copy, download or print DataTables based tables in Koha

There are many tables in Koha where it would be useful
for librarians to easily copy, download or print the table
for various purposes. These functions are available via
DataTables button plugins.

Test Plan:
1) Clear your browser cache ( just in case )
2) Apply this patch
3) Browse to boraccount.pl ( or another page using DataTabes )
4) Note the new Excel, CSV, Copy and Print buttons
5) Test each button to ensure they work

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 19 Katrin Fischer 2018-04-12 12:45:16 UTC
Created attachment 74086 [details] [review]
Bug 18791: (follow-up) Make buttons translatable

Signed-off-by: Roch D'Amour <roch.damour@inlibro.com>

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 20 Katrin Fischer 2018-04-12 12:45:21 UTC
Created attachment 74087 [details] [review]
Bug 18791: (follow up) Fix translation of copy messages

This patch updates DataTables configuration so that more strings are
translatable:

https://datatables.net/extensions/buttons/examples/html5/copyi18n.html

To test, apply the patch and clear your browser cache.

- Open the account tab for a patron who has only one fine.
- Confirm that the new DataTables buttons appear.
- Click the 'Copy' button and confirm that a "Copied 1 row to clipboard"
  message appears.
- Test again with a patron who has multiple fines, confirm that the
  message reads "Copied X rows to clipboard."

To test the translation:

- Confirm that "Copied 1 row to clipboard" is missing from the language
  file you're testing with (misc/translator/po/xx-YY-staff-prog.po).
- Run 'translate update xx-YY'
- Check that the clipboard strings are now in the po file.
- Add translations for those strings.
- Run 'translate update xx-YY' and 'translate install xx-YY'
- Switch to the translated language and clear your browser cache.
- Test the 'Copy' button again. Your translated text should appear.

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 21 Jonathan Druart 2018-04-12 16:56:34 UTC
It does not work well with the column visibility settings.

For instance:
Search for patrons, hide date of birth, export
=> date of birth is displayed

Did you try and fix that already?
Comment 22 Jonathan Druart 2018-04-12 17:04:30 UTC
Reading https://datatables.net/extensions/buttons/examples/html5/columns.html
It seems we need
  exportOptions: {
    columns: ':visible'
  }

Maybe we could also add the PDF export and create a new pref with the list of available exports (on a separate bug report of course).
Comment 23 Katrin Fischer 2018-04-12 17:06:30 UTC
Hope there is an easy solution! Pref for later sounds good.
Comment 24 Jonathan Druart 2018-04-12 17:10:32 UTC
+    var MSG_DT_COPY_KEYS = _("Press ctrl or ⌘ + C to copy the table data<br>to your system clipboard.<br><br>To cancel, click this message or press escape.");


When am I supposed to see this message?
Comment 25 Kyle M Hall 2018-04-12 17:34:21 UTC
(In reply to Jonathan Druart from comment #24)
> +    var MSG_DT_COPY_KEYS = _("Press ctrl or ⌘ + C to copy the table
> data<br>to your system clipboard.<br><br>To cancel, click this message or
> press escape.");
> 
> 
> When am I supposed to see this message?

I remember seeing that message in the past. It's in a fallback feature that you won't see in a recent browser.
Comment 26 Jonathan Druart 2018-04-13 14:07:06 UTC
Failing QA to get answers.
Comment 27 Kyle M Hall 2018-04-13 14:11:38 UTC
(In reply to Jonathan Druart from comment #26)
> Failing QA to get answers.

The answer is on any recent browser, you will never see that message.
Comment 28 Jonathan Druart 2018-04-13 14:52:42 UTC
I was referring to comment 21 and comment 22.
Comment 29 Kyle M Hall 2018-04-13 16:31:39 UTC
(In reply to Jonathan Druart from comment #28)
> I was referring to comment 21 and comment 22.

I wonder if Owen might be able to take a look. I'm not sure where to implement that.
Comment 30 Jonathan Druart 2018-04-13 16:54:45 UTC
Created attachment 74174 [details] [review]
Bug 18791: Export visible columns only

We certainly will want to improve that and explicitely list the columns
to export. For instance the actions and checkboxes should not be
exported, even if visible.
Comment 31 Jonathan Druart 2018-04-13 17:07:14 UTC
Pushed to master for 18.05, thanks to everybody involved!
Comment 32 Kyle M Hall 2018-04-13 17:34:49 UTC
(In reply to Jonathan Druart from comment #31)
> Pushed to master for 18.05, thanks to everybody involved!

\O/ Thanks Jonathan!
Comment 33 Nick Clemens 2018-05-21 17:38:39 UTC
Ehancement, not backported for 17.11.X