adaptation couleur
This commit is contained in:
parent
c07395efcf
commit
f5997d89ad
@ -269,28 +269,46 @@ export function mapEventToFullCalendar(ev) {
|
||||
});
|
||||
}
|
||||
} else if (isPermanenceAssigned) {
|
||||
// 2) Attribuée : a type intervention ? couleur type : couleur défaut
|
||||
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);
|
||||
// 2) Attribuée : ordre de priorité - département puis local
|
||||
|
||||
// Priorité 1 : Couleur du département
|
||||
const departementId = ev.id_departement ? parseInt(ev.id_departement) : null;
|
||||
if (departementId && !isNaN(departementId) && window.crviACFData && window.crviACFData.departements) {
|
||||
// Chercher le département par ID
|
||||
for (const key in window.crviACFData.departements) {
|
||||
const dept = window.crviACFData.departements[key];
|
||||
if (dept.id === departementId && dept.couleur) {
|
||||
backgroundColor = dept.couleur;
|
||||
console.log('🎨 [COULEUR] Permanence assignée - département:', {
|
||||
eventId: ev.id,
|
||||
departementId: departementId,
|
||||
departementNom: dept.nom,
|
||||
backgroundColor: backgroundColor,
|
||||
source: 'departement'
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (typeInterventionId && !isNaN(typeInterventionId) && window.crviAjax && window.crviAjax.couleurs_types_intervention) {
|
||||
const couleurTypeIntervention = window.crviAjax.couleurs_types_intervention[typeInterventionId];
|
||||
if (couleurTypeIntervention) {
|
||||
backgroundColor = couleurTypeIntervention;
|
||||
console.log('🎨 [COULEUR] Permanence assignée - avec type intervention:', {
|
||||
// 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,
|
||||
typeInterventionId: typeInterventionId,
|
||||
localType: localType,
|
||||
backgroundColor: backgroundColor,
|
||||
source: 'permanence_assignee_type'
|
||||
source: 'type_local'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Si pas de type d'intervention, utiliser couleur défaut
|
||||
// Fallback : couleur par défaut des permanences
|
||||
if (!backgroundColor) {
|
||||
backgroundColor = (window.crviACFData && window.crviACFData.couleurs_permanence && window.crviACFData.couleurs_permanence.permanence)
|
||||
? window.crviACFData.couleurs_permanence.permanence
|
||||
|
||||
@ -558,16 +558,44 @@ export function initializeCalendar() {
|
||||
bgColor = window.crviAjax.couleur_permanence_non_attribuee;
|
||||
}
|
||||
} else if (isPermanenceAssigned) {
|
||||
// 2) Attribuée : a type intervention ? couleur type : couleur défaut
|
||||
const typeInterventionId = eventProps.id_type_intervention ? parseInt(eventProps.id_type_intervention) : null;
|
||||
// 2) Attribuée : ordre de priorité - département puis local
|
||||
|
||||
if (typeInterventionId && !isNaN(typeInterventionId) && window.crviAjax && window.crviAjax.couleurs_types_intervention) {
|
||||
const couleurType = window.crviAjax.couleurs_types_intervention[typeInterventionId];
|
||||
if (couleurType) {
|
||||
bgColor = couleurType;
|
||||
// Priorité 1 : Couleur du département
|
||||
const departementId = eventProps.id_departement ? parseInt(eventProps.id_departement) : null;
|
||||
if (departementId && !isNaN(departementId) && crviACFData && crviACFData.departements) {
|
||||
// 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) {
|
||||
bgColor = (crviACFData && crviACFData.couleurs_permanence && crviACFData.couleurs_permanence.permanence)
|
||||
? crviACFData.couleurs_permanence.permanence
|
||||
@ -822,8 +850,6 @@ export function initializeCalendar() {
|
||||
</div>
|
||||
`;
|
||||
|
||||
console.log('popoverContent:', popoverContent);
|
||||
|
||||
// Initialiser le popover Bootstrap avec titre coloré
|
||||
if (window.bootstrap && window.bootstrap.Popover) {
|
||||
const popover = new bootstrap.Popover(eventEl, {
|
||||
@ -856,6 +882,20 @@ export function initializeCalendar() {
|
||||
if (bodyElement && 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
|
||||
});
|
||||
}
|
||||
|
||||
// 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
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user