Bugzilla – Attachment 156562 Details for
Bug 34977
Allow to delete multiple patron lists at once
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34977: The "Patron Lists" only allows deleting one list at a time
Bug-34977-The-Patron-Lists-only-allows-deleting-on.patch (text/plain), 5.57 KB, created by
David Nind
on 2023-10-04 22:13:02 UTC
(
hide
)
Description:
Bug 34977: The "Patron Lists" only allows deleting one list at a time
Filename:
MIME Type:
Creator:
David Nind
Created:
2023-10-04 22:13:02 UTC
Size:
5.57 KB
patch
obsolete
>From 1aac5a1b8b76a8dc31bbf54c4884aba391985bb3 Mon Sep 17 00:00:00 2001 >From: Salah Ghedds <salah.ghedda@inLibro.com> >Date: Wed, 4 Oct 2023 14:43:54 -0400 >Subject: [PATCH] Bug 34977: The "Patron Lists" only allows deleting one list > at a time > >In the patrons lists, it's only possible to delete on list at a time. This patch add the possibility to select lists and delete them at once. > >TEST PLAN >1. Apply the patch. >2. Create at least 2 patron lists (Navigate to Tools > Patron lists > New patron list). >3. Select the lists you want to delete. >4. Click the "Delete selected lists" button. >5. Confirm that the selected lists have been deleted. >6. Ensure that the button cannot be used if no list is selected. > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../prog/en/modules/patron_lists/lists.tt | 35 +++++++++++++++++-- > patron_lists/delete.pl | 12 +++++-- > 2 files changed, 42 insertions(+), 5 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/lists.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/lists.tt >index 2404e9cd07..4131530e24 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/lists.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/patron_lists/lists.tt >@@ -47,6 +47,7 @@ > <table id="patron-lists-table"> > <thead> > <tr> >+ <input type="button" type="submit" class="btn btn-default btn-sm disabled" value="Delete selected lists" id="delete_selected_lists"/> > <th>Name</th> > <th>Patrons in list</th> > <th>Shared</th> >@@ -58,7 +59,10 @@ > [% FOREACH l IN lists %] > [% SET shared_by_other = l.owner.id != logged_in_user.id %] > <tr> >- <td><a href="/cgi-bin/koha/patron_lists/list.pl?patron_list_id=[% l.patron_list_id | uri %]">[% l.name | html %]</a></td> >+ <td> >+ <input class="select_patron" type="checkbox" autocomplete="off" data-patron-list-id="[% l.patron_list_id | html %]"> >+ <a href="/cgi-bin/koha/patron_lists/list.pl?patron_list_id=[% l.patron_list_id | uri %]">[% l.name | html %]</a> >+ </td> > <td>[% l.patron_list_patrons_rs.count || 0 | html %]</td> > <td> > [% IF l.shared %] >@@ -68,6 +72,7 @@ > by you > [% END %] > [% END %] >+ > </td> > <td> > <div class="btn-group dropup"> >@@ -147,17 +152,41 @@ > var patronExportModal = $("#patronExportModal"); > var patronExportModalBody = $("#patronExportModal .modal-body"); > >+ let selectedPatronLists = new Array(); >+ > $('#patron-lists-table').dataTable($.extend(true, {}, dataTablesDefaults, { > "autoWidth": false, > "aoColumnDefs": [ >- { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] } >+ {"bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ]} > ], > "sPaginationType": "full" > } )); > $(".delete_patron").on("click", function(){ > $(".dropdown").removeClass("open"); > var list = $(this).data("list-name"); >- return confirmDelete( _("Are you sure you want to delete the list %s?").format(list) ); >+ return confirmDelete( _("Are you sure you want to delete the list %s?").format(list)); >+ }); >+ >+ $("#delete_selected_lists").on("click", function() { >+ if (selectedPatronLists.length != 0) { >+ if (confirm(_("Are you sure you want to delete the selected lists ?"))) { >+ var delete_lists_url = '/cgi-bin/koha/patron_lists/delete.pl?patron_lists_ids=' + selectedPatronLists.join("&patron_lists_ids="); >+ window.location.href = delete_lists_url; >+ } >+ } >+ }); >+ >+ $(".select_patron").on("click", function() { >+ if($(this).is(':checked')){ >+ $("#delete_selected_lists").attr("class","btn btn-default btn-sm"); >+ selectedPatronLists.push($(this).data("patron-list-id")); >+ } >+ else { >+ selectedPatronLists = selectedPatronLists.filter(item => item !== $(this).data("patron-list-id")); >+ if(selectedPatronLists.length === 0){ >+ $("#delete_selected_lists").attr("class","btn btn-default btn-sm disabled"); >+ } >+ } > }); > > $(".print_cards").on("click", function(e){ >diff --git a/patron_lists/delete.pl b/patron_lists/delete.pl >index 773ec3d168..56aa9ba2ca 100755 >--- a/patron_lists/delete.pl >+++ b/patron_lists/delete.pl >@@ -37,7 +37,15 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > ); > > my $id = $cgi->param('patron_list_id'); >- >-DelPatronList( { patron_list_id => $id } ); >+my @lists_ids = $cgi->multi_param('patron_lists_ids'); >+ >+if (defined $id && $id ne '') { >+ DelPatronList({ patron_list_id => $id }); >+} >+if (@lists_ids) { >+ foreach my $list_id (@lists_ids) { >+ DelPatronList({ patron_list_id => $list_id }); >+ } >+} > > print $cgi->redirect('lists.pl'); >-- >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 34977
:
156553
|
156554
|
156562
|
158349
|
158350
|
159483
|
159484