mirror of
https://github.com/kakwa/ldapcherry
synced 2025-07-03 11:57:41 +02:00
adding js to better handle parent/sub roles
now js functions automatically enables parent roles of a selected roles, and disables sub roles unselected role
This commit is contained in:
parent
a62c5a64ac
commit
5ddaa4c44f
2 changed files with 40 additions and 16 deletions
|
@ -1,3 +1,22 @@
|
|||
<script type="text/javascript">
|
||||
var roles = ${graph_js};
|
||||
function enableParentRoles(roleid){
|
||||
var parentRoles = roles[roleid]['parent_roles'];
|
||||
var len = parentRoles.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
var role = parentRoles[i];
|
||||
$('input[name=' + role +']').bootstrapSwitch('state', true, true);
|
||||
}
|
||||
}
|
||||
function disableSubRoles(roleid){
|
||||
var parentRoles = roles[roleid]['sub_roles'];
|
||||
var len = parentRoles.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
var role = parentRoles[i];
|
||||
$('input[name=' + role +']').bootstrapSwitch('state', false, true);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<table id="RecordTable" class="table table-hover table-condensed tablesorter">
|
||||
<thead>
|
||||
<tr>
|
||||
|
@ -35,11 +54,21 @@
|
|||
${parents}
|
||||
</td>
|
||||
<td>
|
||||
<input data-on-color="success" data-off-color="danger" data-on-text="Enabled" data-off-text="Disabled" data-handle-width="75" type="checkbox" name="${role}" data-size="mini">
|
||||
<script>$("[name='${role}']").bootstrapSwitch();</script>
|
||||
<input data-on-color="success" data-off-color="danger" data-on-text="Enabled"
|
||||
data-off-text="Disabled" data-handle-width="75" type="checkbox"
|
||||
name="${role}" data-size="mini" id="${role}" >
|
||||
<script>$("[name='${role}']").bootstrapSwitch();
|
||||
$('input[name="${role}"]').on('switchChange.bootstrapSwitch', function(event, state) {
|
||||
if (state) {
|
||||
enableParentRoles('${role}');
|
||||
}
|
||||
else {
|
||||
disableSubRoles('${role}');
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
% endfor
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue