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
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:
+38
-17
@@ -2,47 +2,68 @@
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>⚡ Sandbox - Modification Catégorie</title>
|
||||
<title>⚡ Sandbox - Test Réconciliation Catégories</title>
|
||||
<style>
|
||||
body { font-family: sans-serif; background: #333; padding: 50px; }
|
||||
.modal { background: white; padding: 20px; border-radius: 12px; width: 400px; margin: 0 auto; }
|
||||
.btn { padding: 10px 20px; border-radius: 8px; border: none; cursor: pointer; margin: 5px; }
|
||||
.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-blue { background: #1976d2; color: white; }
|
||||
.btn-cancel { background: #666; color: white; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="modal">
|
||||
<div class="modal" id="app-container">
|
||||
<h3>Produit : Jus Ananas</h3>
|
||||
<p>Catégorie actuelle : <b>Boissons</b></p>
|
||||
<button class="btn btn-blue" onclick="editCategory()">✏️ Modifier la catégorie</button>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Simulation des données d'EverShelf
|
||||
const app = {
|
||||
categories: ["Fruits", "Légumes", "Boissons", "Épicerie", "Surgelés", "Produits laitiers"],
|
||||
updateProductCategory: function(newCat) {
|
||||
alert("SUCCESS : EverShelf a enregistré la nouvelle catégorie : " + newCat);
|
||||
}
|
||||
};
|
||||
// 1. Fonction pour récupérer les VRAIES catégories d'EverShelf
|
||||
// Elle scanne l'objet 'app' ou les variables globales de l'application
|
||||
function getRealCategories() {
|
||||
// Liste par défaut si jamais l'app n'est pas chargée
|
||||
let fallback = ["Fruits", "Légumes", "Boissons", "Épicerie"];
|
||||
|
||||
try {
|
||||
// On tente de récupérer la liste réelle dans EverShelf
|
||||
// (Remplace 'app.categories' par le chemin exact que tu trouveras en console)
|
||||
if (typeof app !== 'undefined' && app.categories) return app.categories;
|
||||
return fallback;
|
||||
} catch (e) {
|
||||
return fallback;
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Fonction d'affichage du formulaire
|
||||
function editCategory() {
|
||||
const container = document.querySelector('.modal');
|
||||
const categories = getRealCategories();
|
||||
const container = document.getElementById('app-container');
|
||||
|
||||
container.innerHTML = `
|
||||
<h3>Changer la catégorie</h3>
|
||||
<select id="cat-select" style="width:100%; padding:10px;">
|
||||
${app.categories.map(c => `<option value="${c}">${c}</option>`).join('')}
|
||||
<label>Choix issus d'EverShelf :</label><br>
|
||||
<select id="cat-select" style="width:100%; padding:10px; margin: 10px 0;">
|
||||
${categories.map(c => `<option value="${c}">${c}</option>`).join('')}
|
||||
</select>
|
||||
<br><br>
|
||||
<br>
|
||||
<button class="btn btn-blue" onclick="save()">Enregistrer</button>
|
||||
<button class="btn" onclick="location.reload()">Annuler</button>
|
||||
<button class="btn btn-cancel" onclick="location.reload()">Annuler</button>
|
||||
`;
|
||||
}
|
||||
|
||||
// 3. Fonction de sauvegarde
|
||||
function save() {
|
||||
const selected = document.getElementById('cat-select').value;
|
||||
app.updateProductCategory(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();
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user