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:
+50
-47
@@ -2011,72 +2011,75 @@
|
|||||||
|
|
||||||
<script src="assets/js/app.js?v=20260606z"></script>
|
<script src="assets/js/app.js?v=20260606z"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
(function() {
|
(function() {
|
||||||
console.log("=> Patch de l'injecteur de bouton initialisé !");
|
console.log("=> Temporisateur de l'éditeur de produit activé (V2-Universelle).");
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
// 1. On cherche la modale de modification ou le formulaire actif
|
// 1. On récupère absolument TOUS les boutons visibles de la page
|
||||||
// On cible le bouton d'action principal qui contient "Aggiungi" ou l'icône de sauvegarde
|
const buttons = document.querySelectorAll('button, .btn, input[type="submit"]');
|
||||||
const buttons = document.querySelectorAll('button');
|
|
||||||
|
|
||||||
buttons.forEach(submitBtn => {
|
buttons.forEach(btn => {
|
||||||
// On repère le bouton vert de validation (Aggiungi ou Salva)
|
// On cible un bouton qui est affiché à l'écran ET qui n'est pas notre bouton bleu
|
||||||
if (submitBtn.offsetWidth > 0 &&
|
if (btn.offsetWidth > 0 && btn.offsetHeight > 0 && !btn.classList.contains('btn-catalog-shortcut')) {
|
||||||
submitBtn.offsetHeight > 0 &&
|
|
||||||
(submitBtn.textContent.includes('Aggiungi') || submitBtn.textContent.includes('Salva')) &&
|
|
||||||
!submitBtn.classList.contains('btn-edit-catalog-shortcut')) {
|
|
||||||
|
|
||||||
const parentForm = submitBtn.parentNode;
|
// EverShelf utilise généralement des classes comme btn-success, btn-primary, full-width ou mt-2 pour ses validations de modales
|
||||||
|
const classes = btn.className.toLowerCase();
|
||||||
|
const text = btn.textContent.toLowerCase();
|
||||||
|
|
||||||
// 2. Si le bouton bleu n'est pas encore présent dans ce bloc
|
// Si le bouton contient une icône de disquette 💾 ou des mots-clés de validation/sauvegarde
|
||||||
if (parentForm && !parentForm.querySelector('.btn-edit-catalog-shortcut')) {
|
if (classes.includes('success') || classes.includes('primary') || text.includes('salva') || text.includes('enregistrer') || text.includes('aggiungi') || text.includes('💾')) {
|
||||||
|
|
||||||
const editBtn = document.createElement('button');
|
const container = btn.parentNode;
|
||||||
editBtn.type = 'button';
|
|
||||||
editBtn.className = 'btn btn-large btn-edit-catalog-shortcut';
|
|
||||||
editBtn.innerText = '✏️ Modifier la fiche produit (Catégorie)';
|
|
||||||
|
|
||||||
// Style calqué sur la charte graphique
|
// Si notre raccourci bleu n'est pas déjà injecté juste au-dessus
|
||||||
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;';
|
if (container && !container.querySelector('.btn-catalog-shortcut')) {
|
||||||
|
|
||||||
// Action lors du clic : on tente de basculer sur l'éditeur global
|
const editBtn = document.createElement('button');
|
||||||
editBtn.onclick = function(e) {
|
editBtn.type = 'button';
|
||||||
e.preventDefault();
|
editBtn.className = 'btn btn-large btn-catalog-shortcut';
|
||||||
let productId = null;
|
editBtn.innerText = '✏️ Modifier la fiche produit (Catégorie)';
|
||||||
|
|
||||||
// Extraction de l'ID via les variables globales disponibles de l'application
|
// Style calqué sur l'application
|
||||||
if (typeof currentProduct !== 'undefined' && currentProduct) productId = currentProduct.id || currentProduct._id;
|
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;';
|
||||||
if (typeof _currentProduct !== 'undefined' && _currentProduct) productId = _currentProduct.id || _currentProduct._id;
|
|
||||||
if (typeof currentItem !== 'undefined' && currentItem) productId = currentItem.product_id || currentItem.productId;
|
|
||||||
|
|
||||||
if (productId) {
|
// Action au clic
|
||||||
// On masque la modale de stock actuelle
|
editBtn.onclick = function(e) {
|
||||||
document.querySelectorAll('.page, .modal').forEach(el => {
|
e.preventDefault();
|
||||||
el.classList.remove('active');
|
let targetId = null;
|
||||||
el.style.display = 'none';
|
|
||||||
});
|
|
||||||
|
|
||||||
// On ouvre la fonction d'édition de produit
|
if (typeof currentProduct !== 'undefined' && currentProduct) targetId = currentProduct.id || currentProduct._id;
|
||||||
if (typeof editProduct === 'function') {
|
if (typeof _currentProduct !== 'undefined' && _currentProduct) targetId = _currentProduct.id || _currentProduct._id;
|
||||||
editProduct(productId);
|
if (typeof currentItem !== 'undefined' && currentItem) targetId = currentItem.product_id || currentItem.productId;
|
||||||
|
|
||||||
|
if (targetId) {
|
||||||
|
document.querySelectorAll('.page, .modal, .popup').forEach(el => {
|
||||||
|
el.classList.remove('active');
|
||||||
|
el.style.display = 'none';
|
||||||
|
});
|
||||||
|
|
||||||
|
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 {
|
} else {
|
||||||
const prodPage = document.getElementById('page-product-form');
|
alert("Raccourci : Impossible de lier l'identifiant du produit.");
|
||||||
if (prodPage) { prodPage.classList.add('active'); prodPage.style.display = 'block'; }
|
|
||||||
}
|
}
|
||||||
} else {
|
};
|
||||||
alert("Identifiant du produit introuvable dans le contexte actuel.");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Insertion immédiate juste au-dessus du bouton de validation
|
// Insertion immédiate au-dessus du bouton vert détecté
|
||||||
parentForm.insertBefore(editBtn, submitBtn);
|
container.insertBefore(editBtn, btn);
|
||||||
console.log("=> Bouton injecté avec succès au-dessus de :", submitBtn.textContent.trim());
|
console.log("=> Bouton injecté avec succès au-dessus de :", btn.textContent.trim());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, 500); // Scan toutes les 500ms
|
}, 500);
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user