Skip to content

Commit

Permalink
Merge pull request #1669 from DFE-Digital/hide-country-information
Browse files Browse the repository at this point in the history
Hide additional fields for countries with one region
  • Loading branch information
thomasleese authored Sep 11, 2023
2 parents 6ef6e66 + 99ed197 commit d01077c
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 20 deletions.
23 changes: 12 additions & 11 deletions app/views/support_interface/countries/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
<% content_for :page_title, CountryName.from_country(@country) %>

<h1 class="govuk-heading-l"><%= CountryName.from_country(@country) %></h1>

<%= form_with model: @form, url: [:support_interface, @country], method: :put do |f| %>
<%= f.govuk_error_summary %>

<%= f.govuk_radio_buttons_fieldset :has_regions, legend: { text: "Regions" }, hint: { text: "Does this country have regions within it that have a different teaching authority or service journey?" } do %>
<%= f.govuk_radio_button :has_regions, :false, label: { text: "No" }, link_errors: true %>
<%= f.govuk_radio_button :has_regions, :true, label: { text: "Yes" } do %>
<%= f.govuk_text_area :region_names, label: nil, hint: { text: "Add regions below, one region per line. (This will allow you to customise the service for each region.) " }, rows: 10 %>
<% end %>
<% end %>
<h1 class="govuk-heading-l"><%= CountryName.from_country(@country) %></h1>

<%= f.govuk_collection_radio_buttons :eligibility_enabled,
[
Expand All @@ -28,10 +21,18 @@
],
:value,
:label,
legend: { text: "Eligibility checker" },
hint: { text: 'Which route will applicants take through the eligibility checker?' } %>
legend: { text: "Which route will applicants take through the eligibility checker?" } %>

<%= render "shared/support_interface/forms/additional_information", f: %>
<%= f.govuk_radio_buttons_fieldset :has_regions, legend: { text: "Does this country have regions within it that have a different teaching authority or service journey?" } do %>
<%= f.govuk_radio_button :has_regions, :true, label: { text: "Yes" }, link_errors: true do %>
<%= f.govuk_text_area :region_names, label: { text: "Add regions below, one region per line." }, hint: { text: "This will allow you to customise the service for each region." }, rows: 10 %>
<% end %>
<%= f.govuk_radio_button :has_regions, :false, label: { text: "No" } %>
<% end %>

<% if @country.regions.count > 1 %>
<%= render "shared/support_interface/country_region_information_fields", f: %>
<% end %>

<%= f.govuk_submit "Preview", name: "preview", value: "true" do %>
<%= f.govuk_submit "Save", name: "preview", value: "false", secondary: true %>
Expand Down
37 changes: 30 additions & 7 deletions app/views/support_interface/regions/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
<% content_for :page_title, CountryName.from_region(@region) %>

<h1 class="govuk-heading-l"><%= CountryName.from_region(@region) %></h1>

<%= form_with model: [:support_interface, @region] do |f| %>
<%= f.govuk_error_summary %>

<%= f.govuk_check_box :application_form_skip_work_history, 1, 0, multiple: false, link_errors: true, small: true, label: { text: "Skip work history" } %>
<h1 class="govuk-heading-l"><%= CountryName.from_region(@region) %></h1>

<%= f.govuk_collection_radio_buttons :application_form_skip_work_history,
[
OpenStruct.new(value: :true, label: "Yes"),
OpenStruct.new(value: :false, label: "No")
],
:value,
:label,
legend: { text: "Skip work history?" } %>

<%= f.govuk_collection_radio_buttons :requires_preliminary_check,
[
Expand All @@ -14,7 +21,7 @@
],
:value,
:label,
legend: { text: "Will applications be subject to a preliminary check?", size: "s" } %>
legend: { text: "Will applications be subject to a preliminary check?" } %>

<%= f.govuk_fieldset legend: { text: "Teacher status and sanctions checks" } do %>
<%= f.govuk_collection_select :status_check, [
Expand Down Expand Up @@ -57,10 +64,26 @@
legend: { text: "Will the teaching authority only send the letter of professional standing (LOPS) directly to the TRA?", size: "s" } %>
<% end %>

<%= f.govuk_check_box :reduced_evidence_accepted, 1, 0, multiple: false, link_errors: true, small: true, label: { text: "Accept reduced evidence" } %>
<%= f.govuk_check_box :written_statement_optional, 1, 0, multiple: false, link_errors: true, small: true, label: { text: "Applicant can submit without uploading the written statement (if a written statement is requested)" } %>
<%= f.govuk_collection_radio_buttons :reduced_evidence_accepted,
[
OpenStruct.new(value: :true, label: "Yes"),
OpenStruct.new(value: :false, label: "No")
],
:value,
:label,
legend: { text: "Accept reduced evidence?" } %>

<%= f.govuk_collection_radio_buttons :written_statement_optional,
[
OpenStruct.new(value: :true, label: "Yes"),
OpenStruct.new(value: :false, label: "No")
],
:value,
:label,
legend: { text: "Applicant can submit without uploading the written statement?" },
hint: { text: "Only applies if a written statement is requested." } %>

<%= render "shared/support_interface/forms/additional_information", f: %>
<%= render "shared/support_interface/country_region_information_fields", f: %>

<%= f.govuk_submit "Preview", name: "preview", value: "true" do %>
<%= f.govuk_submit "Save", name: "preview", value: "false", secondary: true %>
Expand Down
6 changes: 4 additions & 2 deletions spec/system/support_interface/countries_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@
def given_countries_exist
create(:region, :national, country: create(:country, code: "IE"))
create(:region, :national, country: create(:country, code: "PL"))
create(:region, name: "Hawaii", country: create(:country, code: "US"))
united_states = create(:country, code: "US")
create(:region, name: "Hawaii", country: united_states)
create(:region, name: "New York", country: united_states)
create(:region, :national, country: create(:country, code: "ES"))
create(
:region,
Expand Down Expand Up @@ -202,7 +204,7 @@ def when_i_fill_qualifications_information
end

def when_i_check_written_statement_optional
check "region-written-statement-optional-1-field", visible: false
choose "region-written-statement-optional-true-field", visible: false
end

def when_i_check_requires_preliminary_check
Expand Down

0 comments on commit d01077c

Please sign in to comment.