diff --git a/todo.md b/todo.md index ff50332..dce7bc0 100755 --- a/todo.md +++ b/todo.md @@ -11,9 +11,6 @@ - [ ] [view/js/machines] Recherche instantanee -- [x] [userDefault] Implementer la modification - - [ ] [userRepo] Gestion des parametres optionnels - - [ ] [view/users] Gestion des parametres optionnels physiques -> separer la selection et modification - [ ] [machineDefault] Implementer la modification - [ ] [view/js/machines] Modification de machine @@ -22,6 +19,9 @@ ######## # FAIT # ######## +- [x] [userDefault] Implementer la modification + - [x] [userRepo] Gestion des parametres optionnels + - [x] [view/users] Gestion des parametres optionnels physiques -> separer la selection et modification - [x] [machineDefault] Implementation de la recherche - [x] [view/js/users] Recherche instantanee - [x] [userDefault] Implementation de la recherche diff --git a/view/js/machines.js b/view/js/machines.js index b4c8df7..ed26921 100644 --- a/view/js/machines.js +++ b/view/js/machines.js @@ -39,7 +39,7 @@ if( section.view.element != null ){ section.view.link.edit[i].addEventListener('click', function(e){ pageManager.vars[1] = e.target.getData('machine'); - autofill_edit(); + autofill_edit(pageManager.vars[1]); navSubMenu('edit'); }, false); @@ -50,7 +50,7 @@ if( section.view.element != null ){ section.view.link.remove[i].addEventListener('click', function(e){ pageManager.vars[1] = e.target.getData('machine'); - autofill_remove(); + autofill_remove(pageManager.vars[1]); navSubMenu('remove'); }, false); @@ -147,11 +147,11 @@ if( section.remove.element != null ){ // Gestion de l'auto-remplissage par lien - function autofill_remove(){ if( pageManager.vars.length >= 2 && !isNaN(pageManager.vars[1]) ){ + function autofill_remove(id_machine){ // On recupere le code + name de la machine selectionnee var machine_data = null; - api.send({path:'machineDefault/getById', data: [pageManager.vars[1]]}, function(answer){ + api.send({path:'machineDefault/getById', data: [id_machine]}, function(answer){ if( answer.ModuleError == 0 ){ // Aucune erreur machine_data = answer.machine; @@ -160,7 +160,7 @@ if( section.remove.element != null ){ section.remove.input.name.value = machine_data.name; } }); - }}autofill_remove(); + }if( pageManager.vars.length >= 2 && !isNaN(pageManager.vars[1]) ) autofill_remove(pageManager.vars[1]); @@ -227,6 +227,12 @@ if( section.edit.element != null ){ // Definition des champs section.edit.input = { + search: { + 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'), name: document.querySelector(section.edit.text + '#edit_name'), @@ -235,11 +241,11 @@ if( section.edit.element != null ){ // Gestion de l'auto-remplissage par lien - function autofill_edit(){ if( pageManager.vars.length >= 2 && !isNaN(pageManager.vars[1]) ){ + function autofill_edit(id_machine){ // On recupere le code + name de la machine selectionnee var machine_data = null; - api.send({path:'machineDefault/getById', data: [pageManager.vars[1]]}, function(answer){ + api.send({path:'machineDefault/getById', data: [id_machine]}, function(answer){ if( answer.ModuleError == 0 ){ // Aucune erreur machine_data = answer.machine; @@ -248,6 +254,48 @@ if( section.edit.element != null ){ section.edit.input.name.value = machine_data.name; } }); - }}autofill_edit(); + }if( pageManager.vars.length >= 2 && !isNaN(pageManager.vars[1]) ) autofill_edit(pageManager.vars[1]); + + + + /* (2) Gestion de la recherche de l'utilisateur */ + var lastsearch = null; + var searchindex = 0; + section.edit.input.search.submit.addEventListener('click', function(e){ + // On annule l'envoi de base (PHP) + e.preventDefault(); + + // Si le champ n'est pas vide, on lance la recherche + if( section.edit.input.search.keyword.value != '' ){ + // Redaction de la requete + var getuid = { + path: 'userDefault/search', + data: [section.edit.input.search.keyword.value] + }; + + // On envoie la requete + api.send(getuid, function(uidanswer){ + if( uidanswer.ModuleError == 0 && uidanswer.users.length > 0 ){ // si on a trouve qqch + // Si on trouve le meme utilisateur que lors de la derniere recherche + if( lastsearch == uidanswer.users[searchindex].id_user ) + searchindex = (searchindex+1) % uidanswer.users.length; // on affiche le prochain (decalage cyclique) + + lastsearch = uidanswer.users[searchindex].id_user; + section.edit.input.search.id.value = lastsearch; + // on auto-remplit le formulaire + autofill_edit(lastsearch); + + }else{ + autofill_edit(null); + } + }); + } + + }, false); + + + + + } \ No newline at end of file diff --git a/view/machines.php b/view/machines.php index 764ffc6..5c8b329 100755 --- a/view/machines.php +++ b/view/machines.php @@ -188,6 +188,10 @@ echo "
"; echo "
"; + echo "
"; + echo "
"; + echo "


"; + echo "
"; echo "
"; echo "";