Bug 22553: Unchecking a subpermission does not uncheck the top level permission

This patch makes a minor change to the set permissions page's JavaScript
so that unchecking a subpermission will uncheck the top level
permission.

To test, apply the patch and open the "Set permissions" page for a
patron.

 - Expand a permission with multiple subpermissions.
 - Check the top level permission. All subpermissions should be checked.
 - Uncheck one of the subpermissions. The top level permission should
   now be unchecked.

Signed-off-by: Liz Rea <wizzyrea@gmail.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Owen Leonard 2019-04-09 13:21:08 +00:00 committed by Nick Clemens
parent 192e3baa75
commit 383ec1f51b

View file

@ -195,13 +195,17 @@
$(".flag").on("change",function(e){
e.preventDefault();
var bit = $(this).data("bit");
if( $(this).is(":checked") ){
$("#flag-" + bit + "-children").show().find(".flag").prop("checked", true);
$(".toggle-" + bit + ".togglechildren_on").hide();
$(".toggle-" + bit + ".togglechildren_off").show();
if( $(this).hasClass("child") ){
$(this).closest(".parent").find(".flag.parent").prop("checked", false);
} else {
$("#flag-" + bit + "-children").show().find(".flag").prop("checked", false);
var bit = $(this).data("bit");
if( $(this).is(":checked") ){
$("#flag-" + bit + "-children").show().find(".flag").prop("checked", true);
$(".toggle-" + bit + ".togglechildren_on").hide();
$(".toggle-" + bit + ".togglechildren_off").show();
} else {
$("#flag-" + bit + "-children").show().find(".flag").prop("checked", false);
}
}
});