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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,7 +1,7 @@
{ {
"processing": "Traitement en cours...", "processing": "Traitement en cours...",
"search": "Rechercher&nbsp;:", "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", "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", "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)", "infoFiltered": "(filtr&eacute; de _MAX_ &eacute;l&eacute;ments au total)",