Altinn / altinn-studio

Next generation open source Altinn platform and applications.
https://docs.altinn.studio
BSD 3-Clause "New" or "Revised" License
114 stars 70 forks source link

Update data model selection in component config #12949

Closed lassopicasso closed 2 months ago

lassopicasso commented 3 months ago

Description

This PR introduces support for two formats of data model binding in config:

  1. Old Format: The data model binding is a string, allowing only the selection of the data model field.
  2. New Format: The data model binding is an object with properties dataType and field.

For now, the new format is behind a feature flag, multipleDataModelsPerTask. Once this flag is removed, changes to data model bindings will always be saved in the new format.

With the feature flag enabled, users can select both the data model and the specific property of the data model bindings in the configuration of the selected component.

Additionally, validation has been added to handle cases where a data model or a data model field binding no longer exists. In both cases, the data model field will fall back to a dummy option with an empty string. If the data model itself no longer exists, it will fall back to the default data model.

Refactoring

Additional

Added/updated unit tests and playwright tests

Note

A new file, SelectDataFieldBinding.tsx, has been created for logic related to data field binding. This decision was made because the existing SelectDataFieldComponent file was difficult to work with due to its linkage to deprecated "rule for calculations" code. The existing file is expected to be removed in issue https://github.com/Altinn/altinn-studio/issues/13027 or later on.

Related Issue(s)

Verification

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 97.93814% with 4 lines in your changes missing coverage. Please review.

Project coverage is 77.76%. Comparing base (0475f96) to head (67e604b).

Files Patch % Lines
...DataModelBinding/DefinedBinding/DefinedBinding.tsx 88.88% 0 Missing and 2 partials :warning:
...l/EditDataModelBinding/EditBinding/EditBinding.tsx 95.45% 1 Missing :warning:
...odal/EditDataModelBinding/EditDataModelBinding.tsx 95.00% 0 Missing and 1 partial :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #12949 +/- ## =========================================== - Coverage 92.16% 77.76% -14.41% =========================================== Files 1444 30 -1414 Lines 20314 625 -19689 Branches 2434 95 -2339 =========================================== - Hits 18723 486 -18237 + Misses 1326 135 -1191 + Partials 265 4 -261 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.