altinn-studio icon indicating copy to clipboard operation
altinn-studio copied to clipboard

v4/ Add Config tools for AttachmentList

Open lassopicasso opened this issue 1 year ago • 3 comments

Description (updated)

This PR enables the configuration of the AttachmentList v4. It consists of a dataTypeIds property, an array defining data types for displaying attachments, and has various combinations:

  1. Specific data types - user-selected types for displaying attachments.
  2. System-generated PDFs ["ref-data-as-pdf"] - for displaying PDFs containing overall app input.
  3. All data types (excluding PDFs) [ ] or undefined - default, displays all attachments except PDFs.
  4. All data types (including PDFs) ["include-all"] - similar to 3, but includes PDFs.
  5. App developers can also choose between two process task options:
    • Default: Include data types from all process tasks.
    • Option: Include only data types from the current process task ["current-task"].

Implemented in Studio for various configurations:

  • Switch 1: Current task (on) and all tasks (off - default).
  • Switch 2: Include system-generated PDFs (on) and exclude them (off - default).
  • Indeterminate checkbox: When checked, all available attachments in the combobox are selected.
  • Combobox multiple: All available attachments.

Operates with two data structures:

  1. External data (dataExternalFormat): Studio data saved to the backend. The function selectionIsValid prevents saving if no data types or reserved data type (PDF) are selected, displaying an error message.
  2. Internal data (dataInternalFormat): Studio data used in the overall code.

Source: https://docs.altinn.studio/community/changelog/app-frontend/v4/#attachmentlist-config-changes

image

lassopicasso avatar Feb 06 '24 06:02 lassopicasso

Codecov Report

Attention: Patch coverage is 98.12500% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 90.18%. Comparing base (e07f414) to head (2395a3b).

Files Patch % Lines
...ackages/schema-model/src/lib/mappers/field-type.ts 50.00% 0 Missing and 2 partials :warning:
...Content/AttachmentList/AttachmentListComponent.tsx 97.87% 0 Missing and 1 partial :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #12250      +/-   ##
==========================================
+ Coverage   90.11%   90.18%   +0.07%     
==========================================
  Files        1289     1296       +7     
  Lines       18410    18547     +137     
  Branches     2242     2259      +17     
==========================================
+ Hits        16590    16727     +137     
+ Misses       1561     1560       -1     
- Partials      259      260       +1     

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

codecov[bot] avatar Feb 06 '24 07:02 codecov[bot]

Description is updated ⬆️

lassopicasso avatar Mar 11 '24 13:03 lassopicasso

Konverteringsfunksjonene er nå oppdatert og har tilpasset React-komponentene.

Møtte på en utfordring med onChangeTask, som førte til at jeg la til en funksjon handleDataTypesWhenCurrentTaskChange for å unngå krasj. Dette var nødvendig for å håndtere et case når currentTask gikk fra false til true mens alle vedlegg var valgt. Den oppdaterte ikke antall vedlegg valgt med bakgrunn i at det kun er nåværende oppgave som nå gjelder. Prøvde å håndtere denne logikken når dataen var på vei ut i convertInternalToExternalFormat, men må også oppdatere staten ellers ville combobox føre til at det krasjer. Jeg funderer på om det kan ha noe med at det ikke rekkes å rerendres før onValueChange i combobox blir trigget. Er et issue på det i designsystemet; https://github.com/digdir/designsystemet/issues/1640

lassopicasso avatar Mar 15 '24 10:03 lassopicasso