diff --git a/build/viewer/view/group/permission.twig b/build/viewer/view/group/permission.twig index 6031e7e..4d2d7dd 100755 --- a/build/viewer/view/group/permission.twig +++ b/build/viewer/view/group/permission.twig @@ -24,12 +24,15 @@ - {% for user_cluster in f_userclusters(machine_cluster.id_machine_cluster,permission.id_permission) %} - - {{ user_cluster.name }} - - - {% endfor %} + + {% for user_cluster in f_userclusters(machine_cluster.id_machine_cluster,permission.id_permission) %} + + {{ user_cluster.name }} + + + {% endfor %} + + diff --git a/public_html/view/js/groups.js b/public_html/view/js/groups.js index 95f835d..9f5305f 100755 --- a/public_html/view/js/groups.js +++ b/public_html/view/js/groups.js @@ -177,7 +177,7 @@ if( section.view.element != null ){ /* (1) Get the group id/type */ - if( !/^(u|m)(\d+)$/.test(e.target.parentNode.parentNode.id) ) + if( !/^(u|m)(\d+)$/.test(e.target.getData('cluster')) ) return; var cluster_id = parseInt(RegExp.$2); @@ -1056,45 +1056,162 @@ if( section.permissions.element != null && !section.permissions.member_view ){ var i; /* (3) On gere la "suppression" d'une permission */ - for( i = 0 ; i < section.permissions.group.rem.length ; i++ ){ - - section.permissions.group.rem[i].addEventListener('click', function(e){ - // {1} On rédige la requête // - var request = { - path: 'clusterDefault/remPermission', - id_target: e.target.getData('target'), - id_source: e.target.getData('source'), - id_action: e.target.getData('permission') - }; + section.permissions.group.remfunc = function(e){ + // {1} On rédige la requête // + var request = { + path: 'clusterDefault/remPermission', + id_target: e.target.getData('target'), + id_source: e.target.getData('source'), + id_action: e.target.getData('permission') + }; - // {2} On envoie la requête // - api.send(request, function(response){ + // {2} On envoie la requête // + api.send(request, function(response){ + + // {3} Si erreur, on ne fait rien // + if( response.error != 0 ) + return false; + + + // {4} Si tout s'est bien passé // + e.target.parentNode.parentNode.removeChild( e.target.parentNode ); + }); + + }; + + + + for( i = 0 ; i < section.permissions.group.rem.length ; i++ ) + section.permissions.group.rem[i].addEventListener('click', section.permissions.group.remfunc, false); - // {3} Si erreur, on ne fait rien // - if( response.error != 0 ) - return false; - // {4} Si tout s'est bien passé // - e.target.parentNode.parentNode.removeChild( e.target.parentNode ); - }); - }, false); - } /* (4) On gere la "modification" des membres d'une permission d'un groupe */ for( i = 0 ; i < section.permissions.group.add.length ; i++ ){ - section.permissions.group.add[i].addEventListener('click', function(e){ - pageManager.vars = [ 'permissions', 'm'+e.target.getData('target'), 'a'+e.target.getData('permission') ]; - pageManager.refresh(); + section.permissions.group.add[i].addEventListener('mouseup', function(e){ + + /* (1) Check if already opened */ + var opened = e.target.innerHTML != '+'; + + /* (2) Hide all dropdowns */ + for( j = 0 ; j < section.permissions.group.add.length ; j++ ) + section.permissions.group.add[j].innerHTML = '+'; + + /* (3) Try to show dropdown if not already */ + if( !opened ){ + + /* (1) Get the group id/permission */ + if( !/^\d+$/.test(e.target.getData('target')) || !/^\d+$/.test(e.target.getData('permission')) ) + return; + + var cluster_id = parseInt(e.target.getData('target')); + var permission_id = parseInt(e.target.getData('permission')); + + /* (2) Get already members ids */ + var brothers = e.target.parentNode.children[1].children; + var already = []; // will contain already ids + + + for( j = 0 ; j < brothers.length ; j++ ) + already += parseInt( brothers[j].children[0].getData('source') ); + + /* (3) Call list of user_cluster members */ + api.send({path: 'clusterDefault/getAll', class: 0}, function(response){ + + // Manage error + if( response.error != 0 ){ + console.warn('error loading list of members'); + return; + } + + + // remove already authed + var members = response.clusters; + + + /* (4) Build dropdown content without already members */ + dropdown = "