Bugzilla – Attachment 112868 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) Remember current filter
Bug-20212-QA-follow-up-Remember-current-filter.patch (text/plain), 9.27 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-11-02 20:20:38 UTC
(
hide
)
Description:
Bug 20212: (QA follow-up) Remember current filter
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-11-02 20:20:38 UTC
Size:
9.27 KB
patch
obsolete
>From 2a05ad9d3d169f25e8b0e0ceb2f4e7ec19985384 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 2 Nov 2020 17:15:31 -0300 >Subject: [PATCH] Bug 20212: (QA follow-up) Remember current filter > >This patch restores the original behaviour: if you jump into receiving >an order, and then go back to receiving, you want the page to remember >your filters. > >This feature was overlooked. On fixing it, I wrapped some JS code in a >function for reusing it and simplified it a bit as well. > >To test: >1. Enter a search term in either of the search fields >2. Add a note, receive or do another action >=> SUCCESS: The search term is kept >3. Apply this patch set >4. Repeat 2 >=> SUCCESS: The search term is kept > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > acqui/parcel.pl | 22 +++- > .../prog/en/modules/acqui/parcel.tt | 117 +++++++++++------- > 2 files changed, 91 insertions(+), 48 deletions(-) > >diff --git a/acqui/parcel.pl b/acqui/parcel.pl >index 3705dfc8336..9e4974ba90f 100755 >--- a/acqui/parcel.pl >+++ b/acqui/parcel.pl >@@ -74,8 +74,7 @@ use Koha::Biblios; > > use JSON; > >-my $input=CGI->new; >-my $sticky_filters = $input->param('sticky_filters') || 0; >+my $input = CGI->new; > > my ($template, $loggedinuser, $cookie) > = get_template_and_user({template_name => "acqui/parcel.tt", >@@ -110,6 +109,25 @@ unless( $invoiceid and $invoice->{invoiceid} ) { > exit; > } > >+my $sticky_filters = $input->param('sticky_filters') || 0; >+ >+if ($sticky_filters) { >+ my $search = $input->cookie("filter_parcel_summary"); >+ my $ean = $input->cookie("filter_parcel_ean"); >+ my $basketname = $input->cookie("filter_parcel_basketname"); >+ my $orderno = $input->cookie("filter_parcel_orderno"); >+ my $basketgroupname = $input->cookie("filter_parcel_basketgroupname"); >+ >+ $template->param( >+ summaryfilter => $search, >+ eanfilter => $ean, >+ basketfilter => $basketname, >+ orderfilter => $orderno, >+ basketgroupnamefilter => $basketgroupname, >+ ); >+} >+ >+ > my $booksellerid = $invoice->{booksellerid}; > my $bookseller = Koha::Acquisition::Booksellers->find( $booksellerid ); > >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 0899a4fdbf0..a10c806bef3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt >@@ -372,6 +372,39 @@ > dt_overwrite_html_sorting_localeCompare(); > var sticky_filters = [% sticky_filters | html %]; > >+ function query_from_filters( base_query, params ) { >+ >+ var query_and = []; >+ >+ if ( params.basket_name != "" ) { >+ query_and.push( { "basket.name": { "like": '%'+params.basket_name+'%' } } ); >+ } >+ if (params.basket_group != "") { >+ query_and.push( { "basket.basket_group.name": { "like": '%'+params.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 (params.ean != "") { >+ query_and.push( { "biblio.ean": params.ean } ); >+ } >+ >+ var query_params = []; >+ >+ if ( query_and.length > 0 ) { >+ query_and.push(base_query); >+ query_params.push('q=' + encodeURIComponent(JSON.stringify({ "-and": query_and }))); >+ } >+ >+ if ( params.order_id != "" ) { >+ query_params.push("order_id="+params.order_id); >+ } >+ >+ return query_params; >+ } >+ > $(document).ready(function(){ > > if ( $("#receivedt").length ) { >@@ -403,10 +436,30 @@ > } > > 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 THE_query = query_params.join("&"); >+ > var pending_orders_url = '/api/v1/acquisitions/orders?only_active=1'; > var pending_orders_table = $("#pending_orders").api({ > "ajax": { >- "url": pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query)) >+ "url": pending_orders_url + '&' + THE_query > }, > "header_filter": true, > "embed": [ >@@ -688,45 +741,32 @@ > > $("#filterform").on("submit", function(e) { > e.preventDefault(); >- // Update the datatable URL >+ > 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_and = []; >- >- if (basket_name != "") { >- query_and.push( { "basket.name": { "like": '%'+basket_name+'%' } } ); >- } >- if (basket_group != "") { >- query_and.push( { "basket.basket_group.name": { "like": '%'+basket_group+'%' } } ); >- } >- if (summary != "") { >- query_and.push( { "-or": [{"biblio.title": { "like": '%'+summary+'%' } }, >- {"biblio.author": { "like": '%'+summary+'%' } }, >- {"biblio.isbn": { "like": '%'+summary+'%' } } ] } ); >- } >- [% IF (UNIMARC) %] >- if (ean != "") { >- query_and.push( { "biblio.ean": ean } ); >- } >- [% END %] >- >- if ( !jQuery.isEmptyObject(query_and) || order_id != "" ) { >- >- var query_params = []; >- >- if ( order_id != "" ) { >- query_params.push("order_id="+order_id); >- } >+ // 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); > >- if ( !jQuery.isEmptyObject(query_and) ) { >- query_and.push(base_query); >- query_params.push('q=' + encodeURI(JSON.stringify({ "-and": query_and }))); >+ 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 > } >+ ); > >+ if ( query_params.length > 0 ) { > pending_orders_table.api().ajax.url( pending_orders_url + '&' + query_params.join("&") ); > } > else { >@@ -740,21 +780,6 @@ > pending_orders_table.api().ajax.url(pending_orders_url + '&q=' + encodeURI(JSON.stringify(base_query))).draw(); > }); > >- // Keep filters from finishreceive.pl to parcel.pl >- $.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()); >- >- $("#filterform").on('submit', function(){ >- $.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()); >- }); >- > $(".previewData").on("click", function(e){ > e.preventDefault(); > var ltitle = $(this).text(); >-- >2.29.2
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