From 174eccdb60664232c484579643f45d6c3981f65f Mon Sep 17 00:00:00 2001 From: Cedric Date: Tue, 30 Jun 2026 12:30:56 +0200 Subject: [PATCH] Actualiser js/admin.js --- js/admin.js | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/js/admin.js b/js/admin.js index 59200a4..c6bdb83 100644 --- a/js/admin.js +++ b/js/admin.js @@ -412,11 +412,24 @@ async function handleCritiqueUpload(input) { loadDashboardData(); } -// Extraction stricte de l'EAN uniquement +// Extraction des données du CSV + EAN function normalizeVideothequeRow(row) { let ean = row['ean_isbn13'] || row['EAN'] || row['ean'] || row['Barcode'] || row['UPC'] || row['upc_isbn10'] || ''; if (ean) ean = String(ean).replace(/[^0-9]/g, ''); - return { ean }; + + let title = row['title'] ? String(row['title']).trim() : ''; + if (!ean && !title) return null; // On garde la ligne si au moins le titre ou l'EAN existe + + return { + ean: ean, + title: title, + publisher: row['publisher'] || '', + length: row['length'] || '', + number_of_discs: row['number_of_discs'] || 1, + aspect_ratio: row['aspect_ratio'] || '', + description: row['description'] || '', + actors: row['creators'] || '' // Le CSV utilise 'creators' pour le casting/réalisateur + }; } function handleVideothequeUpload(input) { @@ -428,12 +441,9 @@ function handleVideothequeUpload(input) { const parsed = parseCSV(text); if (!parsed.length) { alert("❌ CSV vide."); return; } - const items = parsed.map(row => { - const { ean } = normalizeVideothequeRow(row); - return (ean && ean.length >= 8) ? { ean } : null; - }).filter(Boolean); + const items = parsed.map(row => normalizeVideothequeRow(row)).filter(Boolean); - if (!items.length) { alert("❌ Aucun EAN valide trouvé."); return; } + if (!items.length) { alert("❌ Aucun titre ou EAN valide trouvé."); return; } showImportModal(items.length, 'videotheque'); let processed = 0, totalImp = 0, totalSkp = 0;