Owen Leonard
53c8014557
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 <maryse.simard@inlibro.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
230 lines
12 KiB
Text
230 lines
12 KiB
Text
[% USE raw %]
|
|
[% USE Asset %]
|
|
[% USE Branches %]
|
|
[% SET footerjs = 1 %]
|
|
[% PROCESS 'permissions.inc' %]
|
|
[% INCLUDE 'doc-head-open.inc' %]
|
|
<title>Koha › Patrons › Set permissions for [% patron.surname | html %], [% patron.firstname | html %]</title>
|
|
[% INCLUDE 'doc-head-close.inc' %]
|
|
</head>
|
|
|
|
<body id="pat_member-flags" class="pat">
|
|
[% INCLUDE 'header.inc' %]
|
|
[% INCLUDE 'patron-search.inc' %]
|
|
|
|
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/members/members-home.pl">Patrons</a> › Set permissions for [% patron.surname | html %], [% patron.firstname | html %]</div>
|
|
|
|
<div class="main container-fluid">
|
|
<div class="row">
|
|
<div class="col-sm-10 col-sm-push-2">
|
|
<main>
|
|
|
|
[% INCLUDE 'members-toolbar.inc' %]
|
|
|
|
<form method="post" action="/cgi-bin/koha/members/member-flags.pl">
|
|
<input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
|
|
<input type="hidden" name="member" id="borrowernumber" value="[% patron.borrowernumber | html %]" />
|
|
<input type="hidden" name="newflags" value="1" />
|
|
<h1>Set permissions for [% patron.surname | html %], [% patron.firstname | html %]</h1>
|
|
|
|
<div id="permissionstree">
|
|
<div id="permissions_toolbar" class="btn-toolbar">
|
|
<button type="submit" class="btn btn-default"><i class="fa fa-save"></i> Save</button>
|
|
<a class="btn btn-default" href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron.borrowernumber | html %]"><i class="fa fa-remove"></i> Cancel</a>
|
|
<a class="toggleall toggleall_on btn btn-link" href="#"><i class="fa fa-plus-square-o"></i> Show all</a>
|
|
<a class="toggleall toggleall_off btn btn-link" href="#"><i class="fa fa-minus-square-o"></i> Hide all</a>
|
|
<div class="btn-group pull-right">
|
|
Filter: <input type="text" name="permissions_filter" id="permissions_filter" size="20" />
|
|
<a href="#" id="clear_filter" style="display:none"><i class="fa fa-remove"></i></a>
|
|
</div>
|
|
</div>
|
|
<div class="permissions">
|
|
[% FOREACH loo IN loop %]
|
|
[% IF ( loo.expand ) %]
|
|
<div id="parent-flag-[% loo.flag | html %]" class="open parent">
|
|
[% ELSE %]
|
|
<div id="parent-flag-[% loo.flag | html %]" class="parent">
|
|
[% END %]
|
|
[% IF ( loo.checked ) %]
|
|
[% IF disable_superlibrarian_privs && loo.bit == 0 %]
|
|
<input type="checkbox" disabled="disabled" data-bit="[% loo.bit | html %]" id="flag-[% loo.bit | html %]_disabled" class="parent flag superlib" name="flag" value="[% loo.flag | html %]" checked="checked" title="The system preference ProtectSuperlibrarianPrivileges is enabled" />
|
|
<input type="hidden" id="flag-[% loo.bit | html %]" name="flag" value="[% loo.flag | html %]" >
|
|
[% ELSE %]
|
|
<input type="checkbox" data-bit="[% loo.bit | html %]" id="flag-[% loo.bit | html %]" class="parent flag" name="flag" value="[% loo.flag | html %]" checked="checked" />
|
|
[% END %]
|
|
[% ELSE %]
|
|
[% IF disable_superlibrarian_privs && loo.bit == 0 %]
|
|
<input type="checkbox" disabled="disabled" class="flag parent" data-bit="[% loo.bit | html %]" id="flag-[% loo.bit | html %]_disabled" name="flag" value="[% loo.flag | html %]" title="The system preference ProtectSuperlibrarianPrivileges is enabled" />
|
|
[% ELSE %]
|
|
<input type="checkbox" class="flag parent" data-bit="[% loo.bit | html %]" id="flag-[% loo.bit | html %]" name="flag" value="[% loo.flag | html %]" />
|
|
[% END %]
|
|
[% END # /IF loo.checked %]
|
|
<label class="permissiondesc" for="flag-[% loo.bit | html %]">
|
|
[% PROCESS main_permissions name=loo.flag %]
|
|
</label>
|
|
[% IF ( loo.flag == "superlibrarian" ) %]<div class="hint superlibrarian-hint">This permission grants access to all areas. If selected, specific sub-permissions cannot be selected.</div>[% END %]
|
|
[% IF ( loo.sub_perm_loop ) %]
|
|
<a class="toggle-[% loo.bit | html %] togglechildren_off" href="#" data-bit="[% loo.bit | html %]"><i class="fa fa-minus-square-o"></i> Hide details</a>
|
|
<a class="toggle-[% loo.bit | html %] togglechildren_on" href="#" data-bit="[% loo.bit | html %]"><i class="fa fa-plus-square-o"></i> Show details</a>
|
|
<div class="children" id="flag-[% loo.bit | html %]-children">
|
|
[% FOREACH sub_perm_loo IN loo.sub_perm_loop %]
|
|
<div class="child-flags">
|
|
[% IF ( sub_perm_loo.checked ) %]
|
|
<input type="checkbox" id="[% sub_perm_loo.id | html %]" class="child flag" name="flag" value="[% sub_perm_loo.perm | html %]" checked="checked" />
|
|
[% ELSE %]
|
|
<input type="checkbox" id="[% sub_perm_loo.id | html %]" class="child flag" name="flag" value="[% sub_perm_loo.perm | html %]" />
|
|
[% END %]
|
|
<label class="permissiondesc" for="[% sub_perm_loo.id | html %]">
|
|
[% PROCESS sub_permissions name=sub_perm_loo.code %]
|
|
</label>
|
|
</div>
|
|
[% END %]
|
|
</div> <!-- /#flag-[% loo.bit | html %]-children -->
|
|
[% END # /IF loo.sub_perm_loop %]
|
|
</div> <!-- /.parent -->
|
|
[% END # /FOREACH loo %]
|
|
</div>
|
|
</div> <!-- /#permissionstree -->
|
|
</form>
|
|
|
|
</main>
|
|
</div> <!-- /.col-sm-10.col-sm-push-2 -->
|
|
|
|
<div class="col-sm-2 col-sm-pull-10">
|
|
<aside>
|
|
[% INCLUDE 'circ-menu.inc' %]
|
|
</aside>
|
|
</div> <!-- /.col-sm-2.col-sm-pull-10 -->
|
|
</div> <!-- /.row -->
|
|
|
|
[% MACRO jsinclude BLOCK %]
|
|
[% INCLUDE 'str/members-menu.inc' %]
|
|
[% Asset.js("js/members-menu.js") | $raw %]
|
|
[% Asset.js("lib/hc-sticky.js") | $raw %]
|
|
<script>
|
|
var Sticky;
|
|
$(document).ready(function() {
|
|
|
|
Sticky = $("#permissions_toolbar");
|
|
Sticky.hcSticky({
|
|
stickTo: "#permissionstree",
|
|
stickyClass: "floating"
|
|
});
|
|
|
|
$(".open div").show();
|
|
|
|
$("#permissions_filter").on("keyup", function(){
|
|
$("#clear_filter").css("display","inline-block");
|
|
$("a[class^=toggle-]").hide();
|
|
var string = $(this).val();
|
|
var divs = $("div[id!='parent-flag-superlibrarian']", ".permissions");
|
|
if( string != "" && string.length > 3 ){
|
|
divs.each(function(){
|
|
if ( $(this).text().search(new RegExp( string, "i")) < 0 ) {
|
|
$(this).hide();
|
|
} else {
|
|
$(this).show();
|
|
}
|
|
});
|
|
} else {
|
|
divs.show();
|
|
}
|
|
});
|
|
|
|
$("#clear_filter").on("click", function(){
|
|
$(".togglechildren_off").show();
|
|
$("#permissions_filter").val("");
|
|
$("div", "#permissionstree").show();
|
|
$(this).css("display","none");
|
|
});
|
|
|
|
// Enforce Superlibrarian Privilege Mutual Exclusivity
|
|
if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
|
|
if ($('input[name="flag"]:checked').length > 1){
|
|
alert(_("Inconsistency detected!") + "\n\n" + _("The superlibrarian privilege is mutually exclusive of other privileges, as it includes them all.") + "\n\n" + _("This patron's privileges will now be reset to include only superlibrarian."));
|
|
}
|
|
|
|
$('input[name="flag"]').each(function() {
|
|
if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
|
|
$(this).prop('disabled', true);
|
|
$(this).prop('checked', false);
|
|
}
|
|
});
|
|
}
|
|
|
|
$('input#flag-0').click(function() {
|
|
if( $('input[id="flag-0"]:checked').length || $(".superlib:checked").length ){
|
|
$('input[name="flag"]').each(function() {
|
|
if($(this).attr('id') != "flag-0" && !$(this).hasClass('superlib') ){
|
|
$(this).prop('disabled', true);
|
|
$(this).prop('checked', false);
|
|
}
|
|
});
|
|
}
|
|
else {
|
|
$('input[name="flag"]').each(function() {
|
|
$(this).prop('disabled', false);
|
|
});
|
|
}
|
|
});
|
|
|
|
|
|
$(".toggleall_off, .toggleall_on").on('click', function(e) {
|
|
e.preventDefault();
|
|
if( $(this).hasClass("toggleall_on")){
|
|
$(".children,.togglechildren_off").show();
|
|
$(".togglechildren_on").hide();
|
|
} else {
|
|
$(".children,.togglechildren_off").hide();
|
|
$(".togglechildren_on").show();
|
|
}
|
|
});
|
|
|
|
$(".togglechildren_off, .togglechildren_on").on('click', function(e) {
|
|
e.preventDefault();
|
|
var bit = $(this).data("bit");
|
|
$("#flag-" + bit + "-children").toggle();
|
|
$(".toggle-" + bit).toggle();
|
|
});
|
|
|
|
$(".togglechildren_off, .togglechildren_on").hover( function(){
|
|
$(this).parent().addClass("permission-highlight");
|
|
}, function(){
|
|
$(this).parent().removeClass("permission-highlight");
|
|
});
|
|
|
|
$(".flag").on("change",function(e){
|
|
e.preventDefault();
|
|
if( $(this).hasClass("child") ){
|
|
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") ){
|
|
$("#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);
|
|
}
|
|
}
|
|
});
|
|
|
|
});
|
|
</script>
|
|
[% END %]
|
|
|
|
[% INCLUDE 'intranet-bottom.inc' %]
|