-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1988 from unboxed/review-policies
Add reviewer interaction with policies
- Loading branch information
Showing
18 changed files
with
469 additions
and
13 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
app/components/reviewing/planning_application_policy_class/link_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# frozen_string_literal: true | ||
|
||
module Reviewing | ||
module PlanningApplicationPolicyClass | ||
class LinkComponent < ViewComponent::Base | ||
erb_template <<~ERB | ||
<%= govuk_link_to(link_text, link_path, aria: {describedby: link_text}) %> | ||
ERB | ||
|
||
def initialize(planning_application_policy_class:) | ||
@planning_application_policy_class = planning_application_policy_class | ||
@planning_application = planning_application_policy_class.planning_application | ||
@policy_class = planning_application_policy_class.policy_class | ||
@part = @policy_class.policy_part | ||
end | ||
|
||
attr_reader :planning_application, :planning_application_policy_class, :policy_class, :part | ||
|
||
def link_path | ||
case planning_application_policy_class.current_review.review_status | ||
when "review_complete" | ||
planning_application_review_policy_areas_policy_class_path(planning_application_policy_class.planning_application, planning_application_policy_class) | ||
else | ||
edit_planning_application_review_policy_areas_policy_class_path( | ||
planning_application, planning_application_policy_class | ||
) | ||
end | ||
end | ||
|
||
def link_text | ||
"Review assessment of Part #{part.number}, Class #{policy_class.section}" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
app/controllers/planning_applications/review/policy_areas/policy_classes_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# frozen_string_literal: true | ||
|
||
module PlanningApplications | ||
module Review | ||
module PolicyAreas | ||
class PolicyClassesController < BaseController | ||
before_action :find_planning_application_policy_class, only: %i[show edit update] | ||
before_action :build_form, only: %i[edit update] | ||
before_action :set_review, only: %i[show edit update] | ||
|
||
def show | ||
respond_to do |format| | ||
format.html | ||
end | ||
end | ||
|
||
def edit | ||
respond_to do |format| | ||
format.html | ||
end | ||
end | ||
|
||
def update | ||
@form.update(policy_section_status_params) | ||
|
||
if @planning_application_policy_class.update_review(review_params) | ||
redirect_to planning_application_review_tasks_path(@planning_application), notice: t(".success") | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
private | ||
|
||
def find_planning_application_policy_class | ||
@planning_application_policy_class = @planning_application.planning_application_policy_classes.find(params[:id]) | ||
end | ||
|
||
def policy_section_status_params | ||
params.require(:planning_application_policy_sections).permit( | ||
params[:planning_application_policy_sections].keys.map do |key| | ||
[key, [:status, {comments_attributes: [:id, :text]}]] | ||
end.to_h | ||
) | ||
end | ||
|
||
def build_form | ||
@form = PolicySectionForm.new( | ||
planning_application: @planning_application, | ||
policy_class: @planning_application_policy_class.policy_class | ||
) | ||
end | ||
|
||
def review_params | ||
params.require(:review).permit(:review_status, :action, :comment).merge(reviewer: current_user, reviewed_at: Time.current) | ||
end | ||
|
||
def set_review | ||
@review = @planning_application_policy_class.current_review | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/views/planning_applications/review/policy_areas/policy_classes/_summary.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<% content_for :page_title do %> | ||
<%= t(".review") %> - <%= t("page_title") %> | ||
<% end %> | ||
<% render( | ||
partial: "shared/review_task_breadcrumbs", | ||
locals: { | ||
planning_application: planning_application, | ||
current_page: t( | ||
".review_policy_class", | ||
part: policy_class.policy_part_number, | ||
class: policy_class.section | ||
) | ||
} | ||
) %> | ||
<%= render( | ||
partial: "shared/proposal_header", | ||
locals: {heading: t(".review_policy_class", part: policy_class.policy_part_number, class: policy_class.section)} | ||
) %> | ||
|
||
<div class="govuk-grid-row"> | ||
<div class="govuk-grid-column-two-thirds"> | ||
<h2 class="govuk-heading-m govuk-!-padding-bottom-3"> | ||
<%= policy_class.name.upcase_first %> | ||
</h2> | ||
|
||
<p class="govuk-body"> | ||
<%= t(".complete_the_assessment") %> | ||
<p class="govuk-body"> | ||
<%= govuk_link_to( | ||
t(".open_legislation_in"), | ||
policy_class.url, | ||
new_tab: "" | ||
) %> | ||
</p> | ||
<%= govuk_accordion do |accordion| | ||
accordion.with_section(heading_text: "Constraints") do | ||
render(partial: "shared/constraints") | ||
end | ||
end %> | ||
</div> | ||
</div> |
88 changes: 88 additions & 0 deletions
88
app/views/planning_applications/review/policy_areas/policy_classes/edit.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<%= render( | ||
partial: "summary", | ||
locals: { | ||
planning_application: @planning_application, | ||
planning_application_policy_class: @planning_application_policy_class, | ||
policy_class: @planning_application_policy_class.policy_class | ||
} | ||
) %> | ||
|
||
<% if @planning_application_policy_class.policy_class.policy_sections.any? %> | ||
<%= govuk_error_summary(@review) %> | ||
|
||
<%= form_with url: planning_application_review_policy_areas_policy_class_path(@planning_application, @planning_application_policy_class), method: :patch, html: {data: unsaved_changes_data} do |form| %> | ||
<%= govuk_table(id: "policy-sections") do |table| %> | ||
<% table.with_head do |head| %> | ||
<% head.with_row do |row| %> | ||
<% row.with_cell(text: "Policy reference") %> | ||
<% PlanningApplicationPolicySection.statuses.keys.each do |status| %> | ||
<% row.with_cell(text: status.humanize) %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
||
<% table.with_body do |body| %> | ||
<% @planning_application_policy_class.policy_class.policy_sections.each do |policy_section| %> | ||
<% pa_policy_section = policy_section.planning_application_policy_section %> | ||
<% body.with_row(html_attributes: {id: "policy-section-#{policy_section.id}"}) do |row| %> | ||
<% row.with_cell do %> | ||
<p><strong><%= @planning_application_policy_class.policy_class.section %>.<%= policy_section.section %></strong></p> | ||
<%= render(FormattedContentComponent.new(text: policy_section.description)) %> | ||
|
||
<%= form.govuk_text_area "planning_application_policy_sections[#{policy_section.id}][comments_attributes][0][text]", | ||
label: {text: "Add comment", class: "govuk-label govuk-label--s"}, | ||
value: pa_policy_section&.last_comment&.text, | ||
class: "govuk-textarea govuk-!-margin-bottom-2", | ||
rows: 2 %> | ||
|
||
<% if pa_policy_section %> | ||
<%= render( | ||
partial: "shared/policy_classes/previous_comments", | ||
locals: {previous_comments: pa_policy_section.previous_comments} | ||
) %> | ||
<% end %> | ||
<% end %> | ||
<% PlanningApplicationPolicySection.statuses.keys.each do |status| %> | ||
<% row.with_cell do %> | ||
<div class="govuk-radios govuk-radios--small"> | ||
<%= form.govuk_radio_button( | ||
"planning_application_policy_sections[#{policy_section.id}][status]", | ||
status, | ||
checked: @form.planning_application_policy_sections[policy_section.id].status == status, | ||
label: {hidden: true}, | ||
disabled: true, | ||
class: "govuk-radios__input" | ||
) %> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
|
||
<fieldset class="govuk-fieldset govuk-!-padding-bottom-5"> | ||
<div class="govuk-radios" data-module="govuk-radios"> | ||
<%= form.govuk_radio_button(:action, "accepted", label: {text: "Accept"}, name: "review[action]", checked: @planning_application_policy_class.current_review.accepted?) %> | ||
<%= form.govuk_radio_button( | ||
:action, "rejected", label: {text: "Return to officer with comment"}, name: "review[action]", checked: @planning_application_policy_class.current_review.rejected? | ||
) do %> | ||
<%= form.govuk_text_area( | ||
:comment, | ||
label: {text: "Explain to the assessor why this needs reviewing"}, | ||
rows: 6, | ||
name: "review[comment]", | ||
value: @planning_application_policy_class.current_review.comment | ||
) %> | ||
<% end %> | ||
</div> | ||
</fieldset> | ||
|
||
<%= form.govuk_submit "Save and mark as complete", name: "review[review_status]", value: "review_complete" do %> | ||
<%= form.govuk_submit "Save and come back later", name: "review[review_status]", value: "review_in_progress", secondary: true %> | ||
<%= govuk_button_link_to(t("back"), planning_application_review_tasks_path(@planning_application), secondary: true) %> | ||
<% end %> | ||
<% end %> | ||
<% else %> | ||
<%= govuk_button_link_to(t("back"), planning_application_review_tasks_path(@planning_application), secondary: true) %> | ||
<% end %> |
35 changes: 35 additions & 0 deletions
35
app/views/planning_applications/review/policy_areas/policy_classes/show.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<%= render( | ||
partial: "summary", | ||
locals: { | ||
planning_application: @planning_application, | ||
planning_application_policy_class: @planning_application_policy_class, | ||
policy_class: @planning_application_policy_class.policy_class | ||
} | ||
) %> | ||
|
||
<%= form_with( | ||
model: [@planning_application, @planning_application_policy_class], | ||
url: planning_application_review_policy_areas_policy_class_path(@planning_application, @planning_application_policy_class) | ||
) do |form| %> | ||
<fieldset class="govuk-fieldset govuk-!-padding-bottom-5"> | ||
<div class="govuk-radios" data-module="govuk-radios"> | ||
<%= form.govuk_radio_button(:action, "accepted", label: {text: "Accept"}, disabled: true, checked: @planning_application_policy_class.current_review.accepted?) %> | ||
<%= form.govuk_radio_button( | ||
:action, "rejected", label: {text: "Return to officer with comment"}, disabled: true, checked: @planning_application_policy_class.current_review.rejected? | ||
) do %> | ||
<%= form.govuk_text_area( | ||
:comment, | ||
label: {text: "Explain to the assessor why this needs reviewing"}, | ||
rows: 6, | ||
disabled: true, | ||
value: @planning_application_policy_class.current_review.comment | ||
) %> | ||
<% end %> | ||
</div> | ||
</fieldset> | ||
<% end %> | ||
|
||
<div class="govuk-button-group"> | ||
<%= back_link %> | ||
<%= govuk_link_to "Edit review of Part #{@planning_application_policy_class.policy_class.policy_part_number}, Class #{@planning_application_policy_class.policy_class.section}", edit_planning_application_review_policy_areas_policy_class_path(@planning_application, @planning_application_policy_class) %> | ||
</div> |
20 changes: 20 additions & 0 deletions
20
app/views/planning_applications/review/tasks/_policy_classes_new.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<% planning_application.planning_application_policy_classes.order(:new_policy_class_id).each do |policy_class| %> | ||
<% next if policy_class.current_review.not_started? || policy_class.current_review.in_progress? %> | ||
|
||
<%= render TaskListItems::Reviewing::Component.new do |c| %> | ||
<% c.with_link do %> | ||
<%= render(Reviewing::PlanningApplicationPolicyClass::LinkComponent.new(planning_application_policy_class: policy_class)) %> | ||
<% end %> | ||
|
||
<% c.with_tag do %> | ||
<div class="govuk-task-list__status app-task-list__task-tag"> | ||
<%= render( | ||
StatusTags::ReviewComponent.new( | ||
review_item: policy_class.current_review, | ||
updated: policy_class.current_review.updated? | ||
) | ||
) %> | ||
</div> | ||
<% end %> | ||
<% end %> | ||
<% end %> |
Oops, something went wrong.