Actualiser js/admin.js

This commit is contained in:
2026-06-20 20:56:01 +02:00
parent 8095feb53e
commit 55e49ac1f6
+10 -12
View File
@@ -145,61 +145,59 @@ function renderAdminTable() {
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 // 4. 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 // 5. Rendu
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>`;
} }
tr.innerHTML = ` tr.innerHTML = `
<td style="text-align:center; width:40px;"> <td>
<input type="checkbox" class="film-checkbox" value="${f.id}" onclick="toggleSingleSelect('${f.id}', this)"> <input type="checkbox" class="film-checkbox" value="${f.id}" onclick="toggleSingleSelect('${f.id}', this)">
</td> </td>
<td style="width:60px; text-align:center;"> <td>
${f.poster ? `<img src="${f.poster}" class="thumb" alt="Affiche">` : '<div class="thumb-ph"><i class="ti ti-photo"></i></div>'} ${f.poster ? `<img src="${f.poster}" class="thumb" alt="Affiche">` : '<div class="thumb-ph"><i class="ti ti-photo"></i></div>'}
</td> </td>
<td><strong>${f.title}</strong></td> <td><strong>${f.title}</strong></td>
<td style="color:var(--text-secondary);">${f.year || '-'}</td> <td>${f.year || '-'}</td>
<td style="color:var(--text-secondary);">${f.director || '-'}</td> <td>${f.director || '-'}</td>
<td><div class="info-cell">${infoHtml}</div></td> <td><div class="info-cell">${infoHtml}</div></td>
<td class="tbl-actions" style="width:100px; text-align:right;"> <td>
<div class="tbl-actions">
<button onclick="openEditModal('${f.id}')" title="Éditer"><i class="ti ti-edit"></i></button> <button onclick="openEditModal('${f.id}')" title="Éditer"><i class="ti ti-edit"></i></button>
<button class="del" onclick="deleteSingleFilm('${f.id}')" title="Supprimer"><i class="ti ti-trash"></i></button> <button class="del" onclick="deleteSingleFilm('${f.id}')" title="Supprimer"><i class="ti ti-trash"></i></button>
</div>
</td>`; </td>`;
tbody.appendChild(tr); tbody.appendChild(tr);
}); });
// 6. Synchronisation des checkboxes avec selectedIds // Synchronisation checkboxes
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);
} }