diff --git a/js/admin.js b/js/admin.js index dde6d6a..7f0ab9e 100644 --- a/js/admin.js +++ b/js/admin.js @@ -94,6 +94,14 @@ function initEventListeners() { e.target.classList.remove('open'); } }); + + const physicalFilter = document.getElementById('admin-physical-checkbox'); + if (physicalFilter) { + physicalFilter.addEventListener('change', () => { + currentPage = 1; + renderAdminTable(); + }); + } } async function loadDashboardData() { @@ -115,9 +123,15 @@ function renderAdminTable() { const searchInput = document.getElementById('search-input'); const currentSearch = searchInput ? searchInput.value.toLowerCase() : ''; + const physicalFilter = document.getElementById('admin-physical-checkbox'); let filtered = allItems.filter(item => item.type === currentAdminTab); + // Nouveau : Filtrage des formats dématérialisés + if (physicalFilter && physicalFilter.checked) { + filtered = filtered.filter(f => f.format && !['dématérialisé', 'vod', 'digital', 'streaming'].includes(f.format.toLowerCase())); + } + if (currentSearch) { filtered = filtered.filter(f => f.title.toLowerCase().includes(currentSearch) || @@ -324,11 +338,15 @@ function toggleFormFields() { } function switchAdminTab(tabName) { - currentAdminTab = tabName; +currentAdminTab = tabName; currentPage = 1; selectedIds.clear(); const searchInput = document.getElementById('search-input'); if (searchInput) searchInput.value = ''; + + const physicalFilter = document.getElementById('admin-physical-checkbox'); + if (physicalFilter) physicalFilter.checked = false; + document.querySelectorAll('.tab-btn').forEach(b => b.classList.remove('active')); const btn = document.getElementById(`btn-tab-${tabName}`); if (btn) btn.classList.add('active');