Bug 27934 - Table sorting using title-string option is obsolete
Summary: Table sorting using title-string option is obsolete
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Staff interface (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords: Academy
Depends on: 27974 27975 27980 27982 27983 27990 27994 27998 28007 28016 28018
Blocks: 40589
  Show dependency treegraph
 
Reported: 2021-03-11 15:39 UTC by Martin Renvoize (ashimema)
Modified: 2025-08-04 15:48 UTC (History)
6 users (show)

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


Attachments
Bug 27934: Update waiting_holds.inc to use data-order (2.25 KB, patch)
2021-03-12 09:00 UTC, Martin Renvoize (ashimema)
Details | Diff | Splinter Review
Bug 27934: Update waiting_holds.inc to use data-order (2.32 KB, patch)
2021-03-12 15:12 UTC, ByWater Sandboxes
Details | Diff | Splinter Review
Bug 27934: Remove title-string to order by dates (7.42 KB, patch)
2025-07-31 10:57 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 27934: Remove title-string to order by dates (7.47 KB, patch)
2025-07-31 12:13 UTC, Owen Leonard
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize (ashimema) 2021-03-11 15:39:59 UTC
We have some interesting code in our datatables wrappers to magically sort on 'title' attributes found in spans in table fields (When the headings are marked up with 'title-string' and 'title-number' classes).

This is weird and a mis-use of the HTML title attribute. It results in tooltips being generated for all fields witch such values and often those tooltips are confusing/mismatched.

We should replace these with either data- attributes or perhaps use hidden datatables columns for sorting?


Basically.. there must be a better way.
Comment 1 Jonathan Druart 2021-03-11 15:56:08 UTC
It must be data-order

https://datatables.net/manual/data/orthogonal-data#HTML-5

We use it already in a few places.
Comment 2 Martin Renvoize (ashimema) 2021-03-12 08:54:11 UTC
That's a really useful page of documentation Jonathan, thanks for linking it :)
Comment 3 Martin Renvoize (ashimema) 2021-03-12 09:00:16 UTC
Created attachment 118182 [details] [review]
Bug 27934: Update waiting_holds.inc to use data-order

This patch updates the waiting_holds table to use data-order attributes
on the "Waiting since" and "Date hold placed" fields.

Test plan
1/ Prior to applying the patch navigate to a page that displays waiting holds
2/ Hover over the the "Waiting since" and "Date hold placed" data fields
and note that you are faced with a tooltip with the iso formatted date.
3/ Apply the patch
4/ Check that sorting still works as expected for the two columns
5/ You should no longer be able to trigger the tooltip
Comment 4 Martin Renvoize (ashimema) 2021-03-12 09:01:11 UTC
Example patch.. there's allot of these to fix...
Comment 5 Martin Renvoize (ashimema) 2021-03-12 09:02:56 UTC
Find more cases with a simple grep for 'title-string' in the templates directories
Comment 6 ByWater Sandboxes 2021-03-12 15:12:20 UTC
Created attachment 118206 [details] [review]
Bug 27934: Update waiting_holds.inc to use data-order

This patch updates the waiting_holds table to use data-order attributes
on the "Waiting since" and "Date hold placed" fields.

Test plan
1/ Prior to applying the patch navigate to a page that displays waiting holds
2/ Hover over the the "Waiting since" and "Date hold placed" data fields
and note that you are faced with a tooltip with the iso formatted date.
3/ Apply the patch
4/ Check that sorting still works as expected for the two columns
5/ You should no longer be able to trigger the tooltip

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Comment 7 Sally 2021-03-12 15:17:11 UTC
Sorry, I keep jumping too soon - who knew that signing off bugs was so exciting?  ;)  

Happy to sign off again once it's ready for testing.
Comment 8 Owen Leonard 2021-03-15 19:00:59 UTC
I agree that we should update the templates to use the newer sorting option. I've updated the bug title to make it clear that it's about an obsolete option.
Comment 9 Jonathan Druart 2021-04-06 13:01:49 UTC
Still a couple of occurrences in waiting_holds.inc then we are good to remove the functions in datatables.js
Comment 10 Jonathan Druart 2021-04-06 13:15:20 UTC
Added a QA check

https://gitlab.com/koha-community/qa-test-tools/-/issues/48

    Issue #48 - Forbid title-string class for sorting
Comment 11 Fridolin Somers 2021-04-15 11:25:12 UTC
Recent push :
 Bug 27926: Add 'title-string' for dates on circ-patron-results

Does it need to be patched ?
Comment 12 Katrin Fischer 2021-04-17 18:05:55 UTC
(In reply to Fridolin Somers from comment #11)
> Recent push :
>  Bug 27926: Add 'title-string' for dates on circ-patron-results
> 
> Does it need to be patched ?

That already had a follow-up to fix it :)
Comment 13 Katrin Fischer 2023-07-04 21:00:10 UTC
It looks like we sill got some remaining title-string attributes:

koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc:        { "targets": [ "title-string" ], "type": "title-string" },
koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_to_pull.tt:                                <th class="recall-date title-string">Earliest recall date</th>
koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_to_pull.tt:                    { "sType": "title-string", "aTargets" : [ "title-string" ] },
koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_waiting.tt:                                            <th class="recall-waitingdate title-string">Available since</th>
koha-tmpl/intranet-tmpl/prog/en/modules/recalls/recalls_waiting.tt:                                                <th class="recall-waitingdate title-string">Available since</th>
Comment 14 Jonathan Druart 2023-07-05 07:00:38 UTC
columns_settings.inc is obviously correct

The recall ones need to be adjusted.
Comment 15 Jonathan Druart 2025-07-31 10:57:33 UTC
Created attachment 184921 [details] [review]
Bug 27934: Remove title-string to order by dates

We must now use data-order to order dates, not title-string.

This patch adjusts the few occurrences that were using it and remove the
function from datatables.js to prevent new occurrences.

Test plan:
Create some recalls, go to the "Recalls to pull" and "Recalls awaiting
pickup" pages and confirm that the dates are ordered correctly when you
sort by dates.
Comment 16 Owen Leonard 2025-07-31 12:13:35 UTC
Created attachment 184923 [details] [review]
Bug 27934: Remove title-string to order by dates

We must now use data-order to order dates, not title-string.

This patch adjusts the few occurrences that were using it and remove
the function from datatables.js to prevent new occurrences.

Test plan:
Create some recalls, go to the "Recalls to pull" and "Recalls awaiting
pickup" pages and confirm that the dates are ordered correctly when you
sort by dates.

Signed-off-by: Owen Leonard <oleonard@myacpl.org>