@@ -, +, @@ "Remove from list" link - View the contents of your list. - Each title on your list should have a "Remove from this list" link. - Click one of these. You should see a modal confirmation, "Are you sure you want to remove this item from the list?" - Confirming should delete the title form the list. - Cancelling should close the modal and uncheck the title's checkbox * I include automatic un-checking of the checkbox because the user didn't "deliberately" check the box, and I want to avoid having that title included with "deliberately" checked items. - Check multiple checkboxes in the list of titles and click "Remove from list" at the top of the list. - You should see a modal confirmation, "Are you sure you want to remove these items from the list?" - Confirming should result in all checked titles being removed from the list. - Cancelling should hide the modal, and your checked checkboxes should remain the same. --- .../bootstrap/en/modules/opac-shelves.tt | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -983,20 +983,23 @@ $(function() { [% END %] [% IF loggedinusername && can_remove_biblios %] + let single_bib; + let selected_titles; $("body").on("click", ".removeitems", function(e){ e.preventDefault(); - var href; + single_bib = $(this).data("biblionumber"); var title; var yes_label; var no_label; var message = ""; /* Single "Remove from list" link has a biblionumber data-attribute */ - if( $(this).data("biblionumber") ){ + if( single_bib ){ /* Use the checkbox with that value to preview the title in the confirmation */ - var selected_titles = $(".cb[value='" + $(this).data("biblionumber") + "'"); - var href = $(this).attr("href"); + selected_titles = $(".cb[value='" + single_bib + "'"); + /* Check the box automatically so we can submit the form from the modal */ + selected_titles.prop("checked", true ); } else { - var selected_titles = $(".cb:checked"); + selected_titles = $(".cb:checked"); } if ( selected_titles.size() < 1 ) { alert( _("No item was selected") ); @@ -1019,15 +1022,17 @@ $(function() { } confirmModal( message, title, yes_label, no_label, function( result ){ if( result ){ - if( href ){ - location.href= href; - } else { - $("#myform").submit(); - } + $("#myform").submit(); } }); } }); + $("body").on("hidden.bs.modal", "#bootstrap-confirm-box-modal", function(){ + /* If the user clicked a single "Remove from list" link, uncheck the checkbox */ + if( single_bib ){ + selected_titles.prop("checked", false ); + } + }); $("#removeitems").html(" "+_("Remove from list")+""); [% END %] --