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

FIO-7302: Prevent clearing the fields that does not exist on the current form revision if they were on the older one #1659

Merged

Conversation

alexandraRamanenka
Copy link
Contributor

@alexandraRamanenka alexandraRamanenka commented Nov 16, 2023

Link to Jira Ticket

https://formio.atlassian.net/browse/FIO-7302

Description

What changed?

If there were some fields on the older form revisions that are not on the current one, and the user edits the submission done with an older revision, those fields are getting cleared during the validation (they are simply not set to the form data because there are no components with correspondent API keys).
With this fix after the validation is complete and right before replacing body's data with data that come from the validation, it will check if the form has revisions allowed and if there are some values paths in the original submission data (taken from the DB, not in the one that was sent fromt he client, so teh user won't be able to change those old fields values) and there are no correspondent components in the current form revision, and it will add those old fields values to the date that came from the validation.

Dependencies

https://github.com/formio/formio-server/pull/1397

How has this PR been tested?

I wrote an automates test, but this will be moved to the formio-server cuase it needs revisions allowed in order to work

Checklist:

  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • My changes generate no new warnings
  • My changes include tests that prove my fix is effective (or that my feature works as intended)
  • New and existing unit/integration tests pass locally with my changes
  • Any dependent changes have corresponding PRs that are listed above

…ent form revision if they were on the older one
@alexandraRamanenka alexandraRamanenka force-pushed the FIO-7302-prevent-clearing-values-from-older-form-revisions branch from 7f41fb6 to cdb798b Compare November 16, 2023 14:35
Copy link
Contributor

@brendanbond brendanbond left a comment

Choose a reason for hiding this comment

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

Since form revisions exist solely in the Enterprise Server, is there a case here for creating a hook here rather than hardcoding this into OSS formio?
e.g.

hook.alter('rehydrateSubmissionRevisions`, submission, (err, submission) => {...});

If you disagree I'm OK with this, it just seems to me a better idea to put enterprise server specific logic (in this case, form revisions) into the enterprise server codebase via hooks

@brendanbond brendanbond merged commit aaeb573 into master Jan 21, 2024
2 checks passed
@brendanbond brendanbond deleted the FIO-7302-prevent-clearing-values-from-older-form-revisions branch January 21, 2024 03:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants