Corrections des methodes 'link' et 'unlink' ainsi que toute l'arborescence de délégation + Suppression des groupes d'une 'machine' ou d'un 'utilisateur' fonctionnel sur l'interface

This commit is contained in:
xdrm-brackets 2016-07-08 19:33:58 +02:00
parent 71de69a042
commit 174ed80059
13 changed files with 140 additions and 56 deletions

View File

@ -190,6 +190,8 @@
&.add-group{ &.add-group{
border-radius: 3px; border-radius: 3px;
cursor: pointer;
} }
& > span.rem-group{ & > span.rem-group{

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -120,7 +120,7 @@
case self::NoMatchFound: return "Aucun résultat correspondant à la requête."; break; case self::NoMatchFound: return "Aucun résultat correspondant à la requête."; break;
default: return "Description d'erreur inconnue..."; break; default: return "Erreur inconnue..."; break;
} }
// Erreur inconnue // Erreur inconnue

View File

@ -97,8 +97,8 @@
clusterRepo::MACHINE_CLASS clusterRepo::MACHINE_CLASS
]); ]);
return []; /* (1) On retourne l'erreur du repo */
return [ 'ModuleError' => $link_machine->answer() ];
} }
@ -125,8 +125,8 @@
clusterRepo::MACHINE_CLASS clusterRepo::MACHINE_CLASS
]); ]);
return []; /* (1) On retourne l'erreur du repo */
return [ 'ModuleError' => $link_machine->answer() ];
} }

View File

@ -117,8 +117,8 @@
clusterRepo::USER_CLASS clusterRepo::USER_CLASS
]); ]);
return []; /* (1) On retourne l'erreur du repo */
return [ 'ModuleError' => $link_user->answer() ];
} }
@ -146,8 +146,8 @@
clusterRepo::USER_CLASS clusterRepo::USER_CLASS
]); ]);
return []; /* (1) On retourne l'erreur du repo */
return [ 'ModuleError' => $link_user->answer() ];
} }

View File

@ -2,6 +2,7 @@
namespace manager\repo; namespace manager\repo;
use \manager\Database; use \manager\Database;
use \manager\ManagerError;
use \manager\repo\machine as machineRepo; use \manager\repo\machine as machineRepo;
use \manager\repo\user as userRepo; use \manager\repo\user as userRepo;
@ -78,7 +79,7 @@
// Si le groupe n'existe pas, on retourne ue erreur // Si le groupe n'existe pas, on retourne ue erreur
if( $group_check === false ) if( $group_check === false )
return false; return ManagerError::NoMatchFound;
@ -99,18 +100,19 @@
} }
// Si aucune entite existante, on retourne une erreur // Si aucune entite existante, on retourne une erreur
if( !$entity_exists ) if( !$entity_exists )
return false; return ManagerError::NoMatchFound;
/* [3] Verification que l'existente n'existe pas deja /* [3] Verification que l'existente n'existe pas deja
=========================================================*/ =========================================================*/
$already_cluster_merge = self::getMerge($id_cluster, $id_entity, $class); $already_cluster_merge = self::getMerge($id_warehouse, $id_cluster, $id_entity, $class);
// Si l'association existe deja, on ne la cree donc pas // Si l'association existe deja, on ne la cree donc pas
if( $already_cluster_merge !== false ) if( $already_cluster_merge !== false )
return $already_cluster_merge['id_cluster_merge']; return ManagerError::Success;
/* [4] On cree l'association /* [4] On cree l'association
@ -124,14 +126,14 @@
/* [5] On retourne l'id_cluster_merge ou FALSE si erreur /* [5] On retourne l'id_cluster_merge ou FALSE si erreur
=========================================================*/ =========================================================*/
$check_cluster_merge = self::getMerge($id_cluster, $id_entity, $class); $check_cluster_merge = self::getMerge($id_warehouse, $id_cluster, $id_entity, $class);
// Si n'existe pas on retourne FALSE // Si n'existe pas on retourne FALSE
if( !is_array($check_cluster_merge) ) if( !is_array($check_cluster_merge) )
return false; return ManagerError::ModuleError;
// Sinon, on retourne son id // Sinon, on retourne son id
return $check_cluster_merge['id_cluster_merge']; return ManagerError::Success;
} }
@ -152,25 +154,33 @@
* *
*/ */
public static function unlink($id_warehouse, $id_cluster, $id_entity, $class){ public static function unlink($id_warehouse, $id_cluster, $id_entity, $class){
/* [1] On redige/execute la requete /* [1] On récupère l'UID du lien
=========================================================*/ =========================================================*/
$delete_cluster_merge = Database::getPDO()->prepare("DELETE FROM cluster_merge as cm, cluster as c /* (1) On récupère le lien */
WHERE cm.id_cluster = c.id_cluster $get_merge_id = self::getMerge($id_warehouse, $id_cluster, $id_entity, $class);
AND c.id_warehouse = :id_warehouse
AND cm.id_cluster = :id_cluster /* (2) Si on ne trouve rien */
AND cm.id_entity = :id_entity if( $get_merge_id == false )
AND c.class = :class"); return ManagerError::NoMatchFound;
/* [2] On supprime le lien
=========================================================*/
$delete_cluster_merge = Database::getPDO()->prepare("DELETE FROM cluster_merge
WHERE id_cluster_merge = :uid");
$delete_cluster_merge->execute([ $delete_cluster_merge->execute([
':id_warehouse' => $id_warehouse, ':uid' => $get_merge_id['id_cluster_merge']
':id_cluster' => $id_cluster,
':id_entity' => $id_entity,
':class' => $class
]); ]);
/* [2] On verifie que l'association n'existe plus /* [2] On verifie que l'association n'existe plus
=========================================================*/ =========================================================*/
return ( self::getMerge($id_cluster, $id_entity, $class) === false ); if( self::getMerge($id_warehouse, $id_cluster, $id_entity, $class) !== false )
return ManagerError::ModuleError;
return ManagerError::Success;
} }
@ -181,6 +191,7 @@
/* RENVOIE L'ID D'UNE ASSOCIATION D'UN(E) UTILISATEUR/MACHINE A UN GROUPE /* RENVOIE L'ID D'UNE ASSOCIATION D'UN(E) UTILISATEUR/MACHINE A UN GROUPE
* *
* @id_warehouse<int> UID de l'entrepot
* @id_cluster<int> UID du groupe * @id_cluster<int> UID du groupe
* @id_entity<int> UID de la machine ou de l'utilisateur * @id_entity<int> UID de la machine ou de l'utilisateur
* @class<int> Spefication du type d'entite (0=user;1=machine) * @class<int> Spefication du type d'entite (0=user;1=machine)
@ -189,20 +200,22 @@
* Renvoie FALSE si une erreur occure * Renvoie FALSE si une erreur occure
* *
*/ */
public static function getMerge($id_cluster, $id_entity, $class){ public static function getMerge($id_warehouse, $id_cluster, $id_entity, $class){
// On ecrit la requete // On ecrit la requete
$request = Database::getPDO()->prepare("SELECT cm.* $request = Database::getPDO()->prepare("SELECT cm.*
FROM cluster_merge as cm, cluster as c FROM cluster_merge as cm, cluster as c
WHERE cm.id_cluster = c.id_cluster WHERE cm.id_cluster = c.id_cluster
AND cm.id_cluster = :id_cluster AND c.id_warehouse = :id_warehouse
AND cm.id_entity = :id_entity AND cm.id_cluster = :id_cluster
AND c.class = :class"); AND cm.id_entity = :id_entity
AND c.class = :class");
// On execute la requete // On execute la requete
$request->execute([ $request->execute([
':id_cluster' => $id_cluster, ':id_warehouse' => $id_warehouse,
':id_entity' => $id_entity, ':id_cluster' => $id_cluster,
':class' => $class ':id_entity' => $id_entity,
':class' => $class
]); ]);
// On recupere 1 seule relation // On recupere 1 seule relation

View File

@ -1,8 +1,9 @@
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"]')}}; edit:{text:'#CONTAINER > section[data-sublink="edit"] ',element:document.querySelector('#CONTAINER > section[data-sublink="edit"]')}};
if(null!=section.view.element){section.view.link={edit:document.querySelectorAll(section.view.text+".link_edit[data-machine]"),remove:document.querySelectorAll(section.view.text+".link_remove[data-machine]")};section.view.searchbar.addEventListener("keyup",function(b){api.send({path:"machineDefault/search",keywords:section.view.searchbar.value},function(a){if(0==a.ModuleError){for(var b=[],c=0;c<a.machines.length;c++)b.push(a.machines[c].id_machine);a=document.querySelectorAll(section.view.text+"> article.inline-box[id]"); if(null!=section.view.element){section.view.link={edit:document.querySelectorAll(section.view.text+".link_edit[data-machine]"),remove:document.querySelectorAll(section.view.text+".link_remove[data-machine]")};section.view.group={rem:document.querySelectorAll(section.view.text+".rem-group[data-machine][data-group]"),add:document.querySelectorAll(section.view.text+".add-group[data-machine]")};section.view.searchbar.addEventListener("keyup",function(b){api.send({path:"machineDefault/search",keywords:section.view.searchbar.value},
for(c=0;c<a.length;c++)-1<b.indexOf(a[c].id)?a[c].remClass("hidden"):a[c].addClass("hidden")}})},!1);for(var i=0;i<section.view.link.edit.length;i++)section.view.link.edit[i].addEventListener("click",function(b){pageManager.vars[1]=b.target.getData("machine");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(b){pageManager.vars[1]=b.target.getData("machine");autofill_remove(pageManager.vars[1]); function(a){if(0==a.ModuleError){for(var b=[],c=0;c<a.machines.length;c++)b.push(a.machines[c].id_machine);a=document.querySelectorAll(section.view.text+"> article.inline-box[id]");for(c=0;c<a.length;c++)-1<b.indexOf(a[c].id)?a[c].remClass("hidden"):a[c].addClass("hidden")}})},!1);for(var i=0;i<section.view.link.edit.length;i++)section.view.link.edit[i].addEventListener("click",function(b){pageManager.vars[1]=b.target.getData("machine");autofill_edit(pageManager.vars[1]);navSubMenu("edit")},!1);for(i=
navSubMenu("remove")},!1)} 0;i<section.view.link.remove.length;i++)section.view.link.remove[i].addEventListener("click",function(b){pageManager.vars[1]=b.target.getData("machine");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(b){var a={path:"machineDefault/unlink",id_machine:b.target.getData("machine"),id_cluster:b.target.getData("group")};api.send(a,function(a){if(0!=a.ModuleError)return!1;b.target.parentNode.parentNode.removeChild(b.target.parentNode)})},
!1)}
if(null!=section.create.element){section.create.input={code:document.querySelector(section.create.text+"#create_code"),name:document.querySelector(section.create.text+"#create_name"),submit:document.querySelector(section.create.text+"#create_submit")};var createChecker=new inputChecker;createChecker.append(section.create.input.code,format_code,"01-AB-CD-23");section.create.input.code.addEventListener("keyup",function(b){b.target.value=b.target.value.toUpperCase();createChecker.check(b.target)||createChecker.correct(b.target, if(null!=section.create.element){section.create.input={code:document.querySelector(section.create.text+"#create_code"),name:document.querySelector(section.create.text+"#create_name"),submit:document.querySelector(section.create.text+"#create_submit")};var createChecker=new inputChecker;createChecker.append(section.create.input.code,format_code,"01-AB-CD-23");section.create.input.code.addEventListener("keyup",function(b){b.target.value=b.target.value.toUpperCase();createChecker.check(b.target)||createChecker.correct(b.target,
!1)},!1);section.create.input.submit.addEventListener("click",function(b){b.preventDefault();api.send({path:"machineDefault/create",code:section.create.input.code.value,name:section.create.input.name.value},function(a){0==a.ModuleError?(console.log("Machine cree!"),section.create.input.submit.anim("active",1500)):console.error("ModuleError::"+a.ModuleError)})},!1)} !1)},!1);section.create.input.submit.addEventListener("click",function(b){b.preventDefault();api.send({path:"machineDefault/create",code:section.create.input.code.value,name:section.create.input.name.value},function(a){0==a.ModuleError?(console.log("Machine cree!"),section.create.input.submit.anim("active",1500)):console.error("ModuleError::"+a.ModuleError)})},!1)}
if(null!=section.remove.element){var autofill_remove=function(b){var a=a={id_machine:"",code:"",name:"",disable_input:!0};api.send({path:"machineDefault/getById",id_machine:b},function(b){0==b.ModuleError&&(a=b.machine,a.diable_input=!1);section.remove.input.search.id.value=a.id_machine;section.remove.input.code.value=a.code;section.remove.input.name.value=a.name;section.remove.input.submit.disabled=a.disable_input;section.remove.input.search.num.innerHTML=searchindex_remove+1})};section.remove.input= if(null!=section.remove.element){var autofill_remove=function(b){var a=a={id_machine:"",code:"",name:"",disable_input:!0};api.send({path:"machineDefault/getById",id_machine:b},function(b){0==b.ModuleError&&(a=b.machine,a.diable_input=!1);section.remove.input.search.id.value=a.id_machine;section.remove.input.code.value=a.code;section.remove.input.name.value=a.name;section.remove.input.submit.disabled=a.disable_input;section.remove.input.search.num.innerHTML=searchindex_remove+1})};section.remove.input=

View File

@ -35,8 +35,14 @@ if( section.view.element != null ){
remove: document.querySelectorAll(section.view.text + '.link_remove[data-machine]') remove: document.querySelectorAll(section.view.text + '.link_remove[data-machine]')
}; };
/* (2) On récupère toutes les actions de groupes */
section.view.group = {
rem: document.querySelectorAll(section.view.text + '.rem-group[data-machine][data-group]'),
add: document.querySelectorAll(section.view.text + '.add-group[data-machine]')
};
/* (2) Gestion de la recherche instantannee */
/* (3) Gestion de la recherche instantannee */
section.view.searchbar.addEventListener('keyup', function(e){ section.view.searchbar.addEventListener('keyup', function(e){
var search = { var search = {
@ -71,7 +77,7 @@ if( section.view.element != null ){
}, false); }, false);
/* (3) On gere la "redirection" vers la modification */ /* (4) On gere la "redirection" vers la modification */
for( var i = 0 ; i < section.view.link.edit.length ; i++ ){ for( var i = 0 ; i < section.view.link.edit.length ; i++ ){
section.view.link.edit[i].addEventListener('click', function(e){ section.view.link.edit[i].addEventListener('click', function(e){
@ -82,7 +88,7 @@ if( section.view.element != null ){
} }
/* (4) On gere la "redirection" vers la suppression */ /* (5) On gere la "redirection" vers la suppression */
for( var i = 0 ; i < section.view.link.remove.length ; i++ ){ for( var i = 0 ; i < section.view.link.remove.length ; i++ ){
section.view.link.remove[i].addEventListener('click', function(e){ section.view.link.remove[i].addEventListener('click', function(e){
@ -93,6 +99,33 @@ if( section.view.element != null ){
} }
/* (6) On gere la "suppression" d'un groupe */
for( var i = 0 ; i < section.view.group.rem.length ; i++ ){
section.view.group.rem[i].addEventListener('click', function(e){
// {1} On rédige la requête //
var request = {
path: 'machineDefault/unlink',
id_machine: e.target.getData('machine'),
id_cluster: e.target.getData('group')
};
// {2} On envoie la requête //
api.send(request, function(response){
// {3} Si erreur, on ne fait rien //
if( response.ModuleError != 0 )
return false;
// {4} Si tout s'est bien passé //
e.target.parentNode.parentNode.removeChild( e.target.parentNode );
});
}, false);
}
} }

11
view/js/users-min.js vendored
View File

@ -1,10 +1,11 @@
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"]')}}; edit:{text:'#CONTAINER > section[data-sublink="edit"] ',element:document.querySelector('#CONTAINER > section[data-sublink="edit"]')}};
if(null!=section.view.element){section.view.link={edit:document.querySelectorAll(section.view.text+".link_edit[data-user]"),remove:document.querySelectorAll(section.view.text+".link_remove[data-user]")};section.view.searchbar.addEventListener("keyup",function(b){api.send({path:"userDefault/search",keywords:section.view.searchbar.value},function(a){if(0==a.ModuleError&&(console.log(a.users.length),0==a.ModuleError)){for(var b=[],c=0;c<a.users.length;c++)b.push(a.users[c].id_user);a=document.querySelectorAll(section.view.text+ if(null!=section.view.element){section.view.link={edit:document.querySelectorAll(section.view.text+".link_edit[data-user]"),remove:document.querySelectorAll(section.view.text+".link_remove[data-user]")};section.view.group={rem:document.querySelectorAll(section.view.text+".rem-group[data-user][data-group]"),add:document.querySelectorAll(section.view.text+".add-group[data-user]")};section.view.searchbar.addEventListener("keyup",function(b){api.send({path:"userDefault/search",keywords:section.view.searchbar.value},
"> article.inline-box[id]");for(c=0;c<a.length;c++)-1<b.indexOf(a[c].id)?a[c].remClass("hidden"):a[c].addClass("hidden")}})},!1);for(var i=0;i<section.view.link.edit.length;i++)section.view.link.edit[i].addEventListener("click",function(b){pageManager.vars[1]=b.target.getData("user");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(b){pageManager.vars[1]=b.target.getData("user");autofill_remove(pageManager.vars[1]); function(a){if(0==a.ModuleError&&(console.log(a.users.length),0==a.ModuleError)){for(var b=[],c=0;c<a.users.length;c++)b.push(a.users[c].id_user);a=document.querySelectorAll(section.view.text+"> article.inline-box[id]");for(c=0;c<a.length;c++)-1<b.indexOf(a[c].id)?a[c].remClass("hidden"):a[c].addClass("hidden")}})},!1);for(var i=0;i<section.view.link.edit.length;i++)section.view.link.edit[i].addEventListener("click",function(b){pageManager.vars[1]=b.target.getData("user");autofill_edit(pageManager.vars[1]);
navSubMenu("remove")},!1)} navSubMenu("edit")},!1);for(i=0;i<section.view.link.remove.length;i++)section.view.link.remove[i].addEventListener("click",function(b){pageManager.vars[1]=b.target.getData("user");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(b){var a={path:"userDefault/unlink",id_user:b.target.getData("user"),id_cluster:b.target.getData("group")};api.send(a,function(a){if(0!=a.ModuleError)return!1;
if(null!=section.create.element){section.create.input={code:document.querySelector(section.create.text+"#create_code"),username:document.querySelector(section.create.text+"#create_username"),firstname:document.querySelector(section.create.text+"#create_firstname"),lastname:document.querySelector(section.create.text+"#create_lastname"),mail:document.querySelector(section.create.text+"#create_mail"),password:document.querySelector(section.create.text+"#create_password"),status:document.querySelector(section.create.text+"#create_status"), b.target.parentNode.parentNode.removeChild(b.target.parentNode)})},!1)}
submit:document.querySelector(section.create.text+"#create_submit")};var createChecker=new inputChecker;createChecker.append(section.create.input.code,format_code,"01-AB-CD-23");section.create.input.code.addEventListener("keyup",function(b){b.target.value=b.target.value.toUpperCase();createChecker.check(b.target)||createChecker.correct(b.target,!1)},!1);section.create.input.submit.addEventListener("click",function(b){b.preventDefault();api.send({path:"userDefault/create",code:section.create.input.code.value, if(null!=section.create.element){section.create.input={code:document.querySelector(section.create.text+"#create_code"),username:document.querySelector(section.create.text+"#create_username"),firstname:document.querySelector(section.create.text+"#create_firstname"),lastname:document.querySelector(section.create.text+"#create_lastname"),mail:document.querySelector(section.create.text+"#create_mail"),password:document.querySelector(section.create.text+"#create_password"),status:document.querySelector(section.create.text+
"#create_status"),submit:document.querySelector(section.create.text+"#create_submit")};var createChecker=new inputChecker;createChecker.append(section.create.input.code,format_code,"01-AB-CD-23");section.create.input.code.addEventListener("keyup",function(b){b.target.value=b.target.value.toUpperCase();createChecker.check(b.target)||createChecker.correct(b.target,!1)},!1);section.create.input.submit.addEventListener("click",function(b){b.preventDefault();api.send({path:"userDefault/create",code:section.create.input.code.value,
username:section.create.input.username.value,firstname:section.create.input.firstname.value,lastname:section.create.input.lastname.value,mail:section.create.input.mail.value,password:section.create.input.password.value,status:section.create.input.status.value},function(a){0==a.ModuleError?(console.log("Utilisateur cree!"),section.create.input.submit.anim("active",1500)):console.error("ModuleError::"+a.ModuleError)})},!1)} username:section.create.input.username.value,firstname:section.create.input.firstname.value,lastname:section.create.input.lastname.value,mail:section.create.input.mail.value,password:section.create.input.password.value,status:section.create.input.status.value},function(a){0==a.ModuleError?(console.log("Utilisateur cree!"),section.create.input.submit.anim("active",1500)):console.error("ModuleError::"+a.ModuleError)})},!1)}
if(null!=section.remove.element){var autofill_remove=function(b){var a={id_user:"",code:"",username:"",firstname:"",lastname:"",mail:"",status:"",disable_input:!0};api.send({path:"userDefault/getById",id_user:b},function(b){0==b.ModuleError&&(a=b.user,a.disable_input=!1);section.remove.input.search.id.value=a.id_user;section.remove.input.code.value=a.code;section.remove.input.username.value=a.username;section.remove.input.submit.disabled=a.disable_input;section.remove.input.search.num.innerHTML=searchindex_remove+ if(null!=section.remove.element){var autofill_remove=function(b){var a={id_user:"",code:"",username:"",firstname:"",lastname:"",mail:"",status:"",disable_input:!0};api.send({path:"userDefault/getById",id_user:b},function(b){0==b.ModuleError&&(a=b.user,a.disable_input=!1);section.remove.input.search.id.value=a.id_user;section.remove.input.code.value=a.code;section.remove.input.username.value=a.username;section.remove.input.submit.disabled=a.disable_input;section.remove.input.search.num.innerHTML=searchindex_remove+
1})};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")},code:document.querySelector(section.remove.text+ 1})};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")},code:document.querySelector(section.remove.text+

View File

@ -2,7 +2,7 @@
var section = { var section = {
view: { view: {
text: '#CONTAINER > section[data-sublink="view"] ', text: '#CONTAINER > section[data-sublink="view"] ',
element: document.querySelector('#CONTAINER > section[data-sublink="view"]'), element: document.querySelector('#CONTAINER > section[data-sublink="view"]'),
searchbar: document.querySelector('#CONTAINER > section[data-sublink="view"] > .searchbar') searchbar: document.querySelector('#CONTAINER > section[data-sublink="view"] > .searchbar')
}, },
@ -37,8 +37,14 @@ if( section.view.element != null ){
remove: document.querySelectorAll(section.view.text + '.link_remove[data-user]') remove: document.querySelectorAll(section.view.text + '.link_remove[data-user]')
}; };
/* (2) On récupère toutes les actions de groupes */
section.view.group = {
rem: document.querySelectorAll(section.view.text + '.rem-group[data-user][data-group]'),
add: document.querySelectorAll(section.view.text + '.add-group[data-user]')
};
/* (2) Gestion de la recherche instantannee */
/* (3) Gestion de la recherche instantannee */
section.view.searchbar.addEventListener('keyup', function(e){ section.view.searchbar.addEventListener('keyup', function(e){
var search = { var search = {
@ -76,7 +82,7 @@ if( section.view.element != null ){
}, false); }, false);
/* (3) On gere la "redirection" vers la modification */ /* (4) On gere la "redirection" vers la modification */
for( var i = 0 ; i < section.view.link.edit.length ; i++ ){ for( var i = 0 ; i < section.view.link.edit.length ; i++ ){
section.view.link.edit[i].addEventListener('click', function(e){ section.view.link.edit[i].addEventListener('click', function(e){
@ -87,7 +93,7 @@ if( section.view.element != null ){
} }
/* (4) On gere la "redirection" vers la suppression */ /* (5) On gere la "redirection" vers la suppression */
for( var i = 0 ; i < section.view.link.remove.length ; i++ ){ for( var i = 0 ; i < section.view.link.remove.length ; i++ ){
section.view.link.remove[i].addEventListener('click', function(e){ section.view.link.remove[i].addEventListener('click', function(e){
@ -98,6 +104,33 @@ if( section.view.element != null ){
} }
/* (6) On gere la "suppression" d'un groupe */
for( var i = 0 ; i < section.view.group.rem.length ; i++ ){
section.view.group.rem[i].addEventListener('click', function(e){
// {1} On rédige la requête //
var request = {
path: 'userDefault/unlink',
id_user: e.target.getData('user'),
id_cluster: e.target.getData('group')
};
// {2} On envoie la requête //
api.send(request, function(response){
// {3} Si erreur, on ne fait rien //
if( response.ModuleError != 0 )
return false;
// {4} Si tout s'est bien passé //
e.target.parentNode.parentNode.removeChild( e.target.parentNode );
});
}, false);
}
} }

View File

@ -115,7 +115,7 @@
if( $clusters != false ) if( $clusters != false )
foreach($clusters as $cluster) foreach($clusters as $cluster)
echo "<span>".$cluster['name']."<span class='rem-group' data-user='".$machine['id_machine']."'></span></span>"; echo "<span>".$cluster['name']."<span class='rem-group' data-group='".$cluster['id_cluster']."' data-machine='".$machine['id_machine']."'></span></span>";
echo "<span class='add-group' data-machine='".$machine['id_machine']."'>+</span>"; echo "<span class='add-group' data-machine='".$machine['id_machine']."'>+</span>";
echo"</span>"; echo"</span>";

View File

@ -125,7 +125,7 @@
if( $clusters != false ) if( $clusters != false )
foreach($clusters as $cluster) foreach($clusters as $cluster)
echo "<span>".$cluster['name']."<span class='rem-group' data-user='".$user['id_user']."'></span></span>"; echo "<span>".$cluster['name']."<span class='rem-group' data-group='".$cluster['id_cluster']."' data-user='".$user['id_user']."'></span></span>";
echo "<span class='add-group' data-user='".$user['id_user']."'>+</span>"; echo "<span class='add-group' data-user='".$user['id_user']."'>+</span>";
echo"</span>"; echo"</span>";