Skip to content

feat: qcu options based on loop response#322

Merged
RemiVerriez merged 6 commits intomainfrom
feat/qcu-options-based-on-loop-response
Feb 17, 2026
Merged

feat: qcu options based on loop response#322
RemiVerriez merged 6 commits intomainfrom
feat/qcu-options-based-on-loop-response

Conversation

@RemiVerriez
Copy link
Contributor

This PR extends the Lunatic flat model to support dynamic response options
for QCU components (Radio, Dropdown, CheckboxOne).

Two mutually exclusive modes are now supported at the model level:

  • static options, using the existing options property
  • dynamic options, using optionSource and an optional optionFilter

The Lunatic model remains flat and does not embed business logic.
As a consequence, the options property is always serialized
(even as an empty array) to preserve a stable and consistent JSON contract.

The responsibility for choosing between static and dynamic modes
remains in upstream business logic (e.g. mapping layer),
not in the Lunatic model itself.

Serialization and deserialization tests have been added to document
and secure this behavior.

Copy link
Contributor

@nsenave nsenave left a comment

Choose a reason for hiding this comment

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

Le type pour les optionFilter correspond vraiment à un LabelType, d'ailleurs à vérifier avec @laurentC35 ou quelqu'un qui connaît bien Lunatic si on a pas besoin des maudits bindingDependencies dans le option filter, dans ce cas là utiliser le type ConditionFilterType


NB : si par défaut je préfère LabelType c'est qu'à terme j'aimerais virer l'objet ConditionFilterType et le remplacer par LabelType.

Cet objet "label" c'est celui qu'on utilise pour les expression VTL dans le modèle Lunatic

Copy link
Contributor

Choose a reason for hiding this comment

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

Cette classe est quasi-identique à LabelType, ça me paraîtrait pertinent de la réutiliser

protected String optionSource;

/** Optional filter for dynamic options. */
protected OptionFilter optionFilter;
Copy link
Contributor

Choose a reason for hiding this comment

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

on peut refacto en protected LabelType optionFilter

protected String optionSource;

/** Optional filter for dynamic options. */
protected OptionFilter optionFilter;
Copy link
Contributor

Choose a reason for hiding this comment

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

idem LabelType

Dropdown dropdown = new Dropdown();
dropdown.setId("dropdown-dyn-id");
dropdown.setOptionSource("FIRST_NAME");
dropdown.setOptionFilter(new OptionFilter("VTL", "AGE >= 18", "FIRST_NAME"));
Copy link
Contributor

Choose a reason for hiding this comment

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

cf. refacto avec LabelType

dropdown.setOptionFilter(new LabelType());
dropdown.getOptionFilter().setType(LabelTypeEnum.VTL);
dropdown.getOptionFilter().setValue("AGE >= 18");
dropdown.getOptionFilter().setShapeFrom("FIRST_NAME");

(ou pourquoi pas ajouter un all args constructor à LabelType)

@sonarqubecloud
Copy link

@RemiVerriez RemiVerriez requested a review from nsenave February 17, 2026 10:27
Copy link
Contributor

@laurentC35 laurentC35 left a comment

Choose a reason for hiding this comment

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

C'est bon par rapport à la PR Lunatic (JS): InseeFr/Lunatic#1296

Pas besoin des bindingDependencies ici

Copy link
Contributor

@nsenave nsenave left a comment

Choose a reason for hiding this comment

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

good job 👍

@RemiVerriez RemiVerriez merged commit eccdab5 into main Feb 17, 2026
3 checks passed
@RemiVerriez RemiVerriez deleted the feat/qcu-options-based-on-loop-response branch February 17, 2026 10:39
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

Comments