Browse Source

feat: update nav behaviour

pull/950/head
natdeanlewissoftwire 3 years ago
parent
commit
0a73d3c347
  1. 2
      app/controllers/organisation_relationships_controller.rb
  2. 15
      app/helpers/navigation_items_helper.rb
  3. 2
      app/models/organisation.rb
  4. 2
      app/views/organisations/housing_providers.html.erb

2
app/controllers/organisation_relationships_controller.rb

@ -12,7 +12,7 @@ class OrganisationRelationshipsController < ApplicationController
end
def housing_providers
housing_providers = organisation.index
housing_providers = organisation.housing_providers
unpaginated_filtered_housing_providers = filtered_collection(housing_providers, search_term)
respond_to do |format|
format.html do

15
app/helpers/navigation_items_helper.rb

@ -17,7 +17,7 @@ module NavigationItemsHelper
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("About your organisation", "/organisations/#{current_user.organisation.id}", subnav_details_path?(path)),
NavigationItem.new("Housing providers", housing_providers_organisation_path(current_user.organisation), subnav_housing_providers_path?(path)),
NavigationItem.new("Housing providers", housing_providers_organisation_path(current_user.organisation), housing_providers_path?(path)),
].compact
else
[
@ -25,7 +25,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_organisation_path(current_user.organisation), subnav_housing_providers_path?(path)),
NavigationItem.new("Housing providers", housing_providers_organisation_path(current_user.organisation), housing_providers_path?(path)),
].compact
end
@ -41,6 +41,7 @@ module NavigationItemsHelper
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("About this organisation", "/organisations/#{current_organisation_id}", subnav_details_path?(path)),
NavigationItem.new("Housing providers", housing_providers_organisation_path, housing_providers_path?(path)),
].compact
else
[
@ -48,7 +49,7 @@ module NavigationItemsHelper
FeatureToggle.sales_log_enabled? ? NavigationItem.new("Sales logs", "/organisations/#{current_organisation_id}/sales-logs", sales_logs_current?(path)) : nil,
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("Housing providers", housing_providers_organisation_path, subnav_housing_providers_path?(path)),
NavigationItem.new("Housing providers", housing_providers_organisation_path, housing_providers_path?(path)),
].compact
end
end
@ -82,10 +83,6 @@ private
path == "/organisations" || path.include?("/organisations/")
end
def subnav_housing_providers_path?(path)
path.include?("/organisations") && path.include?("/housing-providers")
end
def subnav_supported_housing_schemes_path?(path)
path.include?("/organisations") && path.include?("/schemes") || path.include?("/schemes/")
end
@ -106,6 +103,10 @@ private
path.include?("/organisations") && path.include?("/details")
end
def housing_providers_path?(path)
path.include?("/housing-providers")
end
def managing_agents_path?(path)
path.include?("/managing-agents")
end

2
app/models/organisation.rb

@ -16,7 +16,7 @@ class Organisation < ApplicationRecord
has_many :managing_agent_relationships, -> { where(relationship_type: OrganisationRelationship::MANAGING) }, foreign_key: :child_organisation_id, class_name: "OrganisationRelationship"
has_many :managing_agents, through: :managing_agent_relationships, source: :parent_organisation
has_many :housing_provider_relationships, -> { where(relationship_type: OrganisationRelationship::OWNING) }, foreign_key: :child_organisation_id, class_name: "OrganisationRelationship"
has_many :index, through: :housing_provider_relationships, source: :parent_organisation
has_many :housing_providers, through: :housing_provider_relationships, source: :parent_organisation
scope :search_by_name, ->(name) { where("name ILIKE ?", "%#{name}%") }

2
app/views/organisations/housing_providers.html.erb

@ -15,7 +15,7 @@
<p class="govuk-body">This organisation does not currently have any housing providers.</p>
<% end %>
<% if current_user.data_coordinator? || current_user.support? %>
<%= govuk_button_link_to "Add a housing provider", new_housing_provider_path(organisation_id: @organisation.id), html: { method: :get } %>
<%= govuk_button_link_to "Add a housing provider", housing_providers_organisation_path(organisation_id: @organisation.id), html: { method: :get } %>
<% end %>
<% if @total_count != 0 %>
<%= render SearchComponent.new(current_user:, search_label: "Search for a housing provider", value: @searched) %>

Loading…
Cancel
Save