comparaison string/number

This commit is contained in:
Jean-Philippe Staelen 2026-01-20 16:20:50 +01:00
parent 0b07a03925
commit dde9503e07
3 changed files with 238 additions and 31 deletions

View File

@ -58,32 +58,130 @@ export function mapEventToFullCalendar(ev) {
// Pour les RDV (individuel/groupe) assignés
if (ev.type && ev.type !== 'permanence' && isEventAssigned) {
// Vérifier si l'événement a un type d'intervention défini
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);
// Ordre de priorité : département > type d'intervention > local > défaut
// Priorité 1 : Couleur du département
const departementId = ev.id_departement ? parseInt(ev.id_departement) : null;
// 🔍 DEBUG pour événement 410
if (ev.id === 410 || ev.id === '410') {
console.log('🔍 [MAPPER DEBUG 410 - RDV] Début analyse couleur département:', {
eventId: ev.id,
type: ev.type,
id_departement_brut: ev.id_departement,
departementId_parsed: departementId,
crviACFData_existe: !!window.crviACFData,
departements_existe: !!(window.crviACFData && window.crviACFData.departements)
});
}
// Si l'événement a un type d'intervention, utiliser sa couleur depuis crviAjax
if (typeInterventionId && !isNaN(typeInterventionId) && window.crviAjax && window.crviAjax.couleurs_types_intervention) {
const couleurTypeIntervention = window.crviAjax.couleurs_types_intervention[typeInterventionId];
if (couleurTypeIntervention) {
backgroundColor = couleurTypeIntervention;
textColor = getTextColor(couleurTypeIntervention);
console.log('🎨 [COULEUR] RDV assigné avec type d\'intervention:', {
eventId: ev.id,
type: ev.type,
typeInterventionId: typeInterventionId,
backgroundColor: backgroundColor,
textColor: textColor,
source: 'type_intervention'
});
if (departementId && !isNaN(departementId) && window.crviACFData && window.crviACFData.departements) {
// 🔍 DEBUG pour événement 410 - liste des départements
if (ev.id === 410 || ev.id === '410') {
console.log('🔍 [MAPPER DEBUG 410 - RDV] Recherche département ID:', departementId);
console.log('🔍 [MAPPER DEBUG 410 - RDV] Départements disponibles:',
Object.keys(window.crviACFData.departements).map(key => ({
key: key,
id: window.crviACFData.departements[key].id,
nom: window.crviACFData.departements[key].nom,
couleur: window.crviACFData.departements[key].couleur
}))
);
}
// Chercher le département par ID
for (const key in window.crviACFData.departements) {
const dept = window.crviACFData.departements[key];
// 🔍 DEBUG pour événement 410 - comparaison
if (ev.id === 410 || ev.id === '410') {
console.log('🔍 [MAPPER DEBUG 410 - RDV] Comparaison:', {
key: key,
dept_id: dept.id,
dept_id_type: typeof dept.id,
recherche_id: departementId,
recherche_id_type: typeof departementId,
sont_egaux: dept.id === departementId,
dept_couleur: dept.couleur
});
}
if (dept.id === departementId && dept.couleur) {
backgroundColor = dept.couleur;
textColor = getTextColor(backgroundColor);
console.log('🎨 [COULEUR] RDV assigné - département:', {
eventId: ev.id,
type: ev.type,
departementId: departementId,
departementNom: dept.nom,
backgroundColor: backgroundColor,
source: 'departement'
});
// 🔍 DEBUG pour événement 410 - succès
if (ev.id === 410 || ev.id === '410') {
console.log('✅ [MAPPER DEBUG 410 - RDV] Couleur département appliquée:', {
departementNom: dept.nom,
couleurAppliquee: backgroundColor
});
}
break;
}
}
// 🔍 DEBUG pour événement 410 - échec de recherche
if ((ev.id === 410 || ev.id === '410') && !backgroundColor) {
console.warn('⚠️ [MAPPER DEBUG 410 - RDV] Aucun département correspondant trouvé!');
}
}
// Si pas de couleur définie (pas de type d'intervention), garder orange par défaut
// Priorité 2 : Type d'intervention (si pas de département)
if (!backgroundColor) {
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);
}
// Si l'événement a un type d'intervention, utiliser sa couleur depuis crviAjax
if (typeInterventionId && !isNaN(typeInterventionId) && window.crviAjax && window.crviAjax.couleurs_types_intervention) {
const couleurTypeIntervention = window.crviAjax.couleurs_types_intervention[typeInterventionId];
if (couleurTypeIntervention) {
backgroundColor = couleurTypeIntervention;
textColor = getTextColor(couleurTypeIntervention);
console.log('🎨 [COULEUR] RDV assigné avec type d\'intervention:', {
eventId: ev.id,
type: ev.type,
typeInterventionId: typeInterventionId,
backgroundColor: backgroundColor,
textColor: textColor,
source: 'type_intervention'
});
}
}
}
// Priorité 3 : 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;
textColor = getTextColor(backgroundColor);
console.log('🎨 [COULEUR] RDV assigné - type de local:', {
eventId: ev.id,
type: ev.type,
localType: localType,
backgroundColor: backgroundColor,
source: 'type_local'
});
}
}
}
// Fallback : orange par défaut
if (!backgroundColor) {
backgroundColor = '#ff9800'; // Orange pour les événements assignés sans type d'intervention
textColor = getTextColor(backgroundColor);

View File

@ -656,16 +656,115 @@ export function initializeCalendar() {
}
}
} else {
// Pour les RDV : type d'intervention ou orange par défaut
const typeInterventionId = eventProps.id_type_intervention ? parseInt(eventProps.id_type_intervention) : null;
// Pour les RDV : ordre de priorité - département > type d'intervention > local > défaut
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;
// 🔍 DEBUG pour événement 410
if (event.id === '410') {
console.log('🔍 [DEBUG 410 - RDV] Début analyse couleur département:', {
eventId: event.id,
type: eventProps.type,
id_departement_brut: eventProps.id_departement,
departementId_parsed: departementId,
crviACFData_existe: !!crviACFData,
departements_existe: !!(crviACFData && crviACFData.departements)
});
}
if (departementId && !isNaN(departementId) && crviACFData && crviACFData.departements) {
// 🔍 DEBUG pour événement 410 - liste des départements
if (event.id === '410') {
console.log('🔍 [DEBUG 410 - RDV] Recherche département ID:', departementId);
console.log('🔍 [DEBUG 410 - RDV] Départements disponibles:',
Object.keys(crviACFData.departements).map(key => ({
key: key,
id: crviACFData.departements[key].id,
nom: crviACFData.departements[key].nom,
couleur: crviACFData.departements[key].couleur
}))
);
}
// Chercher le département par ID
for (const key in crviACFData.departements) {
const dept = crviACFData.departements[key];
// 🔍 DEBUG pour événement 410 - comparaison
if (event.id === '410') {
console.log('🔍 [DEBUG 410 - RDV] Comparaison:', {
key: key,
dept_id: dept.id,
dept_id_type: typeof dept.id,
recherche_id: departementId,
recherche_id_type: typeof departementId,
sont_egaux: dept.id === departementId,
dept_couleur: dept.couleur
});
}
if (dept.id === departementId && dept.couleur) {
bgColor = dept.couleur;
console.log('🎨 [COULEUR] RDV - département trouvé:', {
eventId: event.id,
type: eventProps.type,
departementId: departementId,
departementNom: dept.nom,
couleur: bgColor
});
// 🔍 DEBUG pour événement 410 - succès
if (event.id === '410') {
console.log('✅ [DEBUG 410 - RDV] Couleur département appliquée:', {
departementNom: dept.nom,
couleurAppliquee: bgColor
});
}
break;
}
}
// 🔍 DEBUG pour événement 410 - échec de recherche
if (event.id === '410' && !bgColor) {
console.warn('⚠️ [DEBUG 410 - RDV] Aucun département correspondant trouvé!');
}
}
// Priorité 2 : Type d'intervention (si pas de département)
if (!bgColor) {
const typeInterventionId = eventProps.id_type_intervention ? parseInt(eventProps.id_type_intervention) : null;
if (typeInterventionId && !isNaN(typeInterventionId) && window.crviAjax && window.crviAjax.couleurs_types_intervention) {
const couleurType = window.crviAjax.couleurs_types_intervention[typeInterventionId];
if (couleurType) {
bgColor = couleurType;
console.log('🎨 [COULEUR] RDV - type intervention trouvé:', {
eventId: event.id,
typeInterventionId: typeInterventionId,
couleur: bgColor
});
}
}
}
// Priorité 3 : 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] RDV - type de local trouvé:', {
eventId: event.id,
localType: localType,
couleur: bgColor
});
}
}
}
// Fallback : orange par défaut
if (!bgColor) {
bgColor = '#ff9800'; // Orange par défaut
}

View File

@ -66,8 +66,11 @@ function mergeEventDataWithAvailability(availabilityData, eventData) {
return availabilityEntities;
}
// Vérifier si l'entité existe déjà
const exists = availabilityEntities.some(entity => entity.id == eventEntityId);
// Vérifier si l'entité existe déjà (conversion en string pour comparaison)
const eventEntityIdStr = eventEntityId != null ? eventEntityId.toString() : null;
const exists = availabilityEntities.some(entity =>
entity.id != null && entity.id.toString() === eventEntityIdStr
);
if (!exists) {
return [...availabilityEntities, eventEntityData];
@ -292,7 +295,14 @@ function filterSelectOptions(data, currentEventData = null) {
if (isPermanence && languesDisponibles && languesDisponibles.trim() !== '') {
const languesPermises = languesDisponibles.split(',').map(l => l.trim()).filter(l => l !== '');
const languesFiltrees = (data.langues || []).filter(langue => {
return languesPermises.includes(langue.id || langue.slug || langue);
// Convertir en string pour comparaison (éviter problème string vs number)
const langueIdStr = langue.id != null ? langue.id.toString() : null;
const langueSlugStr = langue.slug != null ? langue.slug.toString() : null;
const langueStr = typeof langue === 'string' ? langue : null;
return languesPermises.includes(langueIdStr) ||
languesPermises.includes(langueSlugStr) ||
languesPermises.includes(langueStr);
});
filterSelect('langue', languesFiltrees);
} else {
@ -430,7 +440,7 @@ export function filterTraducteursByLangue() {
return;
}
const selectedLangue = langueSelect.value;
const selectedLangue = langueSelect.value ? langueSelect.value.toString() : '';
const currentTraducteurValue = traducteurSelect.value;
// Si aucune langue sélectionnée, afficher tous les traducteurs