InseeFr / Lunatic-Model

Data model for Lunatic
MIT License
1 stars 10 forks source link

`BodyLine` object doesn't have min and max attribute for `"Datepicker"` component type #78

Open nsenave opened 2 years ago

nsenave commented 2 years ago

Table cells are modeled using a BodyLine object.

This objects is design to represent components that are in the table.

It has min and max attributes of type double. This fits the "InputNumber" type of component.

Unfortunately, "Datepicker" component also have min and max attributes, but of String type.

Thus is it impossible to set the min and max attribute for BodyLine objects that represent a "Datepicker" component.


As far as I know, this property is not used in the Lunatic library yet, so it's not a big deal for now.

I don't see an easy quick solution to this since attribute names are the same (even there should be a workaround to do it).

A better solution would to use polymorphism instead of the BodyLine object to put proper components in table cells.

This would also improve the modeling of tables. For instance, Lunatic-Model allows to create a component of type "InputNumber" and set it a maxLength, which would be invalid for Lunatic.

nsenave commented 2 months ago

This would be achievable with custom serializer/deserializer for BodyCell objects.

Yet, a better solution would be to define an interface, and make objects that can be held in a a table implement it, and use these objects (subclassses of ComponentType, LabelType etc.) directly in tables.