diff --git a/app/controllers/organisations_controller.rb b/app/controllers/organisations_controller.rb index 7f2094926..0bcb05022 100644 --- a/app/controllers/organisations_controller.rb +++ b/app/controllers/organisations_controller.rb @@ -135,6 +135,18 @@ class OrganisationsController < ApplicationController end end + def housing_providers + respond_to do |format| + format.html do + all_organisations = Organisation.order(:name) + @pagy, @organisations = pagy(filtered_collection(all_organisations, search_term)) + @searched = search_term.presence + @total_count = all_organisations.size + render "housing_providers", layout: "application" + end + end + end + private def org_params diff --git a/app/helpers/navigation_items_helper.rb b/app/helpers/navigation_items_helper.rb index 12216309e..e7c677690 100644 --- a/app/helpers/navigation_items_helper.rb +++ b/app/helpers/navigation_items_helper.rb @@ -9,7 +9,6 @@ module NavigationItemsHelper NavigationItem.new("Lettings logs", lettings_logs_path, lettings_logs_current?(path)), FeatureToggle.sales_log_enabled? ? NavigationItem.new("Sales logs", sales_logs_path, sales_logs_current?(path)) : nil, NavigationItem.new("Schemes", "/schemes", supported_housing_schemes_current?(path)), - NavigationItem.new("Housing providers", "/housing-providers", housing_providers_current?(path)), ].compact elsif current_user.data_coordinator? && current_user.organisation.holds_own_stock? [ @@ -25,6 +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)), ].compact end end @@ -32,18 +32,19 @@ module NavigationItemsHelper def secondary_items(path, current_organisation_id) if current_user.organisation.holds_own_stock? [ - NavigationItem.new("Lettings logs", "/organisations/#{current_organisation_id}/lettings-logs", subnav_logs_path?(path)), - FeatureToggle.sales_log_enabled? ? NavigationItem.new("Sales logs", "/organisations/#{current_organisation_id}/sales-logs", sales_logs_current?(path)) : nil, + NavigationItem.new("Lettings logs", "/organisations/#{current_organisation_id}/lettings-logs", subnav_lettings_logs_path?(path)), + FeatureToggle.sales_log_enabled? ? NavigationItem.new("Sales logs", "/organisations/#{current_organisation_id}/sales-logs", subnav_sales_logs_path?(path)) : nil, 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)), ].compact else [ - NavigationItem.new("Lettings logs", "/organisations/#{current_organisation_id}/lettings-logs", subnav_logs_path?(path)), - FeatureToggle.sales_log_enabled? ? NavigationItem.new("Sales logs", "/organisations/#{current_organisation_id}/sales-logs", sales_logs_current?(path)) : nil, + NavigationItem.new("Lettings logs", "/organisations/#{current_organisation_id}/lettings-logs", subnav_lettings_logs_path?(path)), + FeatureToggle.sales_log_enabled? ? NavigationItem.new("Sales logs", "/organisations/#{current_organisation_id}/sales-logs", subnav_sales_logs_path?(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", "/organisations/#{current_organisation_id}/housing-providers", subnav_housing_providers_path?(path)), ].compact end end @@ -76,8 +77,8 @@ private def organisations_current?(path) path == "/organisations" || path.include?("/organisations/") end - def housing_providers_current?(path) - path == "/housing-providers" + def subnav_housing_providers_path?(path) + path.include?("/organisations") && path.include?("/housing-providers") end def subnav_supported_housing_schemes_path?(path) @@ -88,10 +89,14 @@ private (path.include?("/organisations") && path.include?("/users")) || path.include?("/users/") end - def subnav_logs_path?(path) + def subnav_lettings_logs_path?(path) path.include?("/organisations") && path.include?("/lettings-logs") end + def subnav_sales_logs_path?(path) + path.include?("/organisations") && path.include?("/sales-logs") + end + def subnav_details_path?(path) path.include?("/organisations") && path.include?("/details") end diff --git a/app/views/housing_providers/_housing_provider_list.html.erb b/app/views/housing_providers/_housing_provider_list.html.erb new file mode 100644 index 000000000..b848f23f5 --- /dev/null +++ b/app/views/housing_providers/_housing_provider_list.html.erb @@ -0,0 +1,20 @@ + +
+ <%= govuk_table do |table| %> + <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %> + <%= render(SearchResultCaptionComponent.new(searched:, count: pagy.count, item_label:, total_count:, item: "housing providers", path: request.path)) %> + <% end %> + <% @organisations.each do |organisation| %> + <%= table.body do |body| %> + <%= body.row do |row| %> + <% row.cell(text: organisation.name) %> + <% row.cell(html_attributes: { + scope: "row", + }) do %> + <%= govuk_link_to("Remove", "organisations/#{organisation.id}") %> + <% end %> + <% end %> + <% end %> + <% end %> + <% end %> +
diff --git a/app/views/housing_providers/index.html.erb b/app/views/housing_providers/index.html.erb index fedc81404..5bf67d181 100644 --- a/app/views/housing_providers/index.html.erb +++ b/app/views/housing_providers/index.html.erb @@ -7,7 +7,7 @@

Your organisation can submit logs for its housing providers.

-<% if current_user.support? %> +<% if current_user.data_coordinator? || current_user.support? %> <%= govuk_button_link_to "Add a housing provider", new_housing_provider_path, html: { method: :get } %> <% end %> @@ -15,5 +15,5 @@ <%= govuk_section_break(visible: true, size: "m") %> -<%= render partial: "organisations/organisation_list", locals: { organisations: @organisations, title: "Organisations", pagy: @pagy, searched: @searched, item_label:, total_count: @total_count } %> +<%= render partial: "housing_providers/housing_provider_list", locals: { organisations: @organisations, title: "Organisations", pagy: @pagy, searched: @searched, item_label:, total_count: @total_count } %> <%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "organisations" } %> diff --git a/app/views/organisations/housing_providers.html.erb b/app/views/organisations/housing_providers.html.erb new file mode 100644 index 000000000..ca112993c --- /dev/null +++ b/app/views/organisations/housing_providers.html.erb @@ -0,0 +1,25 @@ +<% item_label = format_label(@pagy.count, "organisation") %> +<% title = "Housing Providers" %> + +<% content_for :title, title %> + +<%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %> + +<% if current_user.support? %> + <%= render SubNavigationComponent.new( + items: secondary_items(request.path, @organisation.id), + ) %> +

Users

+<% end %> + +<% if current_user.data_coordinator? || current_user.support? %> + <%= govuk_button_link_to "Add a housing provider", new_housing_provider_path, html: { method: :get } %> +<% end %> + +<%= render SearchComponent.new(current_user:, search_label: "Search for a housing provider", value: @searched) %> + +<%= govuk_section_break(visible: true, size: "m") %> + +<%= render partial: "housing_providers/housing_provider_list", locals: { organisations: @organisations, title: "Organisations", pagy: @pagy, searched: @searched, item_label:, total_count: @total_count } %> +<%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "organisations" } %> + diff --git a/config/routes.rb b/config/routes.rb index f4aefab4f..4c4de9b3a 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -79,6 +79,7 @@ Rails.application.routes.draw do post "logs/email-csv", to: "organisations#email_csv" get "logs/csv-confirmation", to: "lettings_logs#csv_confirmation" get "schemes", to: "organisations#schemes" + get "housing-providers", to: "organisations#housing_providers" end end