Avancement sur groups.js/view pour la gestion de la page 'groups/view'

This commit is contained in:
xdrm-brackets 2016-07-20 17:33:38 +02:00
parent e0bfe89cc6
commit 6b7bb03b07
6 changed files with 52 additions and 48 deletions

View File

@ -124,8 +124,7 @@
$link_user = new Repo('user_cluster/unlink', [
$_SESSION['WAREHOUSE']['id'],
$id_cluster,
$id_user,
clusterRepo::USER_CLASS
$id_user
]);
/* (1) On retourne l'erreur du repo */

View File

@ -14,26 +14,25 @@
case 'machine': return "
<span>
@name
<span class='rem-member' data-member='@id_machine' data-cluster='@id_machine_cluster'></span>
<span class='rem-member' data-member='@id_machine' data-cluster='@id_cluster'></span>
</span>";
break;
case 'user': return "
<span>
@username
<span class='rem-member' data-member='@id_user' data-cluster='@id_user_cluster'></span>
<span class='rem-member' data-member='@id_user' data-cluster='@id_cluster'></span>
</span>";
break;
case 'machine_cluster': return "
<article class='inline-box' id='@id_machine_cluster'>
<input type='hidden' value='@class'>
<article class='inline-box' id='@id_cluster'>
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name <span>#@name</span></span>
<span class='link_remove' data-cluster='@id_machine_cluster'>@icon_remove</span>
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name</span>
<span class='link_remove' data-cluster='@id_cluster'>@icon_remove</span>
<span class='link_edit' data-cluster='@id_machine_cluster'>@icon_edit</span>
<span class='link_edit' data-cluster='@id_cluster'>@icon_edit</span>
<span class='code'>
@icon_type
@ -43,7 +42,7 @@
<span class='groups'>
@icon_group
@machines
<span class='add-member' data-cluster='@id_machine_cluster'>+</span>
<span class='add-member' data-cluster='@id_cluster'>+</span>
</span>
</article>";
@ -52,13 +51,12 @@
case 'user_cluster': return "
<article class='inline-box' id='@id_user_cluster'>
<input type='hidden' value='@class'>
<article class='inline-box' id='@id_cluster'>
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name <span>#@name</span></span>
<span class='link_remove' data-cluster='@id_user_cluster'>@icon_remove</span>
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name</span>
<span class='link_remove' data-cluster='@id_cluster'>@icon_remove</span>
<span class='link_edit' data-cluster='@id_user_cluster'>@icon_edit</span>
<span class='link_edit' data-cluster='@id_cluster'>@icon_edit</span>
<span class='code'>
@icon_type
@ -68,7 +66,7 @@
<span class='groups'>
@icon_group
@users
<span class='add-member' data-cluster='@id_user_cluster'>+</span>
<span class='add-member' data-cluster='@id_cluster'>+</span>
</span>
</article>";
@ -133,11 +131,12 @@
$USERCLUSTERS[$u]['users'] = View::replaceMultiple(
self::template('user'),
$members,
[ 'id_cluster' => $cluster['id_user_cluster'] ]
[ 'id_cluster' => 'u'.$cluster['id_user_cluster'] ]
);
/* (4) On ajoute les attributs utiles */
$USERCLUSTERS[$u]['members'] = (count($members)<2) ? count($members).' utilisateur' : count($members).' utilisateurs';
$USERCLUSTERS[$u]['id_cluster'] = 'u'.$cluster['id_user_cluster'];
$USERCLUSTERS[$u]['members'] = (count($members)<2) ? count($members).' utilisateur' : count($members).' utilisateurs';
$USERCLUSTERS[$u]['icon_type'] = file_get_contents(__ROOT__.'/src/static/menu-side/users.svg');
}
@ -173,11 +172,12 @@
$MACHINECLUSTERS[$u]['machines'] = View::replaceMultiple(
self::template('machine'),
$members,
[ 'id_cluster' => $cluster['id_machine_cluster'] ]
[ 'id_cluster' => 'm'.$cluster['id_machine_cluster'] ]
);
/* (4) On ajoute les attributs utiles */
$MACHINECLUSTERS[$u]['members'] = (count($members)<2) ? count($members).' machine' : count($members).' machines';
$MACHINECLUSTERS[$u]['id_cluster'] = 'm'.$cluster['id_machine_cluster'];
$MACHINECLUSTERS[$u]['members'] = (count($members)<2) ? count($members).' machine' : count($members).' machines';
$MACHINECLUSTERS[$u]['icon_type'] = file_get_contents(__ROOT__.'/src/static/menu-side/machines.svg');
}

View File

@ -21,7 +21,7 @@
case 'machine_cluster': return "
<article class='inline-box' id='@id_machine_cluster'>
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name <span>#@name</span></span>
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name</span>
<span class='link_remove' data-cluster='@id_machine_cluster'>@icon_remove</span>
<span class='code'>

View File

@ -21,7 +21,7 @@
case 'user_cluster': return "
<article class='inline-box' id='@id_user_cluster'>
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name <span>#@name</span></span>
<span class='title' style='color: ".$_SESSION['WAREHOUSE']['theme']."'>@name</span>
<span class='link_remove' data-cluster='@id_user_cluster'>@icon_remove</span>
<span class='code'>

22
view/js/groups-min.js vendored
View File

@ -1,24 +1,24 @@
var section={view:{text:'#CONTAINER > section[data-sublink="view"] ',element:document.querySelector('#CONTAINER > section[data-sublink="view"]'),searchbar:document.querySelector('#CONTAINER > section[data-sublink="view"] > .searchbar')},create:{text:'#CONTAINER > section[data-sublink="create"] ',element:document.querySelector('#CONTAINER > section[data-sublink="create"]')},remove:{text:'#CONTAINER > section[data-sublink="remove"] ',element:document.querySelector('#CONTAINER > section[data-sublink="remove"]')},
edit:{text:'#CONTAINER > section[data-sublink="edit"] ',element:document.querySelector('#CONTAINER > section[data-sublink="edit"]')},members:{text:'#CONTAINER > section[data-sublink="members"] ',element:document.querySelector('#CONTAINER > section[data-sublink="members"]'),chooser:{text:'#CONTAINER > section[data-sublink="members"] form#choose-cluster ',element:document.querySelector('#CONTAINER > section[data-sublink="members"] form#choose-cluster')}},permissions:{text:'#CONTAINER > section[data-sublink="permissions"] ',
element:document.querySelector('#CONTAINER > section[data-sublink="permissions"]')}};
if(null!=section.view.element){1<pageManager.vars.length&&!isNaN(pageManager.vars[1])&&(document.location="#"+pageManager.vars[1],document.getElementById(pageManager.vars[1]).addClass("selected"));section.view.link={edit:document.querySelectorAll(section.view.text+".link_edit[data-cluster]"),remove:document.querySelectorAll(section.view.text+".link_remove[data-cluster]")};section.view.group={rem:document.querySelectorAll(section.view.text+".rem-member[data-cluster][data-member]"),add:document.querySelectorAll(section.view.text+
".add-member[data-cluster]")};section.view.searchbar.addEventListener("keyup",function(a){api.send({path:"clusterDefault/search",keywords:section.view.searchbar.value},function(a){if(0==a.ModuleError){for(var d=[],b=0;b<a.clusters.length;b++)d.push(a.clusters[b].id_cluster);a=document.querySelectorAll(section.view.text+"> article.inline-box[id]");for(b=0;b<a.length;b++)-1<d.indexOf(a[b].id)?a[b].remClass("hidden"):a[b].addClass("hidden")}})},!1);for(var i=0;i<section.view.link.edit.length;i++)section.view.link.edit[i].addEventListener("click",
function(a){pageManager.vars[1]=a.target.getData("cluster");autofill_edit(pageManager.vars[1]);navSubMenu("edit")},!1);for(i=0;i<section.view.link.remove.length;i++)section.view.link.remove[i].addEventListener("click",function(a){pageManager.vars[1]=a.target.getData("cluster");autofill_remove(pageManager.vars[1]);navSubMenu("remove")},!1);for(i=0;i<section.view.group.rem.length;i++)section.view.group.rem[i].addEventListener("click",function(a){var c=a.target.parentNode.parentNode.parentNode.children[0].value,
d={};d.path=0==c?"userDefault/unlink":"machineDefault/unlink";d.id_cluster=a.target.getData("cluster");0==c?d.id_user=a.target.getData("member"):d.id_machine=a.target.getData("member");api.send(d,function(c){if(0!=c.ModuleError)return!1;a.target.parentNode.parentNode.removeChild(a.target.parentNode)})},!1);for(i=0;i<section.view.group.add.length;i++)section.view.group.add[i].addEventListener("click",function(a){pageManager.vars[1]=a.target.getData("cluster");navSubMenu("members");document.location=
if(null!=section.view.element){1<pageManager.vars.length&&/^[um]\d+$/.test(pageManager.vars[1])&&(document.location="#"+pageManager.vars[1],document.getElementById(pageManager.vars[1]).addClass("selected"));section.view.link={edit:document.querySelectorAll(section.view.text+".link_edit[data-cluster]"),remove:document.querySelectorAll(section.view.text+".link_remove[data-cluster]")};section.view.group={rem:document.querySelectorAll(section.view.text+".rem-member[data-cluster][data-member]"),add:document.querySelectorAll(section.view.text+
".add-member[data-cluster]")};section.view.searchbar.addEventListener("keyup",function(a){api.send({path:"clusterDefault/search",keywords:section.view.searchbar.value},function(a){if(0==a.ModuleError){for(var d=[],c=0;c<a.clusters.length;c++)d.push(a.clusters[c].id_cluster);a=document.querySelectorAll(section.view.text+"> article.inline-box[id]");for(c=0;c<a.length;c++)-1<d.indexOf(a[c].id)?a[c].remClass("hidden"):a[c].addClass("hidden")}})},!1);var i;for(i=0;i<section.view.link.edit.length;i++)section.view.link.edit[i].addEventListener("click",
function(a){pageManager.vars[1]=a.target.getData("cluster");autofill_edit(pageManager.vars[1]);navSubMenu("edit")},!1);for(i=0;i<section.view.link.remove.length;i++)section.view.link.remove[i].addEventListener("click",function(a){pageManager.vars[1]=a.target.getData("cluster");autofill_remove(pageManager.vars[1]);navSubMenu("remove")},!1);for(i=0;i<section.view.group.rem.length;i++)section.view.group.rem[i].addEventListener("click",function(a){var b=a.target.getData("cluster")[0],d=a.target.getData("cluster").slice(1);
console.log(a.target);var c={};c.path="u"==b?"userDefault/unlink":"machineDefault/unlink";c.id_cluster=d;"u"==b?c.id_user=a.target.getData("member"):c.id_machine=a.target.getData("member");api.send(c,function(b){if(0!=b.ModuleError)return!1;a.target.parentNode.parentNode.removeChild(a.target.parentNode)})},!1);for(i=0;i<section.view.group.add.length;i++)section.view.group.add[i].addEventListener("click",function(a){pageManager.vars[1]=a.target.getData("cluster");navSubMenu("members");document.location=
""},!1)}
null!=section.create.element&&(section.create.input={name:document.querySelector(section.create.text+"#create_name"),"class":document.querySelector(section.create.text+"#create_class"),submit:document.querySelector(section.create.text+"#create_submit")},section.create.input.submit.addEventListener("click",function(a){a.preventDefault();api.send({path:"clusterDefault/create",name:section.create.input.name.value,"class":section.create.input["class"].value},function(a){0==a.ModuleError&&(console.log("Groupe cree!"),section.create.input.submit.anim("active",
1500))})},!1));
if(null!=section.remove.element){var autofill_remove=function(){var a="",c="",d=!0;null==found_remove[searchindex_remove]?searchindex_remove=section.remove.input.search.num.innerHTML=0:(a=found_remove[searchindex_remove].id_cluster,c=found_remove[searchindex_remove].name,d=!1,section.remove.input.search.num.innerHTML=searchindex_remove+1);section.remove.input.search.id.value=a;section.remove.input.name.value=c;section.remove.input.submit.disabled=d};section.remove.input={search:{view:document.querySelector(section.remove.text+".remove_search_view"),
if(null!=section.remove.element){var autofill_remove=function(){var a="",b="",d=!0;null==found_remove[searchindex_remove]?searchindex_remove=section.remove.input.search.num.innerHTML=0:(a=found_remove[searchindex_remove].id_cluster,b=found_remove[searchindex_remove].name,d=!1,section.remove.input.search.num.innerHTML=searchindex_remove+1);section.remove.input.search.id.value=a;section.remove.input.name.value=b;section.remove.input.submit.disabled=d};section.remove.input={search:{view:document.querySelector(section.remove.text+".remove_search_view"),
num:document.querySelector(section.remove.text+".remove_search_num"),sum:document.querySelector(section.remove.text+".remove_search_sum"),keyword:document.querySelector(section.remove.text+"#remove_search_keyword"),id:document.querySelector(section.remove.text+"#remove_search_id"),submit:document.querySelector(section.remove.text+"#remove_search_submit")},name:document.querySelector(section.remove.text+"#remove_name"),submit:document.querySelector(section.remove.text+"#remove_submit")};var lastkeywords_remove=
"",found_remove=[],searchindex_remove=0;2<=pageManager.vars.length&&!isNaN(pageManager.vars[1])&&api.send({path:"clusterDefault/getById",id_cluster:pageManager.vars[1]},function(a){0==a.ModuleError&&(found_remove=[a.cluster],searchindex_remove=0,autofill_remove())});section.remove.input.search.submit.addEventListener("click",function(a){a.preventDefault();if(""!=section.remove.input.search.keyword.value)if(section.remove.input.search.keyword.value==lastkeywords_remove)searchindex_remove=(searchindex_remove+
1)%found_remove.length,autofill_remove();else{var c={path:"clusterDefault/search",keywords:section.remove.input.search.keyword.value};api.send(c,function(a){0==a.ModuleError&&(section.remove.input.search.submit.anim("active",1E3),searchindex_remove=0,found_remove=a.clusters,section.remove.input.search.sum.innerHTML=found_remove.length,autofill_remove());lastkeywords_remove=c.keywords})}},!1);section.remove.input.submit.addEventListener("click",function(a){a.preventDefault();""!=section.remove.input.search.id.value&&
1)%found_remove.length,autofill_remove();else{var b={path:"clusterDefault/search",keywords:section.remove.input.search.keyword.value};api.send(b,function(a){0==a.ModuleError&&(section.remove.input.search.submit.anim("active",1E3),searchindex_remove=0,found_remove=a.clusters,section.remove.input.search.sum.innerHTML=found_remove.length,autofill_remove());lastkeywords_remove=b.keywords})}},!1);section.remove.input.submit.addEventListener("click",function(a){a.preventDefault();""!=section.remove.input.search.id.value&&
api.send({path:"clusterDefault/delete",id_cluster:section.remove.input.search.id.value},function(a){0==a.ModuleError&&1==a.status?(console.log("Groupe supprimee!"),section.remove.input.submit.anim("active",1500),autofill_remove(null)):console.error("ModuleError::"+a.ModuleError)})},!1)}
if(null!=section.edit.element){var autofill_edit=function(){var a="",c="",d=!0;null==found_edit[searchindex_edit]?searchindex_edit=section.edit.input.search.num.innerHTML=0:(a=found_edit[searchindex_edit].id_cluster,c=found_edit[searchindex_edit].name,d=!1,section.edit.input.search.num.innerHTML=searchindex_edit+1);section.edit.input.search.id.value=a;section.edit.input.name.value=c;section.edit.input.submit.disabled=d};section.edit.input={search:{view:document.querySelector(section.edit.text+".edit_search_view"),
if(null!=section.edit.element){var autofill_edit=function(){var a="",b="",d=!0;null==found_edit[searchindex_edit]?searchindex_edit=section.edit.input.search.num.innerHTML=0:(a=found_edit[searchindex_edit].id_cluster,b=found_edit[searchindex_edit].name,d=!1,section.edit.input.search.num.innerHTML=searchindex_edit+1);section.edit.input.search.id.value=a;section.edit.input.name.value=b;section.edit.input.submit.disabled=d};section.edit.input={search:{view:document.querySelector(section.edit.text+".edit_search_view"),
num:document.querySelector(section.edit.text+".edit_search_num"),sum:document.querySelector(section.edit.text+".edit_search_sum"),keyword:document.querySelector(section.edit.text+"#edit_search_keyword"),id:document.querySelector(section.edit.text+"#edit_search_id"),submit:document.querySelector(section.edit.text+"#edit_search_submit")},name:document.querySelector(section.edit.text+"#edit_name"),submit:document.querySelector(section.edit.text+"#edit_submit")};var lastkeywords_edit="",found_edit=[],
searchindex_edit=0;2<=pageManager.vars.length&&!isNaN(pageManager.vars[1])&&api.send({path:"clusterDefault/getById",id_cluster:pageManager.vars[1]},function(a){0==a.ModuleError&&(found_edit=[a.cluster],searchindex_edit=0,autofill_edit())});section.edit.input.search.submit.addEventListener("click",function(a){a.preventDefault();if(""!=section.edit.input.search.keyword.value)if(section.edit.input.search.keyword.value==lastkeywords_edit)searchindex_edit=(searchindex_edit+1)%found_edit.length,autofill_edit();
else{var c={path:"clusterDefault/search",keywords:section.edit.input.search.keyword.value};api.send(c,function(a){0==a.ModuleError&&(section.edit.input.search.submit.anim("active",1E3),searchindex_edit=0,found_edit=a.clusters,section.edit.input.search.sum.innerHTML=found_edit.length,autofill_edit());lastkeywords_edit=c.keywords})}},!1);section.edit.input.submit.addEventListener("click",function(a){a.preventDefault();""!=section.edit.input.search.id.value&&api.send({path:"clusterDefault/edit",id_cluster:section.edit.input.search.id.value,
else{var b={path:"clusterDefault/search",keywords:section.edit.input.search.keyword.value};api.send(b,function(a){0==a.ModuleError&&(section.edit.input.search.submit.anim("active",1E3),searchindex_edit=0,found_edit=a.clusters,section.edit.input.search.sum.innerHTML=found_edit.length,autofill_edit());lastkeywords_edit=b.keywords})}},!1);section.edit.input.submit.addEventListener("click",function(a){a.preventDefault();""!=section.edit.input.search.id.value&&api.send({path:"clusterDefault/edit",id_cluster:section.edit.input.search.id.value,
name:section.edit.input.name.value},function(a){0==a.ModuleError&&1==a.status?(console.log("Groupe modifiee!"),section.edit.input.submit.anim("active",1500),autofill_edit(section.edit.input.search.id.value)):console.error("ModuleError::"+a.ModuleError)})},!1)}
null!=section.members.element&&null!=section.members.chooser.element&&(section.members.chooser.deflater=new FormDeflater(section.members.chooser.element,["select"],["data-name"]),section.members.chooser.submit=document.querySelector(section.members.chooser.text+"#choose-cluster"),section.members.chooser.submit.addEventListener("click",function(a){a.preventDefault();a=section.members.chooser.deflater.deflate().cluster;isNaN(a)||(pageManager.vars[1]=a,pageManager.refresh(),document.location="")},!1));
null!=section.members.element&&null==section.members.chooser.element&&(section.members.deflater=new FormDeflater(section.members.element,["input"],["data-name"]),section.members.baseData=section.members.deflater.deflate().members,section.members["class"]=document.querySelector("#members-member-class").value,section.members.idcluster=document.querySelector("#members-member-idcluster").value,section.members.element.addEventListener("click",function(a){var c=[];a=[];var d=section.members.deflater.deflate().members;
d instanceof Array||(d=[d]);for(var b=0;b<d.length;b++)-1==section.members.baseData.indexOf(d[b])&&c.push(d[b]);for(b=0;b<section.members.baseData.length;b++)-1==d.indexOf(section.members.baseData[b])&&a.push(section.members.baseData[b]);for(b=0;b<c.length;b++){var e={};e.path=0==section.members["class"]?"userDefault/link":"machineDefault/link";e.id_cluster=section.members.idcluster;0==section.members["class"]?e.id_user=c[b]:e.id_machine=c[b];api.send(e,function(a){0!=a.ModuleError&&console.error("Erreur d'ajout de membre")})}for(b=
0;b<a.length;b++)c={},c.path=0==section.members["class"]?"userDefault/unlink":"machineDefault/unlink",c.id_cluster=section.members.idcluster,0==section.members["class"]?c.id_user=a[b]:c.id_machine=a[b],api.send(c,function(a){0!=a.ModuleError&&console.error("Erreur d'ajout de membre")});section.members.baseData=d},!1));
null!=section.members.element&&null==section.members.chooser.element&&(section.members.deflater=new FormDeflater(section.members.element,["input"],["data-name"]),section.members.baseData=section.members.deflater.deflate().members,section.members["class"]=document.querySelector("#members-member-class").value,section.members.idcluster=document.querySelector("#members-member-idcluster").value,section.members.element.addEventListener("click",function(a){var b=[],d=[],c=section.members.deflater.deflate().members;
c instanceof Array||(c=[c]);for(a=0;a<c.length;a++)-1==section.members.baseData.indexOf(c[a])&&b.push(c[a]);for(a=0;a<section.members.baseData.length;a++)-1==c.indexOf(section.members.baseData[a])&&d.push(section.members.baseData[a]);for(a=0;a<b.length;a++){var e={};e.path=0==section.members["class"]?"userDefault/link":"machineDefault/link";e.id_cluster=section.members.idcluster;0==section.members["class"]?e.id_user=b[a]:e.id_machine=b[a];api.send(e,function(a){0!=a.ModuleError&&console.error("Erreur d'ajout de membre")})}for(a=
0;a<d.length;a++)b={},b.path=0==section.members["class"]?"userDefault/unlink":"machineDefault/unlink",b.id_cluster=section.members.idcluster,0==section.members["class"]?b.id_user=d[a]:b.id_machine=d[a],api.send(b,function(a){0!=a.ModuleError&&console.error("Erreur d'ajout de membre")});section.members.baseData=c},!1));

View File

@ -45,12 +45,12 @@ var section = {
if( section.view.element != null ){
/* (0) On gère le zoom sur un utilisateur via URL */
if( pageManager.vars.length > 1 && !isNaN(pageManager.vars[1]) ){
if( pageManager.vars.length > 1 && /^[um]\d+$/.test(pageManager.vars[1]) ){
document.location = '#'+pageManager.vars[1];
document.getElementById(pageManager.vars[1]).addClass('selected');
}
/* (1) On recupere tous les liens */
/* (1) On recupere tous les liens vers des sous-sections */
section.view.link = {
edit: document.querySelectorAll(section.view.text + '.link_edit[data-cluster]'),
remove: document.querySelectorAll(section.view.text + '.link_remove[data-cluster]')
@ -97,9 +97,11 @@ if( section.view.element != null ){
}, false);
var i;
/* (4) On gere la "redirection" vers la modification */
for( var i = 0 ; i < section.view.link.edit.length ; i++ ){
for( i = 0 ; i < section.view.link.edit.length ; i++ ){
section.view.link.edit[i].addEventListener('click', function(e){
pageManager.vars[1] = e.target.getData('cluster');
@ -110,7 +112,7 @@ if( section.view.element != null ){
}
/* (5) On gere la "redirection" vers la suppression */
for( var i = 0 ; i < section.view.link.remove.length ; i++ ){
for( i = 0 ; i < section.view.link.remove.length ; i++ ){
section.view.link.remove[i].addEventListener('click', function(e){
pageManager.vars[1] = e.target.getData('cluster');
@ -121,18 +123,20 @@ if( section.view.element != null ){
}
/* (6) On gere la "suppression" d'un groupe */
for( var i = 0 ; i < section.view.group.rem.length ; i++ ){
for( i = 0 ; i < section.view.group.rem.length ; i++ ){
section.view.group.rem[i].addEventListener('click', function(e){
var clusterClass = e.target.parentNode.parentNode.parentNode.children[0].value;
var prefix = e.target.getData('cluster')[0];
var cluster = e.target.getData('cluster').slice(1);
console.log(e.target);
// {1} On rédige la requête //
var request = {};
request.path = (clusterClass==0) ? 'userDefault/unlink' : 'machineDefault/unlink';
request.id_cluster = e.target.getData('cluster');
request.path = (prefix=='u') ? 'userDefault/unlink' : 'machineDefault/unlink';
request.id_cluster = cluster;
if( clusterClass == 0 ) request.id_user = e.target.getData('member');
else request.id_machine = e.target.getData('member');
if( prefix == 'u' ) request.id_user = e.target.getData('member');
else request.id_machine = e.target.getData('member');
// {2} On envoie la requête //
api.send(request, function(response){
@ -151,7 +155,7 @@ if( section.view.element != null ){
}
/* (7) On gere la "modification" des membres d'un groupe */
for( var i = 0 ; i < section.view.group.add.length ; i++ ){
for( i = 0 ; i < section.view.group.add.length ; i++ ){
section.view.group.add[i].addEventListener('click', function(e){
@ -701,6 +705,7 @@ if( section.members.element != null && section.members.chooser.element == null )
section.members.element.addEventListener('click', function(e){
/* (0) On récupère les données + initialise les variables */
var i;
var linked = [];
var unlinked = [];
@ -710,18 +715,18 @@ if( section.members.element != null && section.members.chooser.element == null )
data = [data];
/* (1) Si on a ajouté des liens */
for( var i = 0 ; i < data.length ; i++ )
for( i = 0 ; i < data.length ; i++ )
if( section.members.baseData.indexOf(data[i]) == -1 ) // Si pas dans les données initiales, on ajoute
linked.push( data[i] );
/* (2) Si on a supprimé des liens */
for( var i = 0 ; i < section.members.baseData.length ; i++ )
for( i = 0 ; i < section.members.baseData.length ; i++ )
if( data.indexOf(section.members.baseData[i]) == -1 ) // Si pas dans les données modifiées, on ajoute
unlinked.push( section.members.baseData[i] );
/* (3) Gestion de l'ajout de liens */
for( var i = 0 ; i < linked.length ; i++ ){
for( i = 0 ; i < linked.length ; i++ ){
// {1} On rédige la requête //
var linkReq = {};
linkReq.path = (section.members.class==0) ? 'userDefault/link' : 'machineDefault/link';
@ -740,7 +745,7 @@ if( section.members.element != null && section.members.chooser.element == null )
/* (4) Gestion de la suppression de liens */
for( var i = 0 ; i < unlinked.length ; i++ ){
for( i = 0 ; i < unlinked.length ; i++ ){
// {1} On rédige la requête //
var unlinkReq = {};
unlinkReq.path = (section.members.class==0) ? 'userDefault/unlink' : 'machineDefault/unlink';