Browse Source

refactored views

pull/662/head
JG 3 years ago
parent
commit
de2cdc5967
  1. 14
      app/helpers/navigation_items_helper.rb
  2. 4
      app/views/schemes/locations.html.erb
  3. 13
      app/views/schemes/show.html.erb

14
app/helpers/navigation_items_helper.rb

@ -7,12 +7,12 @@ module NavigationItemsHelper
NavigationItem.new("Organisations", organisations_path, organisations_current?(path)), NavigationItem.new("Organisations", organisations_path, organisations_current?(path)),
NavigationItem.new("Users", "/users", users_current?(path)), NavigationItem.new("Users", "/users", users_current?(path)),
NavigationItem.new("Logs", case_logs_path, logs_current?(path)), NavigationItem.new("Logs", case_logs_path, logs_current?(path)),
NavigationItem.new("Schemes", "/schemes", supported_housing_current?(path)), NavigationItem.new("Schemes", "/schemes", supported_housing_schemes_current?(path)),
] ]
elsif current_user.data_coordinator? elsif current_user.data_coordinator?
[ [
NavigationItem.new("Logs", case_logs_path, logs_current?(path)), NavigationItem.new("Logs", case_logs_path, logs_current?(path)),
NavigationItem.new("Schemes", "/schemes", subnav_supported_housing_path?(path)), NavigationItem.new("Schemes", "/schemes", subnav_supported_housing_schemes_path?(path)),
NavigationItem.new("Users", users_organisation_path(current_user.organisation), subnav_users_path?(path)), NavigationItem.new("Users", users_organisation_path(current_user.organisation), subnav_users_path?(path)),
NavigationItem.new("About your organisation", "/organisations/#{current_user.organisation.id}", subnav_details_path?(path)), NavigationItem.new("About your organisation", "/organisations/#{current_user.organisation.id}", subnav_details_path?(path)),
] ]
@ -28,16 +28,16 @@ module NavigationItemsHelper
def secondary_items(path, current_organisation_id) def secondary_items(path, current_organisation_id)
[ [
NavigationItem.new("Logs", "/organisations/#{current_organisation_id}/logs", subnav_logs_path?(path)), NavigationItem.new("Logs", "/organisations/#{current_organisation_id}/logs", subnav_logs_path?(path)),
NavigationItem.new("Schemes", "/organisations/#{current_organisation_id}/schemes", subnav_supported_housing_path?(path)), NavigationItem.new("Schemes", "/organisations/#{current_organisation_id}/schemes", subnav_supported_housing_schemes_path?(path)),
NavigationItem.new("Users", "/organisations/#{current_organisation_id}/users", subnav_users_path?(path)), NavigationItem.new("Users", "/organisations/#{current_organisation_id}/users", subnav_users_path?(path)),
NavigationItem.new("About this organisation", "/organisations/#{current_organisation_id}", subnav_details_path?(path)), NavigationItem.new("About this organisation", "/organisations/#{current_organisation_id}", subnav_details_path?(path)),
] ]
end end
def scheme_items(_path, current_scheme_id, count) def scheme_items(path, current_scheme_id, title)
[ [
NavigationItem.new("Scheme", "/schemes/#{current_scheme_id}", true), NavigationItem.new("Schemes", "/schemes/#{current_scheme_id}", !path.include?("locations")),
NavigationItem.new("#{count} locations", "/schemes/#{current_scheme_id}/locations", false), NavigationItem.new(title, "/schemes/#{current_scheme_id}/locations", path.include?("locations")),
] ]
end end
@ -51,7 +51,7 @@ private
path == "/users" || path.include?("/users/") path == "/users" || path.include?("/users/")
end end
def supported_housing_current?(path) def supported_housing_schemes_current?(path)
path == "/schemes" || path.include?("/schemes/") path == "/schemes" || path.include?("/schemes/")
end end

4
app/views/schemes/locations.html.erb

@ -5,9 +5,7 @@
<%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %> <%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %>
<%= render SubNavigationComponent.new( <%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, @scheme.locations.count.eql?(1) ? "1 location" : "#{@scheme.locations.count} locations")) %>
items: scheme_items(request.path, @scheme.id, @scheme.locations.count),
) %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters"> <div class="govuk-grid-column-three-quarters">

13
app/views/schemes/show.html.erb

@ -5,20 +5,17 @@
<%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %> <%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %>
<%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, @scheme.locations.count.eql?(1) ? "1 location" : "#{@scheme.locations.count} locations")) %>
<%= render SubNavigationComponent.new(
items: scheme_items(request.path, @scheme.id, @scheme.locations.count),
) %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<%= govuk_summary_list do |summary_list| %> <%= govuk_summary_list do |summary_list| %>
<% @scheme.display_attributes.each do |attr| %> <% @scheme.display_attributes.each do |attr| %>
<%= summary_list.row do |row| %> <%= summary_list.row do |row| %>
<% row.key { attr[:name].to_s.humanize } %> <% row.key { attr[:name].to_s.humanize } %>
<% row.value { details_html(attr) } %> <% row.value { details_html(attr) } %>
<% end %>
<% end %> <% end %>
<% end %>
<% end %> <% end %>
</div> </div>
</div> </div>

Loading…
Cancel
Save