6c63bb17a3
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
78 lines
3.7 KiB
HTML
78 lines
3.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>⚡ Sandbox - Test Récupération ID</title>
|
|
<style>
|
|
body { font-family: sans-serif; background: #333; color: #fff; padding: 50px; }
|
|
.modal-preview { background: #fff; color: #000; padding: 20px; border-radius: 12px; width: 500px; margin: 0 auto; box-shadow: 0 4px 15px rgba(0,0,0,0.5); }
|
|
.button-container { display: flex; justify-content: space-between; align-items: center; margin-top: 20px; gap: 8px; }
|
|
|
|
.btn { padding: 12px; border-radius: 8px; border: none; font-weight: bold; cursor: pointer; flex: 1; text-align: center; text-decoration: none; }
|
|
.btn-success { background-color: #2e7d32; color: white; }
|
|
.btn-danger { background-color: #d32f2f; color: white; }
|
|
.btn-purple { background-color: #7b1fa2; color: white; }
|
|
.btn-catalog-shortcut { background-color: #1976d2; color: white; font-size: 11px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<h2 style="text-align: center;">Test de Capture d'attribut HTML</h2>
|
|
|
|
<div class="modal-preview">
|
|
<h3>Jus ananas</h3>
|
|
<p>Emplacement : 🍷 Cave</p>
|
|
|
|
<div class="button-container">
|
|
<button class="btn btn-danger">Utiliser</button>
|
|
<button class="btn btn-success" data-id="145">Modifier</button>
|
|
<button class="btn btn-purple">Recette</button>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
// 1. Fonction qui affiche le formulaire
|
|
function mockEditProduct(id) {
|
|
// 1. On va chercher les catégories directement dans la mémoire de l'appli.
|
|
// Si 'categories' n'est pas définie, on prévoit une liste de secours.
|
|
const appCategories = (typeof categories !== 'undefined') ? categories : ["Fruits", "Légumes", "Boissons", "Épicerie", "Surgelés"];
|
|
|
|
// 2. On construit les options dynamiquement
|
|
let optionsHTML = appCategories.map(cat => `<option value="${cat}">${cat}</option>`).join('');
|
|
|
|
const container = document.querySelector('.modal-preview');
|
|
container.innerHTML = `
|
|
<h3>Modification du produit #${id}</h3>
|
|
<form onsubmit="event.preventDefault(); alert('Catégorie ' + document.getElementById('cat-select').value + ' appliquée !'); location.reload();">
|
|
<label>Catégories EverShelf :</label><br>
|
|
<select id="cat-select" style="width:100%; padding:8px; margin: 10px 0;">
|
|
${optionsHTML}
|
|
</select>
|
|
<br>
|
|
<button type="submit" class="btn btn-success">Enregistrer</button>
|
|
<button type="button" class="btn btn-danger" onclick="location.reload()">Annuler</button>
|
|
</form>
|
|
`;
|
|
}
|
|
|
|
// 2. Injecteur qui ajoute le bouton bleu
|
|
setInterval(() => {
|
|
const greenBtn = document.querySelector('.btn-success');
|
|
if (greenBtn && !document.querySelector('.btn-catalog-shortcut')) {
|
|
const container = greenBtn.parentNode;
|
|
let pId = greenBtn.getAttribute('data-id');
|
|
|
|
const blueBtn = document.createElement('button');
|
|
blueBtn.type = 'button';
|
|
blueBtn.className = 'btn btn-catalog-shortcut';
|
|
blueBtn.innerText = '✏️ Modifier la fiche';
|
|
|
|
// Au clic, on appelle notre fonction de test
|
|
blueBtn.onclick = () => mockEditProduct(pId);
|
|
|
|
container.insertBefore(blueBtn, greenBtn);
|
|
}
|
|
}, 500);
|
|
</script>
|
|
</body>
|
|
</html> |