Skip to content

Commit

Permalink
[rubyforgood#5777] Fix missing instantiated object every now and then
Browse files Browse the repository at this point in the history
  • Loading branch information
priyapower committed Jul 17, 2024
1 parent e9ae652 commit 5160d38
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions app/components/form/step_navigation_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand All @@ -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 %>
Expand Down
7 changes: 5 additions & 2 deletions app/controllers/case_contacts/form_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@ 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

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}
Expand Down
2 changes: 1 addition & 1 deletion app/views/case_contacts/form/expenses.html.erb
Original file line number Diff line number Diff line change
@@ -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))) %>

<div>
<%= 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 %>

<div class="card-style-1 pl-25 mb-10 pr-50">
Expand Down

0 comments on commit 5160d38

Please sign in to comment.