Browse Source

feat: more updated dynamic text and linking

pull/1034/head
natdeanlewissoftwire 4 years ago
parent
commit
7da0d306a8
  1. 4
      app/models/location.rb
  2. 6
      app/views/locations/check_answers.html.erb
  3. 2
      app/views/locations/index.html.erb

4
app/models/location.rb

@ -450,6 +450,10 @@ class Location < ApplicationRecord
end end
end end
def incomplete?
[postcode, name, location_admin_district, units, type_of_unit, mobility_type, startdate].any?(&:blank?)
end
private private
PIO = PostcodeService.new PIO = PostcodeService.new

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

@ -4,7 +4,7 @@
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(
text: "Back", text: "Back",
href: scheme_location_availability_path(@scheme, @location), href: :back,
) %> ) %>
<% end %> <% end %>
@ -22,7 +22,7 @@
if attr[:attribute].eql?("status") if attr[:attribute].eql?("status")
status_tag(attr[:value]) status_tag(attr[:value])
elsif attr[:attribute].eql?("availability") elsif attr[:attribute].eql?("availability")
details_html(name: "Availability", value: @location.startdate.to_formatted_s(:govuk_date), attribute: "startdate") details_html(name: "Availability", value: @location.startdate.present? ? @location.startdate.to_formatted_s(:govuk_date) : nil, attribute: "startdate")
else else
details_html(attr) details_html(attr)
end } %> end } %>
@ -34,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", disabled: [@location.postcode, @location.name, @location.location_admin_district, @location.units, @location.type_of_unit, @location.mobility_type, @location.startdate].any?(&:blank?) %> <%= f.govuk_submit "Add this location", disabled: @location.incomplete? %>
<%= 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}/check-answers"), { 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" if location.incomplete?}"), { 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