Browse Source

feat: add navbar current highlight behaviour and refactoring

CLDC-1661-new-page-for-housing-providers
natdeanlewissoftwire 2 years ago
parent
commit
91213f6183
  1. 11
      app/controllers/housing_providers_controller.rb
  2. 6
      app/controllers/organisations_controller.rb
  3. 7
      app/helpers/navigation_items_helper.rb
  4. 1
      app/views/housing_providers/_housing_provider_list.html.erb

11
app/controllers/housing_providers_controller.rb

@ -3,10 +3,15 @@ class HousingProvidersController < ApplicationController
include Modules::SearchFilter
def index
all_organisations = Organisation.order(:name)
@pagy, @organisations = pagy(filtered_collection(all_organisations, search_term))
housing_providers = Organisation.order(:name)
respond_to do |format|
format.html do
@pagy, @organisations = pagy(filtered_collection(housing_providers, search_term))
@searched = search_term.presence
@total_count = all_organisations.size
@total_count = housing_providers.size
render "housing_providers/index"
end
end
end
private

6
app/controllers/organisations_controller.rb

@ -136,12 +136,12 @@ class OrganisationsController < ApplicationController
end
def housing_providers
housing_providers = Organisation.order(:name)
respond_to do |format|
format.html do
all_organisations = Organisation.order(:name)
@pagy, @organisations = pagy(filtered_collection(all_organisations, search_term))
@pagy, @organisations = pagy(filtered_collection(housing_providers, search_term))
@searched = search_term.presence
@total_count = all_organisations.size
@total_count = housing_providers.size
render "housing_providers", layout: "application"
end
end

7
app/helpers/navigation_items_helper.rb

@ -24,7 +24,7 @@ module NavigationItemsHelper
FeatureToggle.sales_log_enabled? ? NavigationItem.new("Sales logs", sales_logs_path, sales_logs_current?(path)) : nil,
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("Housing providers", "/housing-providers", subnav_housing_providers_path?(path)),
NavigationItem.new("Housing providers", "/housing-providers", housing_providers_current?(path)),
].compact
end
end
@ -77,6 +77,11 @@ private
def organisations_current?(path)
path == "/organisations" || path.include?("/organisations/")
end
def housing_providers_current?(path)
path == "/housing-providers"
end
def subnav_housing_providers_path?(path)
path.include?("/organisations") && path.include?("/housing-providers")
end

1
app/views/housing_providers/_housing_provider_list.html.erb

@ -1,4 +1,3 @@
<section class="app-table-group" tabindex="0" aria-labelledby="<%= title.dasherize %>">
<%= govuk_table do |table| %>
<%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>

Loading…
Cancel
Save