diff --git a/app/controllers/housing_providers_controller.rb b/app/controllers/housing_providers_controller.rb new file mode 100644 index 000000000..32866fd15 --- /dev/null +++ b/app/controllers/housing_providers_controller.rb @@ -0,0 +1,17 @@ +class HousingProvidersController < ApplicationController + include Pagy::Backend + include Modules::SearchFilter + + def index + all_organisations = Organisation.order(:name) + @pagy, @organisations = pagy(filtered_collection(all_organisations, search_term)) + @searched = search_term.presence + @total_count = all_organisations.size + end + +private + + def search_term + params["search"] + end +end diff --git a/app/helpers/housing_providers_helper.rb b/app/helpers/housing_providers_helper.rb new file mode 100644 index 000000000..34586fb27 --- /dev/null +++ b/app/helpers/housing_providers_helper.rb @@ -0,0 +1,2 @@ +module HousingProvidersHelper +end diff --git a/app/helpers/navigation_items_helper.rb b/app/helpers/navigation_items_helper.rb index 3ac422c2d..12216309e 100644 --- a/app/helpers/navigation_items_helper.rb +++ b/app/helpers/navigation_items_helper.rb @@ -9,6 +9,7 @@ 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? [ @@ -75,6 +76,9 @@ private def organisations_current?(path) path == "/organisations" || path.include?("/organisations/") end + def housing_providers_current?(path) + path == "/housing-providers" + end def subnav_supported_housing_schemes_path?(path) path.include?("/organisations") && path.include?("/schemes") || path.include?("/schemes/") diff --git a/app/views/housing_providers/index.html.erb b/app/views/housing_providers/index.html.erb new file mode 100644 index 000000000..fedc81404 --- /dev/null +++ b/app/views/housing_providers/index.html.erb @@ -0,0 +1,19 @@ +<% item_label = format_label(@pagy.count, "organisation") %> +<% title = "Housing Providers" %> + +<% content_for :title, title %> + +<%= render partial: "organisations/headings", locals: { main: "Your housing providers", sub: nil } %> + +

Your organisation can submit logs for its housing providers.

+ +<% if 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: "organisations/organisation_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 0be5f5b6a..f4aefab4f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -119,6 +119,9 @@ Rails.application.routes.draw do end end + resources :housing_providers, path: "/housing-providers" do + end + scope via: :all do match "/404", to: "errors#not_found" match "/429", to: "errors#too_many_requests", status: 429 diff --git a/db/schema.rb b/db/schema.rb index 59a0dbd24..40f13ee80 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -359,14 +359,14 @@ ActiveRecord::Schema[7.0].define(version: 2022_10_17_095918) do t.integer "hholdcount" t.integer "age3" t.integer "age3_known" - t.integer "income1" - t.integer "income1nk" t.integer "age4" t.integer "age4_known" t.integer "age5" t.integer "age5_known" t.integer "age6" t.integer "age6_known" + t.integer "income1" + t.integer "income1nk" t.index ["created_by_id"], name: "index_sales_logs_on_created_by_id" t.index ["managing_organisation_id"], name: "index_sales_logs_on_managing_organisation_id" t.index ["owning_organisation_id"], name: "index_sales_logs_on_owning_organisation_id"