diff --git a/js/admin.js b/js/admin.js index 485ba92..b9ad0ad 100644 --- a/js/admin.js +++ b/js/admin.js @@ -65,7 +65,7 @@ function renderAdminTable() { if (!tbody) return; tbody.innerHTML = ''; - // 1. Filtrage par onglet et recherche + // 1. Filtrage let filtered = allItems.filter(item => item.type === currentAdminTab); if (searchQuery) { const q = searchQuery.toLowerCase(); @@ -78,24 +78,31 @@ function renderAdminTable() { const countLabel = document.getElementById('admin-count-label'); if(countLabel) countLabel.textContent = `${filtered.length} élément(s)`; - // 2. Gestion de la pagination + // 2. 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); - // 3. Rendu des lignes + // 3. Rendu — 7 cellules pour correspondre aux 7 pageItems.forEach(f => { const tr = document.createElement('tr'); let infoHtml = ''; if (currentAdminTab === 'critique') { - const rating = Math.round(f.rating || 0); - const stars = '★'.repeat(rating) + '☆'.repeat(5 - rating); - infoHtml = `${stars}`; + // 🌟 Gestion précise des notes Letterboxd (0.5 à 5) + const rating = parseFloat(f.rating) || 0; + const fullStars = Math.floor(rating); // partie entière + const emptyStars = 5 - Math.ceil(rating); // étoiles vides + const stars = '★'.repeat(fullStars) + '☆'.repeat(emptyStars); - // Affichage Streaming ou Physique + infoHtml = ` +
+ ${stars} + ${rating.toFixed(1)} +
`; + + // Badge streaming if (f.streaming && f.streaming !== 'Disponible en support physique ou Cinéma') { infoHtml += `${f.streaming}`; } else { @@ -103,36 +110,28 @@ function renderAdminTable() { } } else { infoHtml = `${f.format || '-'}`; - if(f.length) infoHtml += `${f.length}`; + if(f.length) infoHtml += `${f.length}`; } + // ✅ 7 cellules pour 7 colonnes tr.innerHTML = ` - + - + ${f.poster ? `Affiche` : '
'} - -
- ${f.title} - ${f.year || '-'} -
- - ${f.director || '-'} - -
- ${infoHtml} -
- - + ${f.title} + ${f.year || '-'} + ${f.director || '-'} +
${infoHtml}
+ `; tbody.appendChild(tr); }); - // 4. Rendu de la pagination renderPagination(totalPages, filtered.length); }