Actualiser test2.html
CI / PHP Syntax Check (push) Has been cancelled
CI / JavaScript Lint (push) Has been cancelled
CI / Docker Build Test (push) Has been cancelled
CI / Validate Translation Files (push) Has been cancelled
CI / Auto-merge develop → main (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled

This commit is contained in:
2026-06-17 17:18:05 +00:00
parent 0502a4d132
commit d35f975ab9
+9 -39
View File
@@ -2,13 +2,12 @@
<html lang="fr"> <html lang="fr">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>⚡ Sandbox - Test Réconciliation Catégories</title> <title>⚡ Sandbox - Fixe</title>
<style> <style>
body { font-family: sans-serif; background: #333; padding: 50px; } body { font-family: sans-serif; background: #333; padding: 50px; }
.modal { background: white; padding: 20px; border-radius: 12px; width: 400px; margin: 0 auto; box-shadow: 0 4px 15px rgba(0,0,0,0.3); } .modal { background: white; padding: 20px; border-radius: 12px; width: 400px; margin: 0 auto; box-shadow: 0 4px 15px rgba(0,0,0,0.3); }
.btn { padding: 10px 20px; border-radius: 8px; border: none; cursor: pointer; margin: 5px; font-weight: bold; } .btn { padding: 10px 20px; border-radius: 8px; border: none; cursor: pointer; margin: 5px; font-weight: bold; }
.btn-blue { background: #1976d2; color: white; } .btn-blue { background: #1976d2; color: white; }
.btn-cancel { background: #666; color: white; }
</style> </style>
</head> </head>
<body> <body>
@@ -20,57 +19,28 @@
</div> </div>
<script> <script>
// 1. Fonction pour récupérer les VRAIES catégories d'EverShelf // On force les données ici pour ne plus dépendre de l'onglet EverShelf
// Elle scanne l'objet 'app' ou les variables globales de l'application const VRAIES_CATEGORIES = [
function getRealCategories() { "Produits laitiers", "Viande", "Poisson", "Fruits",
// On vérifie si la variable globale existe "Légumes", "Boissons", "Épicerie", "Surgelés"
if (typeof CATEGORY_LABELS !== 'undefined') { ];
// Object.values extrait juste les noms (ex: "Produits laitiers", "Viande")
// de l'objet {latticini: "Produits laitiers", carne: "Viande"}
return Object.values(CATEGORY_LABELS);
}
// Liste de secours si la variable n'est pas encore chargée
return ["Fruits", "Légumes", "Boissons", "Épicerie"];
}
// 2. Fonction d'affichage du formulaire
function editCategory() { function editCategory() {
const container = document.getElementById('app-container'); const container = document.getElementById('app-container');
// 1. On vérifie si la variable existe vraiment
const rawData = typeof CATEGORY_LABELS !== 'undefined' ? CATEGORY_LABELS : {};
// 2. On transforme les valeurs en tableau
const categories = Object.values(rawData);
// 3. Sécurité : si toujours vide, on alerte
if (categories.length === 0) {
alert("Erreur : CATEGORY_LABELS est vide ou non chargé.");
return;
}
container.innerHTML = ` container.innerHTML = `
<h3>Changer la catégorie</h3> <h3>Changer la catégorie</h3>
<select id="cat-select" style="width:100%; padding:10px; margin: 10px 0;"> <select id="cat-select" style="width:100%; padding:10px; margin: 10px 0;">
${categories.map(c => `<option value="${c}">${c}</option>`).join('')} ${VRAIES_CATEGORIES.map(c => `<option value="${c}">${c}</option>`).join('')}
</select> </select>
<br> <br>
<button class="btn btn-blue" onclick="save()">Enregistrer</button> <button class="btn btn-blue" onclick="save()">Enregistrer</button>
<button class="btn btn-cancel" onclick="location.reload()">Annuler</button> <button class="btn" onclick="location.reload()">Annuler</button>
`; `;
} }
// 3. Fonction de sauvegarde
function save() { function save() {
const selected = document.getElementById('cat-select').value; const selected = document.getElementById('cat-select').value;
alert("Simulation : Appel de la fonction réelle d'EverShelf avec la valeur : " + selected);
// Ici, on appelle la vraie fonction de mise à jour d'EverShelf
if (typeof app !== 'undefined' && typeof app.updateProductCategory === 'function') {
app.updateProductCategory(selected);
alert("Donnée envoyée à EverShelf : " + selected);
} else {
alert("Simulation : Catégorie " + selected + " retenue.");
}
location.reload(); location.reload();
} }
</script> </script>