Actualiser index.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:
-83
@@ -2011,87 +2011,4 @@
|
|||||||
|
|
||||||
<script src="assets/js/app.js?v=20260606z"></script>
|
<script src="assets/js/app.js?v=20260606z"></script>
|
||||||
</body>
|
</body>
|
||||||
<script>
|
|
||||||
(function() {
|
|
||||||
console.log("=> Temporisateur de l'éditeur de produit activé (V3-ID-Hunter).");
|
|
||||||
|
|
||||||
setInterval(() => {
|
|
||||||
const buttons = document.querySelectorAll('button, .btn, input[type="submit"]');
|
|
||||||
|
|
||||||
buttons.forEach(btn => {
|
|
||||||
if (btn.offsetWidth > 0 && btn.offsetHeight > 0 && !btn.classList.contains('btn-catalog-shortcut')) {
|
|
||||||
const classes = btn.className.toLowerCase();
|
|
||||||
const text = btn.textContent.toLowerCase();
|
|
||||||
|
|
||||||
// On cible les boutons d'action de la modale (comme Modifier ou Recette) pour s'insérer à côté
|
|
||||||
if (text === 'modifier' || text.includes('modifier') || classes.includes('success') || text.includes('salva')) {
|
|
||||||
const container = btn.parentNode;
|
|
||||||
|
|
||||||
if (container && !container.querySelector('.btn-catalog-shortcut')) {
|
|
||||||
const editBtn = document.createElement('button');
|
|
||||||
editBtn.type = 'button';
|
|
||||||
editBtn.className = 'btn btn-large btn-catalog-shortcut';
|
|
||||||
editBtn.innerText = '✏️ Modifier la fiche produit (Catégorie)';
|
|
||||||
|
|
||||||
// Style bleu, parfaitement intégré à la ligne de boutons
|
|
||||||
editBtn.style.cssText = 'margin-bottom: 12px; background-color: #1976d2; color: white; width: 100%; border: none; border-radius: 8px; padding: 14px; font-size: 16px; font-weight: bold; cursor: pointer; display: block; text-align: center;';
|
|
||||||
|
|
||||||
editBtn.onclick = function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
let targetId = null;
|
|
||||||
|
|
||||||
// 1. Scan massif des variables globales potentielles d'EverShelf
|
|
||||||
if (typeof currentProduct !== 'undefined' && currentProduct) targetId = currentProduct.id || currentProduct._id;
|
|
||||||
if (typeof _currentProduct !== 'undefined' && _currentProduct) targetId = _currentProduct.id || _currentProduct._id;
|
|
||||||
if (typeof currentItem !== 'undefined' && currentItem) targetId = currentItem.product_id || currentItem.productId || currentItem.id;
|
|
||||||
if (typeof currentInventoryItem !== 'undefined' && currentInventoryItem) targetId = currentInventoryItem.product_id || currentInventoryItem.productId || currentInventoryItem.product;
|
|
||||||
if (typeof selectedItem !== 'undefined' && selectedItem) targetId = selectedItem.product_id || selectedItem.productId || selectedId;
|
|
||||||
|
|
||||||
// 2. Plan B : Si l'ID est introuvable, on regarde si un attribut HTML sur la modale le contient
|
|
||||||
if (!targetId) {
|
|
||||||
const modal = btn.closest('.modal, .popup, [id*="modal"], [id*="popup"]');
|
|
||||||
if (modal) {
|
|
||||||
targetId = modal.getAttribute('data-product-id') || modal.getAttribute('data-id');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. Si l'ID est enfin trouvé, on redirige en mode réconciliation
|
|
||||||
if (targetId) {
|
|
||||||
// Fermer la modale actuelle
|
|
||||||
document.querySelectorAll('.page, .modal, .popup').forEach(el => {
|
|
||||||
el.classList.remove('active');
|
|
||||||
el.style.display = 'none';
|
|
||||||
});
|
|
||||||
|
|
||||||
// Ouvrir le catalogue sur le bon produit
|
|
||||||
if (typeof editProduct === 'function') {
|
|
||||||
editProduct(targetId);
|
|
||||||
} else {
|
|
||||||
const targetPage = document.getElementById('page-product-form');
|
|
||||||
if (targetPage) {
|
|
||||||
targetPage.classList.add('active');
|
|
||||||
targetPage.style.display = 'block';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Au pire du pire, si l'ID reste introuvable, on simule un clic sur le VRAI bouton "Modifier" vert d'EverShelf
|
|
||||||
// pour laisser l'application ouvrir sa propre page d'édition native !
|
|
||||||
if (typeof btn.click === 'function') {
|
|
||||||
btn.click();
|
|
||||||
} else {
|
|
||||||
alert("Raccourci : Impossible de lier l'identifiant du produit automatiquement.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
container.insertBefore(editBtn, btn);
|
|
||||||
console.log("=> Raccourci injecté avec filet de sécurité.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}, 500);
|
|
||||||
})();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user