- [x] [view/js/machines] Modification de machine

This commit is contained in:
xdrm-brackets 2016-02-16 14:42:48 +01:00
parent 8abbf00c15
commit 0496fc33f6
2 changed files with 25 additions and 15 deletions

View File

@ -12,12 +12,12 @@
- [ ] [view/js/machines] Recherche instantanee - [ ] [view/js/machines] Recherche instantanee
- [ ] [view/js/users] Recherche instantanee - [ ] [view/js/users] Recherche instantanee
- [ ] [view/js/machines] Modification de machine
######## ########
# FAIT # # FAIT #
######## ########
- [x] [view/js/machines] Modification de machine
- [x] [machineDefault] Implementer la modification - [x] [machineDefault] Implementer la modification
- [x] [userDefault] Implementer la modification - [x] [userDefault] Implementer la modification
- [x] [userRepo] Gestion des parametres optionnels - [x] [userRepo] Gestion des parametres optionnels

View File

@ -249,16 +249,27 @@ if( section.edit.element != null ){
if( answer.ModuleError == 0 ){ // Aucune erreur if( answer.ModuleError == 0 ){ // Aucune erreur
machine_data = answer.machine; machine_data = answer.machine;
}else{ // Si erreuron utilise un jeu de donnees vides
machine_data = {
id_machine: '',
code: '',
name: ''
};
}
// On enregistre l'UID de la machine
section.edit.input.search.id.value = machine_data.id_machine;
// Auto-remplissage du formulaire // Auto-remplissage du formulaire
section.edit.input.code.value = machine_data.code; section.edit.input.code.value = machine_data.code;
section.edit.input.name.value = machine_data.name; section.edit.input.name.value = machine_data.name;
}
}); });
}if( pageManager.vars.length >= 2 && !isNaN(pageManager.vars[1]) ) autofill_edit(pageManager.vars[1]); }if( pageManager.vars.length >= 2 && !isNaN(pageManager.vars[1]) ) autofill_edit(pageManager.vars[1]);
/* (2) Gestion de la recherche de l'utilisateur */ /* (2) Gestion de la recherche de la machine */
var lastsearch = null; var lastsearch = null;
var searchindex = 0; var searchindex = 0;
section.edit.input.search.submit.addEventListener('click', function(e){ section.edit.input.search.submit.addEventListener('click', function(e){
@ -269,25 +280,24 @@ if( section.edit.element != null ){
if( section.edit.input.search.keyword.value != '' ){ if( section.edit.input.search.keyword.value != '' ){
// Redaction de la requete // Redaction de la requete
var getuid = { var getuid = {
path: 'userDefault/search', path: 'machineDefault/search',
data: [section.edit.input.search.keyword.value] data: [section.edit.input.search.keyword.value]
}; };
// On envoie la requete // On envoie la requete
api.send(getuid, function(uidanswer){ api.send(getuid, function(uidanswer){
if( uidanswer.ModuleError == 0 && uidanswer.users.length > 0 ){ // si on a trouve qqch if( uidanswer.ModuleError == 0 && uidanswer.machines.length > 0 ){ // si on a trouve qqch
// Si on trouve le meme utilisateur que lors de la derniere recherche // Si on trouve la meme machine que lors de la derniere recherche
if( lastsearch == uidanswer.users[searchindex].id_user ) if( lastsearch == uidanswer.machines[searchindex].id_machine )
searchindex = (searchindex+1) % uidanswer.users.length; // on affiche le prochain (decalage cyclique) searchindex = (searchindex+1) % uidanswer.machines.length; // on affiche le prochain (decalage cyclique)
lastsearch = uidanswer.users[searchindex].id_user; lastsearch = uidanswer.machines[searchindex].id_machine;
section.edit.input.search.id.value = lastsearch; section.edit.input.search.id.value = lastsearch;
// on auto-remplit le formulaire // on auto-remplit le formulaire
autofill_edit(lastsearch); autofill_edit(lastsearch);
}else{ }else
autofill_edit(null); autofill_edit(null);
}
}); });
} }