Bugzilla – Attachment 154741 Details for
Bug 34509
Cannot create baskets if too many vendors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34509: Use select2 to load vendors on basket creation
Bug-34509-Use-select2-to-load-vendors-on-basket-cr.patch (text/plain), 4.84 KB, created by
Martin Renvoize (ashimema)
on 2023-08-24 15:51:20 UTC
(
hide
)
Description:
Bug 34509: Use select2 to load vendors on basket creation
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2023-08-24 15:51:20 UTC
Size:
4.84 KB
patch
obsolete
>From b9324cc4ac730489268a11b16fad4da0cb949815 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 9 Aug 2023 17:39:45 +0000 >Subject: [PATCH] Bug 34509: Use select2 to load vendors on basket creation > >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 'New->basket' > 4 - Note the dropdown of all vendors > 5 - Choose a vendor and create a basket > 6 - Apply patch > 7 - Repeat > 8 - Note only a partial list of vendors is loaded > 9 - Search in the dropdown and confirm vendors are returned >10 - Select a vendor and create the basket > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > acqui/basketheader.pl | 4 -- > .../prog/en/modules/acqui/basketheader.tt | 58 ++++++++++++++++--- > 2 files changed, 50 insertions(+), 12 deletions(-) > >diff --git a/acqui/basketheader.pl b/acqui/basketheader.pl >index e79daa70a7..4cf1736715 100755 >--- a/acqui/basketheader.pl >+++ b/acqui/basketheader.pl >@@ -116,9 +116,6 @@ if ( $op eq 'add_form' ) { > $template->param(contractloop => \@contractloop, > basketcontractnumber => $basket->{'contractnumber'}); > } >- my $booksellers = Koha::Acquisition::Booksellers->search( >- undef, >- { order_by => { -asc => 'name' } } ); > > $template->param( add_form => 1, > basketname => $basket->{'basketname'}, >@@ -127,7 +124,6 @@ if ( $op eq 'add_form' ) { > booksellername => $bookseller->name, > booksellerid => $booksellerid, > basketno => $basketno, >- booksellers => $booksellers, > is_standing => $basket->{is_standing}, > create_items => $basket->{create_items}, > ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt >index 88dd4cb354..2414e69363 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/basketheader.tt >@@ -82,14 +82,8 @@ > <li> > <label for="basketbooksellerid">Vendor: </label> > <select name="basketbooksellerid" id="basketbooksellerid"> >- [% FOREACH b IN booksellers %] >- [% IF booksellerid == b.id %] >- <option value="[% b.id | html %]" selected="selected">[% b.name | html %]</option> >- [% ELSE %] >- <option value="[% b.id | html %]">[% b.name | html %]</option> >- [% END %] >- [% END %] >- </select> >+ <option value="[% booksellerid | html %]" selected="selected">Current vendor ([% booksellername | html %])</option> >+ </select> > </li> > <li> > <label for="basketnote">Internal note: </label> >@@ -163,6 +157,54 @@ > [% MACRO jsinclude BLOCK %] > [% Asset.js("js/acquisitions-menu.js") | $raw %] > [% Asset.js("js/acq.js") | $raw %] >+ [% INCLUDE 'select2.inc' %] >+<script> >+ >+$(document).ready(function() { >+ >+ function display_vendor(vendor) { >+ var $text; >+ $text = $('<span>'+vendor.text+'</span>'); >+ >+ return $text; >+ }; >+ >+ $("#basketbooksellerid").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 %] > > [% INCLUDE 'intranet-bottom.inc' %] >-- >2.41.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 34509
:
154337
|
154341
|
154732
|
154734
|
154735
| 154741