Browse Source

refactor: add helper method for action text

pull/1034/head
natdeanlewissoftwire 4 years ago
parent
commit
9d3ff88b01
  1. 6
      app/helpers/locations_helper.rb
  2. 2
      app/views/locations/check_answers.html.erb

6
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)

2
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 %>

Loading…
Cancel
Save