Bugzilla – Attachment 115893 Details for
Bug 20212
Improve performance of acquisitions receive page
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20212: (QA follow-up) Resurrect column filtering
Bug-20212-QA-follow-up-Resurrect-column-filtering.patch (text/plain), 12.35 KB, created by
Andrew Fuerste-Henry
on 2021-01-27 15:51:35 UTC
(
hide
)
Description:
Bug 20212: (QA follow-up) Resurrect column filtering
Filename:
MIME Type:
Creator:
Andrew Fuerste-Henry
Created:
2021-01-27 15:51:35 UTC
Size:
12.35 KB
patch
obsolete
>From 6b15e8100ccfdce178b50d7045d4e528f9b06348 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 6 Nov 2020 15:16:00 -0300 >Subject: [PATCH] Bug 20212: (QA follow-up) Resurrect column filtering > >This patch adds per-column filtering to the order receiving table. > >The order cost column proved difficult to filter, because of the syntax >DBIC requires for comparing replacement_cost * quantity, and passing >that all the way down from the API request to DBIC itself. > >I'm still looking for options. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> > >Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com> >--- > Koha/REST/V1/Acquisitions/Orders.pm | 6 +- > .../intranet-tmpl/prog/en/modules/acqui/parcel.tt | 156 ++++++++++++++------- > 2 files changed, 107 insertions(+), 55 deletions(-) > >diff --git a/Koha/REST/V1/Acquisitions/Orders.pm b/Koha/REST/V1/Acquisitions/Orders.pm >index 3fb9b28b22..06e125e24a 100644 >--- a/Koha/REST/V1/Acquisitions/Orders.pm >+++ b/Koha/REST/V1/Acquisitions/Orders.pm >@@ -312,8 +312,10 @@ sub fix_query { > > my $query = $args->{query}; > my $biblioitem_fields = { >- 'biblio.isbn' => 'biblio.biblioitem.isbn', >- 'biblio.ean' => 'biblio.biblioitem.ean' >+ 'biblio.isbn' => 'biblio.biblioitem.isbn', >+ 'biblio.ean' => 'biblio.biblioitem.ean', >+ 'biblio.publisher' => 'biblio.biblioitem.publisher', >+ 'biblio.publication_year' => 'biblio.biblioitem.publication_year' > }; > > if ( ref($query) eq 'HASH' ) { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >index c2701a4d69..7f46839411 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >@@ -118,6 +118,24 @@ > <th> </th> > <th> </th> > </tr> >+ <tr> >+ <th><div class="input-group input-group-sm"><input id="basket_name_column_search" type="text" class="form-control column-filter" data-search-fields='["basket.name"]'></div></th> >+ <th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["basket.basket_group.name"]'></div></th> >+ <th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["me.order_id"]'></div></th> >+ <th class="hidden"> </th> >+ <th class="hidden"> </th> >+ <th class="hidden"> </th> >+ <th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["me.internal_note","me.vendor_note","biblio.title","biblio.author","biblio.isbn","biblio.publisher","biblio.publication_year","biblio.copyright_date","biblio.suggestions.suggester.surname","biblio.suggestions.suggester.firstname"]'></div></th> >+ <th> </th> >+ <th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["me.replacement_price"]'></div></th> >+ <th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["me.quantity"]'></div></th> >+ <th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["me.ecost"]'></div></th> >+ <th> </th> >+ <!--th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["order_cost"]'></div></th--> >+ <th><div class="input-group input-group-sm"><input type="text" class="form-control column-filter" data-search-fields='["fund.name"]'></div></th> >+ <th> </th> >+ <th> </th> >+ </tr> > </thead> > </table> > </div> >@@ -371,26 +389,71 @@ > <script> > dt_overwrite_html_sorting_localeCompare(); > var sticky_filters = [% sticky_filters | html %]; >+ var columns_filter = {}; > >- function query_from_filters( base_query, params ) { >+ function query_from_filters( base_query ) { > > var query_and = []; > >- if ( params.basket_name != "" ) { >- query_and.push( { "basket.name": { "like": '%'+params.basket_name+'%' } } ); >+ var summary = $("#summaryfilter").val(); >+ var basket_group = $("#basketgroupnamefilter").val(); >+ var basket_name = $("#basketfilter").val(); >+ var order_id = $("#orderfilter").val(); >+ var ean = $("#eanfilter").val(); >+ >+ // ean == undefined if the HTML doens't have it >+ ean = (ean === undefined) ? '' : ean; >+ >+ if ( basket_name != "" ) { >+ query_and.push( { "basket.name": { "like": '%'+basket_name+'%' } } ); > } >- if (params.basket_group != "") { >- query_and.push( { "basket.basket_group.name": { "like": '%'+params.basket_group+'%' } } ); >+ if (basket_group != "") { >+ query_and.push( { "basket.basket_group.name": { "like": '%'+basket_group+'%' } } ); > } >- if (params.summary != "") { >- query_and.push( { "-or": [{"biblio.title": { "like": '%'+params.summary+'%' } }, >- {"biblio.author": { "like": '%'+params.summary+'%' } }, >- {"biblio.isbn": { "like": '%'+params.summary+'%' } } ] } ); >+ if (summary != "") { >+ query_and.push( { "-or": [{"biblio.title": { "like": '%'+summary+'%' } }, >+ {"biblio.author": { "like": '%'+summary+'%' } }, >+ {"biblio.isbn": { "like": '%'+summary+'%' } } ] } ); > } >- if (params.ean != "") { >- query_and.push( { "biblio.ean": params.ean } ); >+ if (ean != "") { >+ query_and.push( { "biblio.ean": ean } ); > } > >+ $(".column-filter").each(function () { >+ var search_fields = $(this).data('search-fields'); >+ var value = this.value; >+ >+ if ( value != '' && >+ value != undefined ) { // skip if empty >+ >+ var columns_filters = []; >+ >+ search_fields.forEach( function (item) { >+ if ( item === "me.order_id" || >+ item === "me.replacement_price" || >+ item === "me.quantity" || >+ item === "me.ecost" ) { >+ // For numbers, we do 'starts with' >+ var object = {}; >+ object[item] = { "like": value+'%' }; >+ columns_filters.push( object ); >+ } >+ else { >+ var object = {}; >+ object[item] = { "like": '%'+value+'%' }; >+ columns_filters.push( object ); >+ } >+ }); >+ >+ if ( columns_filters.length > 1 ) { >+ query_and.push( { "-or": columns_filters } ); >+ } >+ else if ( columns_filters.length > 0 ) { >+ query_and.push( columns_filters[0] ); >+ } >+ } >+ }); >+ > var query_params = []; > > if ( query_and.length > 0 ) { >@@ -398,8 +461,8 @@ > query_params.push('q=' + encodeURIComponent(JSON.stringify({ "-and": query_and }))); > } > >- if ( params.order_id != "" ) { >- query_params.push("order_id="+params.order_id); >+ if ( order_id != "" ) { >+ query_params.push("order_id="+order_id); > } > > return query_params; >@@ -435,24 +498,8 @@ > })); > } > >- var base_query = { "basket.vendor_id": [% booksellerid | html %] }; >- >- var summary = $("#summaryfilter").val(); >- var basket_name = $("#basketfilter").val(); >- var basket_group = $("#basketgroupnamefilter").val(); >- var order_id = $("#orderfilter").val(); >- var ean = $("#eanfilter").val(); >- >- var query_params = query_from_filters( >- base_query, >- { >- "summary": summary, >- "basket_name": basket_name, >- "basket_group": basket_group, >- "order_id": order_id, >- "ean": (ean === undefined) ? '' : ean // ean == undefined if the DOM doens't have it >- } >- ); >+ var base_query = { "basket.vendor_id": [% booksellerid | html %] }; >+ var query_params = query_from_filters( base_query ); > > var THE_query = query_params.join("&"); > >@@ -473,6 +520,8 @@ > "items" > ], > "stateSave": true, // remember state on page reload >+ "orderCellsTop": true, // tell the datatable sorting is done on the top row >+ "fixedHeader": true, > 'dom': 'C<"top pager"ilpfB><"#filter_c">tr<"bottom pager"ip>', > "drawCallback": function (settings) { > $(".previewData").on("click", function(e){ >@@ -740,32 +789,33 @@ > ] > }); > >+ // column filter events handling >+ $(".column-filter").each(function () { >+ $(this).on( 'keyup change', function () { >+ // recalculate the query >+ var query_params = query_from_filters( base_query ); >+ // refresh the datatable as appropriate >+ if ( query_params.length > 0 ) { >+ pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") ); >+ } >+ else { >+ pending_orders_table.api().ajax.url( pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query)) ); >+ } >+ pending_orders_table.api().ajax.reload( null, false ); >+ }); >+ }); >+ > $("#filterform").on("submit", function(e) { > e.preventDefault(); > >- var summary = $("#summaryfilter").val(); >- var basket_name = $("#basketfilter").val(); >- var basket_group = $("#basketgroupnamefilter").val(); >- var order_id = $("#orderfilter").val(); >- var ean = $("#eanfilter").val(); >- > // Save the filters in the cookie >- $.cookie("filter_parcel_summary", summary); >- $.cookie("filter_parcel_basketname", basket_name); >- $.cookie("filter_parcel_orderno", basket_group); >- $.cookie("filter_parcel_basketgroupname", order_id); >- $.cookie("filter_parcel_ean", ean); >- >- var query_params = query_from_filters( >- base_query, >- { >- "summary": summary, >- "basket_name": basket_name, >- "basket_group": basket_group, >- "order_id": order_id, >- "ean": (ean === undefined) ? '' : ean // ean == undefined if the HTML doens't have it >- } >- ); >+ $.cookie("filter_parcel_summary", $("#summaryfilter").val()); >+ $.cookie("filter_parcel_basketname", $("#basketfilter").val()); >+ $.cookie("filter_parcel_orderno", $("#orderfilter").val()); >+ $.cookie("filter_parcel_basketgroupname", $("#basketgroupnamefilter").val()); >+ $.cookie("filter_parcel_ean", $("#eanfilter").val()); >+ >+ var query_params = query_from_filters( base_query ); > > if ( query_params.length > 0 ) { > pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") ); >-- >2.11.0
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 20212
:
97545
|
97546
|
97547
|
97629
|
97630
|
97633
|
97634
|
97635
|
97745
|
98226
|
98230
|
98241
|
99724
|
99725
|
99727
|
100142
|
100475
|
100476
|
100477
|
100478
|
100552
|
100553
|
100554
|
100555
|
100600
|
100601
|
100602
|
100603
|
100605
|
100606
|
100643
|
101320
|
103684
|
103685
|
103686
|
103687
|
103688
|
109861
|
109862
|
109863
|
109864
|
109866
|
109867
|
109868
|
109869
|
109870
|
109936
|
110229
|
110234
|
110478
|
110482
|
111568
|
111569
|
112310
|
112521
|
112522
|
112523
|
112524
|
112686
|
112695
|
112698
|
112699
|
112700
|
112702
|
112703
|
112704
|
112705
|
112706
|
112868
|
112882
|
112987
|
113278
|
113279
|
114607
|
114608
|
114609
|
114610
|
114611
|
114612
|
114613
|
114614
|
114615
|
114616
|
114617
|
114942
|
114953
|
114954
|
114956
|
114959
|
114963
|
115050
|
115056
|
115057
|
115060
|
115062
|
115107
|
115108
|
115109
|
115817
|
115818
|
115819
|
115820
|
115821
|
115822
|
115886
|
115887
|
115888
|
115889
|
115890
|
115891
|
115892
|
115893
|
115894
|
115895
|
115896
|
115897
|
115898
|
115899
|
115900
|
115901
|
115902
|
115903
|
115904
|
115905
|
115906
|
115920
|
115921
|
115940
|
115941
|
115943
|
115944
|
115945
|
115946
|
115947
|
115948
|
115949
|
115950
|
115951
|
115952
|
115953
|
115954
|
115955
|
115956
|
115957
|
115958
|
115959
|
115960
|
115961
|
115962
|
115963
|
115964
|
115965
|
116139