Skip to content

Commit

Permalink
Show stage_changed timeline events
Browse files Browse the repository at this point in the history
This updates the timeline entry component to be able to show the new
stage changed timeline events, explaining to the user what has changed.
  • Loading branch information
thomasleese committed Sep 27, 2023
1 parent 0af5dc8 commit 2c4da3e
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 10 deletions.
4 changes: 4 additions & 0 deletions app/components/status_tag/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def classes

COLOURS = {
accepted: "green",
assessment: "blue",
assessment_in_progress: "blue",
awarded: "green",
awarded_pending_checks: "turquoise",
Expand All @@ -37,6 +38,7 @@ def classes
overdue_qualification: "pink",
overdue_reference: "pink",
potential_duplicate_in_dqt: "pink",
pre_assessment: "pink",
preliminary_check: "pink",
received: "purple",
received_further_information: "purple",
Expand All @@ -45,8 +47,10 @@ def classes
received_reference: "purple",
rejected: "red",
requested: "yellow",
review: "purple",
submitted: "grey",
valid: "green",
verification: "yellow",
waiting_on: "yellow",
waiting_on_further_information: "yellow",
waiting_on_professional_standing: "yellow",
Expand Down
19 changes: 19 additions & 0 deletions app/components/timeline_entry/component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,24 @@ def action_required_by_changed_vars
end,
}
end

def stage_changed_vars
{
old_stage:
render(
StatusTag::Component.new(
status: timeline_event.old_value,
class_context: "timeline-event",
),
).strip,
new_stage:
render(
StatusTag::Component.new(
status: timeline_event.new_value,
class_context: "timeline-event",
),
).strip,
}
end
end
end
26 changes: 16 additions & 10 deletions config/locales/components.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ en:
components:
status_tag:
accepted: Accepted
assessment: Assessment
assessment_in_progress: Assessment in progress
awarded: Awarded
awarded_pending_checks: Award pending
Expand All @@ -19,6 +20,7 @@ en:
overdue_qualification: Overdue qualification
overdue_reference: Overdue reference
potential_duplicate_in_dqt: Potential duplication in DQT
pre_assessment: Pre-assessment
preliminary_check: Preliminary check
received: Received
received_further_information: Received further information
Expand All @@ -27,8 +29,10 @@ en:
received_reference: Received reference
rejected: Rejected
requested: Waiting on
review: Review
submitted: Not started
valid: Valid
verification: Verification
waiting_on: Waiting on
waiting_on_further_information: Waiting on further information
waiting_on_professional_standing: Waiting on professional standing
Expand All @@ -39,14 +43,14 @@ en:
timeline_entry:
title:
action_required_by_changed: Action required by changed
assessor_assigned: Assessor assigned
reviewer_assigned: Reviewer assigned
state_changed: Status changed
assessment_section_completed: Section completed
note_created: Note created
email_sent: Email sent
age_range_subjects_verified: Age range and subjects verified
assessment_section_completed: Section completed
assessment_section_recorded: Assessment section recorded
assessor_assigned: Assessor assigned
email_sent: Email sent
information_changed: Information changed after submission
note_created: Note created
reviewer_assigned: Reviewer assigned
requestable_requested:
FurtherInformationRequest: Further information requested
ProfessionalStandingRequest: Professional standing requested
Expand All @@ -67,14 +71,14 @@ en:
ProfessionalStandingRequest: Professional standing assessed
QualificationRequest: Qualification assessed
ReferenceRequest: Reference assessed
information_changed: Information changed after submission
stage_changed: Stage changed
state_changed: Status changed
description:
action_required_by_changed: Application requires %{action} action.
assessor_assigned: "%{assignee_name} is assigned as the assessor."
reviewer_assigned: "%{assignee_name} is assigned as the reviewer."
state_changed: Status changed from %{old_state} to %{new_state}.
note_created: "%{text}"
email_sent: "%{subject}"
note_created: "%{text}"
reviewer_assigned: "%{assignee_name} is assigned as the reviewer."
requestable_requested:
FurtherInformationRequest: Further information has been requested.
ProfessionalStandingRequest: The professional standing has been requested.
Expand All @@ -95,6 +99,8 @@ en:
ProfessionalStandingRequest: The professional standing request has been assessed.
QualificationRequest: A qualification has been assessed.
ReferenceRequest: A reference has been assessed.
stage_changed: Stage changed from %{old_stage} to %{new_stage}.
state_changed: Status changed from %{old_state} to %{new_state}.
columns:
contact_email: Reference email address
contact_job: Reference job
Expand Down
20 changes: 20 additions & 0 deletions spec/components/timeline_entry_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -518,4 +518,24 @@
expect(component.text).to include(creator.name)
end
end

context "stage changed" do
let(:timeline_event) { create(:timeline_event, :stage_changed) }
let(:old_stage) do
I18n.t("components.status_tag.#{timeline_event.old_value}")
end
let(:new_stage) do
I18n.t("components.status_tag.#{timeline_event.new_value}")
end

it "describes the event" do
expect(component.text.squish).to include(
"Stage changed from #{old_stage} to #{new_stage}",
)
end

it "attributes to the creator" do
expect(component.text).to include(creator.name)
end
end
end
6 changes: 6 additions & 0 deletions spec/factories/timeline_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,11 @@
old_value { %w[admin assessor external none].sample }
new_value { %w[admin assessor external none].sample }
end

trait :stage_changed do
event_type { "stage_changed" }
old_value { ApplicationForm.stages.values.sample }
new_value { ApplicationForm.stages.values.sample }
end
end
end

0 comments on commit 2c4da3e

Please sign in to comment.