Commit 6ac102da authored by Mat's avatar Mat
Browse files

un bouton dupliquer, ouvre une modale comme pour delete

parent a61744a9
<div class="modal modal-{{ legume.id }} fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal fade" id="delmodal-{{ legume.id }}"
tabindex="-1" role="dialog" aria-labelledby="DeleteModal" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
......
<div class="modal fade" id="dupmodal-{{ legume.id }}"
tabindex="-1" role="dialog" aria-labelledby="DuplicateModal" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Dupliquer la rangée n°{{ legume.id }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<p>Un nouvel élément va être créé. Souhaitez-vous continuer ?</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Annuler</button>
<a class="btn btn-danger" role="button" href="">
Oui, effacer !
</a>
</div>
</div>
</div>
</div>
......@@ -44,15 +44,22 @@
<td>{{ legume.quantiteStep }}</td>
<td>{{ legume.prixUnitaire }} €/{{ legume.unite }}</td>
<td>
<a class="btn btn-primary btn-sm" role="button" href="{{ path('potage_legume_update', {'id': legume.id }) }}">Editer</a>
<a class="btn btn-danger btn-sm" role="button" href="#" id="btn-{{ legume.id }}">Effacer</a>
<a class="btn btn-primary btn-sm" role="button" href="{{ path('potage_legume_update', {'id': legume.id }) }}" title="Editer">
<i class="fas fa-edit fa-fw"></i></a>
<a class="btn btn-primary btn-sm btn-modal" role="button" href="#" id="dup-{{ legume.id }}" title="Dupliquer">
<i class="fas fa-clone fa-fw"></i></a>
{% include '@Potage/Legume/duplicate-modal.html.twig' %}
<a class="btn btn-danger btn-sm btn-modal" role="button" href="#" id="del-{{ legume.id }}" title="Effacer">
<i class="fas fa-trash-alt fa-fw"></i></a>
{% include '@Potage/Legume/delete-modal.html.twig' %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<nav aria-label="Page navigation">
<ul class="pagination justify-content-center">
{#<li class="page-item disabled">
......@@ -67,10 +74,10 @@
</li>
{% endfor %}
{#<li class="page-item">
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
<span class="sr-only">Suivant</span>
</a>
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
<span class="sr-only">Suivant</span>
</a>
</li>#}
</ul>
</nav>
......
......@@ -2,13 +2,18 @@
// 1
// Modale de confirmation avant effacement
let dropbtns = document.querySelectorAll("table.table a.btn-danger:not(.disabled)");
for (let bouton of dropbtns)
let modal_boutons = document.querySelectorAll("table.table a.btn-modal:not(.disabled)");
for (let bouton of modal_boutons)
{
if (bouton.getAttribute('id') !== null) {
let id = bouton.getAttribute('id').replace("btn-", "");
let gid = bouton.getAttribute('id');
if (gid !== null) {
bouton.addEventListener("click", function() {
$('.modal-' + id ).modal({
id = gid.replace("dup-", "");
$('#dupmodal-' + id ).modal({
focus: true
});
id = gid.replace("del-", "");
$('#delmodal-' + id ).modal({
focus: true
});
});
......
Supports Markdown
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