Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions app/assets/stylesheets/sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 13 additions & 2 deletions app/components/sidebar_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
Expand All @@ -22,26 +23,43 @@ def update(params)
save_and_complete
when "mark_as_valid"
mark_as_valid
when "delete_request"
delete_validation_request
end
end
end

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)
Expand All @@ -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

Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@
<p class="govuk-body govuk-!-margin-top-4">Waiting for applicant response.</p>

<% if @planning_application.not_started? %>
<p class="govuk-body">
<%= delete_confirmation_request_link(
@planning_application,
@form.validation_request,
classname: "govuk-link"
) %>
</p>
<%= 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? %>
<p><%= govuk_link_to "Cancel request", @form.cancel_url %></p>
<% end %>
<% elsif @form.validation_request.closed? && @form.validation_request.approved? %>
<h2 class="govuk-heading-m">Red line boundary change approved</h2>
Expand Down Expand Up @@ -64,11 +66,20 @@
<p><%= @form.validation_request.updated_at.to_fs %></p>
</div>

<p>
<%= 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" %>
</p>
<h3 class="govuk-heading-s">Current red line boundary</h3>
<%= 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 %>
<p>This digital red line boundary was submitted by the applicant.</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= render "shared/task_header", task: @task %>

<div id="check-tag-documents-tasks">
<div id="check-tag-documents-tasks" data-controller="download" data-application-reference-value="<%= @planning_application.reference %>">
<h2 class="app-task-list__section">
Submitted documents
</h2>
Expand Down
6 changes: 0 additions & 6 deletions engines/bops_preapps/app/views/shared/_task_header.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand Down
4 changes: 4 additions & 0 deletions engines/bops_preapps/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion engines/bops_preapps/spec/system/tasks/check_fee_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,25 @@
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"
end

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
Expand Down
Loading