Lunatic icon indicating copy to clipboard operation
Lunatic copied to clipboard

Min / max in loop not handled correctly

Open romaintailhurat opened this issue 1 year ago • 5 comments

When specifying a loop using min and max attribute, we're supposed to handle min < max by presenting only one iteration (one element of the loop), the user being able to add iteration to the max defined.

It currently only works when the max is a value (eg 5) but not when it's a variable: in this case, all the elements are displayed.

How to reproduce: copy the questionnaire JSON below 👇 into the storybook.

For now, we leave this issue in stand-by, in order to find which way of handling the case is the best.

Example JSON
{
  "cleaning": {},
  "variables": [
    {
      "variableType": "COLLECTED",
      "values": {
        "COLLECTED": null,
        "EDITED": null,
        "INPUTED": null,
        "FORCED": null,
        "PREVIOUS": null
      },
      "name": "COMMENT_QE"
    },
    {
      "variableType": "COLLECTED",
      "values": {
        "COLLECTED": null,
        "EDITED": null,
        "INPUTED": null,
        "FORCED": null,
        "PREVIOUS": null
      },
      "name": "N"
    },
    {
      "variableType": "COLLECTED",
      "values": {
        "COLLECTED": [
          null
        ],
        "EDITED": [
          null
        ],
        "INPUTED": [
          null
        ],
        "FORCED": [
          null
        ],
        "PREVIOUS": [
          null
        ]
      },
      "name": "ARPTER"
    },
    {
      "variableType": "CALCULATED",
      "expression": {
        "type": "VTL",
        "value": "true"
      },
      "name": "FILTER_RESULT_N",
      "inFilter": "false"
    },
    {
      "variableType": "CALCULATED",
      "expression": {
        "type": "VTL",
        "value": "true"
      },
      "name": "FILTER_RESULT_REPEAT",
      "inFilter": "false",
      "shapeFrom": "ARPTER"
    }
  ],
  "components": [
    {
      "componentType": "Sequence",
      "hierarchy": {
        "sequence": {
          "id": "lhywno65",
          "page": "1",
          "label": {
            "type": "VTL|MD",
            "value": "\"I - \" || \"S1\""
          }
        }
      },
      "conditionFilter": {
        "type": "VTL",
        "value": "true"
      },
      "id": "lhywno65",
      "page": "1",
      "label": {
        "type": "VTL|MD",
        "value": "\"I - \" || \"S1\""
      }
    },
    {
      "componentType": "InputNumber",
      "controls": [
        {
          "criticality": "ERROR",
          "errorMessage": {
            "type": "VTL|MD",
            "value": "\" La valeur doit être comprise entre 1 et 100.\""
          },
          "typeOfControl": "FORMAT",
          "control": {
            "type": "VTL",
            "value": "not(not(isnull(N)) and (1>N or 100<N))"
          },
          "id": "lhywv2my-format-borne-inf-sup"
        },
        {
          "criticality": "ERROR",
          "errorMessage": {
            "type": "VTL|MD",
            "value": "\"Le nombre doit comporter au maximum 0 chiffre(s) après la virgule.\""
          },
          "typeOfControl": "FORMAT",
          "control": {
            "type": "VTL",
            "value": "not(not(isnull(N))  and round(N,0)<>N)"
          },
          "id": "lhywv2my-format-decimal"
        }
      ],
      "max": 100,
      "hierarchy": {
        "sequence": {
          "id": "lhywno65",
          "page": "1",
          "label": {
            "type": "VTL|MD",
            "value": "\"I - \" || \"S1\""
          }
        }
      },
      "conditionFilter": {
        "type": "VTL",
        "value": "true"
      },
      "label": {
        "type": "VTL|MD",
        "value": "\"➡ 1. \" || \"N\""
      },
      "mandatory": false,
      "bindingDependencies": [
        "N"
      ],
      "min": 1,
      "response": {
        "name": "N"
      },
      "decimals": 0,
      "id": "lhywv2my",
      "page": "2"
    },
    {
      "paginatedLoop": false,
      "componentType": "Loop",
      "loopDependencies": [
        "N"
      ],
      "components": [
        {
          "componentType": "Subsequence",
          "bindingDependencies": [
            "N"
          ],
          "goToPage": "3",
          "hierarchy": {
            "sequence": {
              "id": "lhywno65",
              "page": "1",
              "label": {
                "type": "VTL|MD",
                "value": "\"I - \" || \"S1\""
              }
            },
            "subSequence": {
              "id": "lhywe099",
              "page": "3",
              "label": {
                "type": "VTL|MD",
                "value": "Pour boucle"
              }
            }
          },
          "conditionFilter": {
            "type": "VTL",
            "value": "true"
          },
          "id": "lhywe099",
          "page": "3",
          "label": {
            "type": "VTL|MD",
            "value": "Pour boucle"
          }
        },
        {
          "componentType": "Input",
          "bindingDependencies": [
            "ARPTER",
            "N"
          ],
          "response": {
            "name": "ARPTER"
          },
          "hierarchy": {
            "sequence": {
              "id": "lhywno65",
              "page": "1",
              "label": {
                "type": "VTL|MD",
                "value": "\"I - \" || \"S1\""
              }
            },
            "subSequence": {
              "id": "lhywe099",
              "page": "3",
              "label": {
                "type": "VTL|MD",
                "value": "Pour boucle"
              }
            }
          },
          "conditionFilter": {
            "type": "VTL",
            "value": "true"
          },
          "id": "lhywfb4h",
          "page": "3",
          "label": {
            "type": "VTL|MD",
            "value": "\"➡ 2. \" || \"A répéter\""
          },
          "mandatory": false,
          "maxLength": 249
        }
      ],
      "bindingDependencies": [
        "N",
        "ARPTER"
      ],
      "depth": 1,
      "hierarchy": {
        "sequence": {
          "id": "lhywno65",
          "page": "1",
          "label": {
            "type": "VTL|MD",
            "value": "\"I - \" || \"S1\""
          }
        }
      },
      "conditionFilter": {
        "type": "VTL",
        "value": "true"
      },
      "id": "lhywodih",
      "page": "3",
      "lines": {
        "min": {
          "type": "VTL",
          "value": "1"
        },
        "max": {
          "type": "VTL",
          "value": "N"
        }
      }
    },
    {
      "componentType": "Sequence",
      "hierarchy": {
        "sequence": {
          "id": "COMMENT-SEQ",
          "page": "4",
          "label": {
            "type": "VTL|MD",
            "value": "\"Commentaire\""
          }
        }
      },
      "conditionFilter": {
        "type": "VTL",
        "value": "true"
      },
      "id": "COMMENT-SEQ",
      "page": "4",
      "label": {
        "type": "VTL|MD",
        "value": "\"Commentaire\""
      }
    },
    {
      "componentType": "Textarea",
      "bindingDependencies": [
        "COMMENT_QE"
      ],
      "response": {
        "name": "COMMENT_QE"
      },
      "hierarchy": {
        "sequence": {
          "id": "COMMENT-SEQ",
          "page": "4",
          "label": {
            "type": "VTL|MD",
            "value": "\"Commentaire\""
          }
        }
      },
      "conditionFilter": {
        "type": "VTL",
        "value": "true"
      },
      "id": "COMMENT-QUESTION",
      "page": "5",
      "label": {
        "type": "VTL|MD",
        "value": "\"Avez-vous des remarques concernant l'enquête ou des commentaires ?\""
      },
      "mandatory": false,
      "maxLength": 2000
    }
  ],
  "pagination": "question",
  "resizing": {
    "N": {
      "variables": [
        "ARPTER"
      ],
      "size": "N"
    }
  },
  "label": {
    "type": "VTL|MD",
    "value": "Test boucle min max"
  },
  "lunaticModelVersion": "2.3.1",
  "modele": "TESTBOUCLE_MINMAX",
  "enoCoreVersion": "2.4.1",
  "generatingDate": "22-05-2023 13:42:08",
  "missing": false,
  "id": "lhywsnvi",
  "maxPage": "5"
}

romaintailhurat avatar May 22 '23 13:05 romaintailhurat