Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v4/ Add Config tools for AttachmentList #12250

Merged
merged 110 commits into from
Apr 18, 2024
Merged

Conversation

lassopicasso
Copy link
Contributor

@lassopicasso lassopicasso commented Feb 6, 2024

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

@github-actions github-actions bot added area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. solution/studio/designer Issues related to the Altinn Studio Designer solution. labels Feb 6, 2024
@lassopicasso lassopicasso linked an issue Feb 6, 2024 that may be closed by this pull request
Copy link

codecov bot commented Feb 6, 2024

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 ⚠️
...Content/AttachmentList/AttachmentListComponent.tsx 97.87% 0 Missing and 1 partial ⚠️
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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@mlqn mlqn left a comment

Choose a reason for hiding this comment

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

Nice work! 🙂 I tested locally and it seems to work as expected. I just encountered some issues when I tried to add/edit/delete selected data types.

An error occurs when I edit a selected component id

error1.mov

An error occurs when I click the current task checkbox and then click an item

error2.mov

The list is not updating when adding or deleting a new data type

adding.mov
deleting.mov

Copy link
Contributor

@mlqn mlqn left a comment

Choose a reason for hiding this comment

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

Nice work! 🚀

@lassopicasso lassopicasso dismissed TomasEng’s stale review April 18, 2024 08:08

Code changes have been approved.

@lassopicasso lassopicasso merged commit 069f3cc into main Apr 18, 2024
11 checks passed
@lassopicasso lassopicasso deleted the update-attachmentList-config-v4 branch April 18, 2024 08:08
Jondyr pushed a commit that referenced this pull request Jun 10, 2024
* remove includePdf property

* init attachmentList + display all datatypes in combobox (minus dataTypes that is datamodel)

* filter added

* Add some texts and cover some scenarios

* include all attachments, all attach (exl. pdf), and sort them + description update

* added behaviour when special variants is used + more

* attachmentList functions as desired now

* Refactor attachmentList + Content, and add pending spinner

* remove unused file

* update type

* init tests for attachmentListComponent

* added unit tests, but need to add some more and clean up the code

* unit tests completed!

* unit test - completed v2

* Add spinner on higher lvl

* update code after ux feedback

* update tests

* other updates

* cover some tests

* naming

* cover more lines

* naming v2

* cover the uncovered partial lines

* one last adjustment + remove comments

* move function removeItemByValue to lib

* change text

* changes after feedback - next step implement indeterminate

* Merge branch 'main' into update-attachmentList-config-v4

* small fix

* remove console.log from App.tsx

* implement indeterminate checkbox + change logic of incoming and outcoming data

* assign state on currentTask to avoid saving to backend when no attachments/pdf selected

* some cleanup

* refactor outgoing data logic

* update component and content logic + refactor

* update onChangeTask - need to use an updated list of attachments

* add unit tests for external format

* add tests when converting to internal and external format

* update tests on converting internal external

* Refactor highest level to only handle incoming and outgoing data

* second level -> attachmentListInternalFormat

* Lvl 3 - internal format combobox

* Updated attachmentListUtils

* AttachmentListUtils - update naming + cleanup

* small change in naming

* Updated arrayUtils

* fix validation function + add tests for validation

* update ArrayUtils.intersection with tests and more use of it

* renaming and get rid of the last bug!

* temperoray status on attachmentListComponent tests before removing the once that are  unecessary

* check test coverage

* try to check coverage

* 3th attempt

* Update unit tests

* update unit tests

* add spinner when data is fetching + tests

* Some cleanup

* renaming convert functions

* update unit tests to use it.each format instead

* test driven dev - update external and internal convert functions to have the same inputs/outputs

* add fieldset wrapper

* Fix converting unit tests after feedback

* Updated convert functions, validation function + small adjustments in tests

* Refactor react logic to handle the updated convert functions

* remove console.log

* Fix: call OnChange when onChangeTask is called :D

* add types

* Update component unit tests

* move convert functions in separate files + own type file

* small adjustments in unit tests

* small changes

* convert functions - split to two files and their own tests files

* updated convertToInternalFunction

* renaming validation function

* refactor attachmentList: -Component, -Content, -InternalFormat files

* simplify convertToExternalFormat function

* rename file

* rename file back

* rename files lowercase

* reuse function extractCurrentAvailableAttachments

* solve a case when convert to internal format and only pdf is selected

* small adjustment in unit test

* fix breaking changes after merge with main

* update naming mockStore after merge with main

* fix - make sure that selected datatypes exists in available datatypes --> if selected data type is deleted or edited

* add useEffect

* Make sure initial selected values in combobox is displayed correctly immidiately when an attachment component is deleted

* removal of key index

* remove index*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/data-modeling Area: Related to data models - e.g. create, edit, use data models. area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. solution/studio/designer Issues related to the Altinn Studio Designer solution.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update AttachmentList component config
4 participants