- [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/users] Recherche instantanee
- [ ] [view/js/machines] Modification de machine
########
# FAIT #
########
- [x] [view/js/machines] Modification de machine
- [x] [machineDefault] Implementer la modification
- [x] [userDefault] Implementer la modification
- [x] [userRepo] Gestion des parametres optionnels

View File

@ -232,7 +232,7 @@ if( section.edit.element != null ){
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'),
@ -248,17 +248,28 @@ if( section.edit.element != null ){
api.send({path:'machineDefault/getById', data: [id_machine]}, function(answer){
if( answer.ModuleError == 0 ){ // Aucune erreur
machine_data = answer.machine;
// Auto-remplissage du formulaire
section.edit.input.code.value = machine_data.code;
section.edit.input.name.value = machine_data.name;
}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
section.edit.input.code.value = machine_data.code;
section.edit.input.name.value = machine_data.name;
});
}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 searchindex = 0;
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 != '' ){
// Redaction de la requete
var getuid = {
path: 'userDefault/search',
path: 'machineDefault/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)
if( uidanswer.ModuleError == 0 && uidanswer.machines.length > 0 ){ // si on a trouve qqch
// Si on trouve la meme machine que lors de la derniere recherche
if( lastsearch == uidanswer.machines[searchindex].id_machine )
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;
// on auto-remplit le formulaire
autofill_edit(lastsearch);
}else{
}else
autofill_edit(null);
}
});
}