diff --git a/view/js/groups-min.js b/view/js/groups-min.js index 722c450..8da873b 100644 --- a/view/js/groups-min.js +++ b/view/js/groups-min.js @@ -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 article.inline-box[id]");for(b=0;b article.inline-box[id]");for(c=0;c 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; diff --git a/view/js/machines-min.js b/view/js/machines-min.js index 0bc7897..837ce8f 100644 --- a/view/js/machines-min.js +++ b/view/js/machines-min.js @@ -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 article.inline-box[id]");for(c=0;c article.inline-box[id]");for(c=0;c 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 diff --git a/view/js/users-min.js b/view/js/users-min.js index bb78680..5b814d8 100644 --- a/view/js/users-min.js +++ b/view/js/users-min.js @@ -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 article.inline-box[id]");for(b=0;b article.inline-box[id]");for(b=0;b 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