Actualiser js/admin.js
This commit is contained in:
+13
@@ -129,7 +129,10 @@ function renderAdminTable() {
|
|||||||
if (!tbody) return;
|
if (!tbody) return;
|
||||||
tbody.innerHTML = '';
|
tbody.innerHTML = '';
|
||||||
|
|
||||||
|
// 1. Filtrage par onglet
|
||||||
let filtered = allItems.filter(item => item.type === currentAdminTab);
|
let filtered = allItems.filter(item => item.type === currentAdminTab);
|
||||||
|
|
||||||
|
// 2. Filtrage par recherche
|
||||||
if (searchQuery) {
|
if (searchQuery) {
|
||||||
const q = searchQuery.toLowerCase();
|
const q = searchQuery.toLowerCase();
|
||||||
filtered = filtered.filter(f =>
|
filtered = filtered.filter(f =>
|
||||||
@@ -138,29 +141,37 @@ function renderAdminTable() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 3. Mise à jour du compteur
|
||||||
const countLabel = document.getElementById('admin-count-label');
|
const countLabel = document.getElementById('admin-count-label');
|
||||||
if (countLabel) countLabel.textContent = `${filtered.length} élément(s)`;
|
if (countLabel) countLabel.textContent = `${filtered.length} élément(s)`;
|
||||||
|
|
||||||
|
// 4. Gestion de la pagination
|
||||||
const totalPages = Math.ceil(filtered.length / itemsPerPage) || 1;
|
const totalPages = Math.ceil(filtered.length / itemsPerPage) || 1;
|
||||||
if (currentPage > totalPages) currentPage = totalPages;
|
if (currentPage > totalPages) currentPage = totalPages;
|
||||||
const startIdx = (currentPage - 1) * itemsPerPage;
|
const startIdx = (currentPage - 1) * itemsPerPage;
|
||||||
const pageItems = filtered.slice(startIdx, startIdx + itemsPerPage);
|
const pageItems = filtered.slice(startIdx, startIdx + itemsPerPage);
|
||||||
|
|
||||||
|
// 5. Rendu des lignes
|
||||||
pageItems.forEach(f => {
|
pageItems.forEach(f => {
|
||||||
const tr = document.createElement('tr');
|
const tr = document.createElement('tr');
|
||||||
|
|
||||||
let infoHtml = '';
|
let infoHtml = '';
|
||||||
if (currentAdminTab === 'critique') {
|
if (currentAdminTab === 'critique') {
|
||||||
|
// Étoiles avec demi-étoiles + badge numérique
|
||||||
infoHtml = `
|
infoHtml = `
|
||||||
<div class="info-cell">
|
<div class="info-cell">
|
||||||
<span class="tbl-stars">${getStarsHTML(f.rating)}</span>
|
<span class="tbl-stars">${getStarsHTML(f.rating)}</span>
|
||||||
<span class="rating-badge">${parseFloat(f.rating).toFixed(1)}</span>
|
<span class="rating-badge">${parseFloat(f.rating).toFixed(1)}</span>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
|
// Badge streaming ou physique
|
||||||
if (f.streaming && f.streaming !== 'Disponible en support physique ou Cinéma') {
|
if (f.streaming && f.streaming !== 'Disponible en support physique ou Cinéma') {
|
||||||
infoHtml += `<span class="streaming-badge" title="${f.streaming}">${f.streaming}</span>`;
|
infoHtml += `<span class="streaming-badge" title="${f.streaming}">${f.streaming}</span>`;
|
||||||
} else {
|
} else {
|
||||||
infoHtml += `<span class="physical-badge">🎟️ Cinéma / Physique</span>`;
|
infoHtml += `<span class="physical-badge">🎟️ Cinéma / Physique</span>`;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Vidéothèque : format + durée
|
||||||
infoHtml = `<span class="badge-format">${f.format || '-'}</span>`;
|
infoHtml = `<span class="badge-format">${f.format || '-'}</span>`;
|
||||||
if (f.length) infoHtml += `<span style="font-size:0.8rem; color:var(--muted); margin-left:0.4rem;">${f.length}</span>`;
|
if (f.length) infoHtml += `<span style="font-size:0.8rem; color:var(--muted); margin-left:0.4rem;">${f.length}</span>`;
|
||||||
}
|
}
|
||||||
@@ -183,10 +194,12 @@ function renderAdminTable() {
|
|||||||
tbody.appendChild(tr);
|
tbody.appendChild(tr);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 6. Synchronisation des checkboxes avec selectedIds
|
||||||
document.querySelectorAll('.film-checkbox').forEach(cb => {
|
document.querySelectorAll('.film-checkbox').forEach(cb => {
|
||||||
cb.checked = selectedIds.has(cb.value);
|
cb.checked = selectedIds.has(cb.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// 7. Rendu de la pagination
|
||||||
renderPagination(totalPages, filtered.length);
|
renderPagination(totalPages, filtered.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user