Bugzilla – Attachment 160703 Details for
Bug 35329
Move patron searches to a modal
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35329: Move patron search to modal - routing list
Bug-35329-Move-patron-search-to-modal---routing-li.patch (text/plain), 5.73 KB, created by
Jonathan Druart
on 2024-01-09 14:54:23 UTC
(
hide
)
Description:
Bug 35329: Move patron search to modal - routing list
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-01-09 14:54:23 UTC
Size:
5.73 KB
patch
obsolete
>From 2fc16e9311d986d95281d1a58d14e885cceaab48 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 5 Jan 2024 14:50:38 +0100 >Subject: [PATCH] Bug 35329: Move patron search to modal - routing list > >The behaviour is a bit different here. Adding a patron from the popup >refreshed the parent page with the newly added patron. > >With this patch the refresh of the page will happen when the modal is >closed (if patrons have been added). > >Test plan: >Create a subscription, receive one item, create a routing list. >Add users. >--- > .../prog/en/modules/serials/routing.tt | 60 ++++++++++++++----- > serials/routing.pl | 8 ++- > 2 files changed, 51 insertions(+), 17 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing.tt >index e74b373f74e..66d9c6f6e1b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/routing.tt >@@ -1,6 +1,8 @@ > [% USE raw %] > [% USE KohaDates %] > [% SET footerjs = 1 %] >+[% PROCESS 'i18n.inc' %] >+[% PROCESS 'patron-search.inc' %] > [% INCLUDE 'doc-head-open.inc' %] > <title>[% IF ( op ) %]Create routing list[% ELSE %]Edit routing list[% END %] › [% title | html %] › Serials › Koha</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -87,9 +89,10 @@ > [% END %] > </table> > [% END %] >+ <input type="hidden" id="new_recipients" name="new_recipients" value=""> > > <p style="margin-left:10em;"> >- <a href="#" id="add_recipients"><i class="fa fa-plus"></i> Add recipients</a> >+ <a href="#patron_search_modal" id="add_recipients" data-toggle="modal"><i class="fa fa-plus"></i> Add recipients</a> > [% IF memberloop %] > <a href="/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscriptionid | uri %]&op=delete"><i class="fa fa-trash-can"></i> Delete all</a> > [% END %] >@@ -115,10 +118,6 @@ > [% MACRO jsinclude BLOCK %] > <script> > $(document).ready(function(){ >- $("#add_recipients").on("click",function(e){ >- e.preventDefault(); >- userPopup(); >- }); > $(".itemrank").on("change",function(){ > var subscriptionid = $(this).data("subscriptionid"); > var routingid = $(this).data("routingid"); >@@ -130,17 +129,50 @@ > window.location.href=mylocation; > } > >- function userPopup() { >- window.open("/cgi-bin/koha/members/search.pl?columns=cardnumber,name,category,branch,action&selection_type=add", >- 'PatronPopup', >- 'width=1024,height=768,scrollbars=yes,toolbar=no,' >- + 'scrollbars=yes,resize=yes' >- ); >+ function add_user(borrowernumber) { >+ let users = $("#new_recipients").val().split(':'); >+ if ( !users.includes(borrowernumber) ) { >+ users.push(borrowernumber); >+ } >+ users = [...new Set(users)]; // unique >+ $("#new_recipients").val(users.filter(Number).join(':')); // remove empty and join > } > >- function add_user(borrowernumber) { >- var myurl = "/cgi-bin/koha/serials/routing.pl?subscriptionid="+[% subscriptionid | html %]+"&borrowernumber="+borrowernumber+"&op=add"; >- window.location.href = myurl; >+ </script> >+ >+ [% INCLUDE 'select2.inc' %] >+ [% SET columns = ['cardnumber','name','category','branch','action'] %] >+ [% PROCESS patron_search_modal columns => columns, modal_title => t("Add recipients") %] >+ [% PROCESS patron_search_js columns => columns, actions => ["add"], preview_on_name_click => 1 %] >+ >+ <script> >+ $(document).on( >+ "hidden.bs.modal", >+ "#patron_search_modal", >+ add_new_recipients); >+ >+ function add_new_recipients(e){ >+ e.preventDefault(); >+ let borrowernumbers = $("#new_recipients").val(); >+ if(!borrowernumbers.length > 0) { >+ return; >+ } >+ $.ajax({ >+ data: { >+ subscriptionid: [% subscriptionid | html %], >+ borrowernumbers, >+ op: 'add_new_recipients' >+ }, >+ type: 'POST', >+ url: '/cgi-bin/koha/serials/routing.pl', >+ success: function (data) { >+ document.location.href = '/cgi-bin/koha/serials/routing.pl?subscriptionid=[% subscriptionid | uri %]'; >+ return false; >+ }, >+ error: function (data) { >+ alert(data); >+ }, >+ }); > } > </script> > [% END %] >diff --git a/serials/routing.pl b/serials/routing.pl >index 2e3122d3b5b..167184924e9 100755 >--- a/serials/routing.pl >+++ b/serials/routing.pl >@@ -41,7 +41,7 @@ my $query = CGI->new; > my $subscriptionid = $query->param('subscriptionid'); > my $serialseq = $query->param('serialseq'); > my $routingid = $query->param('routingid'); >-my $borrowernumber = $query->param('borrowernumber'); >+my $borrowernumbers = $query->param('borrowernumbers'); > my $notes = $query->param('notes'); > my $op = $query->param('op') || q{}; > my $date_selected = $query->param('date_selected'); >@@ -66,8 +66,10 @@ if($op eq 'delete'){ > delroutingmember($routingid,$subscriptionid); > } > >-if($op eq 'add'){ >- addroutingmember($borrowernumber,$subscriptionid); >+if ( $op eq 'add_new_recipients' ) { >+ for my $borrowernumber ( split ':', $borrowernumbers ) { >+ addroutingmember( $borrowernumber, $subscriptionid ); >+ } > } > if($op eq 'save'){ > my $sth = $dbh->prepare('UPDATE serial SET routingnotes = ? WHERE subscriptionid = ?'); >-- >2.34.1
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 35329
:
160698
|
160699
|
160700
|
160701
|
160702
|
160703
|
160704
|
160705
|
160706
|
160728
|
160729
|
160733
|
160734
|
160735
|
160736
|
160737
|
160738
|
160739
|
160740
|
160741
|
160742
|
160743
|
160759
|
160760
|
160761
|
160762
|
160763
|
160768
|
160769
|
160770
|
160771
|
160773
|
160774
|
160940
|
160941
|
160943
|
160944
|
160945
|
160946
|
160947
|
160948
|
160949
|
160950
|
160951
|
160952
|
160953
|
160954
|
160955
|
160956
|
160957
|
160958
|
160959
|
161165
|
161166
|
161183
|
161184
|
161185
|
161186
|
161187
|
161188
|
161189
|
161190
|
161191
|
161192
|
161193
|
161194
|
161195
|
161196
|
161197
|
161198
|
161199
|
161259
|
161260
|
161274
|
161275
|
161276
|
161277
|
161278
|
161279
|
161280
|
161281
|
161282
|
161283
|
161284
|
161285
|
161286
|
161287
|
161288
|
161289
|
161290
|
161291
|
161292
|
161293
|
161294
|
161295
|
161398
|
161399
|
161400
|
161401
|
161402
|
161403
|
161404
|
161405
|
161406
|
161407
|
161408
|
161409
|
161410
|
161411
|
161412
|
161413
|
161414
|
161415
|
161416
|
161417
|
162436
|
162437
|
162438
|
162439
|
162440
|
162441
|
162442
|
162443
|
162444
|
162445
|
162446
|
162447
|
162448
|
162449
|
162450
|
162451
|
162452
|
162453
|
162454
|
162455
|
162456
|
162457
|
162670
|
162671
|
162713
|
162714