Bug 27467 - Provide a static URL for tables
Summary: Provide a static URL for tables
Status: In Discussion
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on: 27353 27402 27403 27465
Blocks:
  Show dependency treegraph
 
Reported: 2021-01-19 12:54 UTC by Jonathan Druart
Modified: 2022-03-22 14:08 UTC (History)
6 users (show)

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


Attachments
Bug 27467: [SOLUTION 1] Add dataTables.keepConditions.js (71.36 KB, patch)
2021-01-19 14:12 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27467: [SOLUTION 1] Don't repeat port (1.67 KB, patch)
2021-01-19 14:12 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27467: [SOLUTION 1] Use keepConditions (6.70 KB, patch)
2021-01-19 14:12 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27467: [SOLUTION 2] Add deepLink.js (3.84 KB, patch)
2021-01-19 14:12 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27467: [SOLUTION 2] Using deepLink.js (2.20 KB, patch)
2021-01-19 14:12 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27467: [SOLUTION 3] Use stateSave (2.30 KB, patch)
2021-01-19 14:13 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27467: [SOLUTION 3] Put filter values into the column filters (1.58 KB, patch)
2021-01-19 14:13 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27467: [SOLUTION 3] Restore atob/btoa calls (1.21 KB, patch)
2021-03-09 10:48 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 Jonathan Druart 2021-01-19 12:54:11 UTC
When using DataTables it would be useful to provide a way to link to the paginated and filtered results.

Especially when rows are retrieved from the REST API (server-side processing).
Comment 1 Jonathan Druart 2021-01-19 14:12:02 UTC
Created attachment 115325 [details] [review]
Bug 27467: [SOLUTION 1] Add dataTables.keepConditions.js
Comment 2 Jonathan Druart 2021-01-19 14:12:05 UTC
Created attachment 115326 [details] [review]
Bug 27467: [SOLUTION 1] Don't repeat port

This patch fixes a bug in the keepConditions plugin
Comment 3 Jonathan Druart 2021-01-19 14:12:08 UTC
Created attachment 115327 [details] [review]
Bug 27467: [SOLUTION 1] Use keepConditions

This first solution use a non longer maintained plugin:
  https://github.com/jhyland87/DataTables-Keep-Conditions/

I've tried to make it works with the column filters. But actually even
with the general search filter the table is not correctly filtered.

I guess it's related to their issue 1
  https://github.com/jhyland87/DataTables-Keep-Conditions/issues/1

To test:
Go to the cities page
Use the general search filter
Copy the URL and open it in a separate tab
=> The filter is kept but the REST API query is not built using it
Comment 4 Jonathan Druart 2021-01-19 14:12:38 UTC
Created attachment 115328 [details] [review]
Bug 27467: [SOLUTION 2] Add deepLink.js
Comment 5 Jonathan Druart 2021-01-19 14:12:41 UTC
Created attachment 115329 [details] [review]
Bug 27467: [SOLUTION 2] Using deepLink.js

This solution is based on
  https://github.com/DataTables/Plugins/tree/master/features/deepLink
  https://datatables.net/blog/2017-07-24

I was expecting it to let us provide the columns filters using the
following query (that would filter on name="cit"):
/cgi-bin/koha/admin/cities.pl?columns=[{"search":""},{"search":"cit"},{"search":""},{"search":""},{"search":""},{"search":""}]

But it does not work. In my understanding this will also set the data
for each columns. As they are not in the URL, DT is using undefined
value (hence the "data is undefined" JS error)
Comment 6 Jonathan Druart 2021-01-19 14:13:04 UTC
Created attachment 115330 [details] [review]
Bug 27467: [SOLUTION 3] Use stateSave

Based on
  https://stackoverflow.com/questions/55446923/datatables-1-10-using-savestate-to-remember-filtering-and-order-but-need-to-upd/60708638#60708638
(I removed the atob and btoa call)

This solution is finally working but it's not the ideal one IMO.
Using stateSave will modify the URL when the user modifies the table's
settings.
We would prefer to not modify it but have a "Copy link" buttons on top
of the table instead.
Comment 7 Jonathan Druart 2021-01-19 14:13:06 UTC
Created attachment 115331 [details] [review]
Bug 27467: [SOLUTION 3] Put filter values into the column filters
Comment 8 Tomás Cohen Arazi 2021-02-03 15:28:55 UTC
I find this interesting, but am still intrigued by the use case that would benefit from this. I guess is coming back from receiving an order, for example? Is that what you have in mind?
Comment 9 Jonathan Druart 2021-02-03 15:35:09 UTC
We are starting to modify our tables to use the REST API routes.

That will replace our GET parameters and users won't be able to share what they really see (copy/pasting the URL).

The first example is parcel.pl, yes. But more will certainly come.
Comment 10 Katrin Fischer 2021-02-06 19:02:24 UTC
(In reply to Jonathan Druart from comment #9)
> We are starting to modify our tables to use the REST API routes.
> 
> That will replace our GET parameters and users won't be able to share what
> they really see (copy/pasting the URL).
> 
> The first example is parcel.pl, yes. But more will certainly come.

I totally agree here. Haven an option to link to exact spots in Koha is really great for a lot of things. We use this a lot in reports, but also of course in support. I'd love if this worked in a transparent way for the datatables.
Comment 11 David Cook 2021-02-09 22:26:35 UTC
(In reply to Tomás Cohen Arazi from comment #8)
> I find this interesting, but am still intrigued by the use case that would
> benefit from this. I guess is coming back from receiving an order, for
> example? Is that what you have in mind?

I'd like some examples too. I don't understand the concept.
Comment 12 Tomás Cohen Arazi 2021-02-09 22:42:57 UTC
(In reply to David Cook from comment #11)
> (In reply to Tomás Cohen Arazi from comment #8)
> > I find this interesting, but am still intrigued by the use case that would
> > benefit from this. I guess is coming back from receiving an order, for
> > example? Is that what you have in mind?
> 
> I'd like some examples too. I don't understand the concept.

I got it. Take the order receipt in acquisitions, you search for an order, receive it, you want to go back to the receive table with the filters you already worked on. So Jonathan proposes some way to prefill the filters, basically, without much work for the devs. Do you can create an usable link to a page that loads the datatable, with the filters already applied.

The specific case would not be needed as per bug 8179, but there are certainly some areas that could benefit.
Comment 13 Jonathan Druart 2021-02-10 06:17:12 UTC
Filters, pagination, order, etc. The current state of a DataTable-base table.

The use case I had in mind was more about sharing a table with a colleague.

With "Solution 3", when the state changes, the URL of the page is updated and become something like:

http://kohadev-intra.mydnsname.org:8081/cgi-bin/koha/acqui/parcel.pl?invoiceid=1&pending_orders_state=%7B%22time%22%3A1612937360234%2C%22start%22%3A10%2C%22length%22%3A10%2C%22order%22%3A%5B%5B0%2C%22asc%22%5D%5D%2C%22search%22%3A%7B%22search%22%3A%22%22%2C%22smart%22%3Atrue%2C%22regex%22%3Afalse%2C%22caseInsensitive%22%3Atrue%7D%2C%22columns%22%3A%5B%7B%22visible%22%3Atrue%2C%22search%22%3A%7B%22search%22%3A%22%22%2C%22smart%22%3Atrue%2C%22regex%22%3Afalse%2C%22caseInsensitive%22%3Atrue%7D%7D%2C%7B%22visible%22%3Atrue%2C%22search%22%3A%7B%22search%22%3A%22%22%2C%22smart%22%3Atrue%2C%22regex%22%3Afalse%2C%22caseInsensitive%22%3Atrue%7D%7D%2C%7B%22visible%22%3Atrue%2C%22search%22%3A%7B%22search%22%3A%22%22%2C%22smart%22%3Atrue%2C%22regex%22%3Afalse%2C%22caseInsensitive%22%3Atrue%7D%7D%2C%7B%22visible%22%3Atrue%2C%22search%22%3A%7B%22search%22%3A%22h%22%2C%22smart%22%3Atrue%2C%22regex%22%3Afalse%2C%22caseInsensitive%22%3Atrue%7D%7D%2C%7B%22visible%22%3Atrue%2C%22search%22%3A%7B%22search%22%3A%22%22%2C%22smart%22%3Atrue%2C%22regex%22%3Afalse%2C%22caseInsensitive%22%3Atrue%7D%7D%2C%7B%22visible%22%3Atrue%2C%22search%22%3A%7B%22search%22%3A%2242%22%2C%22smart%22%3Atrue%2C%22regex%22%3Afalse%2C%22caseInsensitive%22%3Atrue%7D%7D%2C%7B%22visible%22%3Atrue%2C%22search%22%3A%7B%22search%22%3A%22%22%2C%22smart%22%3Atrue%2C%22regex%22%3Afalse%2C%22caseInsensitive%22%3Atrue%7D%7D%2C%7B%22visible%22%3Atrue%2C%22search%22%3A%7B%22search%22%3A%22%22%2C%22smart%22%3Atrue%2C%22regex%22%3Afalse%2C%22caseInsensitive%22%3Atrue%7D%7D%2C%7B%22visible%22%3Atrue%2C%22search%22%3A%7B%22search%22%3A%22%22%2C%22smart%22%3Atrue%2C%22regex%22%3Afalse%2C%22caseInsensitive%22%3Atrue%7D%7D%2C%7B%22visible%22%3Atrue%2C%22search%22%3A%7B%22search%22%3A%22%22%2C%22smart%22%3Atrue%2C%22regex%22%3Afalse%2C%22caseInsensitive%22%3Atrue%7D%7D%2C%7B%22visible%22%3Atrue%2C%22search%22%3A%7B%22search%22%3A%22%22%2C%22smart%22%3Atrue%2C%22regex%22%3Afalse%2C%22caseInsensitive%22%3Atrue%7D%7D%2C%7B%22visible%22%3Atrue%2C%22search%22%3A%7B%22search%22%3A%22%22%2C%22smart%22%3Atrue%2C%22regex%22%3Afalse%2C%22caseInsensitive%22%3Atrue%7D%7D%5D%7D

Yes, it's ugly, but it contains the values of the different column filters.

But any of your colleagues with the link can see the same table as you: https://snipboard.io/7pILMF.jpg
Comment 14 Martin Renvoize 2021-03-02 16:39:51 UTC
Right.. so solution 3 is the one that works.. we should drop solutions 1 and 2 to clarify what people should be testing.

Silly question.. why drop the base64 encode/decode?  I find that string a less ugly than the URL encoded set or state params myself..

So.. what's waiting to happen here to push this from 'In discussion' into 'Needs signoff' ?.. is it the addition of a 'Share' button?
Comment 15 Jonathan Druart 2021-03-09 10:45:54 UTC
(In reply to Martin Renvoize from comment #14)
> Right.. so solution 3 is the one that works.. we should drop solutions 1 and
> 2 to clarify what people should be testing.

I was expecting more love on this one and so maybe follow-up to improve what I wrote. Hence the different versions and explanations.

> Silly question.. why drop the base64 encode/decode?  I find that string a
> less ugly than the URL encoded set or state params myself..

Do you prefer the URL above or this one? I prefer the first one, at least you can read it. But I am not attached to it.

http://kohadev-intra.mydnsname.org:8081/cgi-bin/koha/admin/cities.pl?table_cities_state=eyJ0aW1lIjoxNjE1Mjg2NDk4ODU1LCJzdGFydCI6MCwibGVuZ3RoIjoyMCwib3JkZXIiOltbMSwiYXNjIl1dLCJzZWFyY2giOnsic2VhcmNoIjoiIiwic21hcnQiOnRydWUsInJlZ2V4IjpmYWxzZSwiY2FzZUluc2Vuc2l0aXZlIjp0cnVlfSwiY29sdW1ucyI6W3sidmlzaWJsZSI6dHJ1ZSwic2VhcmNoIjp7InNlYXJjaCI6IiIsInNtYXJ0Ijp0cnVlLCJyZWdleCI6ZmFsc2UsImNhc2VJbnNlbnNpdGl2ZSI6dHJ1ZX19LHsidmlzaWJsZSI6dHJ1ZSwic2VhcmNoIjp7InNlYXJjaCI6Im5hbV8iLCJzbWFydCI6dHJ1ZSwicmVnZXgiOmZhbHNlLCJjYXNlSW5zZW5zaXRpdmUiOnRydWV9fSx7InZpc2libGUiOnRydWUsInNlYXJjaCI6eyJzZWFyY2giOiIiLCJzbWFydCI6dHJ1ZSwicmVnZXgiOmZhbHNlLCJjYXNlSW5zZW5zaXRpdmUiOnRydWV9fSx7InZpc2libGUiOnRydWUsInNlYXJjaCI6eyJzZWFyY2giOiIiLCJzbWFydCI6dHJ1ZSwicmVnZXgiOmZhbHNlLCJjYXNlSW5zZW5zaXRpdmUiOnRydWV9fSx7InZpc2libGUiOnRydWUsInNlYXJjaCI6eyJzZWFyY2giOiIiLCJzbWFydCI6dHJ1ZSwicmVnZXgiOmZhbHNlLCJjYXNlSW5zZW5zaXRpdmUiOnRydWV9fSx7InZpc2libGUiOnRydWUsInNlYXJjaCI6eyJzZWFyY2giOiIiLCJzbWFydCI6dHJ1ZSwicmVnZXgiOmZhbHNlLCJjYXNlSW5zZW5zaXRpdmUiOnRydWV9fV19

> So.. what's waiting to happen here to push this from 'In discussion' into
> 'Needs signoff' ?.. is it the addition of a 'Share' button?

Yes, but first I wanted feedback from people. Looks like it didn't get unanimity on its usefulness.
Comment 16 Jonathan Druart 2021-03-09 10:48:11 UTC
Created attachment 117962 [details] [review]
Bug 27467: [SOLUTION 3] Restore atob/btoa calls
Comment 17 Tomás Cohen Arazi 2021-09-30 13:38:39 UTC
Hi all, I'm looking at this. It is an important addition.
Comment 18 Jonathan Druart 2022-03-22 14:08:39 UTC
(In reply to Tomás Cohen Arazi from comment #17)
> Hi all, I'm looking at this. It is an important addition.

So?