Browse Source
* failing test for having service and location tabs on the show page * links on the page * asking for locations in the link * created locations * linked locations to schemes * locations migration and model * testing seeing locations * rubocop * failing feature to see locations on the page * route to locations * controller action plus other bits * added facatory and view for locations * supported housing to schemes * supported housing to schemes - part 2 * supported housing to schemes - part 3 * correct route * controller test for locations * added view for locations * correct and compact view for locations * testing all attributes on the page * testing heading * testing title * refactored views * refactored views * fixed county * testing pagination * testing and coding pagy bits for locations * testing and coding pagy bits for locations page 2 * added tests for support user * small refactoring of before actions and tests for 401 and 404 * small refactoring * Trigger WF * simplified return * fixing spec failures * fixed names * testing back link * oops * required changes from comments * required changes from comments * renums * fixed failing tests * typo * Managing agent to by * tests for scheme_itemspull/670/head
J G
3 years ago
committed by
GitHub
22 changed files with 547 additions and 103 deletions
@ -0,0 +1,20 @@
|
||||
class Location < ApplicationRecord |
||||
belongs_to :scheme |
||||
|
||||
WHEELCHAIR_ADAPTATIONS = { |
||||
no: 0, |
||||
yes: 1, |
||||
}.freeze |
||||
|
||||
enum wheelchair_adaptation: WHEELCHAIR_ADAPTATIONS |
||||
|
||||
def display_attributes |
||||
[ |
||||
{ name: "Location code ", value: location_code, suffix: false }, |
||||
{ name: "Postcode", value: postcode, suffix: county }, |
||||
{ name: "Type of unit", value: type_of_unit, suffix: false }, |
||||
{ name: "Type of building", value: type_of_building, suffix: false }, |
||||
{ name: "Wheelchair adaptation", value: wheelchair_adaptation, suffix: false }, |
||||
] |
||||
end |
||||
end |
@ -0,0 +1,41 @@
|
||||
<% title = @scheme.service_name %> |
||||
<% content_for :title, title %> |
||||
|
||||
<%= govuk_back_link(href: request.referer.to_s) %> |
||||
|
||||
<%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %> |
||||
|
||||
<%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, @scheme.locations.count.eql?(1) ? "1 location" : "#{@scheme.locations.count} locations")) %> |
||||
|
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-three-quarters"> |
||||
<% @locations.each do |location| %> |
||||
<section class="x-govuk-summary-card govuk-!-margin-bottom-6"> |
||||
<header class="x-govuk-summary-card__header"> |
||||
<h2 class="x-govuk-summary-card__title"> |
||||
<%= "#{location.address_line1}, #{location.address_line2}" %> |
||||
</h2> |
||||
</header> |
||||
<div class="x-govuk-summary-card__body"> |
||||
<dl class="govuk-summary-list"> |
||||
<% location.display_attributes.each do |attribute| %> |
||||
<div class="govuk-summary-list__row"> |
||||
<dt class="govuk-summary-list__key"> |
||||
<%= attribute[:name] %> |
||||
</dt> |
||||
<dd class="govuk-summary-list__value app-!-font-tabular"> |
||||
<span class="govuk-!-margin-right-4"><%= attribute[:value] %></span> |
||||
<% if attribute[:suffix] %> |
||||
<span class="govuk-!-font-weight-regular app-!-colour-muted"><%= attribute[:suffix] %></span> |
||||
<% end %> |
||||
</dd> |
||||
</div> |
||||
<% end %> |
||||
</dl> |
||||
</div> |
||||
</section> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
|
||||
<%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "locations" } %> |
@ -1,17 +1,21 @@
|
||||
<% title = @scheme.service_name %> |
||||
<% content_for :title, title %> |
||||
|
||||
<%= govuk_back_link(href: request.referer.to_s) %> |
||||
|
||||
<%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %> |
||||
|
||||
<%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, @scheme.locations.count.eql?(1) ? "1 location" : "#{@scheme.locations.count} locations")) %> |
||||
|
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<%= govuk_summary_list do |summary_list| %> |
||||
<% @scheme.display_attributes.each do |attr| %> |
||||
<%= summary_list.row do |row| %> |
||||
<% row.key { attr[:name].to_s.humanize } %> |
||||
<% row.value { details_html(attr) } %> |
||||
<% end %> |
||||
<%= summary_list.row do |row| %> |
||||
<% row.key { attr[:name].eql?("Registered under Care Standards Act 2000") ? "Registered under Care Standards Act 2000" : attr[:name].to_s.humanize } %> |
||||
<% row.value { details_html(attr) } %> |
||||
<% end %> |
||||
<% end %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
|
@ -0,0 +1,17 @@
|
||||
class CreateLocations < ActiveRecord::Migration[7.0] |
||||
def change |
||||
create_table :locations do |t| |
||||
t.string :location_code |
||||
t.string :postcode |
||||
t.string :type_of_unit |
||||
t.string :type_of_building |
||||
t.integer :wheelchair_adaptation |
||||
t.references :scheme, null: false, foreign_key: true |
||||
t.string :address_line1 |
||||
t.string :address_line2 |
||||
t.string :county |
||||
|
||||
t.timestamps |
||||
end |
||||
end |
||||
end |
@ -0,0 +1,13 @@
|
||||
FactoryBot.define do |
||||
factory :location do |
||||
location_code { Faker::Name.initials(number: 10) } |
||||
postcode { Faker::Address.postcode } |
||||
address_line1 { Faker::Address.street_name } |
||||
address_line2 { Faker::Address.city } |
||||
type_of_unit { Faker::Lorem.word } |
||||
type_of_building { Faker::Lorem.word } |
||||
wheelchair_adaptation { 0 } |
||||
county { Faker::Address.state } |
||||
scheme |
||||
end |
||||
end |
Loading…
Reference in new issue