Actualiser js/admin.js
This commit is contained in:
+10
-12
@@ -145,61 +145,59 @@ function renderAdminTable() {
|
||||
const countLabel = document.getElementById('admin-count-label');
|
||||
if (countLabel) countLabel.textContent = `${filtered.length} élément(s)`;
|
||||
|
||||
// 4. Gestion de la pagination
|
||||
// 4. Pagination
|
||||
const totalPages = Math.ceil(filtered.length / itemsPerPage) || 1;
|
||||
if (currentPage > totalPages) currentPage = totalPages;
|
||||
const startIdx = (currentPage - 1) * itemsPerPage;
|
||||
const pageItems = filtered.slice(startIdx, startIdx + itemsPerPage);
|
||||
|
||||
// 5. Rendu des lignes
|
||||
// 5. Rendu
|
||||
pageItems.forEach(f => {
|
||||
const tr = document.createElement('tr');
|
||||
|
||||
let infoHtml = '';
|
||||
if (currentAdminTab === 'critique') {
|
||||
// Étoiles avec demi-étoiles + badge numérique
|
||||
infoHtml = `
|
||||
<div class="info-cell">
|
||||
<span class="tbl-stars">${getStarsHTML(f.rating)}</span>
|
||||
<span class="rating-badge">${parseFloat(f.rating).toFixed(1)}</span>
|
||||
</div>`;
|
||||
|
||||
// Badge streaming ou physique
|
||||
if (f.streaming && f.streaming !== 'Disponible en support physique ou Cinéma') {
|
||||
infoHtml += `<span class="streaming-badge" title="${f.streaming}">${f.streaming}</span>`;
|
||||
} else {
|
||||
infoHtml += `<span class="physical-badge">🎟️ Cinéma / Physique</span>`;
|
||||
}
|
||||
} else {
|
||||
// Vidéothèque : format + durée
|
||||
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>`;
|
||||
}
|
||||
|
||||
tr.innerHTML = `
|
||||
<td style="text-align:center; width:40px;">
|
||||
<td>
|
||||
<input type="checkbox" class="film-checkbox" value="${f.id}" onclick="toggleSingleSelect('${f.id}', this)">
|
||||
</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>'}
|
||||
</td>
|
||||
<td><strong>${f.title}</strong></td>
|
||||
<td style="color:var(--text-secondary);">${f.year || '-'}</td>
|
||||
<td style="color:var(--text-secondary);">${f.director || '-'}</td>
|
||||
<td>${f.year || '-'}</td>
|
||||
<td>${f.director || '-'}</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 class="del" onclick="deleteSingleFilm('${f.id}')" title="Supprimer"><i class="ti ti-trash"></i></button>
|
||||
</div>
|
||||
</td>`;
|
||||
tbody.appendChild(tr);
|
||||
});
|
||||
|
||||
// 6. Synchronisation des checkboxes avec selectedIds
|
||||
// Synchronisation checkboxes
|
||||
document.querySelectorAll('.film-checkbox').forEach(cb => {
|
||||
cb.checked = selectedIds.has(cb.value);
|
||||
});
|
||||
|
||||
// 7. Rendu de la pagination
|
||||
renderPagination(totalPages, filtered.length);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user