From 9d3ff88b01f3d056d47d523387cf945569306658 Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Mon, 5 Dec 2022 11:09:57 +0000 Subject: [PATCH] refactor: add helper method for action text --- app/helpers/locations_helper.rb | 6 +++++- app/views/locations/check_answers.html.erb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/helpers/locations_helper.rb b/app/helpers/locations_helper.rb index 7e9bf47cf..0c9e23582 100644 --- a/app/helpers/locations_helper.rb +++ b/app/helpers/locations_helper.rb @@ -62,7 +62,11 @@ module LocationsHelper end end -private + def action_text_helper(attr, location) + attr[:value].blank? || (attr[:attribute] == "availability" && location.startdate.blank?) ? "Answer" : "Change" + end + + private ActivePeriod = Struct.new(:from, :to) def location_active_periods(location) diff --git a/app/views/locations/check_answers.html.erb b/app/views/locations/check_answers.html.erb index 0018144d8..88a6a3d59 100644 --- a/app/views/locations/check_answers.html.erb +++ b/app/views/locations/check_answers.html.erb @@ -33,7 +33,7 @@ details_html(attr) end %> <% end %> - <% row.action(text: attr[:value].blank? || (attr[:attribute] == "availability" && @location.startdate.blank?) ? "Answer" : "Change", href: location_edit_path(@location, attr[:attribute])) unless attr[:attribute] == "status" %> + <% row.action(text: action_text_helper(attr, @location), href: location_edit_path(@location, attr[:attribute])) unless attr[:attribute] == "status" %> <% end %> <% end %> <% end %>