Browse Source

Scheme tweaks (#723)

pull/725/head
Paul Robert Lloyd 3 years ago committed by GitHub
parent
commit
2ef45f491b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      app/views/locations/edit.html.erb
  2. 12
      app/views/locations/index.html.erb
  3. 2
      app/views/schemes/check_answers.html.erb
  4. 2
      app/views/schemes/confirm_secondary.html.erb
  5. 2
      app/views/schemes/details.html.erb
  6. 3
      app/views/schemes/edit_name.html.erb
  7. 2
      app/views/schemes/new.html.erb
  8. 3
      app/views/schemes/primary_client_group.html.erb
  9. 3
      app/views/schemes/secondary_client_group.html.erb
  10. 4
      app/views/schemes/show.html.erb
  11. 3
      app/views/schemes/support.html.erb
  12. 6
      spec/features/schemes_spec.rb
  13. 8
      spec/helpers/navigation_items_helper_spec.rb
  14. 4
      spec/requests/locations_controller_spec.rb

3
app/views/locations/edit.html.erb

@ -30,7 +30,6 @@
autofocus: true %> autofocus: true %>
<% type_of_units_selection = Location.type_of_units.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> <% type_of_units_selection = Location.type_of_units.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>
<%= f.govuk_collection_radio_buttons :type_of_unit, <%= f.govuk_collection_radio_buttons :type_of_unit,
type_of_units_selection, type_of_units_selection,
:id, :id,
@ -38,7 +37,6 @@
legend: { text: "What is this type of scheme?", size: "m" } %> legend: { text: "What is this type of scheme?", size: "m" } %>
<% wheelchair_user_selection = Location.wheelchair_adaptations.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> <% wheelchair_user_selection = Location.wheelchair_adaptations.keys.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>
<%= f.govuk_collection_radio_buttons :wheelchair_adaptation, <%= f.govuk_collection_radio_buttons :wheelchair_adaptation,
wheelchair_user_selection, wheelchair_user_selection,
:id, :id,
@ -49,7 +47,6 @@
<%= govuk_section_break(visible: true, size: "m") %> <%= govuk_section_break(visible: true, size: "m") %>
<% another_location_selection = %w[Yes no].map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> <% another_location_selection = %w[Yes no].map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>
<%= f.govuk_collection_radio_buttons :add_another_location, <%= f.govuk_collection_radio_buttons :add_another_location,
another_location_selection, another_location_selection,
:id, :id,

12
app/views/locations/index.html.erb

@ -1,20 +1,20 @@
<% title = @scheme.service_name %> <% title = @scheme.service_name %>
<% content_for :title, title %> <% content_for :title, title %>
<% content_for :before_content do %> <% content_for :before_content do %>
<%= govuk_back_link( <%= govuk_back_link(
text: "Back", text: "Back",
href: "/schemes/#{@scheme.id}", href: "/schemes/#{@scheme.id}",
) %> ) %>
<% end %> <% end %>
<%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %> <%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %>
<% location_caption = @scheme.locations.count.eql?(1) ? "1 location" : "#{@scheme.locations.count} locations" %>
<%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, location_caption)) %>
<div class="govuk-grid-row"> <%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, "Locations")) %>
<div class="govuk-grid-column-three-quarters">
<%= govuk_table do |table| %> <%= govuk_table do |table| %>
<%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %> <%= table.caption(classes: %w[govuk-!-font-size-19 govuk-!-font-weight-regular]) do |caption| %>
<strong><%= @scheme.locations.count %></strong> <%= @scheme.locations.count.eql?(1) ? "location" : "locations" %>. <strong><%= @scheme.locations.count %></strong> <%= @scheme.locations.count.eql?(1) ? "location" : "locations" %>
<% end %> <% end %>
<%= table.head do |head| %> <%= table.head do |head| %>
<%= head.row do |row| %> <%= head.row do |row| %>
@ -43,7 +43,5 @@
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% end %>
</div>
</div>
<%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "locations" } %> <%== render partial: "pagy/nav", locals: { pagy: @pagy, item_name: "locations" } %>

2
app/views/schemes/check_answers.html.erb

@ -2,8 +2,6 @@
<%= render partial: "organisations/headings", locals: { main: "Check your changes before creating this scheme", sub: @scheme.service_name } %> <%= render partial: "organisations/headings", locals: { main: "Check your changes before creating this scheme", sub: @scheme.service_name } %>
<% location_caption = @scheme.locations.count.eql?(1) ? "1 location" : "#{@scheme.locations.count} locations" %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-three-quarters-from-desktop"> <div class="govuk-grid-column-three-quarters-from-desktop">
<%= govuk_tabs(title: "Check your answers before creating this scheme") do |component| %> <%= govuk_tabs(title: "Check your answers before creating this scheme") do |component| %>

2
app/views/schemes/confirm_secondary.html.erb

@ -12,9 +12,7 @@
<%= form_for(@scheme, method: :patch) do |f| %> <%= form_for(@scheme, method: :patch) do |f| %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<% selection = [OpenStruct.new(id: "Yes", name: "Yes"), OpenStruct.new(id: "No", name: "No")] %> <% selection = [OpenStruct.new(id: "Yes", name: "Yes"), OpenStruct.new(id: "No", name: "No")] %>
<%= f.govuk_collection_radio_buttons :has_other_client_group, <%= f.govuk_collection_radio_buttons :has_other_client_group,
selection, selection,
:id, :id,

2
app/views/schemes/details.html.erb

@ -16,7 +16,7 @@
<%= f.govuk_text_field :service_name, <%= f.govuk_text_field :service_name,
label: { text: "Scheme name", size: "m" }, label: { text: "Scheme name", size: "m" },
hint: { text: "This is how you’ll refer to this supported housing scheme within your organisation. For example, the name could relate to the address or location. You’ll be able to see the client group when selecting it." } %> hint: { text: "This is how you refer to this supported housing scheme within your organisation. For example, the name could relate to the address or location. You’ll be able to see the client group when selecting it." } %>
<%= f.govuk_check_boxes_fieldset :sensitive, <%= f.govuk_check_boxes_fieldset :sensitive,
legend: nil do %> legend: nil do %>

3
app/views/schemes/edit_name.html.erb

@ -16,7 +16,7 @@
<%= f.govuk_text_field :service_name, <%= f.govuk_text_field :service_name,
label: { text: "Scheme name", size: "m" }, label: { text: "Scheme name", size: "m" },
hint: { text: "This is how you’ll refer to this supported housing scheme within your organisation. For example, the name could relate to the address or location. You’ll be able to see the client group when selecting it." } %> hint: { text: "This is how you refer to this supported housing scheme within your organisation. For example, the name could relate to the address or location. You’ll be able to see the client group when selecting it." } %>
<%= f.govuk_check_boxes_fieldset :sensitive, <%= f.govuk_check_boxes_fieldset :sensitive,
legend: nil do %> legend: nil do %>
@ -29,7 +29,6 @@
<% end %> <% end %>
<% organisations = Organisation.all.map { |org| OpenStruct.new(id: org.id, name: org.name) } %> <% organisations = Organisation.all.map { |org| OpenStruct.new(id: org.id, name: org.name) } %>
<% if current_user.support? %> <% if current_user.support? %>
<%= f.govuk_collection_select :owning_organisation_id, <%= f.govuk_collection_select :owning_organisation_id,
organisations, organisations,

2
app/views/schemes/new.html.erb

@ -53,7 +53,6 @@
<% end %> <% end %>
<% scheme_types_selection = Scheme.scheme_types.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> <% scheme_types_selection = Scheme.scheme_types.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>
<%= f.govuk_collection_radio_buttons :scheme_type, <%= f.govuk_collection_radio_buttons :scheme_type,
scheme_types_selection, scheme_types_selection,
:id, :id,
@ -61,7 +60,6 @@
legend: { text: "What is this type of scheme?", size: "m" } %> legend: { text: "What is this type of scheme?", size: "m" } %>
<% care_acts_selection = Scheme.registered_under_care_acts.keys.reverse.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> <% care_acts_selection = Scheme.registered_under_care_acts.keys.reverse.map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>
<%= f.govuk_collection_radio_buttons :registered_under_care_act, <%= f.govuk_collection_radio_buttons :registered_under_care_act,
care_acts_selection, care_acts_selection,
:id, :id,

3
app/views/schemes/primary_client_group.html.erb

@ -14,9 +14,6 @@
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>
<legend class="govuk-fieldset__legend">
</legend>
<% primary_client_group_selection = Scheme.primary_client_groups.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> <% primary_client_group_selection = Scheme.primary_client_groups.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>
<%= f.govuk_collection_radio_buttons :primary_client_group, <%= f.govuk_collection_radio_buttons :primary_client_group,
primary_client_group_selection, primary_client_group_selection,

3
app/views/schemes/secondary_client_group.html.erb

@ -14,9 +14,6 @@
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>
<legend class="govuk-fieldset__legend">
</legend>
<% secondary_client_group_selection = Scheme.secondary_client_groups.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> <% secondary_client_group_selection = Scheme.secondary_client_groups.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>
<%= f.govuk_collection_radio_buttons :secondary_client_group, <%= f.govuk_collection_radio_buttons :secondary_client_group,
secondary_client_group_selection, secondary_client_group_selection,

4
app/views/schemes/show.html.erb

@ -10,10 +10,10 @@
<%= render partial: "organisations/headings", locals: { main: @scheme.service_name, sub: nil } %> <%= 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")) %> <%= render SubNavigationComponent.new(items: scheme_items(request.path, @scheme.id, "Locations")) %>
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-three-quarters-from-desktop">
<%= govuk_summary_list do |summary_list| %> <%= govuk_summary_list do |summary_list| %>
<% @scheme.display_attributes.each do |attr| %> <% @scheme.display_attributes.each do |attr| %>
<% next if current_user.data_coordinator? && attr[:name] == ("Housing stock owned by") %> <% next if current_user.data_coordinator? && attr[:name] == ("Housing stock owned by") %>

3
app/views/schemes/support.html.erb

@ -14,9 +14,6 @@
<div class="govuk-grid-column-two-thirds"> <div class="govuk-grid-column-two-thirds">
<%= f.govuk_error_summary %> <%= f.govuk_error_summary %>
<legend class="govuk-fieldset__legend">
</legend>
<% support_type_selection = Scheme.support_types.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %> <% support_type_selection = Scheme.support_types.keys.excluding("Missing").map { |key, _| OpenStruct.new(id: key, name: key.to_s.humanize) } %>
<%= f.govuk_collection_radio_buttons :support_type, <%= f.govuk_collection_radio_buttons :support_type,
support_type_selection, support_type_selection,

6
spec/features/schemes_spec.rb

@ -198,12 +198,12 @@ RSpec.describe "Schemes scheme Features" do
it "shows service and locations tab" do it "shows service and locations tab" do
expect(page).to have_link("Scheme") expect(page).to have_link("Scheme")
expect(page).to have_link("#{scheme.locations.count} locations") expect(page).to have_link("Locations")
end end
context "when I click locations link" do context "when I click locations link" do
before do before do
click_link("#{scheme.locations.count} locations") click_link("Locations")
end end
it "shows details of those locations" do it "shows details of those locations" do
@ -725,7 +725,7 @@ RSpec.describe "Schemes scheme Features" do
context "when I click to see locations" do context "when I click to see locations" do
before do before do
click_link "1 location" click_link "Locations"
end end
it "I see location details" do it "I see location details" do

8
spec/helpers/navigation_items_helper_spec.rb

@ -190,13 +190,13 @@ RSpec.describe NavigationItemsHelper do
let(:expected_scheme_items) do let(:expected_scheme_items) do
[ [
NavigationItemsHelper::NavigationItem.new("Scheme", "/schemes/1", true), NavigationItemsHelper::NavigationItem.new("Scheme", "/schemes/1", true),
NavigationItemsHelper::NavigationItem.new("1 location", "/schemes/1/locations", false), NavigationItemsHelper::NavigationItem.new("Locations", "/schemes/1/locations", false),
] ]
end end
it "returns navigation items with Schemes item set as current" do it "returns navigation items with Schemes item set as current" do
expect(primary_items("/schemes/1", current_user)).to eq(expected_navigation_items) expect(primary_items("/schemes/1", current_user)).to eq(expected_navigation_items)
expect(scheme_items("/schemes/1", 1, "1 location")).to eq(expected_scheme_items) expect(scheme_items("/schemes/1", 1, "Locations")).to eq(expected_scheme_items)
end end
end end
@ -213,13 +213,13 @@ RSpec.describe NavigationItemsHelper do
let(:expected_scheme_items) do let(:expected_scheme_items) do
[ [
NavigationItemsHelper::NavigationItem.new("Scheme", "/schemes/1", false), NavigationItemsHelper::NavigationItem.new("Scheme", "/schemes/1", false),
NavigationItemsHelper::NavigationItem.new("1 location", "/schemes/1/locations", true), NavigationItemsHelper::NavigationItem.new("Locations", "/schemes/1/locations", true),
] ]
end end
it "returns navigation items with Schemes item set as current" do it "returns navigation items with Schemes item set as current" do
expect(primary_items("/schemes/1/locations", current_user)).to eq(expected_navigation_items) expect(primary_items("/schemes/1/locations", current_user)).to eq(expected_navigation_items)
expect(scheme_items("/schemes/1/locations", 1, "1 location")).to eq(expected_scheme_items) expect(scheme_items("/schemes/1/locations", 1, "Locations")).to eq(expected_scheme_items)
end end
end end

4
spec/requests/locations_controller_spec.rb

@ -418,7 +418,7 @@ RSpec.describe LocationsController, type: :request do
it "updates existing location for scheme with valid params and redirects to correct page" do it "updates existing location for scheme with valid params and redirects to correct page" do
follow_redirect! follow_redirect!
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(page).to have_content("1 location") expect(page).to have_content("Locations")
end end
it "updates existing location for scheme with valid params" do it "updates existing location for scheme with valid params" do
@ -541,7 +541,7 @@ RSpec.describe LocationsController, type: :request do
it "updates existing location for scheme with valid params and redirects to correct page" do it "updates existing location for scheme with valid params and redirects to correct page" do
follow_redirect! follow_redirect!
expect(response).to have_http_status(:ok) expect(response).to have_http_status(:ok)
expect(page).to have_content("1 location") expect(page).to have_content("Locations")
end end
it "updates existing location for scheme with valid params" do it "updates existing location for scheme with valid params" do

Loading…
Cancel
Save