Skip to content

Conversation

basseche
Copy link
Contributor

No description provided.

… equipment type and add new Fields for Aleas by filter

Signed-off-by: basseche <[email protected]>
@basseche basseche self-assigned this Aug 22, 2025
@basseche basseche changed the title Add color map to DirectoryItemInput so we can give different color by equipmentType and add Fields needed for contingency list by filter WIP : Add color map to DirectoryItemInput so we can give different color by equipmentType and add Fields needed for contingency list by filter Sep 2, 2025
@basseche basseche force-pushed the contingencyListByFilter branch 3 times, most recently from b0f47df to 5b94394 Compare September 4, 2025 07:58
Signed-off-by: basseche <[email protected]>
@basseche basseche force-pushed the contingencyListByFilter branch from 5b94394 to bf01977 Compare September 4, 2025 07:59
@basseche basseche changed the title WIP : Add color map to DirectoryItemInput so we can give different color by equipmentType and add Fields needed for contingency list by filter Add color map to DirectoryItemInput so we can give different color by equipmentType and add Fields needed for contingency list by filter Sep 11, 2025
@flomillot flomillot self-requested a review September 17, 2025 15:18
fields: elements,
append,
remove,
} = useFieldArray({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

À mon avis il n'y a plus besoin de renommer fields ici vu qu'il est déjà renommé en bas, autant garder le nom d'origine ici plutôt que de le changer 2 fois

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok renommage enlevé

Comment on lines 198 to 201
item.specificMetadata?.equipmentType &&
equipmentColorsMap?.has(item.specificMetadata?.equipmentType)
? equipmentColorsMap.get(item.specificMetadata.equipmentType)
: undefined,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
item.specificMetadata?.equipmentType &&
equipmentColorsMap?.has(item.specificMetadata?.equipmentType)
? equipmentColorsMap.get(item.specificMetadata.equipmentType)
: undefined,
equipmentColorsMap?.get(item.specificMetadata?.equipmentType)

Corrigez moi si je me trompe mais je crois que du coup ça revient exactement a la même chose

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pas vraiment car si item.specificMetadata?.equipmentType est null ou undefined il y a possibilité de crash.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non ça renvoit juste undefined (j'ai testé avant d'écrire le commentaire :p )
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/get#return_value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

modifié

}
/>
{elementsWithMetaData.map((item, index) => (
<Box key={`Box${item.id}`} sx={{ display: 'flex', flexDirection: 'column', gap: 1 }}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est pas quelque chose dont on risque d'avoir besoin ailleurs ? il faudrait peut-être sortir ce code et en faire un composant ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

le but de cela est de mettre une couleur pour les chip et le type en HelperText en dessous. Pour le moment cette caractéristique n'est utilisée que par le formulaire des aléas. Je ne sais pas si on aurait besoin de ça ailleurs dans le futur. Le fait de faire une composant séparé j'y ai pensé, mais ça fait tout de même un certain pourcentage de duplication de code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi duplication, quel code serait dupliqué ? Au contraire sortir le code en un composant permettra de limiter la duplication de code dans le futur, et d'alléger DirectoryItemsInput.
Mais bon pas grave au pire on pourra le faire dans une autre US quand on en aura besoin.

} = useFieldArray({
name,
});
const elementsWithMetaData: TreeViewFinderNodeProps[] = elements as unknown as TreeViewFinderNodeProps[];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On est sûr que les champs correspondent toujours à ce type TreeViewFinderNodeProps ?
J'ai essayé de remonter pour voir où se composant était utilisé et franchement j'ai toujours aucune idée d'à quoi ressemble ce formulaire.
En tout cas rien que le nom est bizarre, d'après le nom c'est censé être utilisé uniquement dans l'arbre mais je vois qu'il est un peu partout...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

normalement ça utilise DirectoryItemSelector, qui lui utilise TreeViewFinder les elements récupérer ont bien ce type.

return '';
}
return equipmentType !== EquipmentType.HVDC_LINE
? (BASE_EQUIPMENTS[equipmentType as EquipmentType]?.label ?? '')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pourquoi ne pas rajouter ce type d'équipement dans BASE_EQUIPMENTS ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parce que BASE_EQUIPMENTS est utilisé un peu partout je suppose et il ne faut pas modifier des listes uniquement pour notre besoin d'affichage de type.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pour moi il faut l'ajouter, sinon je vois pas l’intérêt de maintenir une liste d’équipement, si on commence à faire des if comme ça c'est pas maintenable, mais bon peut être que je me trompe...
@thangqp a créé cette liste, peut être peut il donner son avis ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

autre enum utilisée finalement

@basseche basseche requested review from flomillot and removed request for Mathieu-Deharbe September 22, 2025 13:33
@thangqp thangqp self-requested a review September 24, 2025 12:57
Copy link

@basseche basseche merged commit 9d2d4df into main Sep 24, 2025
5 checks passed
@basseche basseche deleted the contingencyListByFilter branch September 24, 2025 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants