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

Implement claim revisions on claim form #508

Closed
wants to merge 1 commit into from

Conversation

CatalinVoineag
Copy link
Contributor

@CatalinVoineag CatalinVoineag commented Apr 22, 2024

Context

In testing the claim form we concluded that we cannot edit the same claim record on the check page when creating a claim.Issues were found when the user would click the back buttons to go back to the check page after completing half their changes. The changes they did were being saved. Even if they backed off from doing them.

To solve this issue and many others, we are implementing a revision system on the claim.

Creating a revision every time a user wants to edit a claim from the check page. If they back off half way through their changes we revert back to the last valid claim revision.

This implementation will increase the audit records and possibly pollute some of them with system changes i.e. changes to previous_revision_id which the user doesn't care about.

This should fix the issue where a support user edits a draft claim and with every edit, the draft claim is updated for everyone.

The way this works is by using the internal_draft status. A generated revision starts with internal_draft as its status and is changed to draft when the support user finishes editing the draft claim. The previous revision is then set to internal_draft, to not show more than 1 claim per reference.

Changes proposed in this pull request

Claim model
Claim form
Claim support form

Guidance to review

Normal User:

  • Create a claim as a normal user and try to edit it on the check page
  • Click all back buttons
  • Add mentors without training hours and click back button until you get back to the check page.

Support User:
Do the same things as the normal user
Edit a draft claim
Edit a draft claim and click back buttons
Your changes to the draft claim should only be saved after you click Update claim

Screenshots

Peek.2024-04-24.11-00.mp4

@CatalinVoineag CatalinVoineag force-pushed the cv/refactor-claims-form branch from 04be47a to 7e10084 Compare April 22, 2024 12:48
@CatalinVoineag CatalinVoineag self-assigned this Apr 22, 2024
@CatalinVoineag CatalinVoineag force-pushed the cv/refactor-claims-form branch 2 times, most recently from fd08e16 to c9b9315 Compare April 24, 2024 09:47
@CatalinVoineag CatalinVoineag added the deploy A Review App will be created for PRs with this label label Apr 24, 2024
@CatalinVoineag CatalinVoineag changed the title Working revision for normal claim form Implement claim revisions on claim form Apr 24, 2024
Copy link

end

def authorize_claim
authorize @claim || Claims::Claim
end

def create_revision?
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be duplicated in a few places. Could we put this into a concern or service to DRY it up?

@Nitemaeric
Copy link
Contributor

After discussion, we've decided to try a different approach.

@@ -0,0 +1,28 @@
class Claims::Claim::UpdateDraft < Claims::Claim::CreateDraft
Copy link
Contributor

Choose a reason for hiding this comment

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

This service does the same btw 😛

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed it 👍🏻

claim record on the check page when creating a claim.

Issues were found when the user would click the back buttons to go back
to the check page after completing half their changes. The changes they
did were being saved. Even if they backed off from doing them.

To solve this issue and many others, we are implementing a revision
system on the claim.

Creating a revision every time a user wants to edit a claim from the
check page. If they back off half way through their changes we revert
back to the last valid claim revision.

This implementation will increase the audit records and possibly pollute
some of them with `system changes` i.e. changes to `previous_revision_id`
or `next_revision_id` which the user doesn't care about.

For the draft claim

This should fix the issue where a support user edits a draft claim and
with every edit, the draft claim is updated for everyone.

This will only `update` the draft claim when the support user actually
clicks `Update claim`.

They way this works is by using the `internal_draft` status. A generated
revision starts with `internal_draft` as its status and is changed to
draft when the support user finishes editing the draft claim. The
previous revision is then set to `internal_draft`, to not show more than
1 claim per reference.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deploy A Review App will be created for PRs with this label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants