From 641c4ffa97a6060c939934ef21d9b59ddd9a05eb Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 25 Aug 2021 11:47:18 +0200 Subject: [PATCH] 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 Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart --- .../prog/en/modules/members/member-flags.tt | 51 +++++++++++-------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-flags.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-flags.tt index d2f4156f51..6acb98bceb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-flags.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/member-flags.tt @@ -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({ -- 2.39.5