diff --git a/app/assets/stylesheets/sidebar.scss b/app/assets/stylesheets/sidebar.scss index 4306371f10..0e1b9e1dcb 100644 --- a/app/assets/stylesheets/sidebar.scss +++ b/app/assets/stylesheets/sidebar.scss @@ -89,12 +89,19 @@ body:has(.bops-fullwidth-container) { width: 100%; } -.bops-sidebar__task { +.bops-sidebar .govuk-list.govuk-list--spaced > .bops-sidebar__task { display: flex; align-items: center; gap: govuk-spacing(2); - padding-bottom: govuk-spacing(2); + padding: govuk-spacing(2) 20px; + margin: 0 -20px; border-bottom: 1px solid #8eb8dc; + border-left: 4px solid transparent; + + &.bops-sidebar__task--active { + background-color: #d4e4f1; + border-left-color: $govuk-link-colour; + } } .bops-sidebar ul h3 { diff --git a/app/components/sidebar_component.rb b/app/components/sidebar_component.rb index cf6d55b55e..5ccb0331e0 100644 --- a/app/components/sidebar_component.rb +++ b/app/components/sidebar_component.rb @@ -26,19 +26,23 @@ def render_task(task) if task.section.present? render_section(task) else + is_active = current_task?(task) target = if task.legacy_url.present? route_for(task.legacy_url, planning_application) else BopsPreapps::Engine.routes.url_helpers.task_path(@case_record, slug: task.full_slug, reference: planning_application_reference) end - link = helpers.govuk_link_to(task.name, target) + link_options = is_active ? {"aria-current" => "page"} : {} + link = helpers.govuk_link_to(task.name, target, **link_options) content = if task.status_hidden? safe_join([invisible_status_placeholder, link], " ") else safe_join([status_indicator_for(task), link], " ") end - helpers.tag.li(content, class: "bops-sidebar__task") + li_classes = ["bops-sidebar__task"] + li_classes << "bops-sidebar__task--active" if is_active + helpers.tag.li(content, class: li_classes.join(" ")) end end @@ -74,4 +78,11 @@ def status_indicator_for(task) def invisible_status_placeholder helpers.content_tag(:span, "", class: "bops-sidebar__task-icon", aria: {hidden: true}) end + + def current_task?(task) + current_slug = params[:slug] + return false if current_slug.blank? + + task.full_slug == current_slug + end end diff --git a/engines/bops_preapps/app/forms/bops_preapps/tasks/check_red_line_boundary_form.rb b/engines/bops_preapps/app/forms/bops_preapps/tasks/check_red_line_boundary_form.rb index 2101f50797..a3916823bc 100644 --- a/engines/bops_preapps/app/forms/bops_preapps/tasks/check_red_line_boundary_form.rb +++ b/engines/bops_preapps/app/forms/bops_preapps/tasks/check_red_line_boundary_form.rb @@ -3,9 +3,10 @@ module BopsPreapps module Tasks class CheckRedLineBoundaryForm < Form - self.task_actions = %w[save_and_complete mark_as_valid] + self.task_actions = %w[save_and_complete mark_as_valid delete_request] attribute :valid_red_line_boundary, :boolean + attribute :validation_request_id, :integer with_options on: :save_and_complete do validates :valid_red_line_boundary, inclusion: {in: [true, false], message: "Select whether the red line boundary is correct"} @@ -22,6 +23,8 @@ def update(params) save_and_complete when "mark_as_valid" mark_as_valid + when "delete_request" + delete_validation_request end end end @@ -29,19 +32,34 @@ def update(params) def redirect_url(options = {}) return return_to if return_to.present? - if valid_red_line_boundary + case action + when "delete_request" super + when "save_and_complete" + if valid_red_line_boundary + super + else + Rails.application.routes.url_helpers.new_planning_application_validation_validation_request_path( + planning_application, + type: "red_line_boundary_change" + ) + end else - Rails.application.routes.url_helpers.new_planning_application_validation_validation_request_path( - planning_application, - type: "red_line_boundary_change" - ) + super end end def validation_request - @validation_request ||= planning_application.red_line_boundary_change_validation_requests.open_or_pending.first || - planning_application.red_line_boundary_change_validation_requests.closed.last + @validation_request ||= if validation_request_id.present? + planning_application.red_line_boundary_change_validation_requests.find(validation_request_id) + else + planning_application.red_line_boundary_change_validation_requests.open_or_pending.first || + planning_application.red_line_boundary_change_validation_requests.closed.last + end + end + + def cancel_url + route_for(:cancel_request, planning_application, validation_request_id: validation_request.id, task_slug: task.full_slug, only_path: true) end def flash(type, controller) @@ -52,6 +70,8 @@ def flash(type, controller) controller.t(".check-red-line-boundary.success") when "mark_as_valid" controller.t(".check-red-line-boundary.mark_as_valid") + when "delete_request" + controller.t(".check-red-line-boundary.delete_request") end end @@ -70,6 +90,13 @@ def mark_as_valid task.complete! end end + + def delete_validation_request + transaction do + validation_request.destroy! + task.not_started! + end + end end end end diff --git a/engines/bops_preapps/app/views/bops_preapps/tasks/check-and-validate/check-application-details/check-red-line-boundary/show.html.erb b/engines/bops_preapps/app/views/bops_preapps/tasks/check-and-validate/check-application-details/check-red-line-boundary/show.html.erb index d3902a62a1..32a3a36e74 100644 --- a/engines/bops_preapps/app/views/bops_preapps/tasks/check-and-validate/check-application-details/check-red-line-boundary/show.html.erb +++ b/engines/bops_preapps/app/views/bops_preapps/tasks/check-and-validate/check-application-details/check-red-line-boundary/show.html.erb @@ -23,13 +23,15 @@

Waiting for applicant response.

<% if @planning_application.not_started? %> -

- <%= delete_confirmation_request_link( - @planning_application, - @form.validation_request, - classname: "govuk-link" - ) %> -

+ <%= form_with url: @form.url, method: :patch, data: {confirm: "Are you sure you want to delete this request?"} do |f| %> + <%= f.hidden_field :task_action, value: "delete_request" %> + <%= f.hidden_field "#{@form.param_key}[validation_request_id]", value: @form.validation_request.id %> + <%= f.govuk_submit "Delete request", secondary: true %> + <% end %> + <% end %> + + <% if @planning_application.invalidated? %> +

<%= govuk_link_to "Cancel request", @form.cancel_url %>

<% end %> <% elsif @form.validation_request.closed? && @form.validation_request.approved? %>

Red line boundary change approved

@@ -64,11 +66,20 @@

<%= @form.validation_request.updated_at.to_fs %>

-

- <%= govuk_link_to "Request a new red line boundary change", - main_app.new_planning_application_validation_validation_request_path(@planning_application, type: "red_line_boundary_change"), - class: "govuk-body" %> -

+

Current red line boundary

+ <%= render "shared/location_map", locals: {geojson: @planning_application.boundary_geojson} %> + + <%= form_with model: @form, url: @form.url do |form| %> + <%= form.govuk_error_summary %> + <%= return_to_hidden_field %> + + <%= form.govuk_radio_buttons_fieldset :valid_red_line_boundary, legend: {text: "Is the red line boundary correct?"} do %> + <%= form.govuk_radio_button :valid_red_line_boundary, true, label: {text: "Yes"} %> + <%= form.govuk_radio_button :valid_red_line_boundary, false, label: {text: "No"} %> + <% end %> + + <%= render "shared/task_submit_buttons", form: form, save_draft: false %> + <% end %> <% end %> <% else %>

This digital red line boundary was submitted by the applicant.

diff --git a/engines/bops_preapps/app/views/bops_preapps/tasks/check-and-validate/check-tag-and-confirm-documents/review-documents/show.html.erb b/engines/bops_preapps/app/views/bops_preapps/tasks/check-and-validate/check-tag-and-confirm-documents/review-documents/show.html.erb index 498c1df5ce..355a632f41 100644 --- a/engines/bops_preapps/app/views/bops_preapps/tasks/check-and-validate/check-tag-and-confirm-documents/review-documents/show.html.erb +++ b/engines/bops_preapps/app/views/bops_preapps/tasks/check-and-validate/check-tag-and-confirm-documents/review-documents/show.html.erb @@ -1,6 +1,6 @@ <%= render "shared/task_header", task: @task %> -
+

Submitted documents

diff --git a/engines/bops_preapps/app/views/shared/_task_header.html.erb b/engines/bops_preapps/app/views/shared/_task_header.html.erb index 5252b5f8dd..1736c39e7b 100644 --- a/engines/bops_preapps/app/views/shared/_task_header.html.erb +++ b/engines/bops_preapps/app/views/shared/_task_header.html.erb @@ -7,12 +7,6 @@ <% if task.top_level_ancestor.section == "Assessment" %> <% add_parent_breadcrumb_link "Assessment", main_app.planning_application_assessment_tasks_path(task.case_record.planning_application) %> -<% elsif task.top_level_ancestor.section == "Validation" %> - <% add_parent_breadcrumb_link "Validation", - main_app.planning_application_validation_tasks_path(task.case_record.planning_application) %> -<% elsif task.top_level_ancestor.section == "Consultation" %> - <% add_parent_breadcrumb_link "Consultation", - main_app.planning_application_consultation_path(task.case_record.planning_application) %> <% end %> <% page_heading = heading || task.title %> diff --git a/engines/bops_preapps/config/locales/en.yml b/engines/bops_preapps/config/locales/en.yml index 9118182f74..6636fe87db 100644 --- a/engines/bops_preapps/config/locales/en.yml +++ b/engines/bops_preapps/config/locales/en.yml @@ -9,6 +9,9 @@ en: check-fee: cancel_request: Fee change request successfully cancelled failure: Fee change request could not be cancelled + check-red-line-boundary: + cancel_request: Red line boundary change request successfully cancelled + failure: Red line boundary change request could not be cancelled constraint_consultees: destroy: success: Consultee was removed from this constraint @@ -163,6 +166,7 @@ en: success: Fee check was successfully saved update_request: Fee change request successfully updated check-red-line-boundary: + delete_request: Red line boundary change request successfully deleted failure: Please select whether the red line boundary is correct mark_as_valid: Red line boundary was successfully marked as valid success: Red line boundary check was successfully saved diff --git a/engines/bops_preapps/spec/system/tasks/add_and_assign_consultees_spec.rb b/engines/bops_preapps/spec/system/tasks/add_and_assign_consultees_spec.rb index f63f5d7755..514255e512 100644 --- a/engines/bops_preapps/spec/system/tasks/add_and_assign_consultees_spec.rb +++ b/engines/bops_preapps/spec/system/tasks/add_and_assign_consultees_spec.rb @@ -78,7 +78,7 @@ expect(page).to have_link("Home") expect(page).to have_link("Application") - expect(page).to have_link("Consultation") + expect(page).not_to have_link("Consultation") end it "hides save buttons when application is determined" do diff --git a/engines/bops_preapps/spec/system/tasks/check_fee_spec.rb b/engines/bops_preapps/spec/system/tasks/check_fee_spec.rb index c649d2414f..346efe2f1f 100644 --- a/engines/bops_preapps/spec/system/tasks/check_fee_spec.rb +++ b/engines/bops_preapps/spec/system/tasks/check_fee_spec.rb @@ -149,6 +149,17 @@ end end + it "highlights the active task in the sidebar" do + within ".bops-sidebar" do + click_link "Check fee" + end + + within ".bops-sidebar" do + expect(page).to have_css(".bops-sidebar__task--active", text: "Check fee") + expect(page).to have_css("a[aria-current='page']", text: "Check fee") + end + end + it "shows correct breadcrumb navigation" do within ".bops-sidebar" do click_link "Check fee" @@ -156,7 +167,7 @@ expect(page).to have_link("Home") expect(page).to have_link("Application") - expect(page).to have_link("Validation") + expect(page).not_to have_link("Validation") end context "when fee change validation request exists" do diff --git a/engines/bops_preapps/spec/system/tasks/check_red_line_boundary_spec.rb b/engines/bops_preapps/spec/system/tasks/check_red_line_boundary_spec.rb index 0f9a37f82c..a69153fb42 100644 --- a/engines/bops_preapps/spec/system/tasks/check_red_line_boundary_spec.rb +++ b/engines/bops_preapps/spec/system/tasks/check_red_line_boundary_spec.rb @@ -118,7 +118,7 @@ expect(page).to have_content("Proposed red line boundary") expect(task.reload).to be_completed - click_link "Delete request" + click_button "Delete request" expect(page).to have_current_path("/preapps/#{planning_application.reference}/check-and-validate/check-application-details/check-red-line-boundary") expect(page).to have_content("Check the digital red line boundary") @@ -157,6 +157,17 @@ end end + it "highlights the active task in the sidebar" do + within ".bops-sidebar" do + click_link "Check red line boundary" + end + + within ".bops-sidebar" do + expect(page).to have_css(".bops-sidebar__task--active", text: "Check red line boundary") + expect(page).to have_css("a[aria-current='page']", text: "Check red line boundary") + end + end + it "shows correct breadcrumb navigation" do within ".bops-sidebar" do click_link "Check red line boundary" @@ -164,7 +175,7 @@ expect(page).to have_link("Home") expect(page).to have_link("Application") - expect(page).to have_link("Validation") + expect(page).not_to have_link("Validation") end it "hides the draw red line boundary task when boundary_geojson is present" do @@ -302,12 +313,46 @@ expect(page).to have_content("The garage is not part of my property") end - it "shows link to request new red line boundary change" do + it "shows Yes/No form to re-check the boundary" do + within ".bops-sidebar" do + click_link "Check red line boundary" + end + + expect(page).to have_field("Yes") + expect(page).to have_field("No") + expect(page).to have_button("Save and mark as complete") + end + + it "marks boundary as valid and completes task when selecting Yes" do + expect(task.reload).to be_action_required + + within ".bops-sidebar" do + click_link "Check red line boundary" + end + + choose "Yes" + click_button "Save and mark as complete" + + expect(page).to have_content("Red line boundary check was successfully saved") + expect(task.reload).to be_completed + expect(planning_application.reload.valid_red_line_boundary).to be true + end + + it "redirects to new validation request when selecting No" do + expect(task.reload).to be_action_required + within ".bops-sidebar" do click_link "Check red line boundary" end - expect(page).to have_link("Request a new red line boundary change") + choose "No" + click_button "Save and mark as complete" + + expect(page).to have_current_path( + "/planning_applications/#{planning_application.reference}/validation/validation_requests/new?type=red_line_boundary_change" + ) + expect(task.reload).to be_in_progress + expect(planning_application.reload.valid_red_line_boundary).to be false end end @@ -364,6 +409,65 @@ end end + context "when application is invalidated with open validation request" do + let(:new_geojson) do + { + type: "Feature", + properties: {}, + geometry: { + type: "Polygon", + coordinates: [ + [ + [-0.054600, 51.537335], + [-0.054590, 51.537290], + [-0.054455, 51.537315], + [-0.054600, 51.537335] + ] + ] + } + } + end + + let!(:validation_request) do + create(:red_line_boundary_change_validation_request, + :open, + planning_application:, + reason: "Boundary needs to include garage", + new_geojson: new_geojson, + original_geojson: boundary_geojson) + end + + before do + task.complete! + planning_application.update!(status: "invalidated") + end + + it "shows cancel link when application is invalidated" do + within ".bops-sidebar" do + click_link "Check red line boundary" + end + + expect(page).to have_link("Cancel request") + expect(page).not_to have_button("Delete request") + end + + it "allows cancelling the validation request" do + within ".bops-sidebar" do + click_link "Check red line boundary" + end + + click_link "Cancel request" + + expect(page).to have_content("Cancel validation request") + + fill_in "Explain to the applicant why this request is being cancelled", with: "Boundary was correct after all" + click_button "Confirm cancellation" + + expect(page).to have_content("Red line boundary change request successfully cancelled") + expect(validation_request.reload).to be_cancelled + end + end + context "when applicant responds to red line boundary change request" do let(:new_geojson) do { diff --git a/engines/bops_preapps/spec/system/tasks/determine_consultation_requirement_spec.rb b/engines/bops_preapps/spec/system/tasks/determine_consultation_requirement_spec.rb index 7411a44aaf..a16c633b85 100644 --- a/engines/bops_preapps/spec/system/tasks/determine_consultation_requirement_spec.rb +++ b/engines/bops_preapps/spec/system/tasks/determine_consultation_requirement_spec.rb @@ -81,7 +81,7 @@ expect(page).to have_link("Home") expect(page).to have_link("Application") - expect(page).to have_link("Consultation") + expect(page).not_to have_link("Consultation") end it "hides save button when application is determined" do diff --git a/engines/bops_preapps/spec/system/tasks/draw_red_line_boundary_spec.rb b/engines/bops_preapps/spec/system/tasks/draw_red_line_boundary_spec.rb index 8d4682d890..aec1e79354 100644 --- a/engines/bops_preapps/spec/system/tasks/draw_red_line_boundary_spec.rb +++ b/engines/bops_preapps/spec/system/tasks/draw_red_line_boundary_spec.rb @@ -156,6 +156,17 @@ end end + it "highlights the active task in the sidebar" do + within ".bops-sidebar" do + click_link "Draw red line boundary" + end + + within ".bops-sidebar" do + expect(page).to have_css(".bops-sidebar__task--active", text: "Draw red line boundary") + expect(page).to have_css("a[aria-current='page']", text: "Draw red line boundary") + end + end + it "shows correct breadcrumb navigation" do within ".bops-sidebar" do click_link "Draw red line boundary" @@ -163,7 +174,7 @@ expect(page).to have_link("Home") expect(page).to have_link("Application") - expect(page).to have_link("Validation") + expect(page).not_to have_link("Validation") end it "hides check red line boundary task when draw task is shown" do diff --git a/engines/bops_preapps/spec/system/tasks/review_documents_spec.rb b/engines/bops_preapps/spec/system/tasks/review_documents_spec.rb index 7ff990da6a..e145baab12 100644 --- a/engines/bops_preapps/spec/system/tasks/review_documents_spec.rb +++ b/engines/bops_preapps/spec/system/tasks/review_documents_spec.rb @@ -15,6 +15,17 @@ visit "/planning_applications/#{planning_application.reference}/validation/tasks" end + it "highlights the active task in the sidebar" do + within ".bops-sidebar" do + click_link "Review documents" + end + + within ".bops-sidebar" do + expect(page).to have_css(".bops-sidebar__task--active", text: "Review documents") + expect(page).to have_css("a[aria-current='page']", text: "Review documents") + end + end + context "when there are no documents" do it "displays a message indicating no active documents" do within ".bops-sidebar" do @@ -36,6 +47,19 @@ expect(page).to have_content("proposed-floorplan.png") end + it "displays the download all documents button with correct data attributes" do + within ".bops-sidebar" do + click_link "Review documents" + end + + expect(page).to have_link("Download all documents") + expect(page).to have_css("[data-controller='download']") + expect(page).to have_css("[data-application-reference-value='#{planning_application.reference}']") + expect(page).to have_css("[data-download-target='documentsElement']") + expect(page).to have_css("[data-document-url-value]") + expect(page).to have_css("[data-document-title-value]") + end + it "redirects back to the task after editing a document" do within ".bops-sidebar" do click_link "Review documents" diff --git a/engines/bops_preapps/spec/system/tasks/summary_of_advice_spec.rb b/engines/bops_preapps/spec/system/tasks/summary_of_advice_spec.rb index 3596e7851a..43acd384ff 100644 --- a/engines/bops_preapps/spec/system/tasks/summary_of_advice_spec.rb +++ b/engines/bops_preapps/spec/system/tasks/summary_of_advice_spec.rb @@ -13,6 +13,17 @@ visit "/planning_applications/#{planning_application.reference}/assessment/tasks" end + it "highlights the active task in the sidebar" do + within ".bops-sidebar" do + click_link "Summary of advice" + end + + within ".bops-sidebar" do + expect(page).to have_css(".bops-sidebar__task--active", text: "Summary of advice") + expect(page).to have_css("a[aria-current='page']", text: "Summary of advice") + end + end + it "Can complete and submit the summary of advice" do within ".bops-sidebar" do click_link "Summary of advice" diff --git a/engines/bops_preapps/spec/system/tasks/view_consultee_responses_spec.rb b/engines/bops_preapps/spec/system/tasks/view_consultee_responses_spec.rb index 8fe7c5c2cf..949e00fbc1 100644 --- a/engines/bops_preapps/spec/system/tasks/view_consultee_responses_spec.rb +++ b/engines/bops_preapps/spec/system/tasks/view_consultee_responses_spec.rb @@ -32,7 +32,16 @@ expect(page).to have_link("Home") expect(page).to have_link("Application") - expect(page).to have_link("Consultation") + expect(page).not_to have_link("Consultation") + end + + it "highlights the active task in the sidebar" do + visit "/preapps/#{planning_application.reference}/consultees/view-consultee-responses" + + within ".bops-sidebar" do + expect(page).to have_css(".bops-sidebar__task--active", text: "View consultee responses") + expect(page).to have_css("a[aria-current='page']", text: "View consultee responses") + end end end