From 5160d386e4056a7e96429701bfd01ee4a2547e02 Mon Sep 17 00:00:00 2001 From: Priya Power <49959312+priyapower@users.noreply.github.com> Date: Wed, 17 Jul 2024 14:50:59 -0500 Subject: [PATCH] [#5777] Fix missing instantiated object every now and then --- app/components/form/step_navigation_component.html.erb | 4 ++-- app/controllers/case_contacts/form_controller.rb | 7 +++++-- app/views/case_contacts/form/expenses.html.erb | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/components/form/step_navigation_component.html.erb b/app/components/form/step_navigation_component.html.erb index fb0b212867..163e7caad6 100644 --- a/app/components/form/step_navigation_component.html.erb +++ b/app/components/form/step_navigation_component.html.erb @@ -3,7 +3,7 @@ <%= button_tag type: @submit_back ? :submit : :button, name: :nav_step, value: @nav_back, - class: "btn btn-link", + class: "btn btn-link #{@nav_back.nil? ? 'disabled' : 'enabled'}", title: "Back step", aria: { label: "Back step" }, disabled: !@nav_back do %> @@ -16,7 +16,7 @@ <%= button_tag type: @submit_next ? :submit : :button, name: :nav_step, value: @nav_forward, - class: "btn btn-link", + class: "btn btn-link #{@nav_next.nil? ? 'disabled' : 'enabled'}", title: "Next step", aria: { label: "Next step" }, disabled: !@nav_next do %> diff --git a/app/controllers/case_contacts/form_controller.rb b/app/controllers/case_contacts/form_controller.rb index f4a8f410ea..305977acad 100644 --- a/app/controllers/case_contacts/form_controller.rb +++ b/app/controllers/case_contacts/form_controller.rb @@ -23,6 +23,7 @@ def update @page = wizard_steps.index(step) + 1 @total_pages = steps.count @nav_step = params[:nav_step] + params[:case_contact][:status] = step.to_s if !@case_contact.active? remove_unwanted_contact_types remove_nil_draft_ids @@ -30,8 +31,10 @@ def update if CaseContactUpdateService.new(@case_contact).update_attrs(case_contact_params) respond_to do |format| format.html { - render @nav_step.split('/').last.to_sym if @nav_step.present? - if step == steps.last + if @nav_step.present? + jump_to(@nav_step.split('/').last.to_sym) + render_wizard @case_contact, {}, {case_contact_id: @case_contact.id} + elsif step == steps.last finish_editing else render_wizard @case_contact, {}, {case_contact_id: @case_contact.id} diff --git a/app/views/case_contacts/form/expenses.html.erb b/app/views/case_contacts/form/expenses.html.erb index abea913197..56b4281922 100644 --- a/app/views/case_contacts/form/expenses.html.erb +++ b/app/views/case_contacts/form/expenses.html.erb @@ -1,7 +1,7 @@ -<%= render(Form::TitleComponent.new(title: @case_contact.decorate.form_title, subtitle: "Contact expenses", step: @page, total_steps: @total_pages, navigable: Form::StepNavigationComponent.new(nav_back: previous_wizard_path, nav_next: next_wizard_path, submit_back: true, submit_next: true))) %>
<%= form_with(model: @case_contact, url: wizard_path(nil, case_contact_id: @case_contact.id), local: true, id: "casa-contact-form", class: "component-validated-form") do |form| %> + <%= render(Form::TitleComponent.new(title: @case_contact.decorate.form_title, subtitle: "Contact expenses", step: @page, total_steps: @total_pages, navigable: Form::StepNavigationComponent.new(nav_back: previous_wizard_path, nav_next: nil, submit_back: true, submit_next: true))) %> <%= render "/shared/error_messages", resource: @case_contact %>