Commit d05253a9 authored by Mat's avatar Mat

submit form et bouton delete + correction controller

parent 1c04e218
......@@ -101,8 +101,8 @@ class MembreAPIController extends MasterAPIController
$membre = $em->getRepository('AssoBundle:Membre')->findOneForAPIDelete($id);
if ($membre !== null) {
$em->remove();
$em->flush;
$em->remove($membre);
$em->flush();
}
return $this->api([]);
}
......
......@@ -130,11 +130,25 @@
});
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);
tbody.appendChild(tr);
}
......@@ -146,8 +160,8 @@
let reloadBtns = document.querySelectorAll('.btn-reload');
reloadBtns.forEach(function(reloadBtn) {
reloadBtn.addEventListener('dblclick', function(e) {
console.log('refresh');
reloadBtn.addEventListener('dblclick', function(e)
{
reloadTableMembre();
});
});
......@@ -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>
{% 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