adaptation couleur
This commit is contained in:
parent
c07395efcf
commit
f5997d89ad
@ -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) {
|
// Priorité 1 : Couleur du département
|
||||||
typeInterventionId = parseInt(ev.id_type_intervention);
|
const departementId = ev.id_departement ? parseInt(ev.id_departement) : null;
|
||||||
} else if (ev.type_intervention && ev.type_intervention.id) {
|
if (departementId && !isNaN(departementId) && window.crviACFData && window.crviACFData.departements) {
|
||||||
typeInterventionId = parseInt(ev.type_intervention.id);
|
// 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) {
|
// Priorité 2 : Couleur du local (type de local)
|
||||||
const couleurTypeIntervention = window.crviAjax.couleurs_types_intervention[typeInterventionId];
|
if (!backgroundColor && ev.local) {
|
||||||
if (couleurTypeIntervention) {
|
const localType = ev.local.type || ev.local_type;
|
||||||
backgroundColor = couleurTypeIntervention;
|
if (localType && window.crviACFData && window.crviACFData.types_local) {
|
||||||
console.log('🎨 [COULEUR] Permanence assignée - avec type intervention:', {
|
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,
|
eventId: ev.id,
|
||||||
typeInterventionId: typeInterventionId,
|
localType: localType,
|
||||||
backgroundColor: backgroundColor,
|
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) {
|
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
|
||||||
|
|||||||
@ -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
|
||||||
@ -822,8 +850,6 @@ export function initializeCalendar() {
|
|||||||
</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) {
|
||||||
const popover = new bootstrap.Popover(eventEl, {
|
const popover = new bootstrap.Popover(eventEl, {
|
||||||
@ -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
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user