Bug 28882: Disable select/hide all links

We want to prevent non-superlibrarian users to remove superlibrarian
flag.
It's handled already in the controller, but needs to be done
client-side.

Here we are disabling the select/hide all links to remove the remaining
possibility to remove the superlibrarian flag from non-superlibrarian
users.

Signed-off-by: Hayley Pelham <hayleypelham@catalyst.net.nz>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Jonathan Druart 2021-08-25 11:47:18 +02:00
parent 3f58ecb609
commit 641c4ffa97

View file

@ -127,28 +127,35 @@
var Sticky;
$(document).ready(function() {
$("#CheckAllFlags").on("click",function(){
$(".flag").attr("disabled", false);
$(".flag").prop("checked", true);
$("#flag-0").prop("checked", false);
[% IF disable_superlibrarian_privs %]
$("#flag-0").prop("disabled", true);
[% END %]
return false;
});
$("#UncheckAllFlags").on("click",function(){
$(".flag").attr("disabled", false);
[% IF disable_superlibrarian_privs %]
$("#flag-0").prop("disabled", true);
[% END %]
$(".flag").prop("checked", false);
return false;
});
$(".flag").change(function(){
if(!$(this).is(':checked')){
$("input#flag-0").prop("checked", false);
}
});
[% IF disable_superlibrarian_privs && patron.is_superlibrarian %]
$("#CheckAllFlags,#UncheckAllFlags")
.attr("disabled", true)
.attr("title", _("The system preference ProtectSuperlibrarian is enabled"))
.on("click", function(e){e.preventDefault()});
[% ELSE %]
$("#CheckAllFlags").on("click",function(){
$(".flag").attr("disabled", false);
$(".flag").prop("checked", true);
$("#flag-0").prop("checked", false);
[% IF disable_superlibrarian_privs %]
$("#flag-0").prop("disabled", true);
[% END %]
return false;
});
$("#UncheckAllFlags").on("click",function(){
$(".flag").attr("disabled", false);
[% IF disable_superlibrarian_privs %]
$("#flag-0").prop("disabled", true);
[% END %]
$(".flag").prop("checked", false);
return false;
});
$(".flag").change(function(){
if(!$(this).is(':checked')){
$("input#flag-0").prop("checked", false);
}
});
[% END %]
Sticky = $("#permissions_toolbar");
Sticky.hcSticky({