Skip to content

Commit

Permalink
Merge pull request #2174 from unboxed/redirect-review-anchor
Browse files Browse the repository at this point in the history
Redirect to anchor not top of page when updating review
  • Loading branch information
benjamineskola authored Feb 19, 2025
2 parents 748a1ac + 1d3d4ec commit 4cf448d
Show file tree
Hide file tree
Showing 27 changed files with 96 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def redirect_failed_create_error(error)
redirect_to planning_application_review_tasks_path(@planning_application), alert: Array.wrap(error).to_sentence
end

def redirect_to_review_tasks
redirect_to planning_application_review_tasks_path(@planning_application)
end

def render_review_tasks
set_planning_application_constraints
set_neighbour_review
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def update
@previous_decision = @planning_application.cil_liable
if @planning_application.update(cil_liability_params)
record_audit_for_cil_liability!
redirect_to planning_application_review_tasks_path(@planning_application), notice: t(".success")
redirect_to planning_application_review_tasks_path(@planning_application, anchor: "review-cil-liability"), notice: t(".success")
else
render :edit
end
Expand Down Expand Up @@ -47,10 +47,6 @@ def activity_information
end
end

def redirect_to_review_tasks
redirect_to planning_application_review_tasks_path(@planning_application)
end

def cil_feature?
@planning_application.application_type.cil?
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def update
respond_to do |format|
format.html do
if @committee_decision.update(committee_decision_params)
redirect_to planning_application_review_tasks_path(@planning_application), notice: t(".success")
redirect_to planning_application_review_tasks_path(@planning_application, anchor: "recommendation_to_committee_section"), notice: t(".success")
else
flash.now[:alert] = @committee_decision.errors.messages.values.flatten.join(", ")
render_review_tasks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def update
respond_to do |format|
format.html do
if @condition_set.update(condition_set_review_params)
redirect_to planning_application_review_tasks_path(@planning_application),
redirect_to planning_application_review_tasks_path(@planning_application, anchor: "review-conditions"),
notice: I18n.t("review.conditions.update.success")
else
flash.now[:alert] = @condition_set.errors.messages.values.flatten.join(", ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def update
respond_to do |format|
format.html do
if @consideration.update(consideration_params)
redirect_to planning_application_review_tasks_path(@planning_application), notice: t(".success")
redirect_to planning_application_review_tasks_path(@planning_application, anchor: "considerations_section"), notice: t(".success")
else
render :edit
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def update
respond_to do |format|
format.html do
if @review.update(review_params)
redirect_to planning_application_review_tasks_path(@planning_application), notice: t(".success")
redirect_to planning_application_review_tasks_path(@planning_application, anchor: "review-considerations"), notice: t(".success")
else
flash.now[:alert] = @review.errors.messages.values.flatten.join(", ")
render_review_tasks
Expand Down Expand Up @@ -45,10 +45,6 @@ def review_params
.permit(:action, :comment, :review_status)
.merge(reviewer: current_user, reviewed_at: Time.current)
end

def redirect_to_review_tasks
redirect_to planning_application_review_tasks_path(@planning_application)
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def update
respond_to do |format|
format.html do
if heads_of_term.update(review_params)
redirect_to planning_application_review_tasks_path(@planning_application),
redirect_to planning_application_review_tasks_path(@planning_application, anchor: "review-heads-of-terms"),
notice: I18n.t("review.heads_of_terms.update.success")
else
flash.now[:alert] = heads_of_term.errors.messages.values.flatten.join(", ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def update
respond_to do |format|
format.html do
if @review_immunity_detail.update(review_immunity_detail_params)
redirect_to planning_application_review_tasks_path(@planning_application),
redirect_to planning_application_review_tasks_path(@planning_application, anchor: "review-immunity-details"),
notice: I18n.t("planning_applications.review..immunity_details.successfully_updated")
else
flash.now[:alert] = @review_immunity_detail.errors.messages.values.flatten.join(", ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def update
respond_to do |format|
format.html do
if @review_immunity_detail.update(review_immunity_detail_params)
redirect_to planning_application_review_tasks_path(@planning_application),
redirect_to planning_application_review_tasks_path(@planning_application, anchor: "review-immunity-enforcements"),
notice: I18n.t("review_immunity_enforcements.successfully_updated")
else
flash.now[:alert] = @review_immunity_detail.errors.messages.values.flatten.join(", ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def update
respond_to do |format|
format.html do
if @informative.update(informative_params)
redirect_to planning_application_review_tasks_path(@planning_application), notice: t(".success")
redirect_to planning_application_review_tasks_path(@planning_application, anchor: "review-informatives"), notice: t(".success")
else
render :edit
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def update
respond_to do |format|
format.html do
if @review.update(review_params)
redirect_to planning_application_review_tasks_path(@planning_application), notice: t(".success")
redirect_to planning_application_review_tasks_path(@planning_application, anchor: "review-informatives"), notice: t(".success")
else
flash.now[:alert] = @review.errors.messages.values.flatten.join(", ")
render_review_tasks
Expand Down Expand Up @@ -48,10 +48,6 @@ def review_params
.merge(reviewer: current_user, reviewed_at: Time.current)
end

def redirect_to_review_tasks
redirect_to planning_application_review_tasks_path(@planning_application)
end

def informatives_not_started?
@review.not_started?
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def update
respond_to do |format|
format.html do
if @neighbour_review.update(review_params) && @consultation.update(status: consultation_status)
redirect_to planning_application_review_tasks_path(@planning_application), notice: t(".success")
redirect_to planning_application_review_tasks_path(@planning_application, anchor: "review-neighbour-responses"), notice: t(".success")
else
error = @neighbour_review.errors.group_by_attribute.transform_values { |errors| errors.map(&:full_message) }.values.flatten
redirect_failed_create_error(error)
Expand All @@ -27,7 +27,7 @@ def create
respond_to do |format|
format.html do
if @neighbour_review.save && @consultation.update(status: consultation_status)
redirect_to planning_application_review_tasks_path(@planning_application), notice: t(".success")
redirect_to planning_application_review_tasks_path(@planning_application, anchor: "review-neighbour-responses"), notice: t(".success")
else
error = @neighbour_review.errors.group_by_attribute.transform_values { |errors| errors.map(&:full_message) }.values.flatten
redirect_failed_create_error(error)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def update
respond_to do |format|
format.html do
if @permitted_development_right.update(permitted_development_right_params)
redirect_to planning_application_review_tasks_path(@planning_application),
redirect_to planning_application_review_tasks_path(@planning_application, anchor: "review-permitted-development-rights"),
notice: I18n.t("permitted_development_rights.successfully_updated")
else
flash.now[:alert] = @permitted_development_right.errors.messages.values.flatten.join(", ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def update
@form.update(policy_section_status_params)

if @planning_application_policy_class.update_review(review_params)
redirect_to planning_application_review_policy_areas_policy_classes_path(@planning_application), notice: t(".success")
redirect_to planning_application_review_policy_areas_policy_classes_path(@planning_application, anchor: "review-policy-classes"), notice: t(".success")
else
render :edit
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def update
respond_to do |format|
format.html do
if @pre_commencement_condition_set.update(review_params)
redirect_to planning_application_review_tasks_path(@planning_application),
redirect_to planning_application_review_tasks_path(@planning_application, anchor: "review-pre-commencement-conditions"),
notice: I18n.t("review.conditions.update.success")
else
flash.now[:alert] = @pre_commencement_condition_set.errors.messages.values.flatten.join(", ")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def update
respond_to do |format|
format.html do
if @assessment_detail.update(assessment_detail_params)
redirect_to planning_application_review_tasks_path(@planning_application), notice: t(".success")
redirect_to planning_application_review_tasks_path(@planning_application, anchor: "review-publicities"), notice: t(".success")
else
flash.now[:alert] = @assessment_detail.errors.messages.values.flatten.join(", ")
render_review_tasks
Expand All @@ -27,7 +27,7 @@ def create
respond_to do |format|
format.html do
if @assessment_detail.save
redirect_to planning_application_review_tasks_path(@planning_application), notice: t(".success")
redirect_to planning_application_review_tasks_path(@planning_application, anchor: "review-publicities"), notice: t(".success")
else
flash.now[:alert] = @assessment_detail.errors.messages.values.flatten.join(", ")
render_review_tasks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def create
)

if @recommendation.save_and_submit(recommendation_form_params)
redirect_to planning_application_review_tasks_path(@planning_application), notice: t(".success")
redirect_to planning_application_review_tasks_path(@planning_application, anchor: "recommendation_to_committee_section"), notice: t(".success")
else
render :new
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<%= render "shared/dates_and_assignment_header" %>

<ul class="app-task-list__items" id="review-legislation">
<ul class="app-task-list__items" id="review-policy-classes">
<% @planning_application.planning_application_policy_classes.order(:policy_class_id).each do |policy_class| %>
<% next if policy_class.current_review.not_started? || policy_class.current_review.in_progress? %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<% accordion.with_heading(text: "Review assessment") %>

<% if @planning_application.application_type.cil? %>
<% accordion.with_section(id: "check-cil", expanded: false) do |section| %>
<% accordion.with_section(id: "review-cil-liability", expanded: false) do |section| %>
<%= section.with_heading(text: "Check Community Infrastructure Levy (CIL)") %>
<%= section.with_status do %>
<%= render(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<% end %>

<% if @planning_application.possibly_immune? && @planning_application.immunity_detail.reviews.evidence.any? %>
<%= accordion.with_section(id: "review-evidence", expanded: @planning_application.immunity_detail.current_evidence_review_immunity_detail.errors.any?) do |section| %>
<%= accordion.with_section(id: "review-immunity-details", expanded: @planning_application.immunity_detail.current_evidence_review_immunity_detail.errors.any?) do |section| %>
<% section.with_heading(text: "Review evidence of immunity") %>

<% section.with_status do %>
Expand All @@ -47,14 +47,14 @@
<%= govuk_link_to "Show evidence", planning_application_review_immunity_detail_path(@planning_application, @planning_application.immunity_detail.current_evidence_review_immunity_detail) %>
<% end %>

<% section.with_footer(id: "review-evidence-form") do %>
<% section.with_footer(id: "review-immunity-details-form") do %>
<%= render(partial: "planning_applications/review/immunity_details/form") %>
<% end %>
<% end %>
<% end %>

<% if @planning_application.possibly_immune? && @planning_application.immunity_detail.reviews.enforcement.any? %>
<%= accordion.with_section(id: "review-enforcement", expanded: @planning_application.immunity_detail.current_enforcement_review_immunity_detail.errors.any?) do |section| %>
<%= accordion.with_section(id: "review-immunity-enforcements", expanded: @planning_application.immunity_detail.current_enforcement_review_immunity_detail.errors.any?) do |section| %>
<% section.with_heading(text: "Review assessment of immunity") %>

<% section.with_status do %>
Expand All @@ -69,7 +69,7 @@
<%= render(partial: "planning_applications/review/immunity_enforcements/details") %>
<% end %>

<% section.with_footer(id: "review-enforcement-form") do %>
<% section.with_footer(id: "review-immunity-enforcements-form") do %>
<%= render(partial: "planning_applications/review/immunity_enforcements/form") %>
<% end %>
<% end %>
Expand Down Expand Up @@ -167,7 +167,7 @@

<ul class="app-task-list__items">
<% if @planning_application.application_type.assess_against_policies? %>
<li class="app-task-list__item" id="review-legislation">
<li class="app-task-list__item" id="review-policy-classes">
<span class="app-task-list__task-name">
<%= govuk_link_to "Review assessment against legislation", planning_application_review_policy_areas_policy_classes_path(@planning_application) %>
</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= bops_task_accordion(id: "review-consultation") do |accordion| %>
<% accordion.with_heading(text: "Review consultation") %>
<%= accordion.with_section(id: "check-neighbour-notifications", expanded: @neighbour_review.errors.any?) do |section| %>
<%= accordion.with_section(id: "review-neighbour-responses", expanded: @neighbour_review.errors.any?) do |section| %>
<% section.with_heading(text: "Check neighbour notifications") %>

<% section.with_status do %>
Expand All @@ -19,7 +19,7 @@
<% end %>
<% end %>

<%= accordion.with_section(id: "check-publicity", expanded: @planning_application.existing_or_new_check_publicity.errors.any?) do |section| %>
<%= accordion.with_section(id: "review-publicities", expanded: @planning_application.existing_or_new_check_publicity.errors.any?) do |section| %>
<% section.with_heading(text: "Check publicity") %>
<% section.with_status do %>
<%= render(
Expand All @@ -37,7 +37,7 @@
<%= render(partial: "planning_applications/review/publicities/press_notice") %>
<% end %>

<% section.with_footer(id: "check-publicity-form") do %>
<% section.with_footer(id: "review-publicities-form") do %>
<%= render(partial: "planning_applications/review/publicities/form") %>
<% end %>
<% end %>
Expand Down
10 changes: 5 additions & 5 deletions spec/system/planning_applications/assessing/immunity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@

click_button "Review evidence of immunity"

within("#review-evidence") do
within("#review-immunity-details") do
choose "Return with comments"
fill_in "Add a comment", with: "Please re-assess the evidence of immunity"
click_button "Save and mark as complete"
Expand All @@ -120,13 +120,13 @@

click_button "Review assessment of immunity"

within("#review-enforcement") do
within("#review-immunity-enforcements") do
expect(page).to have_content("Assessor decision: Yes")
expect(page).to have_content("Reason: no action is taken within 4 years for an unauthorised change of use to a single dwellinghouse")
expect(page).to have_content("Summary: A summary")
end

within("#review-enforcement-form") do
within("#review-immunity-enforcements-form") do
choose "Return with comments"
fill_in "Add a comment", with: "Please re-assess immunity enforcement response"
click_button "Save and mark as complete"
Expand Down Expand Up @@ -188,15 +188,15 @@

click_button "Review evidence of immunity"

within("#review-evidence") do
within("#review-immunity-details") do
choose "Agree"
click_button "Save and mark as complete"
end
expect(page).to have_content("Review immunity details was successfully updated")

click_button "Review assessment of immunity"

within("#review-enforcement") do
within("#review-immunity-enforcements") do
expect(page).to have_content("Assessor decision: No")
expect(page).to have_content("Reason: Application is not immune")

Expand Down
Loading

0 comments on commit 4cf448d

Please sign in to comment.