Browse Source

feat: add updated availability text in check_answers

pull/1034/head
natdeanlewissoftwire 4 years ago
parent
commit
274ef0fd6e
  1. 2
      app/helpers/tab_nav_helper.rb
  2. 11
      app/views/locations/check_answers.html.erb
  3. 2
      app/views/locations/index.html.erb

2
app/helpers/tab_nav_helper.rb

@ -7,7 +7,7 @@ module TabNavHelper
end end
def location_cell_postcode(location, link) def location_cell_postcode(location, link)
link_text = location.postcode link_text = location.postcode || "Add postcode"
[govuk_link_to(link_text, link, method: :patch), "<span class=\"govuk-visually-hidden\">Location </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{location.name}</span>"].join("\n") [govuk_link_to(link_text, link, method: :patch), "<span class=\"govuk-visually-hidden\">Location </span><span class=\"govuk-!-font-weight-regular app-!-colour-muted\">#{location.name}</span>"].join("\n")
end end

11
app/views/locations/check_answers.html.erb

@ -18,7 +18,14 @@
<% next if %w[location_code status].include? attr[:attribute] %> <% next if %w[location_code status].include? attr[:attribute] %>
<%= summary_list.row do |row| %> <%= summary_list.row do |row| %>
<% row.key { attr[:name] } %> <% row.key { attr[:name] } %>
<% row.value { attr[:attribute].eql?("status") ? status_tag(attr[:value]) : details_html(attr) } %> <% row.value {
if attr[:attribute].eql?("status")
status_tag(attr[:value])
elsif attr[:attribute].eql?("availability")
details_html(name: "Availability", value: @location.startdate.to_formatted_s(:govuk_date), attribute: "startdate")
else
details_html(attr)
end } %>
<% row.action(text: "Change", href: location_edit_path(@location, attr[:attribute])) unless attr[:name] == "Status" %> <% row.action(text: "Change", href: location_edit_path(@location, attr[:attribute])) unless attr[:name] == "Status" %>
<% end %> <% end %>
<% end %> <% end %>
@ -27,7 +34,7 @@
</div> </div>
<%= f.hidden_field :confirmed %> <%= f.hidden_field :confirmed %>
<div class="govuk-button-group"> <div class="govuk-button-group">
<%= f.govuk_submit "Add this location" %> <%= f.govuk_submit "Add this location", disabled: [@location.postcode, @location.name, @location.location_admin_district, @location.units, @location.type_of_unit, @location.mobility_type, @location.startdate].any?(&:blank?) %>
<%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %> <%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %>
</div> </div>
<% end %> <% end %>

2
app/views/locations/index.html.erb

@ -52,7 +52,7 @@
<%= table.body do |body| %> <%= table.body do |body| %>
<%= body.row do |row| %> <%= body.row do |row| %>
<% row.cell(text: location.id) %> <% row.cell(text: location.id) %>
<% row.cell(text: simple_format(location_cell_postcode(location, "/schemes/#{@scheme.id}/locations/#{location.id}"), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %> <% row.cell(text: simple_format(location_cell_postcode(location, "/schemes/#{@scheme.id}/locations/#{location.id}/check-answers"), { class: "govuk-!-font-weight-bold" }, wrapper_tag: "div")) %>
<% row.cell(text: location.units) %> <% row.cell(text: location.units) %>
<% row.cell(text: simple_format("<span>#{location.type_of_unit}</span>")) %> <% row.cell(text: simple_format("<span>#{location.type_of_unit}</span>")) %>
<% row.cell(text: location.mobility_type) %> <% row.cell(text: location.mobility_type) %>

Loading…
Cancel
Save