Browse Source

feat: add housing provider page with details and button

pull/954/head
natdeanlewissoftwire 3 years ago
parent
commit
1bfb05a0d3
  1. 14
      app/components/related_organisation_search_component.html.erb
  2. 2
      app/components/related_organisation_search_component.rb
  3. 13
      app/controllers/organisation_relationships_controller.rb
  4. 11
      app/views/organisation_relationships/add_housing_provider.html.erb
  5. 9
      app/views/organisation_relationships/housing_providers.html.erb
  6. 1
      config/routes.rb

14
app/components/related_organisation_search_component.html.erb

@ -0,0 +1,14 @@
<%= form_with model: @user, url: path(current_user), method: "get", local: true do |f| %>
<div class="app-search govuk-!-margin-bottom-4">
<%= f.govuk_text_field :search,
form_group: {
class: "app-search__form-group",
},
label: { text: search_label },
type: "search",
value:,
autocomplete: "off",
class: "app-search__input" %>
</div>
<%= f.govuk_submit "Add" %>
<% end %>

2
app/components/related_organisation_search_component.rb

@ -0,0 +1,2 @@
class RelatedOrganisationSearchComponent < SearchComponent
end

13
app/controllers/organisation_relationships_controller.rb

@ -18,6 +18,19 @@ class OrganisationRelationshipsController < ApplicationController
end
end
def add_housing_provider
housing_providers = organisation.housing_providers
unpaginated_filtered_housing_providers = filtered_collection(housing_providers, search_term)
respond_to do |format|
format.html do
@pagy, @housing_providers = pagy(unpaginated_filtered_housing_providers)
@searched = search_term.presence
@total_count = housing_providers.size
render "organisation_relationships/add_housing_provider", layout: "application"
end
end
end
private
def organisation

11
app/views/organisation_relationships/add_housing_provider.html.erb

@ -0,0 +1,11 @@
<%= render partial: "organisations/headings", locals: { main: "What is the name of your housing provider?", sub: nil } %>
<%= render RelatedOrganisationSearchComponent.new(current_user:, search_label: "Start typing to search for your housing provider", value: @searched) %>
<%= govuk_details(summary_text: "Can't find the housing provider you're looking for?") do %>
<ul class="govuk-list govuk-list--bullet">
<li>Double check the spelling and try again</li>
<li>Type the first few letters to see the suggestions</li>
<li>If you still can't find it,
<%= govuk_link_to("contact the DLUHC service desk", "https://digital.dclg.gov.uk/jira/servicedesk/customer/portal/4/group/21", rel: "noreferrer noopener", target: "_blank") %>
</li>
</ul>
<% end %>

9
app/views/organisation_relationships/housing_providers.html.erb

@ -1,6 +1,4 @@
<% item_label = format_label(@pagy.count, "housing providers") %>
<% title = "Housing Providers" %>
<% content_for :title, title %>
<% if current_user.support? %>
<%= render partial: "organisations/headings", locals: { main: @organisation.name, sub: nil } %>
<%= render SubNavigationComponent.new(items: secondary_items(request.path, @organisation.id)) %>
@ -10,12 +8,13 @@
<%= render partial: "organisations/headings", locals: { main: "Your housing providers", sub: nil } %>
<p class="govuk-body">Your organisation can submit logs for its housing providers.</p>
<% end %>
<% if @total_count == 0 %>
<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", housing_providers_organisation_path(organisation_id: @organisation.id), html: { method: :get } %>
<% if current_user.support? %>
<%= govuk_button_link_to "Add a housing provider", add_housing_provider_organisation_path(organisation_id: @organisation.id), html: { method: :get } %>
<% elsif current_user.data_coordinator? %>
<%= govuk_button_link_to "Add a housing provider", add_housing_provider_organisation_path, html: { method: :get } %>
<% end %>
<% if @total_count != 0 %>
<%= render SearchComponent.new(current_user:, search_label: "Search for a housing provider", value: @searched) %>

1
config/routes.rb

@ -80,6 +80,7 @@ Rails.application.routes.draw do
get "logs/csv-confirmation", to: "lettings_logs#csv_confirmation"
get "schemes", to: "organisations#schemes"
get "housing-providers", to: "organisation_relationships#housing_providers"
get "add-housing-provider", to: "organisation_relationships#add_housing_provider"
end
end

Loading…
Cancel
Save