From ddad175f1131442b60513370b2cf00b0d87f1652 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 24 Apr 2020 18:29:21 +0000 Subject: [PATCH] Bug 25281: Use modal confirmation when deleting a list in the OPAC This patch modifies the process of deleting a list in the OPAC so that the deletion confirmation alert is replaced with a Bootstrap modal. In the process, I moved the repeated deletion form markup into a block To test, apply the patch and log in to the OPAC as a user who has multiple lists, including some which have been shared with other users. Go to the list of your lists and click the "Delete" link next to any of your lists. It should trigger a confirmation modal: - The modal should show the title of the list you're deleting. - If the list has titles on it, it show how many. - If the list has been shared with someone it should say so. Next, view a list which is not empty. - Test the "Delete list" link in the toolbar. - You should see the same information in the confirmation message as in the previous step. Do the same with a list which is empty. Signed-off-by: Lucas Gass Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize --- .../bootstrap/en/modules/opac-shelves.tt | 64 +++++++++++++------ 1 file changed, 44 insertions(+), 20 deletions(-) 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 52cf9578cf..37d2b8108f 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt @@ -8,6 +8,22 @@ [% SET AdlibrisEnabled = Koha.Preference('AdlibrisCoversEnabled') %] [% SET AdlibrisURL = Koha.Preference('AdlibrisCoversURL') %] +[% BLOCK delete_shelf %] +
+ + + + + +
+[% END %] + [% INCLUDE 'doc-head-open.inc' %] [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog › [% IF op == 'view' %]Contents of [% shelf.shelfname | html %][% ELSE %]Your lists[% END %][% INCLUDE 'doc-head-close.inc' %] [% BLOCK cssinclude %][% END %] @@ -159,6 +175,8 @@ [% IF ( itemsloop ) %] + [% SET contents = shelf.get_contents %] + [% IF ( contents.count ) %]

This list contains [% contents.count | html %] titles

[% END %]
@@ -181,13 +199,8 @@ -
- - - - - -
+ [% PROCESS delete_shelf context = "details" %] + [% IF category == PRIVATE && Koha.Preference('OpacAllowSharingPrivateLists') %] Share list [% END %] @@ -504,12 +517,8 @@ -
- - - - -
+ [% PROCESS delete_shelf context = "details" %] + [% END %]
@@ -688,13 +697,7 @@ [% END %] [% IF s.can_be_deleted( loggedinusernumber ) %] -
- - - - - -
+ [% PROCESS delete_shelf shelf = s context = "list" %] [% END %] [% IF s.is_private AND s.can_be_managed( loggedinusernumber ) AND Koha.Preference('OpacAllowSharingPrivateLists') %] Share @@ -966,6 +969,27 @@ $(function() { }); [% END %] + $(".deleteshelf").on("click", function(e){ + e.preventDefault(); + var shelf_name = $(this).data("shelfname"); + var shelf_number = $(this).data("shelfnumber"); + var is_shared = $(this).data("shared"); + var count = $(this).data("count"); + var message = "

" + shelf_name + "

"; + if( count ){ + message += "

" + _("Items on this list:") + " " + count + "

"; + } + if( is_shared ){ + message += "

" + _("This list is shared. Other users will lose access to it.") + "

"; + } + confirmModal( message, _("Are you sure you want to delete this list?"), _("Yes, delete"), _("No, do not delete"), function( result ){ + if( result ){ + $("#deleteshelf" + shelf_number ).submit(); + } + } + ); + }); + $(".remove_share").on("click", function(e){ e.preventDefault(); var shelf_name = $(this).data("shelfname");