Actualiser js/admin.js
This commit is contained in:
+23
@@ -5,6 +5,7 @@ let currentPage = 1;
|
||||
const itemsPerPage = 12;
|
||||
let selectedIds = new Set();
|
||||
let pendingDeleteAction = null;
|
||||
let adminPhysicalOnlyFilter = false;
|
||||
|
||||
// ── UTILITAIRES DOM SÉCURISÉS (Anti-Crash) ──
|
||||
function safeGetValue(id, defaultValue = '') {
|
||||
@@ -79,6 +80,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
|
||||
function initEventListeners() {
|
||||
const physicalCheckbox = document.getElementById('admin-physical-checkbox');
|
||||
if (physicalCheckbox) {
|
||||
physicalCheckbox.addEventListener('change', (e) => {
|
||||
adminPhysicalOnlyFilter = e.target.checked;
|
||||
currentPage = 1;
|
||||
renderAdminTable();
|
||||
});
|
||||
}
|
||||
const filmForm = document.getElementById('film-form');
|
||||
if (filmForm) filmForm.addEventListener('submit', saveFilmForm);
|
||||
|
||||
@@ -143,6 +152,20 @@ function renderAdminTable() {
|
||||
if (!tbody) return;
|
||||
tbody.innerHTML = '';
|
||||
|
||||
const searchInput = document.getElementById('search-input');
|
||||
const currentSearch = searchInput ? searchInput.value.toLowerCase() : '';
|
||||
|
||||
let filtered = allItems.filter(item => item.type === currentAdminTab);
|
||||
|
||||
// FILTRE PHYSIQUE UNIQUEMENT
|
||||
if (adminPhysicalOnlyFilter) {
|
||||
filtered = filtered.filter(f =>
|
||||
!f.streaming ||
|
||||
f.streaming === 'Disponible en support physique ou Cinéma' ||
|
||||
f.streaming.trim() === ''
|
||||
);
|
||||
}
|
||||
|
||||
const filtered = getFilteredItems();
|
||||
|
||||
const countLabel = document.getElementById('admin-count-label');
|
||||
|
||||
Reference in New Issue
Block a user