Bugzilla – Attachment 163102 Details for
Bug 36233
Cannot search invoices if too many vendors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36233: Use select2 to load vendors on invoice search
Bug-36233-Use-select2-to-load-vendors-on-invoice-s.patch (text/plain), 7.04 KB, created by
Victor Grousset/tuxayo
on 2024-03-12 22:44:04 UTC
(
hide
)
Description:
Bug 36233: Use select2 to load vendors on invoice search
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2024-03-12 22:44:04 UTC
Size:
7.04 KB
patch
obsolete
>From 1414bb6b2ed4bad0d1ff12bcd6603718d8de9a90 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 5 Mar 2024 14:52:16 +0000 >Subject: [PATCH] Bug 36233: Use select2 to load vendors on invoice search > >This patch moves the dropdown to use select2 and avoids loading all >vendors at page load. > >To test: > 1 - Create some extra vendors in your system, ideally over 20 > 2 - Search for a vendor in acquisitions > 3 - Click 'Invoices' > 4 - Note the dropdown of all vendors 'Vendor:' in search bar on left > 5 - The vendor you came from shoudl eb selected > 6 - Apply patch > 7 - Repeat > 8 - Note only a partial list of vendors is loaded, confirm current vendor still selected > 9 - Search in the dropdown and confirm vendors are returned >10 - Select a vendor and search >11 - confirm selection is retained > >Signed-off-by: Lisette Scheer <lisette@bywatersolutions.com> >Rebased-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > acqui/invoices.pl | 49 ++++++---------- > .../prog/en/modules/acqui/invoices.tt | 56 ++++++++++++++++--- > 2 files changed, 65 insertions(+), 40 deletions(-) > >diff --git a/acqui/invoices.pl b/acqui/invoices.pl >index 5cf2e338aa..309060efff 100755 >--- a/acqui/invoices.pl >+++ b/acqui/invoices.pl >@@ -105,22 +105,8 @@ $template->param( > ); > > # Build suppliers list >-my @suppliers = Koha::Acquisition::Booksellers->search( undef, { order_by => { -asc => 'name' } } )->as_list; >-my $suppliers_loop = []; >-my $suppliername; >-foreach (@suppliers) { >- my $selected = 0; >- if ($supplierid && $supplierid == $_->id ) { >- $selected = 1; >- $suppliername = $_->name; >- } >- push @{$suppliers_loop}, >- { >- suppliername => $_->name, >- booksellerid => $_->id, >- selected => $selected, >- }; >-} >+my $supplier; >+$supplier = Koha::Acquisition::Booksellers->find($supplierid) if $supplierid; > > my $budgets = GetBudgets(); > my @budgets_loop; >@@ -140,24 +126,23 @@ for my $sub ( @{$invoices} ) { > $template->{'VARS'}->{'budgets_loop'} = \@budgets_loop; > > $template->param( >- openedinvoices => \@openedinvoices, >- closedinvoices => \@closedinvoices, >- do_search => ( $op and $op eq 'do_search' ) ? 1 : 0, >- invoices => $invoices, >- invoicenumber => $invoicenumber, >- booksellerid => $supplierid, >- suppliername => $suppliername, >+ openedinvoices => \@openedinvoices, >+ closedinvoices => \@closedinvoices, >+ do_search => ( $op and $op eq 'do_search' ) ? 1 : 0, >+ invoices => $invoices, >+ invoicenumber => $invoicenumber, >+ booksellerid => $supplierid, >+ supplier => $supplier, > shipmentdatefrom => $shipmentdatefrom, > shipmentdateto => $shipmentdateto, >- billingdatefrom => $billingdatefrom, >- billingdateto => $billingdateto, >- isbneanissn => $isbneanissn, >- title => $title, >- author => $author, >- publisher => $publisher, >- publicationyear => $publicationyear, >- branch => $branch, >- suppliers_loop => $suppliers_loop, >+ billingdatefrom => $billingdatefrom, >+ billingdateto => $billingdateto, >+ isbneanissn => $isbneanissn, >+ title => $title, >+ author => $author, >+ publisher => $publisher, >+ publicationyear => $publicationyear, >+ branch => $branch, > ); > > output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt >index b045a90264..7973d64217 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/invoices.tt >@@ -317,14 +317,9 @@ > </li> > <li> > <label for="supplier">Vendor:</label> >- <select id="supplier" name="supplierid"> >- <option value="">All</option> >- [% FOREACH supplier IN suppliers_loop %] >- [% IF ( supplier.selected ) %] >- <option selected="selected" value="[% supplier.booksellerid | html %]">[% supplier.suppliername | html %]</option> >- [% ELSE %] >- <option value="[% supplier.booksellerid | html %]">[% supplier.suppliername | html %]</option> >- [% END %] >+ <select id="supplierid" name="supplierid"> >+ [% IF ( supplier ) %] >+ <option selected="selected" value="[% supplier.id | html %]">[% supplier.name | html %]</option> > [% END %] > </select> > </li> >@@ -425,6 +420,7 @@ > [% Asset.js("js/acquisitions-menu.js") | $raw %] > [% INCLUDE 'datatables.inc' %] > [% INCLUDE 'calendar.inc' %] >+ [% INCLUDE 'select2.inc' %] > <script> > $(document).ready(function() { > $('[id^="CheckAll"]').click( function() { >@@ -527,6 +523,50 @@ > $('#merge_invoices').show(); > } > }); >+ >+ function display_vendor(vendor) { >+ var $text; >+ $text = $('<span>'+vendor.text+'</span>'); >+ return $text; >+ } >+ >+ $("#supplierid").kohaSelect({ >+ width: '50%', >+ allowClear: false, >+ ajax: { >+ url: '/api/v1/acquisitions/vendors', >+ delay: 300, // wait 300 milliseconds before triggering the request >+ cache: true, >+ dataType: 'json', >+ data: function (params) { >+ var search_term = (params.term === undefined) ? '' : params.term; >+ var query = { >+ "q": JSON.stringify({"name":{"-like":'%'+search_term+'%'}}), >+ "_order_by": "name", >+ "_page": params.page >+ }; >+ >+ return query; >+ }, >+ processResults: function (data) { >+ var results = []; >+ data.results.forEach( function ( vendor ) { >+ results.push( >+ { >+ "id": vendor.id, >+ "text": vendor.name.escapeHtml() >+ } >+ ); >+ }); >+ return { "results": results, "pagination": { "more": data.pagination.more } }; >+ } >+ }, >+ templateResult: display_vendor, >+ templateSelection: display_vendor >+ }); >+ >+ >+ > }); > </script> > [% END %] >-- >2.44.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 36233
:
162753
|
162839
|
162848
|
162849
|
162853
|
163102
|
163103
|
163132
|
163146
|
163147
|
163148