From 3499ebb289057cb09f9c8fff21dbe1ded5d9b102 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 21 Nov 2019 17:12:30 +0000 Subject: [PATCH] Bug 14741: Selecting all child permissions doesn't select the top level check box This patch modifies the patron flags page so that manually selecting all the child permissions also checks the checkbox for the parent permission. To test, apply the patch, open a patron record, select More -> Set permissions. - Expand a set of permissions, for instance "Add, modify, and view patron information." - If any boxes are checked, uncheck them. - Check each of the "child" checkboxes ("Add, modify, and view..." and "View patron infos..." ). - When both checkboxes are checked, the "Add, modify, and view" parent permission should be automatically checked. Signed-off-by: Maryse Simard --- .../prog/en/modules/members/member-flags.tt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 de955cc..d9eef9a 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 @@ -196,7 +196,21 @@ $(".flag").on("change",function(e){ e.preventDefault(); if( $(this).hasClass("child") ){ - $(this).closest(".parent").find(".flag.parent").prop("checked", false); + if( $(this).prop("checked") ){ + // If this is the last of all the child boxes to be checked the parent should be checked too + var unchecked = 0; + $(this).closest(".children").find(".child").each(function(){ + if( !$(this).prop("checked") ){ + // There are still unchecked checkboxes in this group + unchecked = 1; + } + }); + if( unchecked === 0 ){ + $(this).closest(".parent").find(".flag.parent").prop("checked", true); + } + } else { + $(this).closest(".parent").find(".flag.parent").prop("checked", false); + } } else { var bit = $(this).data("bit"); if( $(this).is(":checked") ){ -- 2.7.4