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

feat: Create datamodel for subform in config #14138

Merged
merged 30 commits into from
Dec 2, 2024

Conversation

lassopicasso
Copy link
Contributor

@lassopicasso lassopicasso commented Nov 22, 2024

Description

This PR introduces an option for users to create a new data model for a subform directly within the Next Recommended Action card when creating a new subform.

Changes in this PR

  1. Code Refactoring

    • Split the use of NextRecommendedAction component into two separate components based on the user flow: one for creating a new subform and one for selecting an existing one.
    • Leveraged the <form> element within NextRecommendedAction to simplify state management, reducing the reliance on useState
  2. Bug Fix

    • Selecting or creating a data model for a subform resulted in a preview error. The error occurred because the layout set did not exist for the corresponding data type during validation in the app.
Video: bug
select-datamodel-for-subform-bug.mp4
  1. New Feature: Create data model in config
    • Added an input option allowing users to create a new data model for the subform, in addition to the existing option to select one.
Video: create datamodel for subform
create-datamodel-for-subform.mp4

Remaining Tasks

Before the linked issue is done, two additional tasks must be addressed, which depends on related issues in domain 1:

  1. Add validation for subform creation input

  2. Extend Backend and Frontend for Subform Data Models (Edit: this is probably not needed to extend anymore)

    • Extend the endpoint for creating new data models to include a parameter that indicates the data model is for a subform. This ensures that the allowInSubform prop in appLogic is set to true. This task depends on the issue Ensure dataModelId is added to appMetadata on create new model #14123.
      Edit: this may not be needed anymore, seems like allowInSubform will not be used in the app, but the issue is still relevant when it comes to create the data model in appMetaData.

Related Issue(s)

  • #{issue number}

Verification

  • Your code builds clean without any errors or warnings
  • Manual testing done (required)
  • Relevant automated test added (if you find this hard, leave it and we'll help out)

Documentation

  • User documentation is updated with a separate linked PR in altinn-studio-docs. (if applicable)

@lassopicasso lassopicasso linked an issue Nov 22, 2024 that may be closed by this pull request
@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. frontend labels Nov 22, 2024
@lassopicasso lassopicasso changed the title 13764 support link a sub form to data model feat: Create datamodel for subform in config Nov 22, 2024
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

Attention: Patch coverage is 99.08257% with 1 line in your changes missing coverage. Please review.

Project coverage is 95.37%. Comparing base (29d6c53) to head (6d5f300).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...reateNewSubformSection/CreateNewSubformSection.tsx 97.36% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #14138   +/-   ##
=======================================
  Coverage   95.37%   95.37%           
=======================================
  Files        1798     1799    +1     
  Lines       23391    23423   +32     
  Branches     2703     2712    +9     
=======================================
+ Hits        22308    22339   +31     
  Misses        836      836           
- Partials      247      248    +1     

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

@lassopicasso lassopicasso marked this pull request as ready for review November 22, 2024 14:41
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 did a little test locally. Everything seems to works as expected 💯 , I just noticed that the submit button remains disabled when we close the create datamodel form:

datamodel-test.mov

@mlqn
Copy link
Contributor

mlqn commented Nov 26, 2024

I also noticed that deleting a new subform fails when it’s linked to a new datamodel. We might need to generate the new datamodel when we create it 🤔

datamodel-error.mov

@lassopicasso
Copy link
Contributor Author

I also noticed that deleting a new subform fails when it’s linked to a new datamodel. We might need to generate the new datamodel when we create it 🤔

Nice catch! I should have pointed this out. The issue mentioned in point 2 under Remaining tasks will address this, #14123. The "Generate" button in the data model will be removed, and creating a new data model will automatically generate it.

@lassopicasso
Copy link
Contributor Author

lassopicasso commented Nov 27, 2024

Nice work! 🚀 I did a little test locally. Everything seems to works as expected 💯 , I just noticed that the submit button remains disabled when we close the create datamodel form:

Will have a 👀 on that! 😄 Thx!

@lassopicasso lassopicasso requested a review from mlqn November 27, 2024 11:28
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! 🚀

@Jondyr Jondyr merged commit ebfb78e into main Dec 2, 2024
8 checks passed
@Jondyr Jondyr deleted the 13764-support-link-a-sub-form-to-data-model branch December 2, 2024 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ui-editor Area: Related to the designer tool for assembling app UI in Altinn Studio. frontend solution/studio/designer Issues related to the Altinn Studio Designer solution. team/studio-domain2
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

Support link a sub-form to data model
4 participants