Valide
This commit is contained in:
parent
a87e165f97
commit
a59c0183b3
File diff suppressed because it is too large
Load Diff
226
Vue/gabarit.php
226
Vue/gabarit.php
|
|
@ -555,14 +555,64 @@ foreach ($menus as $key0 => $menuParent) {
|
||||||
<!-- Service Worker Registration -->
|
<!-- Service Worker Registration -->
|
||||||
<script src="/Js/sw-register.js?ver=2025.12.22.00"></script>
|
<script src="/Js/sw-register.js?ver=2025.12.22.00"></script>
|
||||||
|
|
||||||
|
<!-- AJOUTEZ APRÈS LES INCLUDES DE SCRIPTS -->
|
||||||
<script>
|
<script>
|
||||||
// Test du système de menus
|
// ATTENTION : Ce script doit venir APRÈS l'inclusion de ux-manager.js
|
||||||
|
window.appNavigation = null; // Initialisation
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
// Attendre que UXManager soit initialisé
|
||||||
|
setTimeout(function() {
|
||||||
|
if (window.appUX && window.appUX.navigation) {
|
||||||
|
window.appNavigation = window.appUX.navigation;
|
||||||
|
console.log('[App] Navigation disponible via window.appNavigation');
|
||||||
|
} else {
|
||||||
|
console.error('[App] NavigationManager non disponible');
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Test du système de menus - VERSION ROBUSTE
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
// Attendre un peu que tout soit chargé
|
||||||
|
setTimeout(function() {
|
||||||
|
testMenuSystem();
|
||||||
|
}, 300);
|
||||||
|
});
|
||||||
|
|
||||||
|
function testMenuSystem() {
|
||||||
console.group('=== TEST SYSTÈME DE MENUS ===');
|
console.group('=== TEST SYSTÈME DE MENUS ===');
|
||||||
|
|
||||||
|
// Méthode 1: Via appUX
|
||||||
|
if (window.appUX && window.appUX.navigation) {
|
||||||
|
console.log('✓ NavigationManager disponible via appUX');
|
||||||
|
executeMenuTest(window.appUX.navigation);
|
||||||
|
}
|
||||||
|
// Méthode 2: Via appNavigation global
|
||||||
|
else if (window.appNavigation && typeof window.appNavigation.closeAllExceptActive === 'function') {
|
||||||
|
console.log('✓ NavigationManager disponible via appNavigation');
|
||||||
|
executeMenuTest(window.appNavigation);
|
||||||
|
}
|
||||||
|
// Méthode 3: Via uxManager
|
||||||
|
else if (window.uxManager) {
|
||||||
|
console.log('✓ uxManager disponible');
|
||||||
|
executeMenuTest(window.uxManager);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.error('✗ Aucun gestionnaire de navigation disponible');
|
||||||
|
manualMenuFix();
|
||||||
|
}
|
||||||
|
|
||||||
|
console.groupEnd();
|
||||||
|
}
|
||||||
|
|
||||||
|
function executeMenuTest(navManager) {
|
||||||
// Vérifier l'état initial
|
// Vérifier l'état initial
|
||||||
const activeMenuId = window.appConfig?.activeParentId !== null ?
|
const activeParentId = window.appConfig?.activeParentId;
|
||||||
`submenu${window.appConfig.activeParentId}` : null;
|
const activeMenuId = activeParentId !== null && activeParentId !== '' ?
|
||||||
|
`submenu${activeParentId}` : null;
|
||||||
|
|
||||||
console.log('Menu actif configuré:', activeMenuId);
|
console.log('Menu actif configuré:', activeMenuId);
|
||||||
console.log('Page active:', window.appConfig?.activeLink);
|
console.log('Page active:', window.appConfig?.activeLink);
|
||||||
|
|
@ -580,111 +630,89 @@ foreach ($menus as $key0 => $menuParent) {
|
||||||
console.warn('⚠️ Plusieurs menus sont ouverts!');
|
console.warn('⚠️ Plusieurs menus sont ouverts!');
|
||||||
console.warn('Seul le menu', activeMenuId, 'devrait être ouvert.');
|
console.warn('Seul le menu', activeMenuId, 'devrait être ouvert.');
|
||||||
|
|
||||||
// Corriger automatiquement
|
// Utiliser la méthode disponible
|
||||||
if (activeMenuId && window.appNavigation) {
|
if (navManager.closeAllExceptActive) {
|
||||||
console.log('Correction automatique en cours...');
|
console.log('Correction via closeAllExceptActive...');
|
||||||
window.appNavigation.closeAllExceptActive();
|
navManager.closeAllExceptActive();
|
||||||
}
|
} else if (navManager.closeAllMenus) {
|
||||||
} else if (openMenus.length === 1 && openMenus[0].id === activeMenuId) {
|
console.log('Correction via closeAllMenus...');
|
||||||
console.log('✅ Parfait! Seul le menu actif est ouvert.');
|
navManager.closeAllMenus();
|
||||||
} else if (openMenus.length === 0 && !activeMenuId) {
|
|
||||||
console.log('✅ Aucun menu ouvert - Comportement attendu.');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Exposer des fonctions de test
|
|
||||||
window.menuTest = {
|
|
||||||
openAllMenus: function() {
|
|
||||||
document.querySelectorAll('.nav-submenu').forEach(menu => {
|
|
||||||
menu.classList.add('show');
|
|
||||||
const link = document.querySelector(`[href="#${menu.id}"]`);
|
|
||||||
if (link) link.setAttribute('aria-expanded', 'true');
|
|
||||||
});
|
|
||||||
console.log('Tous les menus ouverts (test)');
|
|
||||||
},
|
|
||||||
|
|
||||||
closeAllMenus: function() {
|
|
||||||
document.querySelectorAll('.nav-submenu').forEach(menu => {
|
|
||||||
menu.classList.remove('show');
|
|
||||||
const link = document.querySelector(`[href="#${menu.id}"]`);
|
|
||||||
if (link) link.setAttribute('aria-expanded', 'false');
|
|
||||||
});
|
|
||||||
console.log('Tous les menus fermés (test)');
|
|
||||||
},
|
|
||||||
|
|
||||||
showMenuState: function() {
|
|
||||||
const menus = document.querySelectorAll('.nav-submenu');
|
|
||||||
console.log('État des menus:');
|
|
||||||
menus.forEach(menu => {
|
|
||||||
const isOpen = menu.classList.contains('show');
|
|
||||||
const link = document.querySelector(`[href="#${menu.id}"]`);
|
|
||||||
const ariaExpanded = link ? link.getAttribute('aria-expanded') : 'N/A';
|
|
||||||
console.log(` ${menu.id}: ${isOpen ? 'OUVERT' : 'FERMÉ'} (aria-expanded: ${ariaExpanded})`);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
console.groupEnd();
|
|
||||||
|
|
||||||
// Ajouter un indicateur visuel de débogage
|
|
||||||
if (window.appConfig?.debugMode) {
|
|
||||||
const debugIndicator = document.createElement('div');
|
|
||||||
debugIndicator.style.cssText = `
|
|
||||||
position: fixed;
|
|
||||||
bottom: 10px;
|
|
||||||
left: 10px;
|
|
||||||
background: rgba(0,0,0,0.8);
|
|
||||||
color: #0f0;
|
|
||||||
padding: 5px 10px;
|
|
||||||
border-radius: 4px;
|
|
||||||
font-family: monospace;
|
|
||||||
font-size: 12px;
|
|
||||||
z-index: 9999;
|
|
||||||
pointer-events: none;
|
|
||||||
`;
|
|
||||||
debugIndicator.textContent = `Menu: ${activeMenuId || 'Aucun'}`;
|
|
||||||
document.body.appendChild(debugIndicator);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Fonction globale pour tester depuis la console
|
|
||||||
function testMenuSystem() {
|
|
||||||
console.log('=== TEST MANUEL DU SYSTÈME DE MENUS ===');
|
|
||||||
|
|
||||||
if (!window.appNavigation) {
|
|
||||||
console.error('appNavigation non disponible');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Test 1: Fermer tous les menus
|
|
||||||
console.log('Test 1: Fermeture de tous les menus...');
|
|
||||||
window.appNavigation.closeAllMenus();
|
|
||||||
|
|
||||||
// Test 2: Ouvrir le menu actif
|
|
||||||
setTimeout(() => {
|
|
||||||
const activeId = window.appConfig?.activeParentId !== null ?
|
|
||||||
`submenu${window.appConfig.activeParentId}` : null;
|
|
||||||
|
|
||||||
if (activeId) {
|
|
||||||
console.log('Test 2: Ouverture du menu actif:', activeId);
|
|
||||||
window.appNavigation.openMenuById(activeId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test 3: Vérification finale
|
// Vérifier le résultat
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const openMenus = document.querySelectorAll('.nav-submenu.show').length;
|
const openAfter = document.querySelectorAll('.nav-submenu.show').length;
|
||||||
console.log('Test 3: Résultat -', openMenus, 'menu(s) ouvert(s)');
|
console.log('Menus ouverts après correction:', openAfter);
|
||||||
|
|
||||||
if (openMenus === 1 || (openMenus === 0 && !activeId)) {
|
if (openAfter <= 1) {
|
||||||
console.log('✅ Système de menus fonctionne correctement!');
|
console.log('✅ Correction réussie!');
|
||||||
} else {
|
} else {
|
||||||
console.warn('⚠️ Problème détecté avec le système de menus');
|
console.warn('⚠️ Correction incomplète, forcer la fermeture...');
|
||||||
|
manualMenuFix();
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 200);
|
||||||
}, 500);
|
} else {
|
||||||
|
console.log('✅ État correct des menus');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Exposer la fonction de test
|
function manualMenuFix() {
|
||||||
|
console.log('🔧 Application du correctif manuel...');
|
||||||
|
|
||||||
|
const activeParentId = window.appConfig?.activeParentId;
|
||||||
|
const activeMenuId = activeParentId !== null && activeParentId !== '' ?
|
||||||
|
`submenu${activeParentId}` : null;
|
||||||
|
|
||||||
|
// 1. Fermer TOUS les menus
|
||||||
|
document.querySelectorAll('.nav-submenu').forEach(menu => {
|
||||||
|
menu.classList.remove('show');
|
||||||
|
menu.style.display = 'none';
|
||||||
|
|
||||||
|
const link = document.querySelector(`[href="#${menu.id}"]`);
|
||||||
|
if (link) {
|
||||||
|
link.setAttribute('aria-expanded', 'false');
|
||||||
|
link.classList.remove('active');
|
||||||
|
const arrow = link.querySelector('.nav-arrow');
|
||||||
|
if (arrow) arrow.style.transform = 'rotate(0deg)';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 2. Ouvrir SEULEMENT le menu actif
|
||||||
|
if (activeMenuId) {
|
||||||
|
setTimeout(() => {
|
||||||
|
const menu = document.getElementById(activeMenuId);
|
||||||
|
const link = document.querySelector(`[href="#${activeMenuId}"]`);
|
||||||
|
|
||||||
|
if (menu && link) {
|
||||||
|
menu.classList.add('show');
|
||||||
|
menu.style.display = 'block';
|
||||||
|
link.setAttribute('aria-expanded', 'true');
|
||||||
|
link.classList.add('active');
|
||||||
|
|
||||||
|
const arrow = link.querySelector('.nav-arrow');
|
||||||
|
if (arrow) arrow.style.transform = 'rotate(90deg)';
|
||||||
|
|
||||||
|
console.log('✅ Menu actif ouvert:', activeMenuId);
|
||||||
|
}
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Vérification finale
|
||||||
|
setTimeout(() => {
|
||||||
|
const openCount = document.querySelectorAll('.nav-submenu.show').length;
|
||||||
|
console.log('📊 Résultat final:', openCount, 'menu(s) ouvert(s)');
|
||||||
|
|
||||||
|
if (openCount === 1 || (openCount === 0 && !activeMenuId)) {
|
||||||
|
console.log('✅ Système de menus corrigé avec succès!');
|
||||||
|
} else {
|
||||||
|
console.error('❌ Échec de la correction manuelle');
|
||||||
|
}
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exposer la fonction de test globalement
|
||||||
window.testMenuSystem = testMenuSystem;
|
window.testMenuSystem = testMenuSystem;
|
||||||
|
window.manualMenuFix = manualMenuFix;
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user