Bugzilla – Attachment 117439 Details for
Bug 27680
API DataTables Wrapper fails for ordering on multi-data-field columns
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27680: Add support for sorting fields with multiple data points
Bug-27680-Add-support-for-sorting-fields-with-mult.patch (text/plain), 3.19 KB, created by
Jonathan Druart
on 2021-03-01 12:19:29 UTC
(
hide
)
Description:
Bug 27680: Add support for sorting fields with multiple data points
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-03-01 12:19:29 UTC
Size:
3.19 KB
patch
obsolete
>From 811db070fbd932850d08a6e2b0e90778d8ba8832 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Fri, 12 Feb 2021 13:14:16 +0000 >Subject: [PATCH] Bug 27680: Add support for sorting fields with multiple data > points > >This patch adds proper handling for sorting a single column that is >constructed of multiple data entities.. i.e `"data": "string1:string2"` > >It does NOT add support for filtering on multiple columns yet. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/REST/Plugin/Query.pm | 3 ++- > api/v1/swagger/parameters.json | 2 +- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 4 ++-- > 3 files changed, 5 insertions(+), 4 deletions(-) > >diff --git a/Koha/REST/Plugin/Query.pm b/Koha/REST/Plugin/Query.pm >index ea6695ff37..c7ab65dc5a 100644 >--- a/Koha/REST/Plugin/Query.pm >+++ b/Koha/REST/Plugin/Query.pm >@@ -92,9 +92,10 @@ Generates the DBIC order_by attributes based on I<$params>, and merges into I<$a > > if ( defined $args->{params}->{_order_by} ) { > my $order_by = $args->{params}->{_order_by}; >+ $order_by = [ split(/,/, $order_by) ] if ( index(',',$order_by) == -1); > if ( reftype($order_by) and reftype($order_by) eq 'ARRAY' ) { > my @order_by = map { _build_order_atom({ string => $_, result_set => $result_set }) } >- @{ $args->{params}->{_order_by} }; >+ @{ $order_by }; > $attributes->{order_by} = \@order_by; > } > else { >diff --git a/api/v1/swagger/parameters.json b/api/v1/swagger/parameters.json >index 92653a41aa..ec4e52ef5a 100644 >--- a/api/v1/swagger/parameters.json >+++ b/api/v1/swagger/parameters.json >@@ -72,7 +72,7 @@ > "required": false, > "description": "Sorting criteria", > "type": "array", >- "collectionFormat": "pipes", >+ "collectionFormat": "csv", > "items": { > "type": "string" > } >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index 7d64b907d5..1b1a719141 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -637,9 +637,9 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { > order.forEach(function (e,i) { > var order_col = e.column; > var order_by = options.columns[order_col].data; >- order_by = order_by.split(':')[0]; >+ order_by = order_by.split(':'); > var order_dir = e.dir == 'asc' ? '+' : '-'; >- dataSet._order_by = order_dir + (!order_by.includes('.')?'me.'+order_by:order_by); >+ dataSet._order_by = order_by.map(x => order_dir + (!x.includes('.')?'me.'+x:x)).join(','); > }); > } > >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27680
:
116794
|
116795
|
116796
|
116829
|
116831
|
116832
|
116833
|
116834
|
116843
|
116844
|
116845
|
116846
|
117335
|
117336
|
117337
|
117338
|
117339
|
117340
|
117341
|
117375
|
117388
|
117389
|
117390
|
117391
|
117392
|
117393
|
117394
|
117438
| 117439 |
117440
|
117441
|
117442
|
117476