From 744d82f8342fea886926a0afcd7071a3f354c638 Mon Sep 17 00:00:00 2001 From: Priya Power <49959312+priyapower@users.noreply.github.com> Date: Mon, 22 Jul 2024 14:58:22 -0500 Subject: [PATCH] [#5777] Refactor with slot --- app/components/form/title_component.html.erb | 4 ++-- app/components/form/title_component.rb | 8 +++++--- app/views/case_contacts/form/details.html.erb | 4 +++- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/components/form/title_component.html.erb b/app/components/form/title_component.html.erb index f9f2131d3f..26873dd92b 100644 --- a/app/components/form/title_component.html.erb +++ b/app/components/form/title_component.html.erb @@ -11,8 +11,8 @@
<%= @steps_in_text %> diff --git a/app/components/form/title_component.rb b/app/components/form/title_component.rb index 7229dd4910..33cad6ee16 100644 --- a/app/components/form/title_component.rb +++ b/app/components/form/title_component.rb @@ -1,16 +1,18 @@ # frozen_string_literal: true class Form::TitleComponent < ViewComponent::Base - def initialize(title:, subtitle:, step: nil, total_steps: nil, notes: nil, autosave: false, navigable: nil) + # `Form::StepNavigationComponent` is defined in another file, so we can refer to it by class name. + renders_one :navigable, Form::StepNavigationComponent + + def initialize(title:, subtitle:, step: nil, total_steps: nil, notes: nil, autosave: false) @title = title @subtitle = subtitle @notes = notes @autosave = autosave - @navigable = navigable if step && total_steps @steps_in_text = "Step #{step} of #{total_steps}" @progress = (step.to_d / total_steps.to_d) * 100 end end -end +end \ No newline at end of file diff --git a/app/views/case_contacts/form/details.html.erb b/app/views/case_contacts/form/details.html.erb index c6ce860b53..c9850302c8 100644 --- a/app/views/case_contacts/form/details.html.erb +++ b/app/views/case_contacts/form/details.html.erb @@ -1,6 +1,8 @@