Browse Source
* feat: wip postcode page * feat: wip add new flow * feat: add check answers page, continue updating flow * feat: add back behaviour * feat: more flow work * feat: further flow work and flash notice, name tidying * feat: add check_answers referrer linking * feat: add controller and details linking and lint * refactor: erblinting * feat: add local_authority page (currenlty separate from edit_local_authority to avoid conflict with add location to newly created scheme path, to be fixed later). also copy and routing updates * feat: add validations to controller (could later be added to model) * fix: correct date order * feat: validate on model (except startdate) * feat: copy update * refactor: railsification * feat: add date model validation * feat: add updated availability text in check_answers * feat: more updated dynamic text and linking * refactor: erblinting * refactor: cleanup of redundant code * refactor: remove redundant create * feat: use rails route * test: wip tests * test: wip tests * feat: add new back behaviour for new scheme path and tests wip * feat: add more back behaviour for new scheme path and fix local auth validation * feat: further linking behaviour with routes and referrers, don't add new location automatically to new schemes * feat: if location with no details added, route to normal path rather than check answers * test: update model and helper location tests * test: more test updates * test: more test updates and remove redundant files * test: remove redundant tests, add postcode test * test: add new #new tests * test: add test for all new controller methods * test: add more startdate tests * refactor: erblinting * test: fix failing tests * test: update scheme test * feat: respond to PR comments * feat: make postcode clear only if changed * feat: add _update methods * refactor: simplify validation and location_edit_path method * refactor: add helper method for action text * refactor: remove redundant logic * refactor: simplify routing * refactor: reintroduce location_params * refactor: use presence validation for postcode * refactor: use presence validation for la * feat: validate confirmed * tests: make tests pass with new startdate validation * WIP * refactor: simplify display attributes helpers and update tests * refactor: linting * feat: design change to save behaviour * test: fix failing tests * feat: location code copy tweak * refactor: remove redundant function * refactor: remove add_another_location and new location page * feat: simplify startdate validations to move to model, use scheme available_from date for in range validation * test: fix failing tests * refactor: linting * feat: remove name validation as a result of PO review * test: update tests * refactor: remove redundant context Co-authored-by: James Rose <james@jbpr.net>pull/1096/head
natdeanlewissoftwire
2 years ago
committed by
GitHub
32 changed files with 1495 additions and 1181 deletions
@ -0,0 +1,33 @@
|
||||
<% content_for :title, "Add a location to this scheme" %> |
||||
|
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link( |
||||
text: "Back", |
||||
href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location, route: params[:route]) : scheme_location_mobility_standards_path(@scheme, @location, route: params[:route]), |
||||
) %> |
||||
<% end %> |
||||
|
||||
<%= form_for(@location, method: :patch, url: scheme_location_availability_path(@scheme, @location, route: params[:route], referrer: params[:referrer])) do |f| %> |
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<%= f.govuk_error_summary %> |
||||
|
||||
<%= render partial: "organisations/headings", locals: { main: I18n.t("questions.location.startdate"), sub: "Add a location to #{@scheme.service_name}" } %> |
||||
|
||||
<%= f.govuk_date_field :startdate, |
||||
hint: { text: I18n.t("hints.location.startdate") }, |
||||
legend: nil, |
||||
width: 20 %> |
||||
|
||||
<div class="govuk-button-group"> |
||||
<% if params[:referrer] == "check_answers" %> |
||||
<%= f.govuk_submit "Save changes" %> |
||||
<%= govuk_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location, route: params[:route]), secondary: true %> |
||||
<% else %> |
||||
<%= f.govuk_submit "Save and continue" %> |
||||
<%= govuk_link_to "Skip for now", scheme_location_check_answers_path(@scheme, @location), secondary: true %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<% end %> |
@ -0,0 +1,34 @@
|
||||
<% title = @location.name %> |
||||
<% content_for :title, title %> |
||||
|
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link( |
||||
text: "Back", |
||||
href: case params[:route] |
||||
when "locations" |
||||
scheme_locations_path(@scheme) |
||||
else |
||||
:back |
||||
end, |
||||
) %> |
||||
<% end %> |
||||
|
||||
<%= render partial: "organisations/headings", locals: { main: "Check your answers", sub: "Add a location to #{@scheme.service_name}" } %> |
||||
|
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds-from-desktop"> |
||||
<%= govuk_summary_list do |summary_list| %> |
||||
<% display_location_attributes_for_check_answers(@location).each do |attr| %> |
||||
<%= summary_list.row do |row| %> |
||||
<% row.key { attr[:name] } %> |
||||
<% row.value { details_html(attr) } %> |
||||
<% row.action(text: action_text_helper(attr, @location), href: location_edit_path(@location, attr[:attribute])) %> |
||||
<% end %> |
||||
<% end %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
<div class="govuk-button-group"> |
||||
<%= govuk_button_to "Save and return to locations", scheme_location_confirm_path(@scheme, @location, route: params[:route]), method: :patch %> |
||||
<%= govuk_button_link_to "Cancel", scheme_locations_path(@scheme), secondary: true %> |
||||
</div> |
@ -1,56 +0,0 @@
|
||||
<% content_for :title, "Add a location to this scheme" %> |
||||
|
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link( |
||||
text: "Back", |
||||
href: scheme_check_answers_path(@scheme, anchor: "locations"), |
||||
) %> |
||||
<% end %> |
||||
|
||||
<%= form_for(@location, method: :patch, url: scheme_location_path(scheme_id: @scheme.id, id: @location.id)) do |f| %> |
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<%= f.govuk_error_summary %> |
||||
|
||||
<%= render partial: "organisations/headings", locals: { main: "Add a location to this scheme", sub: @scheme.service_name } %> |
||||
|
||||
<%= f.govuk_text_field :postcode, |
||||
label: { size: "m" }, |
||||
hint: { text: I18n.t("hints.location.postcode") }, |
||||
width: 5 %> |
||||
|
||||
<%= f.govuk_text_field :name, |
||||
label: { text: I18n.t("questions.location.name"), size: "m" }, |
||||
hint: { text: I18n.t("hints.location.name") } %> |
||||
|
||||
<%= f.govuk_number_field :units, |
||||
label: { text: I18n.t("questions.location.units"), size: "m" }, |
||||
width: 2, |
||||
hint: { text: I18n.t("hints.location.units") }, |
||||
autofocus: true %> |
||||
|
||||
<%= f.govuk_collection_radio_buttons :type_of_unit, |
||||
type_of_units_selection, |
||||
:id, |
||||
:name, |
||||
legend: { text: I18n.t("questions.location.type_of_unit"), size: "m" } %> |
||||
|
||||
<%= f.govuk_collection_radio_buttons :mobility_type, |
||||
mobility_type_selection, |
||||
:id, |
||||
:name, |
||||
:description, |
||||
legend: { text: I18n.t("questions.location.mobility_type"), size: "m" } %> |
||||
|
||||
<%= f.govuk_date_field :startdate, |
||||
legend: { text: I18n.t("questions.location.startdate"), size: "m" }, |
||||
width: 20 %> |
||||
|
||||
<%= govuk_section_break(visible: true, size: "m") %> |
||||
|
||||
<%= f.hidden_field :page, value: "edit" %> |
||||
|
||||
<%= f.govuk_submit "Save and continue" %> |
||||
</div> |
||||
</div> |
||||
<% end %> |
@ -1,31 +0,0 @@
|
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link( |
||||
text: "Back", |
||||
href: "/schemes/#{@scheme.id}/locations", |
||||
) %> |
||||
<% end %> |
||||
|
||||
<%= form_for(@location, method: :patch, url: scheme_location_path(scheme_id: @scheme.id, id: @location.id, add_another_location: params[:add_another_location])) do |f| %> |
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<%= f.govuk_error_summary %> |
||||
|
||||
<%= render partial: "organisations/headings", locals: { main: "What is the local authority of #{@location.postcode}?", sub: @scheme.service_name } %> |
||||
|
||||
<%= f.govuk_collection_select :location_admin_district, |
||||
local_authorities_selection, |
||||
:name, |
||||
:name, |
||||
label: { hidden: true }, |
||||
"data-controller": %w[conditional-filter accessible-autocomplete] %> |
||||
|
||||
<%= f.hidden_field :page, value: "edit-local-authority" %> |
||||
|
||||
<div class="govuk-button-group"> |
||||
<%= f.govuk_submit "Save and continue" %> |
||||
|
||||
<%= govuk_link_to "Skip for now", "/schemes/#{@scheme.id}/check-answers#locations" %> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<% end %> |
@ -1,26 +0,0 @@
|
||||
<% content_for :title, "Location name for #{@location.postcode}" %> |
||||
|
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link( |
||||
text: "Back", |
||||
href: scheme_location_path(@scheme, @location), |
||||
) %> |
||||
<% end %> |
||||
|
||||
<%= form_for(@location, method: :patch, url: scheme_location_path(scheme_id: @scheme.id, id: @location.id)) do |f| %> |
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<%= f.govuk_error_summary %> |
||||
|
||||
<%= render partial: "organisations/headings", locals: { main: "Location name for #{@location.postcode}", sub: @scheme.service_name } %> |
||||
|
||||
<%= f.govuk_text_field :name, |
||||
label: { hidden: true }, |
||||
hint: { text: "This is how you refer to this location within your organisation" } %> |
||||
|
||||
<%= f.hidden_field :page, value: "edit-name" %> |
||||
|
||||
<%= f.govuk_submit "Save and continue" %> |
||||
</div> |
||||
</div> |
||||
<% end %> |
@ -0,0 +1,40 @@
|
||||
<% content_for :title, "Add a location to this scheme" %> |
||||
|
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link( |
||||
text: "Back", |
||||
href: case params[:referrer] |
||||
when "check_local_authority" |
||||
scheme_location_check_answers_path(@scheme, @location, route: params[:route]) |
||||
else |
||||
scheme_location_postcode_path(@scheme, @location, route: params[:route], referrer: params[:referrer]) |
||||
end, |
||||
) %> |
||||
<% end %> |
||||
|
||||
<%= form_for(@location, method: :patch, url: scheme_location_local_authority_path(@scheme, @location, route: params[:route], referrer: params[:referrer])) do |f| %> |
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<%= f.govuk_error_summary %> |
||||
|
||||
<%= render partial: "organisations/headings", locals: { main: "What is the local authority of #{@location.postcode}?", sub: @scheme.service_name } %> |
||||
|
||||
<%= f.govuk_collection_select :location_admin_district, |
||||
local_authorities_selection, |
||||
:name, |
||||
:name, |
||||
label: { text: "Start typing to search for your local authority" }, |
||||
"data-controller": %w[conditional-filter accessible-autocomplete] %> |
||||
|
||||
<div class="govuk-button-group"> |
||||
<% if params[:referrer] == "check_answers" || params[:referrer] == "check_local_authority" %> |
||||
<%= f.govuk_submit "Save changes" %> |
||||
<%= govuk_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location, route: params[:route]), secondary: true %> |
||||
<% else %> |
||||
<%= f.govuk_submit "Save and continue" %> |
||||
<%= govuk_link_to "Skip for now", scheme_location_name_path(@scheme, @location), secondary: true %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<% end %> |
@ -0,0 +1,35 @@
|
||||
<% content_for :title, "Add a location to this scheme" %> |
||||
|
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link( |
||||
text: "Back", |
||||
href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location, route: params[:route]) : scheme_location_type_of_unit_path(@scheme, @location, route: params[:route]), |
||||
) %> |
||||
<% end %> |
||||
|
||||
<%= form_for(@location, method: :patch, url: scheme_location_mobility_standards_path(@scheme, @location, route: params[:route], referrer: params[:referrer])) do |f| %> |
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<%= f.govuk_error_summary %> |
||||
|
||||
<%= render partial: "organisations/headings", locals: { main: I18n.t("questions.location.mobility_type"), sub: "Add a location to #{@scheme.service_name}" } %> |
||||
|
||||
<%= f.govuk_collection_radio_buttons :mobility_type, |
||||
mobility_type_selection, |
||||
:id, |
||||
:name, |
||||
:description, |
||||
legend: nil %> |
||||
|
||||
<div class="govuk-button-group"> |
||||
<% if params[:referrer] == "check_answers" %> |
||||
<%= f.govuk_submit "Save changes" %> |
||||
<%= govuk_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location, route: params[:route]), secondary: true %> |
||||
<% else %> |
||||
<%= f.govuk_submit "Save and continue" %> |
||||
<%= govuk_link_to "Skip for now", scheme_location_availability_path(@scheme, @location), secondary: true %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<% end %> |
@ -0,0 +1,42 @@
|
||||
<% content_for :title, "Add a location to this scheme" %> |
||||
|
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link( |
||||
text: "Back", |
||||
href: case params[:referrer] |
||||
when "check_answers" |
||||
scheme_location_check_answers_path(@scheme, @location, route: params[:route]) |
||||
when "details" |
||||
scheme_location_path(@scheme, @location) |
||||
else |
||||
scheme_location_postcode_path(@scheme, @location, route: params[:route]) |
||||
end, |
||||
) %> |
||||
<% end %> |
||||
|
||||
<%= form_for(@location, method: :patch, url: scheme_location_name_path(@scheme, @location, route: params[:route], referrer: params[:referrer])) do |f| %> |
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<%= f.govuk_error_summary %> |
||||
|
||||
<%= render partial: "organisations/headings", locals: { main: I18n.t("questions.location.name"), sub: "Add a location to #{@scheme.service_name}" } %> |
||||
|
||||
<%= f.govuk_text_field :name, |
||||
label: nil, |
||||
hint: { text: I18n.t("hints.location.name") } %> |
||||
|
||||
<div class="govuk-button-group"> |
||||
<% if params[:referrer] == "check_answers" %> |
||||
<%= f.govuk_submit "Save changes" %> |
||||
<%= govuk_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location, route: params[:route]), secondary: true %> |
||||
<% elsif params[:referrer] == "details" %> |
||||
<%= f.govuk_submit "Save changes" %> |
||||
<%= govuk_link_to "Cancel", scheme_location_path(@scheme, @location), secondary: true %> |
||||
<% else %> |
||||
<%= f.govuk_submit "Save and continue" %> |
||||
<%= govuk_link_to "Skip for now", scheme_location_units_path(@scheme, @location), secondary: true %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<% end %> |
@ -1,61 +0,0 @@
|
||||
<% content_for :title, "Add a location to this scheme" %> |
||||
|
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link( |
||||
text: "Back", |
||||
href: "/schemes/#{@scheme.id}/support", |
||||
) %> |
||||
<% end %> |
||||
|
||||
<%= form_for(@location, method: :post, url: scheme_locations_path) do |f| %> |
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<%= f.govuk_error_summary %> |
||||
|
||||
<%= render partial: "organisations/headings", locals: { main: "Add a location to this scheme", sub: @scheme.service_name } %> |
||||
|
||||
<%= f.govuk_text_field :postcode, |
||||
label: { size: "m" }, |
||||
hint: { text: I18n.t("hints.location.postcode") }, |
||||
width: 5 %> |
||||
|
||||
<%= f.govuk_text_field :name, |
||||
label: { text: I18n.t("questions.location.name"), size: "m" }, |
||||
hint: { text: I18n.t("hints.location.name") } %> |
||||
|
||||
<%= f.govuk_number_field :units, |
||||
label: { text: I18n.t("questions.location.units"), size: "m" }, |
||||
width: 2, |
||||
hint: { text: I18n.t("hints.location.units") }, |
||||
autofocus: true %> |
||||
|
||||
<%= f.govuk_collection_radio_buttons :type_of_unit, |
||||
type_of_units_selection, |
||||
:id, |
||||
:name, |
||||
legend: { text: I18n.t("questions.location.type_of_unit"), size: "m" } %> |
||||
|
||||
<%= f.govuk_collection_radio_buttons :mobility_type, |
||||
mobility_type_selection, |
||||
:id, |
||||
:name, |
||||
:description, |
||||
legend: { text: I18n.t("questions.location.mobility_type"), size: "m" } %> |
||||
|
||||
<%= f.govuk_date_field :startdate, |
||||
legend: { text: I18n.t("questions.location.startdate"), size: "m" }, |
||||
width: 20 %> |
||||
|
||||
<%= govuk_section_break(visible: true, size: "m") %> |
||||
|
||||
<%= f.govuk_collection_radio_buttons :add_another_location, |
||||
another_location_selection, |
||||
:id, |
||||
:name, |
||||
inline: true, |
||||
legend: { text: I18n.t("questions.location.add_another_location"), size: "m" } %> |
||||
|
||||
<%= f.govuk_submit "Save and continue" %> |
||||
</div> |
||||
</div> |
||||
<% end %> |
@ -0,0 +1,37 @@
|
||||
<% content_for :title, "Add a location to this scheme" %> |
||||
|
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link( |
||||
text: "Back", |
||||
href: if params[:referrer] == "check_answers" |
||||
scheme_location_check_answers_path(@scheme, @location, route: params[:route]) |
||||
else |
||||
scheme_locations_path(@scheme) |
||||
end, |
||||
) %> |
||||
<% end %> |
||||
|
||||
<%= form_for(@location, method: :patch, url: scheme_location_postcode_path(@scheme, @location, route: params[:route], referrer: params[:referrer])) do |f| %> |
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<%= f.govuk_error_summary %> |
||||
|
||||
<%= render partial: "organisations/headings", locals: { main: I18n.t("questions.location.postcode"), sub: "Add a location to #{@scheme.service_name}" } %> |
||||
|
||||
<%= f.govuk_text_field :postcode, |
||||
label: nil, |
||||
hint: { text: I18n.t("hints.location.postcode") }, |
||||
width: 5 %> |
||||
|
||||
<div class="govuk-button-group"> |
||||
<% if params[:referrer] == "check_answers" %> |
||||
<%= f.govuk_submit "Save changes" %> |
||||
<%= govuk_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location, route: params[:route]), secondary: true %> |
||||
<% else %> |
||||
<%= f.govuk_submit "Save and continue" %> |
||||
<%= govuk_link_to "Skip for now", scheme_location_name_path(@scheme, @location), secondary: true %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<% end %> |
@ -0,0 +1,34 @@
|
||||
<% content_for :title, "Add a location to this scheme" %> |
||||
|
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link( |
||||
text: "Back", |
||||
href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location, route: params[:route]) : scheme_location_units_path(@scheme, @location, route: params[:route]), |
||||
) %> |
||||
<% end %> |
||||
|
||||
<%= form_for(@location, method: :patch, url: scheme_location_type_of_unit_path(@scheme, @location, route: params[:route], referrer: params[:referrer])) do |f| %> |
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<%= f.govuk_error_summary %> |
||||
|
||||
<%= render partial: "organisations/headings", locals: { main: I18n.t("questions.location.type_of_unit"), sub: "Add a location to #{@scheme.service_name}" } %> |
||||
|
||||
<%= f.govuk_collection_radio_buttons :type_of_unit, |
||||
type_of_units_selection, |
||||
:id, |
||||
:name, |
||||
legend: nil %> |
||||
|
||||
<div class="govuk-button-group"> |
||||
<% if params[:referrer] == "check_answers" %> |
||||
<%= f.govuk_submit "Save changes" %> |
||||
<%= govuk_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location, route: params[:route]), secondary: true %> |
||||
<% else %> |
||||
<%= f.govuk_submit "Save and continue" %> |
||||
<%= govuk_link_to "Skip for now", scheme_location_mobility_standards_path(@scheme, @location), secondary: true %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<% end %> |
@ -0,0 +1,34 @@
|
||||
<% content_for :title, "Add a location to this scheme" %> |
||||
|
||||
<% content_for :before_content do %> |
||||
<%= govuk_back_link( |
||||
text: "Back", |
||||
href: params[:referrer] == "check_answers" ? scheme_location_check_answers_path(@scheme, @location, route: params[:route]) : scheme_location_name_path(@scheme, @location, route: params[:route]), |
||||
) %> |
||||
<% end %> |
||||
|
||||
<%= form_for(@location, method: :patch, url: scheme_location_units_path(@scheme, @location, route: params[:route], referrer: params[:referrer])) do |f| %> |
||||
<div class="govuk-grid-row"> |
||||
<div class="govuk-grid-column-two-thirds"> |
||||
<%= f.govuk_error_summary %> |
||||
|
||||
<%= render partial: "organisations/headings", locals: { main: I18n.t("questions.location.units"), sub: "Add a location to #{@scheme.service_name}" } %> |
||||
|
||||
<%= f.govuk_number_field :units, |
||||
label: nil, |
||||
width: 2, |
||||
hint: { text: I18n.t("hints.location.units") }, |
||||
autofocus: true %> |
||||
|
||||
<div class="govuk-button-group"> |
||||
<% if params[:referrer] == "check_answers" %> |
||||
<%= f.govuk_submit "Save changes" %> |
||||
<%= govuk_link_to "Cancel", scheme_location_check_answers_path(@scheme, @location, route: params[:route]), secondary: true %> |
||||
<% else %> |
||||
<%= f.govuk_submit "Save and continue" %> |
||||
<%= govuk_link_to "Skip for now", scheme_location_type_of_unit_path(@scheme, @location), secondary: true %> |
||||
<% end %> |
||||
</div> |
||||
</div> |
||||
</div> |
||||
<% end %> |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue