- [x] [view/js/machines] Implementer la recherche pour la suppression
This commit is contained in:
parent
71708949da
commit
0767632aab
File diff suppressed because one or more lines are too long
|
@ -406,7 +406,7 @@
|
|||
}
|
||||
|
||||
// "OU" separant les boutons
|
||||
hr.OR{
|
||||
hr.OR[data-label]{
|
||||
display: block;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
|
@ -416,7 +416,7 @@
|
|||
border-bottom: 1px dashed $form-invalid-color;
|
||||
|
||||
&:before{
|
||||
content: 'OU';
|
||||
content: attr(data-label);
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
top: 50%;
|
||||
|
|
4
todo.md
4
todo.md
|
@ -7,7 +7,8 @@
|
|||
############
|
||||
# EN COURS #
|
||||
############
|
||||
- [ ] [container.scss] Icone dans bouton quand succes sur l'operation
|
||||
- [ ] [view/js/users] Implementer la recherche pour la suppression
|
||||
- [ ] [container.scss] Icone dans bouton quand succes sur l'operation
|
||||
|
||||
- [ ] [view/users][view/js/users.js] Suppression avec recherche comme pour la modification
|
||||
- [ ] [view/machines][view/js/machines.js] Suppression avec recherche comme pour la modification
|
||||
|
@ -16,6 +17,7 @@
|
|||
########
|
||||
# FAIT #
|
||||
########
|
||||
- [x] [view/js/machines] Implementer la recherche pour la suppression
|
||||
- [x] Nettoyage git
|
||||
- [x] [ResourceDispatcher] Gestion de la coloration de svg
|
||||
- [x] [src/*.svg] Modification des svg (attribution des ID)
|
||||
|
|
|
@ -174,8 +174,14 @@ if( section.create.element != null ){
|
|||
=========================================================*/
|
||||
if( section.remove.element != null ){
|
||||
|
||||
// Definition des champs
|
||||
/* (1) Definition des champs */
|
||||
section.remove.input = {
|
||||
search: {
|
||||
keyword: document.querySelector(section.remove.text + '#remove_search_keyword'),
|
||||
id: document.querySelector(section.remove.text + '#remove_search_id'),
|
||||
submit: document.querySelector(section.remove.text + '#remove_search_submit')
|
||||
},
|
||||
|
||||
code: document.querySelector(section.remove.text + '#remove_code'),
|
||||
name: document.querySelector(section.remove.text + '#remove_name'),
|
||||
|
||||
|
@ -183,68 +189,98 @@ if( section.remove.element != null ){
|
|||
};
|
||||
|
||||
|
||||
// Gestion de l'auto-remplissage par lien
|
||||
/* (2) Gestion de l'auto-remplissage par lien */
|
||||
function autofill_remove(id_machine){
|
||||
// On recupere le code + name de la machine selectionnee
|
||||
var machine_data = null;
|
||||
var machine_data = machine_data = {
|
||||
id_machine: '',
|
||||
code: '',
|
||||
name: '',
|
||||
disable_input: true
|
||||
};
|
||||
|
||||
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.remove.input.code.value = machine_data.code;
|
||||
section.remove.input.name.value = machine_data.name;
|
||||
machine_data.diable_input = false;
|
||||
}
|
||||
|
||||
// Auto-remplissage du formulaire
|
||||
section.remove.input.code.value = machine_data.code;
|
||||
section.remove.input.name.value = machine_data.name;
|
||||
|
||||
// On gere le caractere "inactif" du submit
|
||||
section.remove.input.submit.disabled = machine_data.disable_input;
|
||||
});
|
||||
}if( pageManager.vars.length >= 2 && !isNaN(pageManager.vars[1]) ) autofill_remove(pageManager.vars[1]);
|
||||
|
||||
|
||||
|
||||
/* (3) Gestion de la recherche */
|
||||
var lastsearch_remove = null;
|
||||
var searchindex_remove = 0;
|
||||
section.remove.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.remove.input.search.keyword.value != '' ){
|
||||
// Redaction de la requete
|
||||
var getuid = {
|
||||
path: 'machineDefault/search',
|
||||
data: [section.remove.input.search.keyword.value]
|
||||
};
|
||||
|
||||
// On envoie la requete
|
||||
api.send(getuid, function(uidanswer){
|
||||
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_remove == uidanswer.machines[searchindex_remove].id_machine )
|
||||
searchindex_remove = (searchindex_remove+1) % uidanswer.machines.length; // on affiche le prochain (decalage cyclique)
|
||||
|
||||
lastsearch_remove = uidanswer.machines[searchindex_remove].id_machine;
|
||||
section.remove.input.search.id.value = lastsearch_remove;
|
||||
// on auto-remplit le formulaire
|
||||
autofill_remove(lastsearch_remove);
|
||||
|
||||
}else
|
||||
autofill_remove(null);
|
||||
});
|
||||
}
|
||||
|
||||
}, false);
|
||||
|
||||
|
||||
|
||||
/* (n) Gestion de l'envoi du formulaire */
|
||||
section.remove.input.submit.addEventListener('click', function(e){
|
||||
// On annule l'envoi de base (PHP)
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
|
||||
/* (1) On recupere l'UID de la machine */
|
||||
var getuid = {};
|
||||
|
||||
// Si l'id est defini
|
||||
if( section.remove.input.search.id.value != '' ){
|
||||
|
||||
// recuperation par CODE
|
||||
if( section.remove.input.code.value != '' ){
|
||||
getuid.path = 'machineDefault/getByCode';
|
||||
getuid.data = [section.remove.input.code.value];
|
||||
/* (2) On supprime la machine */
|
||||
var request = {
|
||||
path: 'machineDefault/delete', // On veut supprimer cet utilisateur
|
||||
data: [section.remove.input.search.id.value]
|
||||
};
|
||||
|
||||
api.send(request, function(answer){
|
||||
if( answer.ModuleError == 0 && answer.status == true ){ // Tout s'est bien deroule
|
||||
console.log('Machine supprimee!');
|
||||
|
||||
// On vide le formulaire
|
||||
autofill_remove(null);
|
||||
}else // Erreur
|
||||
console.error('ModuleError::'+answer.ModuleError);
|
||||
});
|
||||
|
||||
// recuperation par NAME
|
||||
}else if( section.remove.input.name.value != '' ){
|
||||
getuid.path = 'machineDefault/getByName';
|
||||
getuid.data = [section.remove.input.name.value];
|
||||
}
|
||||
|
||||
// On envoie la requete de demande d'uid
|
||||
api.send(getuid, function(uid_answer){
|
||||
if( uid_answer.ModuleError == 0 ){ // Si aucune erreur
|
||||
|
||||
/* (2) On supprime la machine */
|
||||
var request = {
|
||||
path: 'machineDefault/delete', // On veut supprimer cet utilisateur
|
||||
data: [uid_answer.machine.id_machine]
|
||||
};
|
||||
|
||||
api.send(request, function(answer){
|
||||
if( answer.ModuleError == 0 && answer.status == true ) // Tout s'est bien deroule
|
||||
console.log('Machine supprimee!');
|
||||
else // Erreur
|
||||
console.error('ModuleError::'+answer.ModuleError);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}, false);
|
||||
|
||||
}
|
||||
|
@ -313,8 +349,8 @@ if( section.edit.element != null ){
|
|||
|
||||
|
||||
/* (2) Gestion de la recherche de la machine */
|
||||
var lastsearch = null;
|
||||
var searchindex = 0;
|
||||
var lastsearch_edit = null;
|
||||
var searchindex_edit = 0;
|
||||
section.edit.input.search.submit.addEventListener('click', function(e){
|
||||
// On annule l'envoi de base (PHP)
|
||||
e.preventDefault();
|
||||
|
@ -331,13 +367,13 @@ if( section.edit.element != null ){
|
|||
api.send(getuid, function(uidanswer){
|
||||
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)
|
||||
if( lastsearch_edit == uidanswer.machines[searchindex_edit].id_machine )
|
||||
searchindex_edit = (searchindex_edit+1) % uidanswer.machines.length; // on affiche le prochain (decalage cyclique)
|
||||
|
||||
lastsearch = uidanswer.machines[searchindex].id_machine;
|
||||
section.edit.input.search.id.value = lastsearch;
|
||||
lastsearch_edit = uidanswer.machines[searchindex_edit].id_machine;
|
||||
section.edit.input.search.id.value = lastsearch_edit;
|
||||
// on auto-remplit le formulaire
|
||||
autofill_edit(lastsearch);
|
||||
autofill_edit(lastsearch_edit);
|
||||
|
||||
}else
|
||||
autofill_edit(null);
|
||||
|
|
|
@ -158,8 +158,13 @@
|
|||
echo "<section data-sublink='remove'>";
|
||||
|
||||
echo "<form class='invalid'>";
|
||||
echo "<input id='remove_code' type='text' placeholder='Code'><br>";
|
||||
echo "<hr class='OR' />";
|
||||
echo "<input id='remove_search_keyword' type='text' class='search' placeholder='Recherche...'><br>";
|
||||
echo "<input id='remove_search_id' type='hidden' value=''><br>";
|
||||
echo "<button id='remove_search_submit' class='search'>Trouver</button><br>";
|
||||
|
||||
echo "<br><br><hr class='OR' data-label='PUIS' /><br><br>";
|
||||
|
||||
echo "<input id='remove_code' type='text' placeholder='CO-DE-RF-ID'><br>";
|
||||
echo "<input id='remove_name' type='text' placeholder='Name'><br>";
|
||||
echo "<button id='remove_submit'>Supprimer</button>";
|
||||
echo "</form>";
|
||||
|
@ -184,7 +189,9 @@
|
|||
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 "<button id='edit_search_submit' class='search'>Trouver</button><br>";
|
||||
|
||||
echo "<br><br><hr class='OR' data-label='PUIS' /><br><br>";
|
||||
|
||||
echo "<input id='edit_code' type='text' placeholder='Code'><br>";
|
||||
echo "<input id='edit_name' type='text' placeholder='Name'><br>";
|
||||
|
|
|
@ -173,12 +173,14 @@
|
|||
echo "<section data-sublink='remove'>";
|
||||
|
||||
echo "<form class='invalid'>";
|
||||
echo "<input id='remove_id' type='hidden' value=''><br>";
|
||||
echo "<input id='remove_code' type='text' placeholder='Code'><br>";
|
||||
echo "<hr class='OR' />";
|
||||
echo "<input id='remove_username' type='text' placeholder='Username'><br>";
|
||||
echo "<input id='remove_search_keyword' type='text' class='search' placeholder='Recherche...'><br>";
|
||||
echo "<input id='remove_search_id' type='hidden' value=''><br>";
|
||||
echo "<button id='remove_search_submit' class='search'>Trouver</button><br>";
|
||||
|
||||
echo "<button id='remove_search' class='search'>Rechercher</button><br><br>";
|
||||
echo "<br><br><hr class='OR' data-label='PUIS' /><br><br>";
|
||||
|
||||
echo "<input id='remove_code' type='text' placeholder='Code'><br>";
|
||||
echo "<input id='remove_username' type='text' placeholder='Username'><br>";
|
||||
echo "<button id='remove_submit' disabled>Supprimer</button>";
|
||||
echo "</form>";
|
||||
|
||||
|
@ -202,7 +204,9 @@
|
|||
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 "<button id='edit_search_submit' class='search'>Trouver</button><br>";
|
||||
|
||||
echo "<br><br><hr class='OR' data-label='PUIS' /><br><br>";
|
||||
|
||||
echo "<input id='edit_code' type='text' placeholder='CO-DE-RF-ID'><br>";
|
||||
echo "<input id='edit_username' type='text' placeholder='Username'><br>";
|
||||
|
|
Loading…
Reference in New Issue