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 2866a8b04d..c212ac48f2 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 @@ + @@ -58,7 +59,10 @@ [% FOREACH l IN lists %] [% SET shared_by_other = l.owner.id != logged_in_user.id %] - +
Name Patrons in list Shared
[% l.name | html %] + + [% l.name | html %] + [% l.patron_list_patrons_rs.count || 0 | html %] [% IF l.shared %] @@ -68,6 +72,7 @@ by you [% END %] [% END %] +
@@ -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'); +my @lists_ids = $cgi->multi_param('patron_lists_ids'); -DelPatronList( { patron_list_id => $id } ); +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');