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

fix(DataModel): Enables the deletion of a child node from a definition that is currently in use #12235

Merged
merged 11 commits into from
Feb 2, 2024

Conversation

framitdavid
Copy link
Collaborator

@framitdavid framitdavid commented Feb 2, 2024

Description

It should be possible to delete fields in a definition that is already in use. It is crucial to notify the user that the specific field they are attempting to remove is in use in one or more instances, and that deleting it will result in the disappearance of this field from all associated locations. We displays the following confirm message to the user: "Feltet du vil slette tilhører en aktiv type og vil påvirke alle tilknyttede områder. Er du sikker på slettingen?"

Related Issue(s)

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)

@github-actions github-actions bot added area/data-modeling Area: Related to data models - e.g. create, edit, use data models. solution/studio/designer Issues related to the Altinn Studio Designer solution. labels Feb 2, 2024
Copy link

codecov bot commented Feb 2, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (f3a7d5d) 86.41% compared to head (f020729) 86.41%.

Files Patch % Lines
...emaTree/SchemaNode/ActionButtons/ActionButtons.tsx 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #12235   +/-   ##
=======================================
  Coverage   86.41%   86.41%           
=======================================
  Files        1188     1188           
  Lines       18045    18045           
  Branches     2290     2290           
=======================================
  Hits        15594    15594           
+ Misses       2164     2163    -1     
- Partials      287      288    +1     

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

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Looks good 😄
A few comments added.

Co-authored-by: WilliamThorenfeldt <133344438+WilliamThorenfeldt@users.noreply.github.com>
@framitdavid framitdavid merged commit c2113ca into main Feb 2, 2024
10 of 11 checks passed
@framitdavid framitdavid deleted the fix/12201_NotPossibleToDeleteFieldFromTypeInUse branch February 2, 2024 09:53
@@ -432,9 +438,10 @@ export class SchemaModel {
}

public deleteNode(pointer: string): SchemaModel {
if (pointer === ROOT_POINTER) throw new Error('It is not possible to delete the root node.');
if (this.isDefinitionInUse(pointer))
Copy link
Contributor

Choose a reason for hiding this comment

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

Hva skjer nå hvis man kaller deleteNode på en type som er i bruk? Kunne det vært bedre å bytte ut denne med hasReferringNodes i stedet for å fjerne den helt?

Copy link
Collaborator Author

@framitdavid framitdavid Feb 2, 2024

Choose a reason for hiding this comment

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

Hva skjer nå hvis man kaller deleteNode på en type som er i bruk? Kunne det vært bedre å bytte ut denne med hasReferringNodes i stedet for å fjerne den helt?

Godt forslag. Jeg gjør et forsøk på det på mandag. Usikker på om det potensielt kan stoppe oss for å kunne slette noden på typen også?

Copy link
Contributor

@TomasEng TomasEng Feb 5, 2024

Choose a reason for hiding this comment

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

Det skal ikke være mulig. hasReferringNodes sjekker kun elementet som det pekes på, mens isDefinitionInUse er rekursiv nettopp fordi den også sjekker oppover i treet. Egentlig tror jeg ikke vi trenger isDefinitionInUse i det hele tatt.

@framitdavid framitdavid linked an issue Feb 5, 2024 that may be closed by this pull request
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. solution/studio/designer Issues related to the Altinn Studio Designer solution.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Not possible to delete a field from a type that is in use
2 participants