From 6db25c99a6df218783fed4060f9e8b936d0f105c Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Fri, 24 Apr 2020 14:48:21 +0000
Subject: [PATCH] Bug 25280: Use modal confirmation when removing share from a
list in the OPAC
This patch updates the process of removing a share from a list in the
OPAC so that the confirmation request shown to the user is a Bootstrap
modal instead of a plain JavaScript confirm dialog.
To test you should have the OpacAllowSharingPrivateLists enabled.
- Log in to the OPAC as a user who has multiple private lists.
- Share two or more lists with another user in the system.
- Accept the list shares on behalf of the other user and log in to the
OPAC as that user.
- In the list of that user's lists, test the process of removing a
share:
- Clicking "Remove share" should trigger a modal which asks if you
want to remove sharing. It should show the name of the list in
question.
- Test the funcionality of both the "No" and "Yes" options.
- Confirm that the "Remove share" button works correctly for any of
multiple lists.
- View the contents of a list which has been shared with this user.
- Test the "Remove share" button at the top of the list's contents.
- The same confirmation dialog should be triggered.
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
---
.../opac-tmpl/bootstrap/en/modules/opac-shelves.tt | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 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 a352cbc5a7..52cf9578cf 100644
--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt
+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-shelves.tt
@@ -192,12 +192,13 @@
<a href="/cgi-bin/koha/opac-shareshelf.pl?op=invite&shelfnumber=[% shelf.shelfnumber | uri %]" class="btn btn-link sharelist"><i class="fa fa-fw fa-share"></i> Share list</a>
[% END %]
[% ELSIF category == PRIVATE # not manageshelf and private means shared %]
- <form action="/cgi-bin/koha/opac-shelves.pl" method="post" class="form-inline">
+ <form action="/cgi-bin/koha/opac-shelves.pl" method="post" id="unshare[% shelf.shelfnumber | html %]" class="form-inline">
<input type="hidden" name="op" value="remove_share" />
<input type="hidden" name="referer" value="list" />
<input type='hidden' name='category' value='[% category | html %]' />
<input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
- <button type="submit" class="btn btn-link deleteshelf" onclick="return confirmDelete(MSG_CONFIRM_REMOVE_SHARE);"><i class="fa fa-fw fa-remove"></i> Remove share</button>
+ <button type="submit" class="btn btn-link remove remove_share"
+ data-shelfname="[% shelf.shelfname | html %]" data-shelfnumber="[% shelf.shelfnumber | html %]"><i class="fa fa-remove" aria-hidden="true"></i> Remove share</button>
</form>
[% END %]
</div>
@@ -699,12 +700,13 @@
<a href="/cgi-bin/koha/opac-shareshelf.pl?op=invite&shelfnumber=[% s.shelfnumber | uri %]" class="sharelist btn btn-link"><i class="fa fa-share"></i> Share</a>
[% END %]
[% IF s.is_shared_with( loggedinusernumber ) %]
- <form action="opac-shelves.pl" method="post" class="form-inline">
+ <form action="opac-shelves.pl" method="post" id="unshare[% s.shelfnumber | html %]" class="form-inline">
<input type="hidden" name="op" value="remove_share" />
<input type="hidden" name="referer" value="list" />
<input type='hidden' name='category' value='[% category | html %]' />
<input type="hidden" name="shelfnumber" value="[% s.shelfnumber | html %]" />
- <input type="submit" class="deleteshelf" onclick="return confirmDelete(MSG_CONFIRM_REMOVE_SHARE);" value="Remove share" />
+ <button type="submit" class="btn btn-link remove remove_share"
+ data-shelfname="[% s.shelfname | html %]" data-shelfnumber="[% s.shelfnumber | html %]"><i class="fa fa-remove" aria-hidden="true"></i> Remove share</button>
</form>
[% END %]
</td>
@@ -964,6 +966,18 @@ $(function() {
});
[% END %]
+ $(".remove_share").on("click", function(e){
+ e.preventDefault();
+ var shelf_name = $(this).data("shelfname");
+ var shelf_number = $(this).data("shelfnumber");
+ confirmModal( shelf_name, _("Are you sure you want to remove sharing? You will no longer have access to the list."), _("Yes, remove sharing"), _("No, do not remove sharing"), function( result ){
+ if( result ){
+ $("#unshare" + shelf_number ).submit();
+ }
+ }
+ );
+ });
+
}); // document.ready
function sortMenu( sorting_form ){
--
2.11.0