Gestion de la suppression si on a chargé l'entité via URL et que le champ de recherche est vide + correction pages 'groups/remove' et 'groups/edit' le champ 'Type de groupe' avait une valeur par défaut
This commit is contained in:
parent
9da6f1a6c5
commit
9d6ad3bc36
|
@ -1,28 +1,28 @@
|
|||
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&&/^(u|m)\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=[],b=0;b<a.clusters.length;b++)a.clusters[b].hasOwnProperty("id_user_cluster")?d.push("u"+a.clusters[b].id_user_cluster):d.push("m"+a.clusters[b].id_machine_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);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");navSubMenu("edit");document.location=""},!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");navSubMenu("remove");document.location=""},!1);for(i=0;i<section.view.group.rem.length;i++)section.view.group.rem[i].addEventListener("click",
|
||||
function(a){var c=a.target.getData("cluster")[0],d=a.target.getData("cluster").slice(1);console.log(a.target);var b={};b.path="u"==c?"userDefault/unlink":"machineDefault/unlink";b.id_cluster=d;"u"==c?b.id_user=a.target.getData("member"):b.id_machine=a.target.getData("member");api.send(b,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)}
|
||||
if(null!=section.view.element){1<pageManager.vars.length&&/^(u|m)\d+$/.test(pageManager.vars[1])&&(document.location="#"+pageManager.vars[1],null!=document.getElementById(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++)a.clusters[c].hasOwnProperty("id_user_cluster")?d.push("u"+a.clusters[c].id_user_cluster):d.push("m"+a.clusters[c].id_machine_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");navSubMenu("edit");document.location=""},!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");navSubMenu("remove");
|
||||
document.location=""},!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),section.create.input.name.value="",section.create.input["class"].children[0].selected="selected")})},!1));
|
||||
if(null!=section.remove.element){var autofill_remove=function(){var a="",c="",d="",b=!0;null==found_remove[searchindex_remove]?searchindex_remove=section.remove.input.search.num.innerHTML=0:(found_remove[searchindex_remove].hasOwnProperty("id_user_cluster")?(a=found_remove[searchindex_remove].id_user_cluster,c=0):(a=found_remove[searchindex_remove].id_machine_cluster,c=1),d=found_remove[searchindex_remove].name,b=!1,section.remove.input.search.num.innerHTML=searchindex_remove+1);section.remove.input.search.id.value=
|
||||
a;section.remove.input.name.value=d;section.remove.input["class"].value=0==c?"utilisateur":"machine";section.remove.input.submit.disabled=b};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"),"class":document.querySelector(section.remove.text+"#remove_class"),submit:document.querySelector(section.remove.text+"#remove_submit")};var lastkeywords_remove="",found_remove=[],searchindex_remove=0;if(2<=pageManager.vars.length&&/^(u|m)\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==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&&(a=found_remove[searchindex_remove].hasOwnProperty("id_user_cluster")?
|
||||
0:1,api.send({path:"clusterDefault/delete",id_cluster:section.remove.input.search.id.value,"class":a},function(a){0==a.ModuleError&&1==a.status?(console.log("Groupe supprimee!"),section.remove.input.submit.anim("active",1500),api.send({path:"clusterDefault/search",keywords:section.remove.input.search.keyword.value},function(a){0==a.ModuleError&&(searchindex_remove=0,found_remove=a.clusters,section.remove.input.search.sum.innerHTML=found_remove.length,autofill_remove())})):console.error("ModuleError::"+
|
||||
a.ModuleError)}))},!1)}
|
||||
if(null!=section.edit.element){var autofill_edit=function(){var a="",c="",d=!0;if(null==found_edit[searchindex_edit])searchindex_edit=section.edit.input.search.num.innerHTML=0;else{var b;found_edit[searchindex_remove].hasOwnProperty("id_user_cluster")?(a=found_edit[searchindex_remove].id_user_cluster,b=0):(a=found_edit[searchindex_remove].id_machine_cluster,b=1);c=found_edit[searchindex_remove].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["class"].value=0==b?"utilisateur":"machine";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"),"class":document.querySelector(section.edit.text+"#edit_class"),submit:document.querySelector(section.edit.text+"#edit_submit")};var lastkeywords_edit="",found_edit=[],searchindex_edit=0;2<=pageManager.vars.length&&/^(u|m)\d+$/.test(pageManager.vars[1])&&(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_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();if(""!=section.edit.input.search.id.value){var c=found_edit[searchindex_edit].hasOwnProperty("id_user_cluster")?0:1,d={path:"clusterDefault/edit",id_cluster:section.edit.input.search.id.value,name:section.edit.input.name.value,"class":c};api.send(d,function(a){0==
|
||||
a.ModuleError&&1==a.status?(console.log("Groupe modifiee!"),section.edit.input.submit.anim("active",1500),api.send({path:"clusterDefault/getById",id_cluster:d.id_cluster,"class":c},function(a){0==a.ModuleError&&(found_edit[searchindex_edit]=a.cluster,autofill_edit())})):console.error("ModuleError::"+a.ModuleError)})}},!1)}
|
||||
if(null!=section.remove.element){var autofill_remove=function(){var a="",b="",d="",c=!0;if(null==found_remove[searchindex_remove])searchindex_remove=section.remove.input.search.num.innerHTML=0;else{var e,b="";found_remove[searchindex_remove].hasOwnProperty("id_user_cluster")?(e=found_remove[searchindex_remove].id_user_cluster,b=0):found_remove[searchindex_remove].hasOwnProperty("id_machine_cluster")&&(e=found_remove[searchindex_remove].id_machine_cluster,b=1);a=e;d=found_remove[searchindex_remove].name;
|
||||
c=!1;section.remove.input.search.num.innerHTML=searchindex_remove+1}section.remove.input.search.id.value=a;section.remove.input.name.value=d;-1<[0,1].indexOf(b)?section.remove.input["class"].value=0==b?"utilisateur":"machine":section.remove.input["class"].value="";section.remove.input.submit.disabled=c};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"),"class":document.querySelector(section.remove.text+"#remove_class"),submit:document.querySelector(section.remove.text+"#remove_submit")};var lastkeywords_remove="",found_remove=[],searchindex_remove=
|
||||
0;if(2<=pageManager.vars.length&&/^(u|m)\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==
|
||||
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();""!=section.remove.input.search.id.value&&(a=found_remove[searchindex_remove].hasOwnProperty("id_user_cluster")?0:1,api.send({path:"clusterDefault/delete",id_cluster:section.remove.input.search.id.value,"class":a},function(a){0==a.ModuleError&&1==a.status?(console.log("Groupe supprimee!"),section.remove.input.submit.anim("active",1500),0==section.remove.input.search.keyword.value.length?(found_remove=[],searchindex_remove=0):api.send({path:"clusterDefault/search",keywords:section.remove.input.search.keyword.value},
|
||||
function(a){0==a.ModuleError&&(searchindex_remove=0,found_remove=a.clusters,section.remove.input.search.sum.innerHTML=found_remove.length)}),autofill_remove()):console.error("ModuleError::"+a.ModuleError)}))},!1)}
|
||||
if(null!=section.edit.element){var autofill_edit=function(){var a="",b="",d="",c=!0;if(null==found_edit[searchindex_edit])searchindex_edit=section.edit.input.search.num.innerHTML=0;else{var e,f;found_edit[searchindex_remove].hasOwnProperty("id_user_cluster")?(e=found_edit[searchindex_remove].id_user_cluster,f=0):found_edit[searchindex_edit].hasOwnProperty("id_machine_cluster")&&(e=found_edit[searchindex_remove].id_machine_cluster,f=1);a=e;b=f;d=found_edit[searchindex_remove].name;c=!1;section.edit.input.search.num.innerHTML=
|
||||
searchindex_edit+1}section.edit.input.search.id.value=a;section.edit.input.name.value=d;-1<[0,1].indexOf(b)?section.edit.input["class"].value=0==b?"utilisateur":"machine":section.edit.input["class"].value="";section.edit.input.submit.disabled=c};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"),"class":document.querySelector(section.edit.text+"#edit_class"),submit:document.querySelector(section.edit.text+"#edit_submit")};var lastkeywords_edit="",found_edit=[],searchindex_edit=0;2<=pageManager.vars.length&&/^(u|m)\d+$/.test(pageManager.vars[1])&&(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_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();if(""!=section.edit.input.search.id.value){var b=found_edit[searchindex_edit].hasOwnProperty("id_user_cluster")?
|
||||
0:1,d={path:"clusterDefault/edit",id_cluster:section.edit.input.search.id.value,name:section.edit.input.name.value,"class":b};api.send(d,function(a){0==a.ModuleError&&1==a.status?(console.log("Groupe modifiee!"),section.edit.input.submit.anim("active",1500),api.send({path:"clusterDefault/getById",id_cluster:d.id_cluster,"class":b},function(a){0==a.ModuleError&&(found_edit[searchindex_edit]=a.cluster,autofill_edit())})):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;/^(u|m)\d+$/.test(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=[],d=[],b=section.members.deflater.deflate().members;b instanceof
|
||||
Array||(b=[b]);for(a=0;a<b.length;a++)-1==section.members.baseData.indexOf(b[a])&&c.push(b[a]);for(a=0;a<section.members.baseData.length;a++)-1==b.indexOf(section.members.baseData[a])&&d.push(section.members.baseData[a]);for(a=0;a<c.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=c[a]:e.id_machine=c[a];api.send(e,function(a){0!=a.ModuleError&&console.error("Erreur d'ajout de membre")})}for(a=
|
||||
0;a<d.length;a++)c={},c.path=0==section.members["class"]?"userDefault/unlink":"machineDefault/unlink",c.id_cluster=section.members.idcluster,0==section.members["class"]?c.id_user=d[a]:c.id_machine=d[a],api.send(c,function(a){0!=a.ModuleError&&console.error("Erreur d'ajout de membre")});section.members.baseData=b},!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));
|
||||
|
|
|
@ -49,7 +49,8 @@ if( section.view.element != null ){
|
|||
/* (0) On gère le zoom sur un utilisateur via URL */
|
||||
if( pageManager.vars.length > 1 && /^(u|m)\d+$/.test(pageManager.vars[1]) ){
|
||||
document.location = '#'+pageManager.vars[1];
|
||||
document.getElementById(pageManager.vars[1]).addClass('selected');
|
||||
if( document.getElementById(pageManager.vars[1]) != null)
|
||||
document.getElementById(pageManager.vars[1]).addClass('selected');
|
||||
}
|
||||
|
||||
/* (1) On recupere tous les liens vers des sous-sections */
|
||||
|
@ -290,14 +291,15 @@ if( section.remove.element != null ){
|
|||
// {2} Si au moins 1 résultat //
|
||||
}else{
|
||||
|
||||
var tmpIdCluster, clusterClass;
|
||||
var tmpIdCluster;
|
||||
var 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{
|
||||
}else if( found_remove[searchindex_remove].hasOwnProperty('id_machine_cluster') ){
|
||||
tmpIdCluster = found_remove[searchindex_remove].id_machine_cluster;
|
||||
clusterClass = 1;
|
||||
}
|
||||
|
@ -322,7 +324,9 @@ if( section.remove.element != null ){
|
|||
|
||||
// Auto-remplissage du formulaire
|
||||
section.remove.input.name.value = cluster_data.name;
|
||||
section.remove.input.class.value = cluster_data.class == 0 ? 'utilisateur' : 'machine';
|
||||
|
||||
if( [0,1].indexOf(cluster_data.class) > -1 ) section.remove.input.class.value = cluster_data.class == 0 ? 'utilisateur' : 'machine';
|
||||
else section.remove.input.class.value = '';
|
||||
|
||||
// On gere le caractere "inactif" du submit
|
||||
section.remove.input.submit.disabled = cluster_data.disable_input;
|
||||
|
@ -436,24 +440,28 @@ if( section.remove.element != null ){
|
|||
|
||||
/* [1] On actualise la recherche
|
||||
=========================================================*/
|
||||
/* (1) Redaction de la requete */
|
||||
var getClusters = {
|
||||
path: 'clusterDefault/search',
|
||||
keywords: section.remove.input.search.keyword.value
|
||||
};
|
||||
if( section.remove.input.search.keyword.value.length == 0 ){ // Si aucun champ de recherche, on efface juste l'entrée
|
||||
|
||||
/* (2) On envoie la requête */
|
||||
api.send(getClusters, function(getClustersResponse){
|
||||
if( getClustersResponse.ModuleError == 0 ){ // si pas d'erreur
|
||||
/* (3) On met à jour les données des users, et le compteur */
|
||||
searchindex_remove = 0;
|
||||
found_remove = getClustersResponse.clusters;
|
||||
section.remove.input.search.sum.innerHTML = found_remove.length;
|
||||
// On supprime toutes les valeurs
|
||||
found_remove = [];
|
||||
searchindex_remove = 0;
|
||||
|
||||
// On met à jour l'auto-remplissage
|
||||
autofill_remove();
|
||||
}
|
||||
});
|
||||
}else{
|
||||
var getClusters = {
|
||||
path: 'clusterDefault/search',
|
||||
keywords: section.remove.input.search.keyword.value
|
||||
};
|
||||
|
||||
api.send(getClusters, function(getClustersResponse){
|
||||
if( getClustersResponse.ModuleError == 0 ){ // si pas d'erreur
|
||||
searchindex_remove = 0;
|
||||
found_remove = getClustersResponse.clusters;
|
||||
section.remove.input.search.sum.innerHTML = found_remove.length;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
autofill_remove();
|
||||
|
||||
|
||||
|
||||
|
@ -535,7 +543,7 @@ if( section.edit.element != null ){
|
|||
tmpIdCluster = found_edit[searchindex_remove].id_user_cluster;
|
||||
clusterClass = 0;
|
||||
// Sinon groupe machine
|
||||
}else{
|
||||
}else if( found_edit[searchindex_edit].hasOwnProperty('id_machine_cluster') ){
|
||||
tmpIdCluster = found_edit[searchindex_remove].id_machine_cluster;
|
||||
clusterClass = 1;
|
||||
}
|
||||
|
@ -560,7 +568,9 @@ if( section.edit.element != null ){
|
|||
|
||||
// Auto-remplissage du formulaire
|
||||
section.edit.input.name.value = cluster_data.name;
|
||||
section.edit.input.class.value = (clusterClass==0) ? 'utilisateur' : 'machine';
|
||||
|
||||
if( [0,1].indexOf(cluster_data.class) > -1 ) section.edit.input.class.value = cluster_data.class == 0 ? 'utilisateur' : 'machine';
|
||||
else section.edit.input.class.value = '';
|
||||
|
||||
// On gere le caractere "inactif" du submit
|
||||
section.edit.input.submit.disabled = cluster_data.disable_input;
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
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"]')},groups:{text:'#CONTAINER > section[data-sublink="groups"] ',element:document.querySelector('#CONTAINER > section[data-sublink="groups"]'),searchbar:document.querySelector('#CONTAINER > section[data-sublink="groups"] > .searchbar')}};
|
||||
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-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(a){api.send({path:"machineDefault/search",keywords:section.view.searchbar.value},function(a){if(0==a.ModuleError){for(var d=[],c=0;c<a.machines.length;c++)d.push(a.machines[c].id_machine);a=document.querySelectorAll(section.view.text+"> article.inline-box[id]");for(c=0;c<a.length;c++)-1<d.indexOf(parseInt(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(a){pageManager.vars[1]=a.target.getData("machine");navSubMenu("edit");document.location=""},!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("machine");navSubMenu("remove");document.location=""},!1);for(i=0;i<section.view.group.rem.length;i++)section.view.group.rem[i].addEventListener("click",function(a){var b={path:"machineDefault/unlink",id_machine:a.target.getData("machine"),id_cluster:a.target.getData("group")};
|
||||
api.send(b,function(b){if(0!=b.ModuleError)return!1;a.target.parentNode.parentNode.removeChild(a.target.parentNode)})},!1)}
|
||||
if(null!=section.view.element){1<pageManager.vars.length&&!isNaN(pageManager.vars[1])&&(document.location="#"+pageManager.vars[1],null!=document.getElementById(pageManager.vars[1])&&document.getElementById(pageManager.vars[1]).addClass("selected"));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(a){api.send({path:"machineDefault/search",keywords:section.view.searchbar.value},function(a){if(0==a.ModuleError){for(var d=[],c=0;c<a.machines.length;c++)d.push(a.machines[c].id_machine);a=document.querySelectorAll(section.view.text+"> article.inline-box[id]");for(c=0;c<a.length;c++)-1<d.indexOf(parseInt(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(a){pageManager.vars[1]=a.target.getData("machine");navSubMenu("edit");document.location=""},!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("machine");navSubMenu("remove");document.location=""},!1);for(i=0;i<section.view.group.rem.length;i++)section.view.group.rem[i].addEventListener("click",
|
||||
function(a){var b={path:"machineDefault/unlink",id_machine:a.target.getData("machine"),id_cluster:a.target.getData("group")};api.send(b,function(b){if(0!=b.ModuleError)return!1;a.target.parentNode.parentNode.removeChild(a.target.parentNode)})},!1)}
|
||||
null!=section.create.element&&(section.create.input={name:document.querySelector(section.create.text+"#create_name"),submit:document.querySelector(section.create.text+"#create_submit")},section.create.input.submit.addEventListener("click",function(a){a.preventDefault();api.send({path:"machineDefault/create",name:section.create.input.name.value},function(a){0==a.ModuleError&&(console.log("Machine cree!"),section.create.input.name.value="",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_machine,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:"machineDefault/getById",id_machine:pageManager.vars[1]},function(a){0==a.ModuleError&&(found_remove=[a.machine],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:"machineDefault/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.machines,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:"machineDefault/delete",id_machine:section.remove.input.search.id.value},function(a){0==a.ModuleError&&1==a.status?(console.log("Machine supprimee!"),section.remove.input.submit.anim("active",1500),api.send({path:"machineDefault/search",keywords:section.remove.input.search.keyword.value},function(a){0==a.ModuleError&&(searchindex_remove=0,found_remove=a.machines,section.remove.input.search.sum.innerHTML=found_remove.length,autofill_remove())})):
|
||||
console.error("ModuleError::"+a.ModuleError)})},!1)}
|
||||
section.remove.input.search.id.value&&api.send({path:"machineDefault/delete",id_machine:section.remove.input.search.id.value},function(a){0==a.ModuleError&&1==a.status?(console.log("Machine supprimee!"),section.remove.input.submit.anim("active",1500),0==section.remove.input.search.keyword.value.length?(found_remove=[],searchindex_remove=0):api.send({path:"machineDefault/search",keywords:section.remove.input.search.keyword.value},function(a){0==a.ModuleError&&(searchindex_remove=0,found_remove=a.machines,
|
||||
section.remove.input.search.sum.innerHTML=found_remove.length)}),autofill_remove()):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_machine,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:"machineDefault/getById",id_machine:pageManager.vars[1]},function(a){0==a.ModuleError&&(found_edit=[a.machine],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();
|
||||
|
|
|
@ -38,7 +38,8 @@ 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]) ){
|
||||
document.location = '#'+pageManager.vars[1];
|
||||
document.getElementById(pageManager.vars[1]).addClass('selected');
|
||||
if( document.getElementById(pageManager.vars[1]) != null )
|
||||
document.getElementById(pageManager.vars[1]).addClass('selected');
|
||||
}
|
||||
|
||||
/* (1) On recupere tous les liens */
|
||||
|
@ -377,25 +378,28 @@ if( section.remove.element != null ){
|
|||
|
||||
/* (1) On actualise la recherche
|
||||
---------------------------------------------------------*/
|
||||
/* (1) Redaction de la requete */
|
||||
var getMachines = {
|
||||
path: 'machineDefault/search',
|
||||
keywords: section.remove.input.search.keyword.value
|
||||
};
|
||||
if( section.remove.input.search.keyword.value.length == 0 ){ // Si aucun champ de recherche, on efface juste l'entrée
|
||||
|
||||
/* (2) On envoie la requête */
|
||||
api.send(getMachines, function(getMachinesResponse){
|
||||
if( getMachinesResponse.ModuleError == 0 ){ // si pas d'erreur
|
||||
// On supprime toutes les valeurs
|
||||
found_remove = [];
|
||||
searchindex_remove = 0;
|
||||
|
||||
/* (3) On met à jour les données des machines, et le compteur */
|
||||
searchindex_remove = 0;
|
||||
found_remove = getMachinesResponse.machines;
|
||||
section.remove.input.search.sum.innerHTML = found_remove.length;
|
||||
}else{
|
||||
var getMachines = {
|
||||
path: 'machineDefault/search',
|
||||
keywords: section.remove.input.search.keyword.value
|
||||
};
|
||||
|
||||
// On met à jour l'auto-remplissage
|
||||
autofill_remove();
|
||||
}
|
||||
});
|
||||
api.send(getMachines, function(getMachinesResponse){
|
||||
if( getMachinesResponse.ModuleError == 0 ){ // si pas d'erreur
|
||||
searchindex_remove = 0;
|
||||
found_remove = getMachinesResponse.machines;
|
||||
section.remove.input.search.sum.innerHTML = found_remove.length;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
autofill_remove();
|
||||
|
||||
|
||||
}else // Erreur
|
||||
|
|
|
@ -1,9 +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"]')},
|
||||
edit:{text:'#CONTAINER > section[data-sublink="edit"] ',element:document.querySelector('#CONTAINER > section[data-sublink="edit"]')},groups:{text:'#CONTAINER > section[data-sublink="groups"] ',element:document.querySelector('#CONTAINER > section[data-sublink="groups"]'),searchbar:document.querySelector('#CONTAINER > section[data-sublink="groups"] > .searchbar')}};
|
||||
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-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(a){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 d=[],b=0;b<a.users.length;b++)d.push(a.users[b].id_user);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("user");navSubMenu("edit");document.location=""},!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("user");navSubMenu("remove");document.location=""},!1);for(i=0;i<section.view.group.rem.length;i++)section.view.group.rem[i].addEventListener("click",function(a){var c={path:"userDefault/unlink",id_user:a.target.getData("user"),id_cluster:a.target.getData("group")};
|
||||
api.send(c,function(c){if(0!=c.ModuleError)return!1;a.target.parentNode.parentNode.removeChild(a.target.parentNode)})},!1)}
|
||||
if(null!=section.view.element){1<pageManager.vars.length&&!isNaN(pageManager.vars[1])&&(document.location="#"+pageManager.vars[1],null!=document.getElementById(pageManager.vars[1])&&document.getElementById(pageManager.vars[1]).addClass("selected"));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(a){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 d=[],b=0;b<a.users.length;b++)d.push(a.users[b].id_user);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("user");navSubMenu("edit");document.location=""},!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("user");navSubMenu("remove");document.location=""},!1);for(i=0;i<section.view.group.rem.length;i++)section.view.group.rem[i].addEventListener("click",
|
||||
function(a){var c={path:"userDefault/unlink",id_user:a.target.getData("user"),id_cluster:a.target.getData("group")};api.send(c,function(c){if(0!=c.ModuleError)return!1;a.target.parentNode.parentNode.removeChild(a.target.parentNode)})},!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"),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(a){a.target.value=a.target.value.toUpperCase();createChecker.check(a.target)||createChecker.correct(a.target,!1)},!1);section.create.input.submit.addEventListener("click",function(a){a.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},function(a){0==a.ModuleError?(console.log("Utilisateur cree!"),section.create.input.submit.anim("active",1500),section.create.input.code.value="",section.create.input.username.value="",section.create.input.firstname.value="",section.create.input.lastname.value="",section.create.input.mail.value=""):console.error("ModuleError::"+a.ModuleError)})},!1)}
|
||||
|
@ -11,8 +11,8 @@ if(null!=section.remove.element){var autofill_remove=function(){var a="",c="",d=
|
|||
b};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+
|
||||
"#remove_code"),username:document.querySelector(section.remove.text+"#remove_username"),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:"userDefault/getById",id_user:pageManager.vars[1]},function(a){0==a.ModuleError&&(found_remove=[a.user],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:"userDefault/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.users,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:"userDefault/delete",id_user:section.remove.input.search.id.value},function(a){0==a.ModuleError&&1==a.status?(console.log("Utilisateur supprime!"),section.remove.input.submit.anim("active",1500),api.send({path:"userDefault/search",keywords:section.remove.input.search.keyword.value},function(a){0==a.ModuleError&&(searchindex_remove=
|
||||
0,found_remove=a.users,section.remove.input.search.sum.innerHTML=found_remove.length,autofill_remove())})):console.error("ModuleError::"+a.ModuleError)})},!1)}
|
||||
lastkeywords_remove=c.keywords})}},!1);section.remove.input.submit.addEventListener("click",function(a){a.preventDefault();""!=section.remove.input.search.id.value&&api.send({path:"userDefault/delete",id_user:section.remove.input.search.id.value},function(a){0==a.ModuleError&&1==a.status?(console.log("Utilisateur supprime!"),section.remove.input.submit.anim("active",1500),0==section.remove.input.search.keyword.value.length?(found_remove=[],searchindex_remove=0):api.send({path:"userDefault/search",
|
||||
keywords:section.remove.input.search.keyword.value},function(a){0==a.ModuleError&&(searchindex_remove=0,found_remove=a.users,section.remove.input.search.sum.innerHTML=found_remove.length)}),autofill_remove()):console.error("ModuleError::"+a.ModuleError)})},!1)}
|
||||
if(null!=section.edit.element){var autofill_edit=function(){var a="",c="",d="",b="",e="",f="",g=!0;null==found_edit[searchindex_edit]?searchindex_edit=section.edit.input.search.num.innerHTML=0:(a=found_edit[searchindex_edit].id_user,c=found_edit[searchindex_edit].code,d=found_edit[searchindex_edit].username,b=found_edit[searchindex_edit].firstname,e=found_edit[searchindex_edit].lastname,f=found_edit[searchindex_edit].mail,g=!1,section.edit.input.search.num.innerHTML=searchindex_edit+1);section.edit.input.search.id.value=
|
||||
a;section.edit.input.code.value=c;section.edit.input.username.value=d;section.edit.input.firstname.value=b;section.edit.input.lastname.value=e;section.edit.input.mail.value=f;section.edit.input.submit.disabled=g};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")},code:document.querySelector(section.edit.text+"#edit_code"),username:document.querySelector(section.edit.text+"#edit_username"),firstname:document.querySelector(section.edit.text+"#edit_firstname"),lastname:document.querySelector(section.edit.text+"#edit_lastname"),mail:document.querySelector(section.edit.text+"#edit_mail"),submit:document.querySelector(section.edit.text+
|
||||
|
|
|
@ -40,7 +40,8 @@ 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]) ){
|
||||
document.location = '#'+pageManager.vars[1];
|
||||
document.getElementById(pageManager.vars[1]).addClass('selected');
|
||||
if( document.getElementById(pageManager.vars[1]) != null )
|
||||
document.getElementById(pageManager.vars[1]).addClass('selected');
|
||||
}
|
||||
|
||||
|
||||
|
@ -413,25 +414,27 @@ if( section.remove.element != null ){
|
|||
|
||||
/* (1) On actualise la recherche
|
||||
---------------------------------------------------------*/
|
||||
/* (1) Redaction de la requete */
|
||||
var getUsers = {
|
||||
path: 'userDefault/search',
|
||||
keywords: section.remove.input.search.keyword.value
|
||||
};
|
||||
if( section.remove.input.search.keyword.value.length == 0 ){ // Si aucun champ de recherche, on efface juste l'entrée
|
||||
|
||||
/* (2) On envoie la requête */
|
||||
api.send(getUsers, function(getUsersResponse){
|
||||
if( getUsersResponse.ModuleError == 0 ){ // si pas d'erreur
|
||||
// On supprime toutes les valeurs
|
||||
found_remove = [];
|
||||
searchindex_remove = 0;
|
||||
|
||||
/* (3) On met à jour les données des users, et le compteur */
|
||||
searchindex_remove = 0;
|
||||
found_remove = getUsersResponse.users;
|
||||
section.remove.input.search.sum.innerHTML = found_remove.length;
|
||||
}else{
|
||||
var getUsers = {
|
||||
path: 'userDefault/search',
|
||||
keywords: section.remove.input.search.keyword.value
|
||||
};
|
||||
|
||||
// On met à jour l'auto-remplissage
|
||||
autofill_remove();
|
||||
}
|
||||
});
|
||||
api.send(getUsers, function(getUsersResponse){
|
||||
if( getUsersResponse.ModuleError == 0 ){ // si pas d'erreur
|
||||
searchindex_remove = 0;
|
||||
found_remove = getUsersResponse.users;
|
||||
section.remove.input.search.sum.innerHTML = found_remove.length;
|
||||
}
|
||||
});
|
||||
}
|
||||
autofill_remove();
|
||||
|
||||
|
||||
}else // Erreur
|
||||
|
|
Loading…
Reference in New Issue