Actualiser test.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:
@@ -31,40 +31,42 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Utilisation d'une fonction pour injecter proprement
|
||||
// 1. Simulation : Fonction qui "modifierait" le produit
|
||||
function mockEditProduct(id) {
|
||||
console.log("Tentative de modification pour l'ID : " + id);
|
||||
|
||||
// On affiche un faux formulaire à la place de la modale
|
||||
const container = document.querySelector('.modal-preview');
|
||||
container.innerHTML = `
|
||||
<h3>Modification du produit #${id}</h3>
|
||||
<form onsubmit="event.preventDefault(); alert('Changement enregistré (simulation réussie !)'); location.reload();">
|
||||
<label>Nouvelle catégorie :</label><br>
|
||||
<input type="text" value="Fruits" style="width:100%; padding:8px; margin: 10px 0;">
|
||||
<br>
|
||||
<button type="submit" class="btn btn-success">Enregistrer les modifications</button>
|
||||
<button type="button" class="btn btn-danger" onclick="location.reload()">Annuler</button>
|
||||
</form>
|
||||
`;
|
||||
}
|
||||
|
||||
// 2. Injection du bouton bleu qui appelle notre simulateur
|
||||
function injectShortcut() {
|
||||
const greenBtn = document.querySelector('.btn-success');
|
||||
|
||||
// Si le bouton existe ET qu'on n'a pas encore ajouté le bouton bleu
|
||||
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.style.cssText = 'background-color: #1976d2; color: white;';
|
||||
blueBtn.innerText = '✏️ Modifier la fiche';
|
||||
|
||||
blueBtn.onclick = function() {
|
||||
if (pId) {
|
||||
alert("Succès ! ID extrait : " + pId);
|
||||
// Ici tu mettras : window.location.href = '/catalogue?id=' + pId;
|
||||
} else {
|
||||
alert("ID introuvable.");
|
||||
}
|
||||
};
|
||||
|
||||
blueBtn.onclick = () => mockEditProduct(pId);
|
||||
container.insertBefore(blueBtn, greenBtn);
|
||||
console.log("Injection réussie.");
|
||||
}
|
||||
}
|
||||
|
||||
// On vérifie la présence du bouton une seule fois si la page est chargée,
|
||||
// ou via un intervalle léger pour s'adapter au rendu dynamique.
|
||||
const observer = setInterval(injectShortcut, 500);
|
||||
|
||||
// Optionnel : arrêter l'intervalle après 5 secondes pour économiser les ressources
|
||||
setTimeout(() => clearInterval(observer), 5000);
|
||||
setInterval(injectShortcut, 500);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user