adaptation couleur

This commit is contained in:
Jean-Philippe Staelen 2026-01-20 15:55:10 +01:00
parent c07395efcf
commit f5997d89ad
2 changed files with 98 additions and 26 deletions

View File

@ -269,28 +269,46 @@ export function mapEventToFullCalendar(ev) {
}); });
} }
} else if (isPermanenceAssigned) { } else if (isPermanenceAssigned) {
// 2) Attribuée : a type intervention ? couleur type : couleur défaut // 2) Attribuée : ordre de priorité - département puis local
let typeInterventionId = null;
if (ev.id_type_intervention) {
typeInterventionId = parseInt(ev.id_type_intervention);
} else if (ev.type_intervention && ev.type_intervention.id) {
typeInterventionId = parseInt(ev.type_intervention.id);
}
if (typeInterventionId && !isNaN(typeInterventionId) && window.crviAjax && window.crviAjax.couleurs_types_intervention) { // Priorité 1 : Couleur du département
const couleurTypeIntervention = window.crviAjax.couleurs_types_intervention[typeInterventionId]; const departementId = ev.id_departement ? parseInt(ev.id_departement) : null;
if (couleurTypeIntervention) { if (departementId && !isNaN(departementId) && window.crviACFData && window.crviACFData.departements) {
backgroundColor = couleurTypeIntervention; // Chercher le département par ID
console.log('🎨 [COULEUR] Permanence assignée - avec type intervention:', { for (const key in window.crviACFData.departements) {
eventId: ev.id, const dept = window.crviACFData.departements[key];
typeInterventionId: typeInterventionId, if (dept.id === departementId && dept.couleur) {
backgroundColor: backgroundColor, backgroundColor = dept.couleur;
source: 'permanence_assignee_type' console.log('🎨 [COULEUR] Permanence assignée - département:', {
}); eventId: ev.id,
departementId: departementId,
departementNom: dept.nom,
backgroundColor: backgroundColor,
source: 'departement'
});
break;
}
} }
} }
// Si pas de type d'intervention, utiliser couleur défaut // Priorité 2 : Couleur du local (type de local)
if (!backgroundColor && ev.local) {
const localType = ev.local.type || ev.local_type;
if (localType && window.crviACFData && window.crviACFData.types_local) {
const typeLocalConfig = window.crviACFData.types_local[localType];
if (typeLocalConfig && typeLocalConfig.couleur) {
backgroundColor = typeLocalConfig.couleur;
console.log('🎨 [COULEUR] Permanence assignée - type de local:', {
eventId: ev.id,
localType: localType,
backgroundColor: backgroundColor,
source: 'type_local'
});
}
}
}
// Fallback : couleur par défaut des permanences
if (!backgroundColor) { if (!backgroundColor) {
backgroundColor = (window.crviACFData && window.crviACFData.couleurs_permanence && window.crviACFData.couleurs_permanence.permanence) backgroundColor = (window.crviACFData && window.crviACFData.couleurs_permanence && window.crviACFData.couleurs_permanence.permanence)
? window.crviACFData.couleurs_permanence.permanence ? window.crviACFData.couleurs_permanence.permanence

View File

@ -558,16 +558,44 @@ export function initializeCalendar() {
bgColor = window.crviAjax.couleur_permanence_non_attribuee; bgColor = window.crviAjax.couleur_permanence_non_attribuee;
} }
} else if (isPermanenceAssigned) { } else if (isPermanenceAssigned) {
// 2) Attribuée : a type intervention ? couleur type : couleur défaut // 2) Attribuée : ordre de priorité - département puis local
const typeInterventionId = eventProps.id_type_intervention ? parseInt(eventProps.id_type_intervention) : null;
if (typeInterventionId && !isNaN(typeInterventionId) && window.crviAjax && window.crviAjax.couleurs_types_intervention) { // Priorité 1 : Couleur du département
const couleurType = window.crviAjax.couleurs_types_intervention[typeInterventionId]; const departementId = eventProps.id_departement ? parseInt(eventProps.id_departement) : null;
if (couleurType) { if (departementId && !isNaN(departementId) && crviACFData && crviACFData.departements) {
bgColor = couleurType; // Chercher le département par ID
for (const key in crviACFData.departements) {
const dept = crviACFData.departements[key];
if (dept.id === departementId && dept.couleur) {
bgColor = dept.couleur;
console.log('🎨 [COULEUR] Département trouvé:', {
eventId: event.id,
departementId: departementId,
departementNom: dept.nom,
couleur: bgColor
});
break;
}
} }
} }
// Priorité 2 : Couleur du local (type de local)
if (!bgColor && eventProps.local) {
const localType = eventProps.local.type || eventProps.local_type;
if (localType && crviACFData && crviACFData.types_local) {
const typeLocalConfig = crviACFData.types_local[localType];
if (typeLocalConfig && typeLocalConfig.couleur) {
bgColor = typeLocalConfig.couleur;
console.log('🎨 [COULEUR] Type de local trouvé:', {
eventId: event.id,
localType: localType,
couleur: bgColor
});
}
}
}
// Fallback : couleur par défaut des permanences
if (!bgColor) { if (!bgColor) {
bgColor = (crviACFData && crviACFData.couleurs_permanence && crviACFData.couleurs_permanence.permanence) bgColor = (crviACFData && crviACFData.couleurs_permanence && crviACFData.couleurs_permanence.permanence)
? crviACFData.couleurs_permanence.permanence ? crviACFData.couleurs_permanence.permanence
@ -821,8 +849,6 @@ export function initializeCalendar() {
</div> </div>
</div> </div>
`; `;
console.log('popoverContent:', popoverContent);
// Initialiser le popover Bootstrap avec titre coloré // Initialiser le popover Bootstrap avec titre coloré
if (window.bootstrap && window.bootstrap.Popover) { if (window.bootstrap && window.bootstrap.Popover) {
@ -856,6 +882,20 @@ export function initializeCalendar() {
if (bodyElement && txtColor) { if (bodyElement && txtColor) {
bodyElement.style.color = txtColor; bodyElement.style.color = txtColor;
} }
// Appliquer les styles du statut
const statutElement = popoverElement.querySelector('.event-status');
if (statutElement) {
const statutDisplay = getStatutDisplay(eventProps.statut, eventProps.type);
statutElement.style.backgroundColor = statutDisplay.color;
statutElement.style.color = getTextColor(statutDisplay.color);
statutElement.style.padding = '2px 8px';
statutElement.style.borderRadius = '3px';
console.log('🎨 [POPOVER] Styles de statut appliqués:', {
statut: statutDisplay.text,
backgroundColor: statutDisplay.color
});
}
} }
}); });
@ -874,6 +914,20 @@ export function initializeCalendar() {
color: popoverTextColor color: popoverTextColor
}); });
} }
// Appliquer aussi les styles du statut
const statutElement = node.querySelector('.event-status');
if (statutElement) {
const statutDisplay = getStatutDisplay(eventProps.statut, eventProps.type);
statutElement.style.backgroundColor = statutDisplay.color;
statutElement.style.color = getTextColor(statutDisplay.color);
statutElement.style.padding = '2px 8px';
statutElement.style.borderRadius = '3px';
console.log('🎨 [POPOVER] Styles de statut appliqués via observer:', {
statut: statutDisplay.text,
backgroundColor: statutDisplay.color
});
}
} }
}); });
}); });