Gestion du choix du groupe par défaut sur la page 'groups/filter' si aucun paramètre n'est dans l'URL
This commit is contained in:
parent
1cbd0d58db
commit
c430270150
|
@ -0,0 +1,85 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace manager\view\group;
|
||||||
|
use \manager\View;
|
||||||
|
use \manager\ModuleRequest;
|
||||||
|
use \manager\ManagerError;
|
||||||
|
use \manager\Authentification;
|
||||||
|
use \manager\repo\cluster as clusterRepo;
|
||||||
|
|
||||||
|
class groupChoice{
|
||||||
|
|
||||||
|
public static function template($type=null){
|
||||||
|
|
||||||
|
switch($type){
|
||||||
|
case 'clusterlist': return "
|
||||||
|
<option value='@id_cluster'>@name (@type)</option>";
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
default: return "
|
||||||
|
<form class='neutral' id='choose-cluster'>
|
||||||
|
<select data-name='cluster'>
|
||||||
|
@clusters
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<button id='choose-cluster'>Modifier la composition</button>
|
||||||
|
</form>";
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function view($params){
|
||||||
|
/* [0] Initialisation des variables (vues)
|
||||||
|
=========================================================*/
|
||||||
|
$view = '';
|
||||||
|
$cluster_view = '';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* [1] On récupére tous les groupes
|
||||||
|
=========================================================*/
|
||||||
|
/* (1) On récupère les groupe */
|
||||||
|
$getClustersRequest = new ModuleRequest('clusterDefault/getAll');
|
||||||
|
$getClustersResponse = $getClustersRequest->dispatch();
|
||||||
|
|
||||||
|
/* (2) Si on ne le trouve pas, on retourne une erreur */
|
||||||
|
if( $getClustersResponse->error != ManagerError::Success )
|
||||||
|
return View::$htmlError;
|
||||||
|
|
||||||
|
/* (3) On récupère les données du groupe */
|
||||||
|
$CLUSTERLIST = $getClustersResponse->get('clusters');
|
||||||
|
|
||||||
|
/* (4) On ajoute le type de groupe textuel */
|
||||||
|
foreach($CLUSTERLIST as $c=>$cluster)
|
||||||
|
$CLUSTERLIST[$c]['type'] = ($cluster['class']==clusterRepo::USER_CLASS) ? 'utilisateurs' : 'machines';
|
||||||
|
|
||||||
|
|
||||||
|
/* [2] On construit la vue des groupes
|
||||||
|
=========================================================*/
|
||||||
|
$cluster_view = View::replaceMultiple(
|
||||||
|
self::template('clusterlist'),
|
||||||
|
$CLUSTERLIST
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return View::replaceSingle(
|
||||||
|
self::template(), [
|
||||||
|
'clusters' => $cluster_view
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
|
@ -173,13 +173,21 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
echo "<section data-sublink='filter'>";
|
echo "<section data-sublink='filter'>";
|
||||||
|
|
||||||
|
/* (1) Si on a un ID_CLUSTER, on affiche la composition
|
||||||
|
---------------------------------------------------------*/
|
||||||
if( isset($post[1]) && is_numeric($post[1]) ){
|
if( isset($post[1]) && is_numeric($post[1]) ){
|
||||||
|
|
||||||
$userForGroup = new View('group.membersChoice', [
|
$membersChoice = new View('group.membersChoice', [
|
||||||
'id_cluster' => $post[1]
|
'id_cluster' => $post[1]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$userForGroup->view();
|
$membersChoice->view();
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$groupChoice = new View('group.groupChoice', []);
|
||||||
|
|
||||||
|
$groupChoice->view();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,22 +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"]')},
|
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"]')},filter:{text:'#CONTAINER > section[data-sublink="filter"] ',element:document.querySelector('#CONTAINER > section[data-sublink="filter"]')},permissions:{text:'#CONTAINER > section[data-sublink="permissions"] ',element:document.querySelector('#CONTAINER > section[data-sublink="permissions"]')}};
|
edit:{text:'#CONTAINER > section[data-sublink="edit"] ',element:document.querySelector('#CONTAINER > section[data-sublink="edit"]')},filter:{text:'#CONTAINER > section[data-sublink="filter"] ',element:document.querySelector('#CONTAINER > section[data-sublink="filter"]'),chooser:{text:'#CONTAINER > section[data-sublink="filter"] form#choose-cluster ',element:document.querySelector('#CONTAINER > section[data-sublink="filter"] 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+
|
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(b){if(0==b.ModuleError){for(var a=[],c=0;c<b.clusters.length;c++)a.push(b.clusters[c].id_cluster);b=document.querySelectorAll(section.view.text+"> article.inline-box[id]");for(c=0;c<b.length;c++)-1<a.indexOf(b[c].id)?b[c].remClass("hidden"):b[c].addClass("hidden")}})},!1);for(var i=0;i<section.view.link.edit.length;i++)section.view.link.edit[i].addEventListener("click",
|
".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 b=a.target.parentNode.parentNode.parentNode.children[0].value,
|
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==b?"userDefault/unlink":"machineDefault/unlink";d.id_cluster=a.target.getData("cluster");0==b?d.id_user=a.target.getData("member"):d.id_machine=a.target.getData("member");api.send(d,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("filter");document.location=
|
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("filter");document.location=
|
||||||
""},!1)}
|
""},!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(b){0==b.ModuleError&&(console.log("Groupe cree!"),pageManager.vars[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!"),pageManager.vars[1]=
|
||||||
b.id_cluster,navSubMenu("view"),document.location="",section.create.input.submit.anim("active",1500))})},!1));
|
a.id_cluster,navSubMenu("view"),document.location="",section.create.input.submit.anim("active",1500))})},!1));
|
||||||
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+
|
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"),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")};
|
".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=
|
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 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();""!=
|
(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&&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)}
|
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="",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"),
|
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"),
|
||||||
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=[],
|
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();
|
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 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,
|
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,
|
||||||
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)}
|
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.filter.element&&(section.filter.deflater=new FormDeflater(section.filter.element,["input"],["data-name"]),section.filter.baseData=section.filter.deflater.deflate().members,section.filter["class"]=document.querySelector("#filter-member-class").value,section.filter.idcluster=document.querySelector("#filter-member-idcluster").value,section.filter.element.addEventListener("click",function(a){var b=[];a=[];var d=section.filter.deflater.deflate().members;d instanceof Array||(d=[d]);for(var c=
|
null!=section.filter.element&&null!=section.filter.chooser.element&&(section.filter.chooser.deflater=new FormDeflater(section.filter.chooser.element,["select"],["data-name"]),section.filter.chooser.submit=document.querySelector(section.filter.chooser.text+"#choose-cluster"),section.filter.chooser.submit.addEventListener("click",function(a){a.preventDefault();a=section.filter.chooser.deflater.deflate().cluster;isNaN(a)||(pageManager.vars[1]=a,pageManager.refresh(),document.location="")},!1));
|
||||||
0;c<d.length;c++)-1==section.filter.baseData.indexOf(d[c])&&b.push(d[c]);for(c=0;c<section.filter.baseData.length;c++)-1==d.indexOf(section.filter.baseData[c])&&a.push(section.filter.baseData[c]);for(c=0;c<b.length;c++){var e={};e.path=0==section.filter["class"]?"userDefault/link":"machineDefault/link";e.id_cluster=section.filter.idcluster;0==section.filter["class"]?e.id_user=b[c]:e.id_machine=b[c];api.send(e,function(a){0!=a.ModuleError&&console.error("Erreur d'ajout de membre")})}for(c=0;c<a.length;c++)b=
|
null!=section.filter.element&&null==section.filter.chooser.element&&(section.filter.deflater=new FormDeflater(section.filter.element,["input"],["data-name"]),section.filter.baseData=section.filter.deflater.deflate().members,section.filter["class"]=document.querySelector("#filter-member-class").value,section.filter.idcluster=document.querySelector("#filter-member-idcluster").value,section.filter.element.addEventListener("click",function(a){var c=[];a=[];var d=section.filter.deflater.deflate().members;
|
||||||
{},b.path=0==section.filter["class"]?"userDefault/unlink":"machineDefault/unlink",b.id_cluster=section.filter.idcluster,0==section.filter["class"]?b.id_user=a[c]:b.id_machine=a[c],api.send(b,function(a){0!=a.ModuleError&&console.error("Erreur d'ajout de membre")});section.filter.baseData=d},!1));
|
d instanceof Array||(d=[d]);for(var b=0;b<d.length;b++)-1==section.filter.baseData.indexOf(d[b])&&c.push(d[b]);for(b=0;b<section.filter.baseData.length;b++)-1==d.indexOf(section.filter.baseData[b])&&a.push(section.filter.baseData[b]);for(b=0;b<c.length;b++){var e={};e.path=0==section.filter["class"]?"userDefault/link":"machineDefault/link";e.id_cluster=section.filter.idcluster;0==section.filter["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.filter["class"]?"userDefault/unlink":"machineDefault/unlink",c.id_cluster=section.filter.idcluster,0==section.filter["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.filter.baseData=d},!1));
|
||||||
|
|
|
@ -23,7 +23,12 @@ var section = {
|
||||||
|
|
||||||
filter: {
|
filter: {
|
||||||
text: '#CONTAINER > section[data-sublink="filter"] ',
|
text: '#CONTAINER > section[data-sublink="filter"] ',
|
||||||
element: document.querySelector('#CONTAINER > section[data-sublink="filter"]')
|
element: document.querySelector('#CONTAINER > section[data-sublink="filter"]'),
|
||||||
|
|
||||||
|
chooser: {
|
||||||
|
text: '#CONTAINER > section[data-sublink="filter"] form#choose-cluster ',
|
||||||
|
element: document.querySelector('#CONTAINER > section[data-sublink="filter"] form#choose-cluster')
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
permissions: {
|
permissions: {
|
||||||
|
@ -613,10 +618,68 @@ if( section.edit.element != null ){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* GESTION DU CHOIX DU GROUPE AUQUEL MODIFIER LA COMPOSITION DES MEMBRES
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
if( section.filter.element != null && section.filter.chooser.element != null ){
|
||||||
|
|
||||||
|
/* [1] Initialisation et gestion statique
|
||||||
|
=========================================================*/
|
||||||
|
/* (1) On initialise le deflater */
|
||||||
|
section.filter.chooser.deflater = new FormDeflater(
|
||||||
|
section.filter.chooser.element,
|
||||||
|
['select'],
|
||||||
|
['data-name']
|
||||||
|
);
|
||||||
|
|
||||||
|
/* (2) On récupère le bouton */
|
||||||
|
section.filter.chooser.submit = document.querySelector(section.filter.chooser.text+'#choose-cluster');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* [2] Gestion de l'évènement
|
||||||
|
=========================================================*/
|
||||||
|
section.filter.chooser.submit.addEventListener('click', function(e){
|
||||||
|
|
||||||
|
/* (0) On annule l'action par défaut (PHP) */
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
/* (1) On récupère les données */
|
||||||
|
var data = section.filter.chooser.deflater.deflate()['cluster'];
|
||||||
|
|
||||||
|
// Vérification du type
|
||||||
|
if( isNaN(data) )
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* (2) Redirection */
|
||||||
|
pageManager.vars[1] = data;
|
||||||
|
pageManager.refresh();
|
||||||
|
document.location = '';
|
||||||
|
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* GESTION DE LA MODIFICATION DES MEMBRES
|
/* GESTION DE LA MODIFICATION DES MEMBRES
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if( section.filter.element != null ){
|
if( section.filter.element != null && section.filter.chooser.element == null ){
|
||||||
|
|
||||||
/* (1) On initialise le Deflater() */
|
/* (1) On initialise le Deflater() */
|
||||||
section.filter.deflater = new FormDeflater(
|
section.filter.deflater = new FormDeflater(
|
||||||
|
|
Loading…
Reference in New Issue