Browse Source

adjust various UI elements: ordering of rows, copy changes, label size and associated tests

pull/2389/head
Arthur Campbell 2 years ago
parent
commit
b86e126d15
  1. 2
      app/helpers/data_sharing_agreement_helper.rb
  2. 5
      app/helpers/organisations_helper.rb
  3. 9
      app/views/organisations/edit.html.erb
  4. 33
      app/views/organisations/show.html.erb
  5. 7
      spec/helpers/organisations_helper_spec.rb
  6. 17
      spec/views/organisations/show.html.erb_spec.rb

2
app/helpers/data_sharing_agreement_helper.rb

@ -1,7 +1,7 @@
module DataSharingAgreementHelper
def data_sharing_agreement_row(user:, organisation:, summary_list:)
summary_list.with_row do |row|
row.with_key { "Data Sharing Agreement" }
row.with_key { "Data protection agreement" }
row.with_action(
href: data_sharing_agreement_organisation_path(organisation),
text: "View agreement",

5
app/helpers/organisations_helper.rb

@ -14,10 +14,11 @@ module OrganisationsHelper
{ name: "Organisation ID", value: "ORG#{organisation.id}", editable: false },
{ name: "Address", value: organisation.address_string, editable: true },
{ name: "Telephone number", value: organisation.phone, editable: true },
{ name: "Type of provider", value: organisation.display_provider_type, editable: false },
{ name: "Registration number", value: organisation.housing_registration_no || "", editable: false },
{ name: "Type of provider", value: organisation.display_provider_type, editable: false },
{ name: "Owns housing stock?", value: organisation.holds_own_stock ? "Yes" : "No", editable: false },
{ name: "Rent periods", value: organisation.rent_period_labels, editable: true, format: :bullet },
{ name: "Owns housing stock", value: organisation.holds_own_stock ? "Yes" : "No", editable: false },
{ name: "Data protection agreement" },
{ name: "Status", value: status_tag(organisation.status), editable: false },
]
end

9
app/views/organisations/edit.html.erb

@ -12,23 +12,24 @@
</h1>
<% if current_user.support? %>
<%= f.govuk_text_field :name, autocomplete: "name" %>
<%= f.govuk_text_field :name, autocomplete: "name", label: { size: "m" } %>
<% end %>
<%= f.govuk_text_field :address_line1,
label: { text: "Address line 1" },
label: { text: "Address line 1", size: "m" },
autocomplete: "address-line1" %>
<%= f.govuk_text_field :address_line2,
label: { text: "Address line 2" },
label: { text: "Address line 2", size: "m" },
autocomplete: "address-line2" %>
<%= f.govuk_text_field :postcode,
label: { size: "m" },
autocomplete: "postal-code",
width: 10 %>
<%= f.govuk_phone_field :phone,
label: { text: "Telephone number" },
label: { text: "Telephone number", size: "m" },
autocomplete: "tel",
width: 20 %>

33
app/views/organisations/show.html.erb

@ -16,25 +16,28 @@
<%= govuk_summary_list do |summary_list| %>
<%= organisation_name_row(user: current_user, organisation: @organisation, summary_list:) %>
<% display_organisation_attributes(@organisation).each do |attr| %>
<% if can_edit_org?(current_user) && attr[:editable] %>
<%= summary_list.with_row do |row| %>
<% row.with_key { attr[:name] } %>
<% row.with_value { details_html(attr) } %>
<% row.with_action(
visually_hidden_text: attr[:name].to_s.humanize.downcase,
href: edit_organisation_path(@organisation),
html_attributes: { "data-qa": "change-#{attr[:name].downcase}" },
) %>
<% end %>
<% if attr[:name] == "Data protection agreement" %>
<%= data_sharing_agreement_row(organisation: @organisation, user: current_user, summary_list:) %>
<% else %>
<%= summary_list.with_row do |row| %>
<% row.with_key { attr[:name] } %>
<% row.with_value { details_html(attr) } %>
<% row.with_action %>
<% if can_edit_org?(current_user) && attr[:editable] %>
<%= summary_list.with_row do |row| %>
<% row.with_key { attr[:name] } %>
<% row.with_value { details_html(attr) } %>
<% row.with_action(
visually_hidden_text: attr[:name].to_s.humanize.downcase,
href: edit_organisation_path(@organisation),
html_attributes: { "data-qa": "change-#{attr[:name].downcase}" },
) %>
<% end %>
<% else %>
<%= summary_list.with_row do |row| %>
<% row.with_key { attr[:name] } %>
<% row.with_value { details_html(attr) } %>
<% row.with_action %>
<% end %>
<% end %>
<% end %>
<% end %>
<%= data_sharing_agreement_row(organisation: @organisation, user: current_user, summary_list:) %>
<% end %>
<p>To report a merge or update your organisation details, <%= govuk_link_to "contact the helpdesk", GlobalConstants::HELPDESK_URL %>.</p>
<%= render partial: "organisations/merged_organisation_details" %>

7
spec/helpers/organisations_helper_spec.rb

@ -12,10 +12,11 @@ RSpec.describe OrganisationsHelper do
name: "Address",
value: "2 Marsham Street\nLondon\nSW1P 4DF" },
{ editable: true, name: "Telephone number", value: nil },
{ editable: false, name: "Type of provider", value: "Local authority" },
{ editable: false, name: "Registration number", value: "1234" },
{ editable: true, format: :bullet, name: "Rent periods", value: %w[All] },
{ editable: false, name: "Owns housing stock", value: "Yes" },
{ editable: false, name: "Type of provider", value: "Local authority" },
{ editable: false, name: "Owns housing stock?", value: "Yes" },
{ editable: true, format: :bullet, name: "Rent periods", value: [] },
{ name: "Data protection agreement" },
{ editable: false, name: "Status", value: status_tag(organisation.status) }],
)
end

17
spec/views/organisations/show.html.erb_spec.rb

@ -2,15 +2,10 @@ require "rails_helper"
RSpec.describe "organisations/show.html.erb" do
before do
Timecop.freeze(Time.zone.local(2023, 1, 10))
allow(view).to receive(:current_user).and_return(user)
assign(:organisation, user.organisation)
end
after do
Timecop.return
end
let(:fragment) { Capybara::Node::Simple.new(rendered) }
let(:organisation_without_dpc) { create(:organisation, :without_dpc) }
let(:organisation_with_dsa) { create(:organisation) }
@ -21,7 +16,7 @@ RSpec.describe "organisations/show.html.erb" do
it "includes data sharing agreement row" do
render
expect(fragment).to have_content("Data Sharing Agreement")
expect(fragment).to have_content("Data protection agreement")
end
it "shows data sharing agreement not accepted" do
@ -42,7 +37,7 @@ RSpec.describe "organisations/show.html.erb" do
it "includes data sharing agreement row" do
render
expect(fragment).to have_content("Data Sharing Agreement")
expect(fragment).to have_content("Data protection agreement")
end
it "shows data sharing agreement accepted" do
@ -65,7 +60,7 @@ RSpec.describe "organisations/show.html.erb" do
it "includes data sharing agreement row" do
render
expect(fragment).to have_content("Data Sharing Agreement")
expect(fragment).to have_content("Data protection agreement")
end
it "shows data sharing agreement not accepted" do
@ -92,7 +87,7 @@ RSpec.describe "organisations/show.html.erb" do
it "includes data sharing agreement row" do
render
expect(fragment).to have_content("Data Sharing Agreement")
expect(fragment).to have_content("Data protection agreement")
end
it "shows data sharing agreement accepted with date" do
@ -135,7 +130,7 @@ RSpec.describe "organisations/show.html.erb" do
it "includes data sharing agreement row" do
render
expect(fragment).to have_content("Data Sharing Agreement")
expect(fragment).to have_content("Data protection agreement")
end
it "shows data sharing agreement not accepted" do
@ -159,7 +154,7 @@ RSpec.describe "organisations/show.html.erb" do
it "includes data sharing agreement row" do
render
expect(fragment).to have_content("Data Sharing Agreement")
expect(fragment).to have_content("Data protection agreement")
end
it "shows data sharing agreement accepted" do

Loading…
Cancel
Save