Skip to content

Commit

Permalink
Move heads of terms review into new layout
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamineskola committed Nov 22, 2024
1 parent 490765b commit 16910b7
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 190 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,6 @@
module PlanningApplications
module Review
class HeadsOfTermsController < BaseController
def show
respond_to do |format|
format.html
end
end

def edit
respond_to do |format|
format.html
end
end

def update
respond_to do |format|
format.html do
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<%= form_with model: @planning_application.heads_of_term,
url: planning_application_review_heads_of_term_path(@planning_application),
class: "govuk-!-margin-top-7" do |form| %>
url: planning_application_review_heads_of_terms_path(@planning_application) do |form| %>
<%= form.govuk_error_summary %>
<% if current_review = heads_of_term.current_review %>
Expand All @@ -9,44 +8,23 @@
<%= review_form.govuk_radio_button(
:action, :accepted,
checked: current_review.accepted?,
label: {text: "Accept"},
disabled: !editable
label: {text: "Accept"}
) %>
<%= review_form.govuk_radio_button(
:action, :edited_and_accepted,
checked: current_review.edited_and_accepted?,
label: {text: "Edit to accept", id: "edit-to-accept"},
hint: {text: "You can only edit minor changes such as spelling errors which have no effect on the content of the accepted terms. Further changes need to be done by case officers."},
disabled: !editable
) do %>
<%= form.govuk_check_boxes_fieldset :heads_of_term, multiple: false, legend: {text: "Heads of terms"} do %>
<%= form.fields_for :terms, heads_of_term.terms do |fields| %>
<%= fields.govuk_check_box :true, false, multiple: false, label: {text: fields.object.title}, checked: fields.object.checked?, class: "term", link_errors: true, disabled: !editable do %>
<%= fields.hidden_field :id %>
<%= fields.govuk_text_field :title, label: {text: "Enter a title"}, disabled: !editable %>
<%= fields.govuk_text_area :text, label: {text: "Enter detail"}, disabled: !editable %>
<% end %>
<% end %>
<% end %>
<% end %>
<%= review_form.govuk_radio_button(
:action, :rejected,
checked: current_review.rejected?,
label: {text: "Return to officer with comment"},
disabled: !editable
label: {text: "Return to officer with comment"}
) do %>
<%= review_form.govuk_text_area(
:comment, value: current_review.comment,
rows: 6, label: {text: "Comment"},
disabled: !editable
rows: 6, label: {text: "Comment"}
) %>
<% end %>
<% end %>
<% end %>
<% if review_complete? %>
<% if @planning_application.review_complete? %>
<div class="govuk-grid-row govuk-!-margin-bottom-7">
<div class="govuk-grid-column-full">
<p class="govuk-body govuk">
Expand All @@ -59,12 +37,6 @@
<% end %>

<div class="govuk-button-group">
<% if editable %>
<%= form.submit "Save and mark as complete", class: "govuk-button", data: {module: "govuk-button"} %>
<%= form.submit "Save and come back later", class: "govuk-button govuk-button--secondary", data: {module: "govuk-button"} %>
<% else %>
<%= govuk_link_to "Edit recommendation", edit_planning_application_review_heads_of_term_path(@planning_application), class: "govuk-body" %>
<% end %>
<%= back_link %>
<%= form.submit "Save and mark as complete", class: "govuk-button", data: {module: "govuk-button"} %>
</div>
<% end %>

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,28 +1,56 @@
<%= bops_task_accordion(id: "review-conditions-section") do |accordion| %>
<% accordion.with_heading(text: "Review conditions") %>
<% if @planning_application.review_heads_of_terms? %>
<% accordion.with_section(id: "review-heads-of-terms", expanded: false) do |section| %>
<%= section.with_heading(text: "Review heads of terms") %>
<%= section.with_status do %>
<%= render(StatusTags::ReviewComponent.new(review_item: @planning_application.heads_of_term.current_review)) %>
<% end %>
<% section.with_block do %>
<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">
<%= render "planning_applications/review/heads_of_terms/terms_summary" %>

<h3 class="govuk-heading-s">
Submitted recommendation
</h3>
<p class="govuk-body">
by <%= @planning_application.user&.name %>, <%= @planning_application.in_assessment_at.to_fs %>
</p>

<%= render(ReviewerCommentComponent.new(comment: @planning_application.heads_of_term.current_review)) %>
</div>
</div>
<% end %>
<%= section.with_footer do %>
<%= render(partial: "planning_applications/review/heads_of_terms/form",
locals: {heads_of_term: @planning_application.heads_of_term}) %>
<% end %>
<% end %>
<% end %>
<% if @planning_application.application_type.planning_conditions? %>
<% if @planning_application.condition_set&.current_review&.started? %>
<%= accordion.with_section(id: "review-conditions", expanded: @planning_application.condition_set.errors.any?) do |section| %>
<% section.with_heading(text: "Review conditions") %>
<%= accordion.with_section(id: "review-conditions", expanded: @planning_application.condition_set.errors.any?) do |section| %>
<% section.with_heading(text: "Review conditions") %>
<% section.with_status do %>
<%= render(
StatusTags::ReviewComponent.new(
review_item: @planning_application.condition_set.current_review,
updated: @planning_application.condition_set.current_review&.status == "updated"
)
) %>
<% end %>
<% section.with_status do %>
<%= render(
StatusTags::ReviewComponent.new(
review_item: @planning_application.condition_set.current_review,
updated: @planning_application.condition_set.current_review&.status == "updated"
)
) %>
<% end %>
<% section.with_block do %>
<%= render(partial: "planning_applications/review/conditions/conditions_table") %>
<% end %>
<% section.with_block do %>
<%= render(partial: "planning_applications/review/conditions/conditions_table") %>
<% end %>
<% section.with_footer do %>
<%= render(partial: "planning_applications/review/conditions/form") %>
<% end %>
<% section.with_footer do %>
<%= render(partial: "planning_applications/review/conditions/form") %>
<% end %>
<% end %>
<% end %>
<% end %>
<% end %>
Expand All @@ -45,13 +73,6 @@
)
) %>
<% end %>
<% if @planning_application.review_heads_of_terms? %>
<%= render(
TaskListItems::Reviewing::HeadsOfTermsComponent.new(
planning_application: @planning_application
)
) %>
<% end %>
<% if @planning_application.review_permitted_development_rights? %>
<%= render(
TaskListItems::Reviewing::PermittedDevelopmentRightComponent.new(
Expand Down
6 changes: 1 addition & 5 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,7 @@
end
end

resources :heads_of_terms do
get :edit, on: :collection
get :show, on: :collection
patch :update, on: :collection
end
resource :heads_of_terms, only: %i[update]

resources :immunity_details, only: %i[edit update show]

Expand Down
81 changes: 22 additions & 59 deletions spec/system/planning_applications/review/heads_of_terms_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,88 +28,51 @@
let!(:term2) { create(:term, title: "Title 2", heads_of_term: planning_application.heads_of_term) }

it "I can accept the planning officer's decision" do
expect(page).to have_list_item_for(
"Review heads of terms",
with: "Not started"
)

click_link "Review heads of terms"
within "#review-heads-of-terms" do
expect(page).to have_content "Not started"
end

expect(page).to have_selector("h1", text: "Review heads of terms")
click_button "Review heads of terms"

choose "Accept"

click_button "Save and mark as complete"

expect(page).to have_content("Review heads of terms successfully updated")

expect(page).to have_list_item_for(
"Review heads of terms",
with: "Completed"
)

term = HeadsOfTerm.last
expect(term.current_review.action).to eq "accepted"
expect(term.current_review.review_status).to eq "review_complete"
end

it "I can edit to accept the planning officer's decision" do
expect(page).to have_list_item_for(
"Review heads of terms",
with: "Not started"
)

click_link "Review heads of terms"

choose "Edit to accept"

# Edit first term
within ".govuk-checkboxes .govuk-checkboxes__conditional", match: :first do
fill_in "Enter a title", with: "This is a new title"
fill_in "Enter detail", with: "This is a new detail"
within "#review-heads-of-terms" do
click_button "Save and mark as complete"
end

# Unchecking second term should accept the term as it currently is
uncheck "Title 2"

click_button "Save and mark as complete"

expect(page).to have_content("Review heads of terms successfully updated")
expect(page).to have_list_item_for(
"Review heads of terms",
with: "Completed"
)
click_link "Review heads of terms"
expect(page).to have_content("Edited and accepted by #{reviewer.name} on 1 January 2024 11:00")

expect(term1.reload.title).to eq("This is a new title")
expect(term2.reload.title).to eq("Title 2")
within "#review-heads-of-terms" do
expect(page).to have_content "Completed"
end

term = HeadsOfTerm.last
expect(term.current_review.action).to eq "edited_and_accepted"
expect(term.current_review.action).to eq "accepted"
expect(term.current_review.review_status).to eq "review_complete"
end

it "I can return to officer with comment" do
expect(page).to have_list_item_for(
"Review heads of terms",
with: "Not started"
)
within "#review-heads-of-terms" do
expect(page).to have_content "Not started"
end

click_link "Review heads of terms"
within "#review-heads-of-terms" do
click_button "Review heads of terms"
end

choose "Return to officer with comment"

fill_in "Comment", with: "I don't think you've assessed heads of terms correctly"

click_button "Save and mark as complete"
within "#review-heads-of-terms" do
click_button "Save and mark as complete"
end

expect(page).to have_content("Review heads of terms successfully updated")

expect(page).to have_list_item_for(
"Review heads of terms",
with: "Awaiting changes"
)
within "#review-heads-of-terms" do
expect(page).to have_content "Awaiting changes"
end

term = HeadsOfTerm.last
expect(term.current_review.action).to eq "rejected"
Expand Down

0 comments on commit 16910b7

Please sign in to comment.