Vue 'groups/membersChoice'
This commit is contained in:
parent
4e14db6565
commit
a7d7e2dece
|
@ -52,7 +52,6 @@
|
||||||
/* RENVOIE UN GROUPE EN FONCTION D'UN MOT CLE
|
/* RENVOIE UN GROUPE EN FONCTION D'UN MOT CLE
|
||||||
*
|
*
|
||||||
* @keywords<String> Element de recherche
|
* @keywords<String> Element de recherche
|
||||||
* @class<int> Type de groupe
|
|
||||||
*
|
*
|
||||||
* @return clusters<Array> Retourne la liste des groupes trouves
|
* @return clusters<Array> Retourne la liste des groupes trouves
|
||||||
*
|
*
|
||||||
|
@ -60,15 +59,22 @@
|
||||||
public static function search($params){
|
public static function search($params){
|
||||||
extract($params);
|
extract($params);
|
||||||
|
|
||||||
$repoMethod = ($class==0) ? 'user_cluster/search' : 'machine_cluster/search';
|
|
||||||
|
|
||||||
// On recupere les donnees des groupes utilisateurs
|
// On recupere les donnees des groupes utilisateurs
|
||||||
$cluster = new Repo($repoMethod, [
|
$userClusters = new Repo('user_cluster/search', [
|
||||||
$_SESSION['WAREHOUSE']['id'],
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
$keywords
|
$keywords
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return [ 'clusters' => $cluster->answer() ];
|
|
||||||
|
// On recupere les donnees des groupes machines
|
||||||
|
$machineClusters = new Repo('machine_cluster/search', [
|
||||||
|
$_SESSION['WAREHOUSE']['id'],
|
||||||
|
$keywords
|
||||||
|
]);
|
||||||
|
|
||||||
|
$merged = array_merge($userClusters->answer(), $machineClusters->answer());
|
||||||
|
|
||||||
|
return [ 'clusters' => $merged ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
/* [0] Initialisation
|
/* [0] Initialisation
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) On vérifie les paramètres */
|
/* (1) On vérifie les paramètres */
|
||||||
if( !isset($params['id_cluster']) && !is_number($params['id_cluster']) )
|
if( !isset($params['id_cluster']) || !is_numeric($params['id_cluster']) || !isset($params['class']) || !is_numeric($params['class']) )
|
||||||
return View::$htmlError;
|
return View::$htmlError;
|
||||||
|
|
||||||
/* (2) On initialise les vues */
|
/* (2) On initialise les vues */
|
||||||
|
@ -76,7 +76,8 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) On récupère le groupe */
|
/* (1) On récupère le groupe */
|
||||||
$checktypeRequest = new ModuleRequest('clusterDefault/getById', [
|
$checktypeRequest = new ModuleRequest('clusterDefault/getById', [
|
||||||
'id_cluster' => $params['id_cluster']
|
'id_cluster' => $params['id_cluster'],
|
||||||
|
'class' => $params['class']
|
||||||
]);
|
]);
|
||||||
$checktypeResponse = $checktypeRequest->dispatch();
|
$checktypeResponse = $checktypeRequest->dispatch();
|
||||||
|
|
||||||
|
@ -93,7 +94,8 @@
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
/* (1) On exécute la requête */
|
/* (1) On exécute la requête */
|
||||||
$getmembersRequest = new ModuleRequest('clusterDefault/getMembers', [
|
$getmembersRequest = new ModuleRequest('clusterDefault/getMembers', [
|
||||||
'id_cluster' => $params['id_cluster']
|
'id_cluster' => $params['id_cluster'],
|
||||||
|
'class' => $params['class']
|
||||||
]);
|
]);
|
||||||
$getmembersResponse = $getmembersRequest->dispatch();
|
$getmembersResponse = $getmembersRequest->dispatch();
|
||||||
|
|
||||||
|
@ -104,13 +106,13 @@
|
||||||
/* (3) On récupère la liste des UID uniquement */
|
/* (3) On récupère la liste des UID uniquement */
|
||||||
$members_id = [];
|
$members_id = [];
|
||||||
foreach($getmembersResponse->get('members') as $member)
|
foreach($getmembersResponse->get('members') as $member)
|
||||||
$members_id[] = $member['id_member'];
|
$members_id[] = ($params['class']==0) ? $member['id_user'] : $member['id_machine'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* [3] SI GROUPE D'UTILISATEURS -> On récupère les utilisateurs
|
/* [3] SI GROUPE D'UTILISATEURS -> On récupère les utilisateurs
|
||||||
=========================================================*/
|
=========================================================*/
|
||||||
if( $currentCluster['class'] == clusterRepo::USER_CLASS ){
|
if( $params['class'] == 0 ){
|
||||||
|
|
||||||
/* (1) On récupère les utilisateurs
|
/* (1) On récupère les utilisateurs
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
|
@ -160,8 +162,8 @@
|
||||||
/* (2) On gère l'affichage des machines
|
/* (2) On gère l'affichage des machines
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
/* (1) On gère l'état 'membre' ou non */
|
/* (1) On gère l'état 'membre' ou non */
|
||||||
foreach($MACHINELIST as $u=>$user)
|
foreach($MACHINELIST as $m=>$machine)
|
||||||
$MACHINELIST[$u]['already_in'] = in_array($user['id_machine'], $members_id) ? 'checked' : '';
|
$MACHINELIST[$m]['already_in'] = in_array($machine['id_machine'], $members_id) ? 'checked' : '';
|
||||||
|
|
||||||
/* (2) On génère la vue */
|
/* (2) On génère la vue */
|
||||||
$members_view = View::replaceMultiple(
|
$members_view = View::replaceMultiple(
|
||||||
|
@ -171,16 +173,14 @@
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$class = ($currentCluster['class'] == clusterRepo::USER_CLASS) ? 0 : 1;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return View::replaceSingle(
|
return View::replaceSingle(
|
||||||
self::template(), [
|
self::template(), [
|
||||||
'id_cluster' => $currentCluster['id_cluster'],
|
'id_cluster' => $params['id_cluster'],
|
||||||
'class' => $class,
|
'class' => $params['class'],
|
||||||
'name' => $currentCluster['name'],
|
'name' => $currentCluster['name'],
|
||||||
'clustertype' => ($class==0) ? 'utilisateurs' : 'machines',
|
'clustertype' => ($params['class']==0) ? 'utilisateurs' : 'machines',
|
||||||
'members' => $members_view
|
'members' => $members_view
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
|
@ -123,7 +123,8 @@
|
||||||
echo "<br><br><hr class='OR' data-label='PUIS' /><br><br>";
|
echo "<br><br><hr class='OR' data-label='PUIS' /><br><br>";
|
||||||
|
|
||||||
// Suppression de groupe
|
// Suppression de groupe
|
||||||
echo "<input id='remove_name' type='text' placeholder='Nom'><br>";
|
echo "<input id='remove_name' type='text' placeholder='Nom' disabled><br>";
|
||||||
|
echo "<input id='remove_class' type='text' placeholder='Type de groupe' disabled><br>";
|
||||||
echo "<button id='remove_submit' disabled>Supprimer</button>";
|
echo "<button id='remove_submit' disabled>Supprimer</button>";
|
||||||
echo "</form>";
|
echo "</form>";
|
||||||
|
|
||||||
|
@ -154,6 +155,7 @@
|
||||||
echo "<br><br><hr class='OR' data-label='PUIS' /><br><br>";
|
echo "<br><br><hr class='OR' data-label='PUIS' /><br><br>";
|
||||||
|
|
||||||
echo "<input id='edit_name' type='text' placeholder='Nom'><br>";
|
echo "<input id='edit_name' type='text' placeholder='Nom'><br>";
|
||||||
|
echo "<input id='edit_class' type='text' placeholder='Type de groupe' disabled><br>";
|
||||||
echo "<button id='edit_submit' disabled>Modifier</button>";
|
echo "<button id='edit_submit' disabled>Modifier</button>";
|
||||||
echo "</form>";
|
echo "</form>";
|
||||||
|
|
||||||
|
@ -176,10 +178,11 @@
|
||||||
|
|
||||||
/* (1) Si on a un ID_CLUSTER, on affiche la composition
|
/* (1) Si on a un ID_CLUSTER, on affiche la composition
|
||||||
---------------------------------------------------------*/
|
---------------------------------------------------------*/
|
||||||
if( isset($post[1]) && is_numeric($post[1]) ){
|
if( isset($post[1]) && preg_match('/^(u|m)(\d+)$/', $post[1], $m) ){
|
||||||
|
|
||||||
$membersChoice = new View('group.membersChoice', [
|
$membersChoice = new View('group.membersChoice', [
|
||||||
'id_cluster' => $post[1]
|
'id_cluster' => $m[2],
|
||||||
|
'class' => ($m[1]=='u') ? 0 : 1
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$membersChoice->view();
|
$membersChoice->view();
|
||||||
|
|
|
@ -3,16 +3,16 @@ edit:{text:'#CONTAINER > section[data-sublink="edit"] ',element:document.querySe
|
||||||
element:document.querySelector('#CONTAINER > section[data-sublink="permissions"]')}};
|
element:document.querySelector('#CONTAINER > section[data-sublink="permissions"]')}};
|
||||||
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+
|
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",
|
".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);
|
function(a){pageManager.vars[1]=a.target.getData("cluster");autofill_edit();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();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);
|
||||||
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=
|
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)}
|
||||||
""},!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!"),
|
||||||
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",
|
section.create.input.submit.anim("active",1500))})},!1));
|
||||||
1500))})},!1));
|
if(null!=section.remove.element){var autofill_remove=function(){var a={id_cluster:"","class":"",name:"",disable_input:!0};if(null==found_remove[searchindex_remove])searchindex_remove=section.remove.input.search.num.innerHTML=0;else{var b;found_remove[searchindex_remove].hasOwnProperty("id_user_cluster")?(a=found_remove[searchindex_remove].id_user_cluster,b=0):(a=found_remove[searchindex_remove].id_machine_cluster,b=1);a={id_cluster:a,"class":b,name:found_remove[searchindex_remove].name,disable_input:!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+".remove_search_view"),
|
section.remove.input.search.num.innerHTML=searchindex_remove+1}section.remove.input.search.id.value=a.id_cluster;section.remove.input.name.value=a.name;section.remove.input["class"].value=0==a["class"]?"utilisateur":"machine";console.log(a);section.remove.input.submit.disabled=a.disable_input};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+
|
||||||
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=
|
".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"),"class":document.querySelector(section.remove.text+"#remove_class"),submit:document.querySelector(section.remove.text+"#remove_submit")};var lastkeywords_remove="",found_remove=[],searchindex_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+
|
0;if(2<=pageManager.vars.length&&/^[um]\d+$/.test(pageManager.vars[1])){var prefix=pageManager.vars[1][0],cluster=pageManager.vars[1].slice(1),request={path:"clusterDefault/getById",id_cluster:cluster,"class":"u"==prefix?0:1};api.send(request,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==
|
||||||
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&&
|
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",
|
||||||
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)}
|
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="",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="",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=[],
|
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();
|
||||||
|
|
|
@ -105,7 +105,7 @@ if( section.view.element != null ){
|
||||||
|
|
||||||
section.view.link.edit[i].addEventListener('click', function(e){
|
section.view.link.edit[i].addEventListener('click', function(e){
|
||||||
pageManager.vars[1] = e.target.getData('cluster');
|
pageManager.vars[1] = e.target.getData('cluster');
|
||||||
autofill_edit(pageManager.vars[1]);
|
autofill_edit();
|
||||||
navSubMenu('edit');
|
navSubMenu('edit');
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ if( section.view.element != null ){
|
||||||
|
|
||||||
section.view.link.remove[i].addEventListener('click', function(e){
|
section.view.link.remove[i].addEventListener('click', function(e){
|
||||||
pageManager.vars[1] = e.target.getData('cluster');
|
pageManager.vars[1] = e.target.getData('cluster');
|
||||||
autofill_remove(pageManager.vars[1]);
|
autofill_remove();
|
||||||
navSubMenu('remove');
|
navSubMenu('remove');
|
||||||
}, false);
|
}, false);
|
||||||
|
|
||||||
|
@ -251,6 +251,7 @@ if( section.remove.element != null ){
|
||||||
},
|
},
|
||||||
|
|
||||||
name: document.querySelector(section.remove.text + '#remove_name'),
|
name: document.querySelector(section.remove.text + '#remove_name'),
|
||||||
|
class: document.querySelector(section.remove.text + '#remove_class'),
|
||||||
|
|
||||||
submit: document.querySelector(section.remove.text + '#remove_submit')
|
submit: document.querySelector(section.remove.text + '#remove_submit')
|
||||||
};
|
};
|
||||||
|
@ -267,6 +268,7 @@ if( section.remove.element != null ){
|
||||||
/* (0) Valeurs par défaut */
|
/* (0) Valeurs par défaut */
|
||||||
var cluster_data = {
|
var cluster_data = {
|
||||||
id_cluster: '',
|
id_cluster: '',
|
||||||
|
class: '',
|
||||||
name: '',
|
name: '',
|
||||||
disable_input: true
|
disable_input: true
|
||||||
};
|
};
|
||||||
|
@ -284,9 +286,22 @@ if( section.remove.element != null ){
|
||||||
// {2} Si au moins 1 résultat //
|
// {2} Si au moins 1 résultat //
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
|
var tmpIdCluster, clusterClass;
|
||||||
|
|
||||||
|
// Si groupe utilisateur
|
||||||
|
if( found_remove[searchindex_remove].hasOwnProperty('id_user_cluster') ){
|
||||||
|
tmpIdCluster = found_remove[searchindex_remove].id_user_cluster;
|
||||||
|
clusterClass = 0;
|
||||||
|
// Sinon groupe machine
|
||||||
|
}else{
|
||||||
|
tmpIdCluster = found_remove[searchindex_remove].id_machine_cluster;
|
||||||
|
clusterClass = 1;
|
||||||
|
}
|
||||||
|
|
||||||
// On recupere les données de la user selectionnee
|
// On recupere les données de la user selectionnee
|
||||||
cluster_data = {
|
cluster_data = {
|
||||||
id_cluster: found_remove[searchindex_remove]['id_cluster'],
|
id_cluster: tmpIdCluster,
|
||||||
|
class: clusterClass,
|
||||||
name: found_remove[searchindex_remove]['name'],
|
name: found_remove[searchindex_remove]['name'],
|
||||||
disable_input: false
|
disable_input: false
|
||||||
};
|
};
|
||||||
|
@ -303,6 +318,8 @@ if( section.remove.element != null ){
|
||||||
|
|
||||||
// Auto-remplissage du formulaire
|
// Auto-remplissage du formulaire
|
||||||
section.remove.input.name.value = cluster_data.name;
|
section.remove.input.name.value = cluster_data.name;
|
||||||
|
section.remove.input.class.value = cluster_data.class == 0 ? 'utilisateur' : 'machine';
|
||||||
|
console.log(cluster_data);
|
||||||
|
|
||||||
// On gere le caractere "inactif" du submit
|
// On gere le caractere "inactif" du submit
|
||||||
section.remove.input.submit.disabled = cluster_data.disable_input;
|
section.remove.input.submit.disabled = cluster_data.disable_input;
|
||||||
|
@ -311,10 +328,18 @@ if( section.remove.element != null ){
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gestion automatique au chargement de la page si ID_CLUSTER dans url "/users/remove/:id_cluster:"
|
// Gestion automatique au chargement de la page si ID_CLUSTER dans url "/users/remove/:id_cluster:"
|
||||||
if( pageManager.vars.length >= 2 && !isNaN(pageManager.vars[1]) ){
|
if( pageManager.vars.length >= 2 && /^[um]\d+$/.test(pageManager.vars[1]) ){
|
||||||
|
var prefix = pageManager.vars[1][0];
|
||||||
|
var cluster = pageManager.vars[1].slice(1);
|
||||||
|
|
||||||
|
var request = {
|
||||||
|
path: 'clusterDefault/getById',
|
||||||
|
id_cluster: cluster,
|
||||||
|
class: (prefix=='u') ? 0 : 1
|
||||||
|
};
|
||||||
|
|
||||||
// On récupère la user d'uid donné dans l'URL
|
// On récupère la user d'uid donné dans l'URL
|
||||||
api.send({path:'clusterDefault/getById', id_cluster:pageManager.vars[1]}, function(response){
|
api.send(request, function(response){
|
||||||
// Si aucune erreur et un résultat
|
// Si aucune erreur et un résultat
|
||||||
if( response.ModuleError == 0 ){
|
if( response.ModuleError == 0 ){
|
||||||
found_remove = [ response.cluster ]; // On récupère le résultat
|
found_remove = [ response.cluster ]; // On récupère le résultat
|
||||||
|
|
Loading…
Reference in New Issue