Browse Source

feat: add new page and routing with dummy org content

CLDC-1661-new-page-for-housing-providers
natdeanlewissoftwire 2 years ago
parent
commit
a775814437
  1. 17
      app/controllers/housing_providers_controller.rb
  2. 2
      app/helpers/housing_providers_helper.rb
  3. 4
      app/helpers/navigation_items_helper.rb
  4. 19
      app/views/housing_providers/index.html.erb
  5. 3
      config/routes.rb
  6. 4
      db/schema.rb

17
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

2
app/helpers/housing_providers_helper.rb

@ -0,0 +1,2 @@
module HousingProvidersHelper
end

4
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/")

19
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 } %>
<p>Your organisation can submit logs for its housing providers.</p>
<% 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" } %>

3
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

4
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"

Loading…
Cancel
Save