Bug 34650: Convert list toolbar delete into form POST
This patch adds a HTML form with a CSRF token to POST the list delete, which is triggered by a click handler on the A element. The A element is still needed for existing style reasons. Test plan: 0. Apply patch 1. koha-plack --reload kohadev 2. In the staff interface, add a list 3. Go into that list (e.g. virtualshelves/shelves.pl?op=view&shelfnumber=X) 4. From the toolbar click the "Edit" dropdown 5. From the dropdown try either "Edit list" or "Delete list" 6. Note no CSRF error and operation completes as expected Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> (cherry picked from commit5d3b7cf089) Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> (cherry picked from commit0c4fe03c23) Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com>
This commit is contained in:
parent
17dcab057f
commit
d0a3ae57c0
|
|
@ -17,7 +17,14 @@
|
|||
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-pencil"></i> Edit <span class="caret"></span></button>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="/cgi-bin/koha/virtualshelves/shelves.pl?op=edit_form&shelfnumber=[% shelf.shelfnumber | uri %]&referer=[% op | uri %]">Edit list</a></li>
|
||||
<li><a id="deleteshelf" href="/cgi-bin/koha/virtualshelves/shelves.pl?op=delete&shelfnumber=[% shelf.shelfnumber | html %]">Delete list</a></li>
|
||||
<li>
|
||||
<a id="deleteshelf_toolbar" href="#">Delete list</a>
|
||||
<form id="deleteshelf_toolbar_form" action="shelves.pl" method="post">
|
||||
[% INCLUDE 'csrf-token.inc' %]
|
||||
<input type="hidden" name="op" value="delete">
|
||||
<input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]">
|
||||
</form>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
[% END %]
|
||||
|
|
|
|||
|
|
@ -941,6 +941,14 @@
|
|||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
$("#deleteshelf_toolbar").on('click',function(e){
|
||||
if(confirm(_("Are you sure you want to delete this list?"))){
|
||||
$("#deleteshelf_toolbar_form").submit();
|
||||
return false;
|
||||
} else {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
[% END %]
|
||||
|
|
|
|||
Loading…
Reference in New Issue