Browse Source

feat: tidy navigation bar behaviour

pull/2031/head
natdeanlewissoftwire 1 year ago
parent
commit
ef100b8720
  1. 14
      app/helpers/navigation_items_helper.rb
  2. 2
      app/views/locations/index.html.erb
  3. 2
      app/views/schemes/show.html.erb
  4. 4
      spec/helpers/navigation_items_helper_spec.rb

14
app/helpers/navigation_items_helper.rb

@ -12,11 +12,11 @@ module NavigationItemsHelper
].compact
else
[
NavigationItem.new("Lettings logs", lettings_logs_path, lettings_logs_current?(path)),
NavigationItem.new("Sales logs", sales_logs_path, sales_logs_current?(path)),
(NavigationItem.new("Schemes", schemes_path, non_support_supported_housing_schemes_current?(path)) if current_user.organisation.holds_own_stock? || current_user.organisation.stock_owners.present?),
NavigationItem.new("Lettings logs", lettings_logs_organisation_path(current_user.organisation), lettings_logs_current?(path)),
NavigationItem.new("Sales logs", sales_logs_organisation_path(current_user.organisation), sales_logs_current?(path)),
(NavigationItem.new("Schemes", schemes_organisation_path(current_user.organisation), non_support_supported_housing_schemes_current?(path)) if current_user.organisation.holds_own_stock? || current_user.organisation.stock_owners.present?),
NavigationItem.new("Users", users_organisation_path(current_user.organisation), subnav_users_path?(path)),
NavigationItem.new("About your organisation", organisation_path(current_user.organisation.id), subnav_details_path?(path)),
NavigationItem.new("About your organisation", details_organisation_path(current_user.organisation.id), subnav_details_path?(path)),
NavigationItem.new("Stock owners", stock_owners_organisation_path(current_user.organisation), stock_owners_path?(path)),
NavigationItem.new("Managing agents", managing_agents_organisation_path(current_user.organisation), managing_agents_path?(path)),
].compact
@ -29,16 +29,16 @@ module NavigationItemsHelper
NavigationItem.new("Sales logs", sales_logs_organisation_path(current_organisation_id), subnav_sales_logs_path?(path)),
(NavigationItem.new("Schemes", schemes_organisation_path(current_organisation_id), subnav_supported_housing_schemes_path?(path)) if current_user.organisation.holds_own_stock? || current_user.organisation.stock_owners.present?),
NavigationItem.new("Users", users_organisation_path(current_organisation_id), subnav_users_path?(path)),
NavigationItem.new("About this organisation", organisation_path(current_organisation_id), subnav_details_path?(path)),
NavigationItem.new("About this organisation", details_organisation_path(current_organisation_id), subnav_details_path?(path)),
NavigationItem.new("Stock owners", stock_owners_organisation_path(current_organisation_id), stock_owners_path?(path)),
NavigationItem.new("Managing agents", managing_agents_organisation_path(current_organisation_id), managing_agents_path?(path)),
].compact
end
def scheme_items(path, current_scheme_id, title)
def scheme_items(path, current_scheme_id)
[
NavigationItem.new("Scheme", scheme_path(current_scheme_id), !path.include?("locations")),
NavigationItem.new(title, scheme_locations_path(current_scheme_id), path.include?("locations")),
NavigationItem.new("Locations", scheme_locations_path(current_scheme_id), path.include?("locations")),
]
end

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

@ -11,7 +11,7 @@
<%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %>
<div class="app-filter-layout" data-controller="filter-layout">
<%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, "Locations")) %>
<%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id)) %>
<%= render partial: "locations/location_filters" %>
<div class="app-filter-layout__content">

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

@ -11,7 +11,7 @@
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds-from-desktop">
<%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, "Locations")) %>
<%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id)) %>
<h2 class="govuk-visually-hidden">Scheme</h2>
<%= govuk_inset_text(text: edit_scheme_text(@scheme, current_user)) %>

4
spec/helpers/navigation_items_helper_spec.rb

@ -349,7 +349,7 @@ RSpec.describe NavigationItemsHelper do
it "returns navigation items with Schemes item set as current" do
expect(primary_items("/schemes/1", current_user)).to eq(expected_navigation_items)
expect(scheme_items("/schemes/1", 1, "Locations")).to eq(expected_scheme_items)
expect(scheme_items("/schemes/1", 1)).to eq(expected_scheme_items)
end
end
@ -373,7 +373,7 @@ RSpec.describe NavigationItemsHelper do
it "returns navigation items with Schemes item set as current" do
expect(primary_items("/schemes/1/locations", current_user)).to eq(expected_navigation_items)
expect(scheme_items("/schemes/1/locations", 1, "Locations")).to eq(expected_scheme_items)
expect(scheme_items("/schemes/1/locations", 1)).to eq(expected_scheme_items)
end
end

Loading…
Cancel
Save