chairemobilite / evolution

Online survey platform for travel survey
MIT License
4 stars 9 forks source link

Support section functions to avoid same calculation many times in a refresh #750

Open tahini opened 1 month ago

tahini commented 1 month ago

In widgets, there are often common code. For example, in the segments section, the modePre and hasNextMode questions should not be asked if the question about the mode same as reverse trip is displayed.

Also many conditionals will do complex operations to get the current trip's destination activity, while the label will also require that information to personalize its string.

While it is possible to extract common code in helpers, this code still needs to be executed each time it is used.

It should be possible to re-use some calculations between widgets/functions from a same refresh run.

This could be easier once we move to objects, to know when to reset the calculation data for each object, but it can still be done now somehow, with a reset every refresh