Browse Source

amend ordering in scheme and location show pages to raise status towards top

implement a muted explanation text on schemes when they have complete details but no active locations to explain why they are incomplete
write tests to ensure this text is shown under the right conditions
pull/1704/head
Arthur Campbell 3 years ago
parent
commit
0916c1e94a
  1. 2
      app/helpers/locations_helper.rb
  2. 2
      app/helpers/schemes_helper.rb
  3. 7
      app/views/schemes/show.html.erb
  4. 17
      spec/requests/schemes_controller_spec.rb

2
app/helpers/locations_helper.rb

@ -27,13 +27,13 @@ module LocationsHelper
[
{ name: "Postcode", value: location.postcode, attribute: "postcode" },
{ name: "Location name", value: location.name, attribute: "name" },
{ name: "Status", value: location.status, attribute: "status" },
{ name: "Local authority", value: formatted_local_authority_timeline(location, "name"), attribute: "local_authority" },
{ name: "Number of units", value: location.units, attribute: "units" },
{ name: "Most common unit", value: location.type_of_unit, attribute: "type_of_unit" },
{ name: "Mobility standards", value: location.mobility_type, attribute: "mobility_standards" },
{ name: "Location code", value: formatted_local_authority_timeline(location, "code"), attribute: "location_code" },
{ name: "Availability", value: location_availability(location), attribute: "availability" },
{ name: "Status", value: location.status, attribute: "status" },
]
end

2
app/helpers/schemes_helper.rb

@ -3,6 +3,7 @@ module SchemesHelper
base_attributes = [
{ name: "Scheme code", value: scheme.id_to_display },
{ name: "Name", value: scheme.service_name, edit: true },
{ name: "Status", value: status_tag(scheme.status) },
{ name: "Confidential information", value: scheme.sensitive, edit: true },
{ name: "Type of scheme", value: scheme.scheme_type },
{ name: "Registered under Care Standards Act 2000", value: scheme.registered_under_care_act },
@ -14,7 +15,6 @@ module SchemesHelper
{ name: "Level of support given", value: scheme.support_type },
{ name: "Intended length of stay", value: scheme.intended_stay },
{ name: "Availability", value: scheme_availability(scheme) },
{ name: "Status", value: status_tag_from_resource(scheme) },
]
if user.data_coordinator?

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

@ -19,7 +19,12 @@
<% display_scheme_attributes(@scheme, current_user).each do |attr| %>
<%= summary_list.row do |row| %>
<% row.key { attr[:name] } %>
<% row.value { details_html(attr) } %>
<% row.value do %>
<%= details_html(attr) %>
<% if attr[:name] == "Status" && @scheme.confirmed? && @scheme.locations.confirmed.none? %>
<span class="app-!-colour-muted">Add a location to complete this scheme</span>
<% end %>
<% end %>
<% if SchemePolicy.new(current_user, @scheme).update? %>
<% row.action(text: "Change", href: scheme_edit_name_path(scheme_id: @scheme.id)) if attr[:edit] %>
<% end %>

17
spec/requests/schemes_controller_spec.rb

@ -364,6 +364,23 @@ RSpec.describe SchemesController, type: :request do
expect(page).not_to have_content("Deactivate this scheme")
end
end
context "when the scheme has all details but no confirmed locations" do
it "shows the scheme as incomplete with text to explain" do
get scheme_path(specific_scheme)
expect(page).to have_content "Incomplete"
expect(page).to have_content "Add a location to complete this scheme"
end
end
context "when the scheme has all details and confirmed locations" do
it "shows the scheme as complete" do
create(:location, scheme: specific_scheme)
get scheme_path(specific_scheme)
expect(page).to have_content "Active"
expect(page).not_to have_content "Add a location to complete this scheme"
end
end
end
context "when signed in as a support user" do

Loading…
Cancel
Save