-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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` 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.
- Loading branch information
1 parent
e0ffcf2
commit 6952488
Showing
37 changed files
with
670 additions
and
241 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ $govuk-assets-path: ""; | |
@import "filter-form"; | ||
@import "app-related-aside"; | ||
@import "lists"; | ||
@import "buttons"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
button.govuk-link { | ||
all: unset; | ||
} | ||
|
||
button.govuk-link { | ||
font-family: "GDS Transport", arial, sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
text-decoration: underline; | ||
text-decoration-thickness: max(1px, .0625rem); | ||
text-underline-offset: 0.1578em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class Claims::Claim::CreateRevision | ||
include ServicePattern | ||
|
||
def initialize(claim:) | ||
@claim = claim | ||
end | ||
|
||
def call | ||
revision_record = deep_dup | ||
revision_record.save! | ||
|
||
revision_record | ||
end | ||
|
||
private | ||
|
||
attr_reader :claim | ||
|
||
def deep_dup | ||
dup_record = claim.dup | ||
dup_record.mentor_trainings = claim.mentor_trainings.map(&:dup) | ||
dup_record.previous_revision_id = claim.id | ||
dup_record.status = :internal_draft | ||
dup_record | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
class Claims::Claim::UpdateDraft < Claims::Claim::CreateDraft | ||
include ServicePattern | ||
|
||
def call | ||
ActiveRecord::Base.transaction do | ||
updated_claim.save! | ||
update_previous_revisions_to_internal_draft | ||
end | ||
end | ||
|
||
private | ||
|
||
def update_previous_revisions_to_internal_draft | ||
claim_record = updated_claim.previous_revision | ||
|
||
while claim_record.present? | ||
claim_record.update!(status: :internal_draft) if claim_record.draft? | ||
claim_record = claim_record.previous_revision | ||
end | ||
end | ||
|
||
def updated_claim | ||
@updated_claim ||= begin | ||
claim.status = :draft | ||
claim | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 4 additions & 3 deletions
7
app/services/claims/mentor/calculate_total_mentor_training_hours_for_provider.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
class Claims::Mentor::CalculateTotalMentorTrainingHoursForProvider | ||
include ServicePattern | ||
|
||
def initialize(mentor:, provider:) | ||
def initialize(mentor:, provider:, claim: nil) | ||
@mentor = mentor | ||
@provider = provider | ||
@claim = claim | ||
end | ||
|
||
def call | ||
mentor.mentor_trainings.joins(:claim).merge(Claims::Claim.active).where(provider:).sum(:hours_completed) | ||
mentor.mentor_trainings.joins(:claim).merge(Claims::Claim.active).where(provider:).where.not(claim_id: claim&.previous_revision_id).sum(:hours_completed) | ||
end | ||
|
||
private | ||
|
||
attr_reader :mentor, :provider | ||
attr_reader :mentor, :provider, :claim | ||
end |
Oops, something went wrong.