ajout d'un bouton "tout sélectionner" dans la gestion admin des galeries
This commit is contained in:
parent
b953112cb0
commit
9d375850f6
@ -170,6 +170,9 @@ $config = getSiteConfig();
|
|||||||
<button onclick="deleteSelected()" id="deleteSelectedBtn" class="action-button action-button-danger">
|
<button onclick="deleteSelected()" id="deleteSelectedBtn" class="action-button action-button-danger">
|
||||||
Supprimer la sélection
|
Supprimer la sélection
|
||||||
</button>
|
</button>
|
||||||
|
<button onclick="toggleSelectAll()" id="selectAllBtn" class="action-button">
|
||||||
|
Tout sélectionner
|
||||||
|
</button>
|
||||||
<a href="arbre-prive.php?path=<?php echo urlencode($currentPath); ?>" class="action-button action-button-secondary">
|
<a href="arbre-prive.php?path=<?php echo urlencode($currentPath); ?>" class="action-button action-button-secondary">
|
||||||
Retour
|
Retour
|
||||||
</a>
|
</a>
|
||||||
@ -291,6 +294,40 @@ $config = getSiteConfig();
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Fonction pour basculer la sélection de toutes les images
|
||||||
|
function toggleSelectAll() {
|
||||||
|
const checkboxes = document.querySelectorAll('.image-checkbox');
|
||||||
|
const allChecked = document.querySelectorAll('.image-checkbox:checked').length === checkboxes.length;
|
||||||
|
|
||||||
|
checkboxes.forEach(checkbox => {
|
||||||
|
checkbox.checked = !allChecked;
|
||||||
|
});
|
||||||
|
|
||||||
|
updateActionButtons();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modifier la fonction updateActionButtons existante
|
||||||
|
function updateActionButtons() {
|
||||||
|
const checkboxes = document.querySelectorAll('.image-checkbox');
|
||||||
|
const selectedCheckboxes = document.querySelectorAll('.image-checkbox:checked');
|
||||||
|
const count = selectedCheckboxes.length;
|
||||||
|
|
||||||
|
const deleteBtn = document.getElementById('deleteSelectedBtn');
|
||||||
|
const selectAllBtn = document.getElementById('selectAllBtn');
|
||||||
|
|
||||||
|
if (deleteBtn) {
|
||||||
|
deleteBtn.style.display = count > 0 ? 'inline-flex' : 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectAllBtn) {
|
||||||
|
selectAllBtn.textContent = checkboxes.length === selectedCheckboxes.length ?
|
||||||
|
'Tout désélectionner' : 'Tout sélectionner';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ajouter l'initialisation au chargement de la page
|
||||||
|
document.addEventListener('DOMContentLoaded', updateActionButtons);
|
||||||
</script>
|
</script>
|
||||||
<button class="scroll-top" title="Retour en haut">↑</button>
|
<button class="scroll-top" title="Retour en haut">↑</button>
|
||||||
<script>
|
<script>
|
||||||
|
@ -221,6 +221,9 @@ $config = getSiteConfig();
|
|||||||
<button onclick="moveSelected()" id="moveSelectedBtn" class="action-button action-button-warning">
|
<button onclick="moveSelected()" id="moveSelectedBtn" class="action-button action-button-warning">
|
||||||
Déplacer la sélection
|
Déplacer la sélection
|
||||||
</button>
|
</button>
|
||||||
|
<button onclick="toggleSelectAll()" id="selectAllBtn" class="action-button">
|
||||||
|
Tout sélectionner
|
||||||
|
</button>
|
||||||
<a href="arbre.php?path=<?php echo urlencode($currentPath); ?>" class="action-button action-button-secondary">
|
<a href="arbre.php?path=<?php echo urlencode($currentPath); ?>" class="action-button action-button-secondary">
|
||||||
Retour
|
Retour
|
||||||
</a>
|
</a>
|
||||||
@ -246,6 +249,18 @@ $config = getSiteConfig();
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fonction pour basculer la sélection de toutes les images
|
||||||
|
function toggleSelectAll() {
|
||||||
|
const checkboxes = document.querySelectorAll('.image-checkbox');
|
||||||
|
const allChecked = document.querySelectorAll('.image-checkbox:checked').length === checkboxes.length;
|
||||||
|
|
||||||
|
checkboxes.forEach(checkbox => {
|
||||||
|
checkbox.checked = !allChecked;
|
||||||
|
});
|
||||||
|
|
||||||
|
updateActionButtons();
|
||||||
|
}
|
||||||
|
|
||||||
// Fonction de suppression multiple
|
// Fonction de suppression multiple
|
||||||
function deleteSelected() {
|
function deleteSelected() {
|
||||||
const checkboxes = document.querySelectorAll('.image-checkbox:checked');
|
const checkboxes = document.querySelectorAll('.image-checkbox:checked');
|
||||||
@ -432,27 +447,22 @@ $config = getSiteConfig();
|
|||||||
// Gestion des boutons d'action
|
// Gestion des boutons d'action
|
||||||
console.log("Définition de updateActionButtons");
|
console.log("Définition de updateActionButtons");
|
||||||
function updateActionButtons() {
|
function updateActionButtons() {
|
||||||
console.log("updateActionButtons appelé");
|
const checkboxes = document.querySelectorAll('.image-checkbox');
|
||||||
const checkboxes = document.querySelectorAll('.image-checkbox:checked');
|
const selectedCheckboxes = document.querySelectorAll('.image-checkbox:checked');
|
||||||
const count = checkboxes.length;
|
const count = selectedCheckboxes.length;
|
||||||
console.log("Nombre d'images sélectionnées:", count);
|
|
||||||
|
|
||||||
const deleteBtn = document.getElementById('deleteSelectedBtn');
|
const deleteBtn = document.getElementById('deleteSelectedBtn');
|
||||||
const moveBtn = document.getElementById('moveSelectedBtn');
|
const moveBtn = document.getElementById('moveSelectedBtn');
|
||||||
|
const selectAllBtn = document.getElementById('selectAllBtn');
|
||||||
|
|
||||||
if (!deleteBtn || !moveBtn) {
|
if (deleteBtn && moveBtn) {
|
||||||
console.log("Boutons non trouvés");
|
deleteBtn.style.display = count > 0 ? 'inline-flex' : 'none';
|
||||||
return;
|
moveBtn.style.display = count > 0 ? 'inline-flex' : 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count > 0) {
|
if (selectAllBtn) {
|
||||||
deleteBtn.style.display = 'inline-flex';
|
selectAllBtn.textContent = checkboxes.length === selectedCheckboxes.length ?
|
||||||
moveBtn.style.display = 'inline-flex';
|
'Tout désélectionner' : 'Tout sélectionner';
|
||||||
console.log("Affichage des boutons");
|
|
||||||
} else {
|
|
||||||
deleteBtn.style.display = 'none';
|
|
||||||
moveBtn.style.display = 'none';
|
|
||||||
console.log("Masquage des boutons");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user