Commit d05253a9 authored by Mat's avatar Mat
Browse files

submit form et bouton delete + correction controller

parent 1c04e218
...@@ -101,8 +101,8 @@ class MembreAPIController extends MasterAPIController ...@@ -101,8 +101,8 @@ class MembreAPIController extends MasterAPIController
$membre = $em->getRepository('AssoBundle:Membre')->findOneForAPIDelete($id); $membre = $em->getRepository('AssoBundle:Membre')->findOneForAPIDelete($id);
if ($membre !== null) { if ($membre !== null) {
$em->remove(); $em->remove($membre);
$em->flush; $em->flush();
} }
return $this->api([]); return $this->api([]);
} }
......
...@@ -130,11 +130,25 @@ ...@@ -130,11 +130,25 @@
}); });
td6.appendChild(editBtn); td6.appendChild(editBtn);
let deleteBtn = document.createElement('button');
deleteBtn.innerHTML = '<i class="fas fa-trash fa-fw"></i> Supprimer';
deleteBtn.classList.add('btn', 'btn-danger', 'btn-sm');
deleteBtn.dataset.membreId = json[i].id;
deleteBtn.addEventListener('click', function(e)
{
let membreId = this.dataset.membreId;
let r = confirm('Are you sure ?');
if (r === true) {
submitURL = Routing.generate('api_membre_delete', {'id': membreId });
AJAX('DELETE', submitURL, function()
{
reloadTableMembre();
});
}
});
td6.appendChild(deleteBtn);
tr.appendChild(td6); tr.appendChild(td6);
tbody.appendChild(tr); tbody.appendChild(tr);
} }
...@@ -146,8 +160,8 @@ ...@@ -146,8 +160,8 @@
let reloadBtns = document.querySelectorAll('.btn-reload'); let reloadBtns = document.querySelectorAll('.btn-reload');
reloadBtns.forEach(function(reloadBtn) { reloadBtns.forEach(function(reloadBtn) {
reloadBtn.addEventListener('dblclick', function(e) { reloadBtn.addEventListener('dblclick', function(e)
console.log('refresh'); {
reloadTableMembre(); reloadTableMembre();
}); });
}); });
...@@ -166,6 +180,18 @@ ...@@ -166,6 +180,18 @@
}); });
}); });
form.addEventListener('submit', function(e)
{
let form = this;
e.preventDefault;
AJAX('POST', submitURL, function()
{
reloadTableMembre();
form.parentNode.classList.add('hidden');
},
form);
});
</script> </script>
{% endblock %} {% endblock %}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment