- [x] [userDefault] Implementer la modification
- [x] [userRepo] Gestion des parametres optionnels - [x] [view/users] Gestion des parametres optionnels physiques -> separer la selection et modification
This commit is contained in:
parent
df0df43916
commit
8d9e5a0b12
6
todo.md
6
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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -188,6 +188,10 @@
|
|||
echo "<section data-sublink='edit'>";
|
||||
|
||||
echo "<form class='neutral'>";
|
||||
echo "<input id='edit_search_keyword' type='text' class='search' placeholder='Recherche...'><br>";
|
||||
echo "<input id='edit_search_id' type='hidden' value=''><br>";
|
||||
echo "<button id='edit_search_submit' class='search'>Trouver</button><br><br><br>";
|
||||
|
||||
echo "<input id='edit_code' type='text' placeholder='Code'><br>";
|
||||
echo "<input id='edit_name' type='text' placeholder='Name'><br>";
|
||||
echo "<button id='edit_submit'>Modifier</button>";
|
||||
|
|
Loading…
Reference in New Issue