Bugzilla – Attachment 154337 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.70 KB, created by
Nick Clemens (kidclamp)
on 2023-08-09 17:50:20 UTC
(
hide
)
Description:
Bug 34509: Use select2 to load vendors on basket creation
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-08-09 17:50:20 UTC
Size:
4.70 KB
patch
obsolete
>From 5586df5604ccc269cc603615f96469964eb42b8f 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 >--- > acqui/basketheader.pl | 4 -- > .../prog/en/modules/acqui/basketheader.tt | 57 ++++++++++++++++--- > 2 files changed, 49 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..643aefdf02 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,53 @@ > [% 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_bookseller (state) { >+ var $text; >+ $text = $('<span>'+state.text+'</span>'); >+ >+ return $text; >+ }; >+ >+ $("#basketbooksellerid").kohaSelect({ >+ width: 'resolve', >+ 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.escapeHtml(), >+ "text": vendor.name.escapeHtml() >+ } >+ ); >+ }); >+ return { "results": results, "pagination": { "more": data.pagination.more } }; >+ } >+ }, >+ template: display_bookseller >+ }); >+}); >+</script> > [% END %] > > [% INCLUDE 'intranet-bottom.inc' %] >-- >2.30.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 34509
:
154337
|
154341
|
154732
|
154734
|
154735
|
154741