Bug 34934: Remove the use of event attributes from OPAC lists page

This patch removes the use of event attributes (onclick, onchange) from
the OPAC lists template. These events are defined now along with the
other in-page JS.

The patch also removes a "delete list" button which was only shown
when viewing an empty list and which was redundant.

To test, apply the patch and log into the OPAC.

- Go to Lists -> New list.
- Change the category to "Private" and the "Allow changes" dropdown to
  "Staff only."
  - You should see a message, 'The "Staff only" permission has no actual
    effect while this list is strictly private'
- Change the category to "Public." The message should disappear.

- View the contents of a list.
  - Click the "Send list" button at the top of the table of titles.
  - It should trigger the "Sending your list" popup window.

Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
(cherry picked from commit 56348379ec)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit ea411a563a)
Signed-off-by: Jacob O'Mara <jacob.omara@ptfs-europe.com>
This commit is contained in:
Owen Leonard 2023-09-27 15:42:26 +00:00 committed by Jacob O'Mara
parent 2282021cb9
commit e0964c19ec

View file

@ -38,7 +38,7 @@
[% BLOCK list_permissions %]
<li>
<label for="allow_changes_from">Allow changes to contents from: </label>
<select name="allow_changes_from" id="allow_changes_from" onchange="AdjustRemark()">
<select name="allow_changes_from" id="allow_changes_from">
[% IF shelf.allow_change_from_owner %]<option value="0">Nobody</option>[% ELSE %]<option value="0" selected="selected">Nobody</option>[% END %]
@ -236,7 +236,7 @@
</div>
[% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
<span class="sendlist"><a href="/cgi-bin/koha/opac-sendshelf.pl?shelfid=[% shelf.shelfnumber | uri %]" class="btn btn-link send" onclick="open('/cgi-bin/koha/opac-sendshelf.pl?shelfid=[% shelf.shelfnumber | html %]','win_form','scrollbars=yes,resizable=yes,height=400,width=500,top=50,left=100'); return false; "><i class="fa fa-fw fa-envelope" aria-hidden="true"></i> Send list</a></span>
<span class="sendlist"><a href="/cgi-bin/koha/opac-sendshelf.pl?shelfid=[% shelf.shelfnumber | uri %]" class="btn btn-link send"><i class="fa fa-fw fa-envelope" aria-hidden="true"></i> Send list</a></span>
[% END %]
<a class="btn btn-link print-small" target="_blank" href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | html %]&sortfield=[% sortfield | html %]&direction=[% direction | uri %]&print=1"><i class="fa fa-fw fa-print" aria-hidden="true"></i> Print list</a>
@ -547,14 +547,6 @@
[% END %]
</div>
[% IF can_manage_shelf %]
<form method="post" action="opac-shelves.pl">
<input type="hidden" name="op" value="delete" />
<input type="hidden" name="referer" value="list" />
<input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]"/>
<input type="submit" class="btn btn-danger" value="Delete this list" onclick="return confirmDelete(MSG_CONFIRM_DELETE_LIST)" />
</form>
[% END %]
[% END # / IF itemsloop %]
[% END # /IF shelf AND op == 'view' %]
@ -610,7 +602,7 @@
[% IF Koha.Preference('OpacAllowPublicListCreation') OR public == 1 %]
<li>
<label for="public">Category:</label>
<select name="public" id="public" onchange="AdjustRemark()">
<select name="public" id="public">
[% IF shelf.is_private %]
<option value="0" selected="selected">Private</option>
[% ELSE %]
@ -1057,6 +1049,16 @@ $(function() {
$("#download_list").submit();
});
$("#allow_changes_from, #public").on("change", function(){
AdjustRemark();
});
$(".send").on("click", function(e){
e.preventDefault();
let link = this.href;
Dopop( link );
});
}); // document.ready
function sortMenu( sorting_form ){