From 2c4da3eac077bc3778cf1058ad9ae272ce345b05 Mon Sep 17 00:00:00 2001 From: Thomas Leese Date: Thu, 14 Sep 2023 09:37:14 +0100 Subject: [PATCH] Show stage_changed timeline events This updates the timeline entry component to be able to show the new stage changed timeline events, explaining to the user what has changed. --- app/components/status_tag/component.rb | 4 ++++ app/components/timeline_entry/component.rb | 19 ++++++++++++++++ config/locales/components.en.yml | 26 +++++++++++++--------- spec/components/timeline_entry_spec.rb | 20 +++++++++++++++++ spec/factories/timeline_events.rb | 6 +++++ 5 files changed, 65 insertions(+), 10 deletions(-) diff --git a/app/components/status_tag/component.rb b/app/components/status_tag/component.rb index ceeb8d70aa..6c56e0129c 100644 --- a/app/components/status_tag/component.rb +++ b/app/components/status_tag/component.rb @@ -21,6 +21,7 @@ def classes COLOURS = { accepted: "green", + assessment: "blue", assessment_in_progress: "blue", awarded: "green", awarded_pending_checks: "turquoise", @@ -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", @@ -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", diff --git a/app/components/timeline_entry/component.rb b/app/components/timeline_entry/component.rb index d1870d1cd1..58121b0198 100644 --- a/app/components/timeline_entry/component.rb +++ b/app/components/timeline_entry/component.rb @@ -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 diff --git a/config/locales/components.en.yml b/config/locales/components.en.yml index 399f9249f9..adafbdb5e5 100644 --- a/config/locales/components.en.yml +++ b/config/locales/components.en.yml @@ -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 @@ -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 @@ -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 @@ -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 @@ -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. @@ -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 diff --git a/spec/components/timeline_entry_spec.rb b/spec/components/timeline_entry_spec.rb index 5b8d9692da..051a83ef7d 100644 --- a/spec/components/timeline_entry_spec.rb +++ b/spec/components/timeline_entry_spec.rb @@ -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 diff --git a/spec/factories/timeline_events.rb b/spec/factories/timeline_events.rb index d9a2af715f..89c356e78e 100644 --- a/spec/factories/timeline_events.rb +++ b/spec/factories/timeline_events.rb @@ -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