|
|
|
@ -22,6 +22,7 @@ |
|
|
|
<table id="coureursTable" class="table table-bordered table-striped"> |
|
|
|
<table id="coureursTable" class="table table-bordered table-striped"> |
|
|
|
<thead> |
|
|
|
<thead> |
|
|
|
<tr> |
|
|
|
<tr> |
|
|
|
|
|
|
|
<th class="select-checkbox"></th> |
|
|
|
<th>Nom</th> |
|
|
|
<th>Nom</th> |
|
|
|
<th>Prénom</th> |
|
|
|
<th>Prénom</th> |
|
|
|
<th>Classe</th> |
|
|
|
<th>Classe</th> |
|
|
|
@ -30,6 +31,7 @@ |
|
|
|
<tbody> |
|
|
|
<tbody> |
|
|
|
{% for c in coureurs %} |
|
|
|
{% for c in coureurs %} |
|
|
|
<tr data-id="{{ c.id }}"> |
|
|
|
<tr data-id="{{ c.id }}"> |
|
|
|
|
|
|
|
<td class="select-checkbox"></td> |
|
|
|
<td>{{ c.nom }}</td> |
|
|
|
<td>{{ c.nom }}</td> |
|
|
|
<td>{{ c.prenom }}</td> |
|
|
|
<td>{{ c.prenom }}</td> |
|
|
|
<td>{{ c.classe }}</td> |
|
|
|
<td>{{ c.classe }}</td> |
|
|
|
@ -90,38 +92,92 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<style> |
|
|
|
|
|
|
|
.dt-select-info span:contains('colonne'), |
|
|
|
|
|
|
|
.dt-select-info span:contains('cellule') { |
|
|
|
|
|
|
|
display: none !important; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
table.dataTable tbody td.select-checkbox { |
|
|
|
|
|
|
|
cursor: pointer; |
|
|
|
|
|
|
|
position: relative; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
table.dataTable tr.selected td.select-checkbox:after { |
|
|
|
|
|
|
|
content: '\2714'; |
|
|
|
|
|
|
|
position: absolute; |
|
|
|
|
|
|
|
top: 50%; |
|
|
|
|
|
|
|
left: 50%; |
|
|
|
|
|
|
|
transform: translate(-50%, -50%); |
|
|
|
|
|
|
|
color: #007bff; |
|
|
|
|
|
|
|
font-size: 1.2em; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
</style> |
|
|
|
|
|
|
|
<link rel="stylesheet" href="{% static 'datatables/select.dataTables.min.css' %}" /> |
|
|
|
{% block extra_js %} |
|
|
|
{% block extra_js %} |
|
|
|
<script src="{% static 'jquery/jquery-3.6.0.min.js' %}"></script> |
|
|
|
<script src="{% static 'jquery/jquery-3.6.0.min.js' %}"></script> |
|
|
|
<script src="{% static 'bootstrap/bootstrap.bundle.min.js' %}"></script> |
|
|
|
<script src="{% static 'bootstrap/bootstrap.bundle.min.js' %}"></script> |
|
|
|
<script src="{% static 'jquery/jquery.dataTables.min.js' %}"></script> |
|
|
|
<script src="{% static 'jquery/jquery.dataTables.min.js' %}"></script> |
|
|
|
<script src="{% static 'bootstrap/dataTables.bootstrap4.min.js' %}"></script> |
|
|
|
<script src="{% static 'bootstrap/dataTables.bootstrap4.min.js' %}"></script> |
|
|
|
|
|
|
|
<script src="{% static 'datatables/dataTables.select.min.js' %}"></script> |
|
|
|
<script src="{% static 'jquery/datatables.fr.js' %}"></script> |
|
|
|
<script src="{% static 'jquery/datatables.fr.js' %}"></script> |
|
|
|
<script> |
|
|
|
<script> |
|
|
|
$(document).ready(function() { |
|
|
|
$(function() { |
|
|
|
// Empêche la double initialisation de DataTables |
|
|
|
|
|
|
|
var table; |
|
|
|
|
|
|
|
if (!$.fn.DataTable.isDataTable('#coureursTable')) { |
|
|
|
if (!$.fn.DataTable.isDataTable('#coureursTable')) { |
|
|
|
table = $('#coureursTable').DataTable({ |
|
|
|
var table = $('#coureursTable').DataTable({ |
|
|
|
pageLength: 50, |
|
|
|
pageLength: 50, |
|
|
|
|
|
|
|
initComplete: function (settings, json) { |
|
|
|
|
|
|
|
table.rows().select(); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
select: { |
|
|
|
|
|
|
|
style: 'multi', |
|
|
|
|
|
|
|
selector: 'td.select-checkbox' |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
info: false, |
|
|
|
|
|
|
|
order: [[1, 'asc']], |
|
|
|
|
|
|
|
columnDefs: [ |
|
|
|
|
|
|
|
{ orderable: false, className: 'select-checkbox', targets: 0 } |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
language: { |
|
|
|
|
|
|
|
url: "https://cdn.datatables.net/plug-ins/1.13.7/i18n/fr-FR.json" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Sélection/désélection totale via l'entête (exemple officiel) |
|
|
|
|
|
|
|
$('#coureursTable thead').on('click', 'th.select-checkbox', function() { |
|
|
|
|
|
|
|
if (table.rows({selected: true, search:'applied'}).count() === table.rows({search:'applied'}).count()) { |
|
|
|
|
|
|
|
table.rows({search:'applied'}).deselect(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
table.rows({search:'applied'}).select(); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Sélection individuelle par clic sur la case (exemple officiel) |
|
|
|
|
|
|
|
$('#coureursTable tbody').on('click', 'td.select-checkbox', function(e) { |
|
|
|
|
|
|
|
e.stopPropagation(); |
|
|
|
|
|
|
|
var row = table.row($(this).closest('tr')); |
|
|
|
|
|
|
|
if (row.selected()) { |
|
|
|
|
|
|
|
row.deselect(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
table = $('#coureursTable').DataTable(); |
|
|
|
row.select(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Affichage du compteur |
|
|
|
function updateMainDossardsCount() { |
|
|
|
function updateMainDossardsCount() { |
|
|
|
var count = table.rows({search:'applied'}).count(); |
|
|
|
var count = table.rows({selected: true, search: 'applied'}).count(); |
|
|
|
$('#mainDossardsCountText').text('Générer ' + count + ' dossards'); |
|
|
|
$('#mainDossardsCountText').text('Générer ' + count + ' dossards'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
table.on('select deselect draw', updateMainDossardsCount); |
|
|
|
updateMainDossardsCount(); |
|
|
|
updateMainDossardsCount(); |
|
|
|
table.on('draw', updateMainDossardsCount); |
|
|
|
|
|
|
|
$('#filterClasse').on('change', updateMainDossardsCount); |
|
|
|
// Filtre classe (colonne 3) |
|
|
|
$('#filterClasse').on('change', function() { |
|
|
|
$('#filterClasse').on('change', function() { |
|
|
|
var val = $(this).val(); |
|
|
|
var val = $(this).val(); |
|
|
|
if(val) { |
|
|
|
if(val) { |
|
|
|
table.column(2).search('^'+val+'$', true, false).draw(); |
|
|
|
table.column(3).search('^'+val+'$', true, false).draw(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
table.column(2).search('').draw(); |
|
|
|
table.column(3).search('').draw(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
table.rows({search:'applied'}).select(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Ouvre le modal au clic sur le bouton |
|
|
|
// Ouvre le modal au clic sur le bouton |
|
|
|
@ -130,19 +186,18 @@ $(document).ready(function() { |
|
|
|
$('#dossardsModal').modal('show'); |
|
|
|
$('#dossardsModal').modal('show'); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
// Prépare la soumission du formulaire pour n'envoyer que les IDs filtrés |
|
|
|
// Prépare la soumission du formulaire pour n'envoyer que les IDs sélectionnés |
|
|
|
$('#dossardsForm').on('submit', function(e) { |
|
|
|
$('#dossardsForm').on('submit', function(e) { |
|
|
|
var ids = []; |
|
|
|
var ids = []; |
|
|
|
table.rows({search:'applied'}).every(function(){ |
|
|
|
table.rows({selected: true, search: 'applied'}).every(function(){ |
|
|
|
var row = this.node(); |
|
|
|
var row = this.node(); |
|
|
|
var id = $(row).data('id'); |
|
|
|
var id = $(row).data('id'); |
|
|
|
if (id) ids.push(id); |
|
|
|
if (id) ids.push(id); |
|
|
|
}); |
|
|
|
}); |
|
|
|
$('#coureurIdsInput').val(ids.join(',')); |
|
|
|
$('#coureurIdsInput').val(ids.join(',')); |
|
|
|
// Ferme le modal juste après la soumission |
|
|
|
|
|
|
|
$('#dossardsModal').modal('hide'); |
|
|
|
$('#dossardsModal').modal('hide'); |
|
|
|
// continue submit |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
{% endblock %} |
|
|
|
{% endblock %} |
|
|
|
|