- [x] [view/js/machines] Modification de machine
This commit is contained in:
parent
8abbf00c15
commit
0496fc33f6
2
todo.md
2
todo.md
|
@ -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
|
||||||
|
|
|
@ -232,7 +232,7 @@ if( section.edit.element != null ){
|
||||||
id: document.querySelector(section.edit.text + '#edit_search_id'),
|
id: document.querySelector(section.edit.text + '#edit_search_id'),
|
||||||
submit: document.querySelector(section.edit.text + '#edit_search_submit')
|
submit: document.querySelector(section.edit.text + '#edit_search_submit')
|
||||||
},
|
},
|
||||||
|
|
||||||
code: document.querySelector(section.edit.text + '#edit_code'),
|
code: document.querySelector(section.edit.text + '#edit_code'),
|
||||||
name: document.querySelector(section.edit.text + '#edit_name'),
|
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){
|
api.send({path:'machineDefault/getById', data: [id_machine]}, function(answer){
|
||||||
if( answer.ModuleError == 0 ){ // Aucune erreur
|
if( answer.ModuleError == 0 ){ // Aucune erreur
|
||||||
machine_data = answer.machine;
|
machine_data = answer.machine;
|
||||||
|
|
||||||
// Auto-remplissage du formulaire
|
}else{ // Si erreuron utilise un jeu de donnees vides
|
||||||
section.edit.input.code.value = machine_data.code;
|
machine_data = {
|
||||||
section.edit.input.name.value = machine_data.name;
|
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]);
|
}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);
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue