add and remove all

This commit is contained in:
Fred Tempez 2023-11-25 15:10:10 +01:00
parent e4647c0702
commit a39985fe62
6 changed files with 49 additions and 15 deletions

View File

@ -658,10 +658,10 @@ class course extends common
// Construction du tableau
self::$courseUsers[] = [
template::checkbox($userId, true, '', ['class' => 'checkboxSelect']),
$userId,
$this->getData(['user', $userId, 'firstname']),
$this->getData(['user', $userId, 'lastname']),
template::checkbox($userId, true, '', ['class' => 'checkboxSelect'])
];
}
@ -802,10 +802,10 @@ class course extends common
// Construction du tableau
self::$courseUsers[] = [
template::checkbox($userId, true, '', ['class' => 'checkboxSelect']),
$userId,
$this->getData(['user', $userId, 'firstname']),
$this->getData(['user', $userId, 'lastname']),
template::checkbox($userId, true, '', ['class' => 'checkboxSelect'])
];
}

View File

@ -13,6 +13,15 @@
$(document).ready((function () {
$('#courseUserAddSelectAll').on('click', function() {
$('.checkboxSelect').prop('checked', true);
saveCheckboxState();
});
$('#courseUserAddSelectNone').on('click', function() {
$('.checkboxSelect').prop('checked', false);
saveCheckboxState();
});
$("#courseFilterGroup, #courseFilterFirstName, #courseFilterLastName").change(function () {
saveCheckboxState();
$("#courseUsersAddForm").submit();
@ -24,7 +33,7 @@ $(document).ready((function () {
},
"columnDefs": [
{
target: 3,
target: 0,
orderable: false,
searchable: false,
}
@ -45,7 +54,6 @@ $(document).ready((function () {
// Empty local storage after submit
$("#courseUsersAddSubmit").on("click", function () {
localStorage.setItem('checkboxState', JSON.stringify({}));
});

View File

@ -7,12 +7,22 @@
'value' => template::ico('left')
]); ?>
</div>
<div class="col1 offset7">
<?php echo template::button('courseUserAddSelectAll', [
'value' => 'Tout'
]); ?>
</div>
<div class="col2 offset10">
<div class="col1">
<?php echo template::button('courseUserAddSelectNone', [
'value' => 'Aucun'
]); ?>
</div>
<div class="col2">
<?php echo template::submit('courseUsersAddSubmit', [
'value' => 'Inscrire'
]); ?>
</div>
</div>
<div class="row" id="Bfrtip">
<div class="col3">
<?php echo template::select('courseFilterGroup', $module::$courseGroups, [
@ -34,7 +44,7 @@
</div>
</div>
<?php if ($module::$courseUsers): ?>
<?php echo template::table([4, 4, 4, 1], $module::$courseUsers, ['Id', 'Prénom', 'Nom', ''], ['id' => 'dataTables']); ?>
<?php echo template::table([1, 4, 4, 3], $module::$courseUsers, ['', 'Id', 'Prénom', 'Nom'], ['id' => 'dataTables']); ?>
<?php else: ?>
<?php echo template::speech('Aucun inscrit'); ?>
<?php endif; ?>

View File

@ -13,6 +13,14 @@
$(document).ready((function () {
$('#courseUserDeleteSelectAll').on('click', function() {
$('.checkboxSelect').prop('checked', true);
saveCheckboxState();
});
$('#courseUserDeleteSelectNone').on('click', function() {
$('.checkboxSelect').prop('checked', false);
saveCheckboxState();
});
$("#courseFilterGroup, #courseFilterFirstName, #courseFilterLastName").change(function () {
saveCheckboxState();
@ -25,7 +33,7 @@ $(document).ready((function () {
},
"columnDefs": [
{
target: 3,
target: 0,
orderable: false,
searchable: false,
}
@ -46,9 +54,7 @@ $(document).ready((function () {
// Empty local storage after submit
$("#courseUsersDeleteSubmit").on("click", function () {
localStorage.setItem('checkboxState', JSON.stringify({}));
});
// Restore checkbox state on page load

View File

@ -1,19 +1,29 @@
<?php echo template::formOpen('courseUsersDeleteForm'); ?>
<div class="row">
<div class="col1">
<?php echo template::button('courseUserAddBack', [
<?php echo template::button('courseUserDeleteBack', [
'class' => 'buttonGrey',
'href' => helper::baseUrl() . 'course/users/' . $this->getUrl(2),
'value' => template::ico('left')
]); ?>
</div>
<div class="col1 offset7">
<?php echo template::button('courseUserDeleteSelectAll', [
'value' => 'Tout'
]); ?>
</div>
<div class="col2 offset10">
<div class="col1">
<?php echo template::button('courseUserDeleteSelectNone', [
'value' => 'Aucun'
]); ?>
</div>
<div class="col2">
<?php echo template::submit('courseUsersDeleteSubmit', [
'class' => 'buttonRed',
'value' => 'Désinscrire'
]); ?>
</div>
</div>
<div class="row" id="Bfrtip">
<div class="col3">
<?php echo template::select('courseFilterGroup', $module::$courseGroups, [
@ -35,7 +45,7 @@
</div>
</div>
<?php if ($module::$courseUsers): ?>
<?php echo template::table([4, 4, 4, 1], $module::$courseUsers, ['Id', 'Prénom', 'Nom', ''], ['id' => 'dataTables']); ?>
<?php echo template::table([1, 4, 4, 3], $module::$courseUsers, ['', 'Id', 'Prénom', 'Nom'], ['id' => 'dataTables']); ?>
<?php else: ?>
<?php echo template::speech('Aucun inscrit'); ?>
<?php endif; ?>

View File

@ -1,7 +1,7 @@
{
"processing": "Traitement en cours...",
"search": "Rechercher&nbsp;:",
"lengthMenu": "Afficher _MENU_ &eacute;l&eacute;ments",
"lengthMenu": "&Eacute;l&eacute;ments par page _MENU_",
"info": "Affichage de l'&eacute;lement _START_ &agrave; _END_ sur _TOTAL_ &eacute;l&eacute;ments",
"infoEmpty": "Affichage de l'&eacute;lement 0 &agrave; 0 sur 0 &eacute;l&eacute;ments",
"infoFiltered": "(filtr&eacute; de _MAX_ &eacute;l&eacute;ments au total)",