From ace488e50f67dfa0986c3dba3e9b85c911539ac1 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Mon, 24 Jun 2024 14:46:36 +0000 Subject: [PATCH] Bug 37150: Can't delete single title from a list using the "Remove from list" link In the OPAC display of titles on a list, the "Remove from list" control needs to trigger a POST operation instead of GET. This patch appends a form for handling single entry deletions, populating the hidden input upon confirmation. To test, apply the patch and create a list if necessary, adding multiple titles to it. - 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. - 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. - Check one or more checkboxes and then click a single "Remove from list" link. After confirming, you should find that only the one title was removed from the list. Sponsored-by: Athens County Public Libraries Signed-off-by: Eric Garcia Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- .../en/includes/title-actions-menu.inc | 2 +- .../bootstrap/en/modules/opac-shelves.tt | 29 ++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/title-actions-menu.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/title-actions-menu.inc index d2b050cd4f..56edfd1795 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/title-actions-menu.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/title-actions-menu.inc @@ -52,7 +52,7 @@ [% IF ( shelf AND op == 'view' ) %] Save to another list [% IF can_remove_biblios %] - Remove from this list + Remove from this list [% END %] [% ELSE %] Save to lists diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt index 0686b5d506..0990eedd83 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -383,7 +383,7 @@ [% END %] [% IF loggedinusername && can_remove_biblios %] - + Remove from list [% END %] @@ -547,6 +547,15 @@ [% END %] + [% IF can_manage_shelf %] +
+ [% INCLUDE 'csrf-token.inc' %] + + + + +
+ [% END %] [% ELSE %]
@@ -985,16 +994,16 @@ $(function() { [% IF loggedinusername && can_remove_biblios %] $("body").on("click", ".removeitems", function(e){ e.preventDefault(); - var href; var title; var yes_label; var no_label; var message = ""; + var biblionumber; /* Single "Remove from list" link has a biblionumber data-attribute */ if( $(this).data("biblionumber") ){ /* 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"); + biblionumber = $(this).data("biblionumber"); } else { var selected_titles = $(".cb:checked"); } @@ -1004,23 +1013,24 @@ $(function() { if( selected_titles.size() > 1 ){ message = $("
    "); title = _("Are you sure you want to remove these items from the list?"); - yes_label = _("Yes, delete from list"); - no_label = _("No, do not delete from list"); + yes_label = _("Yes, remove from list"); + no_label = _("No, do not remove from list"); selected_titles.each(function(){ message.append( "
  • " + $(this).data("title") + "
  • " ); }); } else { title = _("Are you sure you want to remove this item from the list?"); - yes_label = _("Yes, delete from list"); - no_label = _("No, do not delete from list"); + yes_label = _("Yes, remove from list"); + no_label = _("No, do not remove from list"); selected_titles.each(function(){ message += $(this).data("title"); }); } confirmModal( message, title, yes_label, no_label, function( result ){ if( result ){ - if( href ){ - location.href= href; + if( selected_titles.size() == 1 ){ + $("#shelf_delete_biblionumber").val( biblionumber ); + $("#shelf_delete_title").submit(); } else { $("#myform").submit(); } @@ -1029,7 +1039,6 @@ $(function() { } }); - $("#removeitems").html(" "+_("Remove from list")+""); [% END %] [% IF OpenLibraryCovers %]KOHA.OpenLibrary.GetCoverFromIsbn();[% END %] [% IF OPACLocalCoverImages %]KOHA.LocalCover.GetCoverFromBibnumber(false);[% END %] -- 2.39.5