From a8cb065838b06246292ada2c46152f16931325ca 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. --- .../opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 58 ++++++++++++++-------- 1 file changed, 38 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..8dd616cec0 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,16 @@ [% 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 +169,8 @@ [% IF ( itemsloop ) %] + [% SET contents = shelf.get_contents %] + [% IF ( contents.count ) %]

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

[% END %]
@@ -181,13 +193,8 @@ -
- - - - - -
+ [% PROCESS delete_shelf delete_label="Delete list" %] + [% IF category == PRIVATE && Koha.Preference('OpacAllowSharingPrivateLists') %] Share list [% END %] @@ -504,12 +511,8 @@ -
- - - - -
+ [% PROCESS delete_shelf delete_label="Delete list" %] + [% END %]
@@ -688,13 +691,7 @@ [% END %] [% IF s.can_be_deleted( loggedinusernumber ) %] -
- - - - - -
+ [% PROCESS delete_shelf shelf = s delete_label="Delete" %] [% END %] [% IF s.is_private AND s.can_be_managed( loggedinusernumber ) AND Koha.Preference('OpacAllowSharingPrivateLists') %] Share @@ -966,6 +963,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"); -- 2.11.0