Page 'machines/view', 'machines/remove', 'machines/edit' DONE + les repos/modules utiles à leur fonctionnement DONE + les liens entre les pages (excepté 'machine/groups' et le liens vers la page 'groups/...') DONE

This commit is contained in:
xdrm-brackets 2016-07-20 19:57:05 +02:00
parent 15e59f55c4
commit 36ac271791
5 changed files with 13 additions and 41 deletions

View File

@ -316,36 +316,8 @@
]); ]);
$deleted_machine = $del_machine->answer(); $deleted_machine = $del_machine->answer();
if( !$deleted_machine )
return [ 'status' => false ];
return [ 'status' => $deleted_machine ];
/* [2] On récupère le groupe personnel
=========================================================*/
$get_personal_cluster = new Repo('cluster/getPersonal', [
$id_warehouse,
$id_machine,
clusterRepo::MACHINE_CLASS
]);
$personal_cluster = $get_personal_cluster->answer();
// si erreur
if( $personal_cluster === false )
return [ 'status' => false ];
/* [3] On supprime le groupe personnel
=========================================================*/
$del_cluster = new Repo('cluster/delete', [
$id_warehouse,
$personal_cluster['id_cluster']
]);
$deleted = $del_cluster->answer();
return [ 'status' => $deleted ];
} }

View File

@ -3,9 +3,8 @@ 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&&/^(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+ 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=[],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();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");autofill_remove();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); 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);
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();var b={path:"clusterDefault/create",name:section.create.input.name.value,"class":section.create.input["class"].value};api.send(b,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();var b={path:"clusterDefault/create",name:section.create.input.name.value,"class":section.create.input["class"].value};api.send(b,function(a){0==a.ModuleError&&(console.log("Groupe cree!"),
pageManager.vars[1]=(0==b["class"]?"u":"m")+a.id_cluster,navSubMenu("view"),document.location="",section.create.input.submit.anim("active",1500))})},!1)); pageManager.vars[1]=(0==b["class"]?"u":"m")+a.id_cluster,navSubMenu("view"),document.location="",section.create.input.submit.anim("active",1500))})},!1));
if(null!=section.remove.element){var autofill_remove=function(){var a={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={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};

View File

@ -105,7 +105,6 @@ 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();
navSubMenu('edit'); navSubMenu('edit');
document.location = ''; document.location = '';
}, false); }, false);
@ -117,7 +116,6 @@ 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();
navSubMenu('remove'); navSubMenu('remove');
document.location = ''; document.location = '';
}, false); }, false);

View File

@ -2,15 +2,15 @@ var section={view:{text:'#CONTAINER > section[data-sublink="view"] ',element:doc
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){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+ 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(b){if(0==b.ModuleError){for(var a=[],c=0;c<b.machines.length;c++)a.push(b.machines[c].id_machine);b=document.querySelectorAll(section.view.text+"> article.inline-box[id]");for(c=0;c<b.length;c++)-1<a.indexOf(b[c].id)?b[c].remClass("hidden"):b[c].addClass("hidden")}})},!1);for(var i=0;i<section.view.link.edit.length;i++)section.view.link.edit[i].addEventListener("click", ".add-group[data-machine]")};section.view.searchbar.addEventListener("keyup",function(a){api.send({path:"machineDefault/search",keywords:section.view.searchbar.value},function(b){if(0==b.ModuleError){for(var a=[],c=0;c<b.machines.length;c++)a.push(b.machines[c].id_machine);b=document.querySelectorAll(section.view.text+"> article.inline-box[id]");for(c=0;c<b.length;c++)-1<a.indexOf(b[c].id)?b[c].remClass("hidden"):b[c].addClass("hidden")}})},!1);for(var i=0;i<section.view.link.edit.length;i++)section.view.link.edit[i].addEventListener("click",
function(a){pageManager.vars[1]=a.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(a){pageManager.vars[1]=a.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(a){var b={path:"machineDefault/unlink",id_machine:a.target.getData("machine"), 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")};
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)} 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!"),pageManager.vars=["view",a.id_machine],pageManager.refresh(),document.location="",section.create.input.submit.anim("active", 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!"),pageManager.vars=["view",a.id_machine],pageManager.refresh(),document.location="",section.create.input.submit.anim("active",
1500))})},!1)); 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"), 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= 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+ "",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&& 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),autofill_remove(null)):console.error("ModuleError::"+a.ModuleError)})},!1)} 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),pageManager.vars[1]="",navSubMenu("view"),document.location=""):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"), 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=[], 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(); 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();

View File

@ -88,8 +88,8 @@ 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('machine'); pageManager.vars[1] = e.target.getData('machine');
autofill_edit(pageManager.vars[1]);
navSubMenu('edit'); navSubMenu('edit');
document.location = '';
}, false); }, false);
} }
@ -99,8 +99,8 @@ 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('machine'); pageManager.vars[1] = e.target.getData('machine');
autofill_remove(pageManager.vars[1]);
navSubMenu('remove'); navSubMenu('remove');
document.location = '';
}, false); }, false);
} }
@ -369,8 +369,11 @@ if( section.remove.element != null ){
console.log('Machine supprimee!'); console.log('Machine supprimee!');
section.remove.input.submit.anim('active', 1500); section.remove.input.submit.anim('active', 1500);
// On vide le formulaire
autofill_remove(null); pageManager.vars[1] = '';
navSubMenu('view');
document.location = '';
}else // Erreur }else // Erreur
console.error('ModuleError::'+answer.ModuleError); console.error('ModuleError::'+answer.ModuleError);
}); });