From ef100b8720901184889908a0a4c763bf1dc4373d Mon Sep 17 00:00:00 2001 From: natdeanlewissoftwire Date: Mon, 4 Dec 2023 15:26:46 +0000 Subject: [PATCH] feat: tidy navigation bar behaviour --- app/helpers/navigation_items_helper.rb | 14 +++++++------- app/views/locations/index.html.erb | 2 +- app/views/schemes/show.html.erb | 2 +- spec/helpers/navigation_items_helper_spec.rb | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/helpers/navigation_items_helper.rb b/app/helpers/navigation_items_helper.rb index 13462eb2b..5597b2e0f 100644 --- a/app/helpers/navigation_items_helper.rb +++ b/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 diff --git a/app/views/locations/index.html.erb b/app/views/locations/index.html.erb index ae35d55f6..b88ca74e7 100644 --- a/app/views/locations/index.html.erb +++ b/app/views/locations/index.html.erb @@ -11,7 +11,7 @@ <%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %>
- <%= 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" %>
diff --git a/app/views/schemes/show.html.erb b/app/views/schemes/show.html.erb index ad2e858b2..ec8c9021d 100644 --- a/app/views/schemes/show.html.erb +++ b/app/views/schemes/show.html.erb @@ -11,7 +11,7 @@
- <%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, "Locations")) %> + <%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id)) %>

Scheme

<%= govuk_inset_text(text: edit_scheme_text(@scheme, current_user)) %> diff --git a/spec/helpers/navigation_items_helper_spec.rb b/spec/helpers/navigation_items_helper_spec.rb index 0c6ced3ba..958442347 100644 --- a/spec/helpers/navigation_items_helper_spec.rb +++ b/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