Skip to content

Commit

Permalink
Merge pull request #2172 from unboxed/add-legislation-to-assessment-r…
Browse files Browse the repository at this point in the history
…eport

Add legislation assessment to assessment report
  • Loading branch information
pixeltrix authored Feb 21, 2025
2 parents 1cc97a6 + 3b7b809 commit 40c9560
Show file tree
Hide file tree
Showing 12 changed files with 301 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/assets/stylesheets/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ $govuk-page-width: 1100px;
@import "bops_core/components/ticket_panel";

// Imports from the application
@import "components/assessment_list";
@import "components/buttons";
@import "components/documents";
@import "components/flashes";
Expand Down
32 changes: 32 additions & 0 deletions app/assets/stylesheets/components/_assessment_list.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
.bops-assessment-list {
border-top: 1px solid $govuk-border-colour;

&__row {
display: flex;
padding-top: govuk-spacing(2);
padding-bottom: govuk-spacing(2);
border-bottom: 1px solid $govuk-border-colour;
}

&__section {
@include govuk-font($size: 19);
font-weight: bold;
width: 10%;
}

&__description {
margin-left: 0;
width: 62%;

p {
margin-bottom: govuk-spacing(2);
}
}

&__status {
margin-left: 0;
text-align: right;
white-space: nowrap;
width: 28%;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,43 @@
</section>
<% end %>

<% if @planning_application.assess_against_policies? %>
<section id="policy-classes-section" class="govuk-!-margin-bottom-7">
<h3 class="govuk-heading-m"><%= t(".assessment_against_legislation") %></h3>

<% policy_classes.each do |policy_class| %>
<p class="govuk-body"><%= govuk_link_to policy_class.description, policy_class.url %></p>

<dl class="bops-assessment-list">
<% policy_class.policy_sections.each do |policy_section| %>
<div class="bops-assessment-list__row">
<dt class="bops-assessment-list__section">
<%= policy_section.section %>
</dt>
<dd class="bops-assessment-list__description">
<p class="govuk-body">
<%= policy_section.description %>
</p>
<% if comment = policy_section.last_comment %>
<%= bops_ticket_panel(colour: "yellow") do |ticket| %>
<% ticket.with_body { comment.text } %>
<% ticket.with_footer { comment.information } %>
<% end %>
<% end %>
</dd>
<dd class="bops-assessment-list__status">
<%= render(StatusTags::BaseComponent.new(status: policy_section.status)) %>
</dd>
</div>
<% end %>
</dl>
<% if show_edit_links && current_user.assessor? %>
<p class="govuk-body-s">
<%= govuk_link_to("Edit assessment", edit_planning_application_assessment_policy_areas_policy_class_path(@planning_application, policy_class)) %>
</p>
<% end %>
<% end %>
</section>
<% end %>

<%= render "planning_applications/assessment/recommendations/documents", planning_application: planning_application, documents: documents %>
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,15 @@ def initialize(planning_application:, show_additional_evidence: false, show_edit
:consultation_summary,
:consultation,
:permitted_development_right,
:planning_application_policy_classes,
:additional_evidence,
:immunity_detail,
:neighbour_summary,
to: :planning_application
)

delegate :bops_ticket_panel, to: :helpers

def considerations
planning_application.consideration_set.considerations
end
Expand All @@ -41,6 +44,10 @@ def documents
planning_application.documents_for_decision_notice
end

def policy_classes
planning_application_policy_classes
end

def current_user
Current.user
end
Expand Down
6 changes: 3 additions & 3 deletions app/components/status_tags/base_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ def link_text

def colour
case status.to_sym
when :approved, :auto_approved, :supportive
when :approved, :auto_approved, :supportive, :complies
"green"
when :not_started, :new, :review_not_started, :not_consulted, :none, :no_response
"blue"
when :in_progress, :awaiting_response
when :in_progress, :awaiting_response, :to_be_determined
"light-blue"
when :updated, :to_be_reviewed, :submitted, :neutral, :amendments_needed, :awaiting_changes
"yellow"
when :refused, :removed, :invalid, :rejected, :objection, :failed, :refused_legal_agreement, :cancelled
when :refused, :removed, :invalid, :rejected, :objection, :failed, :refused_legal_agreement, :cancelled, :does_not_comply
"red"
end
end
Expand Down
6 changes: 6 additions & 0 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ def deleted?
deleted_at.present?
end

def information
if user.present?
"By #{user.name} on #{created_at.to_fs(:day_month_year_slashes)}"
end
end

private

def previous
Expand Down
3 changes: 2 additions & 1 deletion app/models/planning_application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class WithdrawOrCancelError < RuntimeError; end
has_many :press_notices, -> { by_created_at_desc }
has_many :planning_application_policy_classes
has_many :policy_classes, through: :planning_application_policy_classes
has_many :planning_application_policy_sections
has_many :planning_application_policy_sections, -> { by_id }
has_many :policy_sections, through: :planning_application_policy_sections
has_many :additional_services

Expand All @@ -85,6 +85,7 @@ class WithdrawOrCancelError < RuntimeError; end

with_options to: :application_type do
delegate :appeals?
delegate :assess_against_policies?
delegate :consultation?
delegate :neighbour_consultation_feature?
delegate :consultee_consultation_feature?
Expand Down
9 changes: 9 additions & 0 deletions app/models/planning_application_policy_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ class PlanningApplicationPolicyClass < ApplicationRecord
validates :reporting_types, presence: true
end

delegate :section, :name, :url, :description, to: :policy_class
delegate :planning_application_policy_sections, to: :planning_application

def policy_sections
planning_application_policy_sections
.includes(:comments, :policy_section)
.where(policy_section: {policy_class_id: policy_class_id})
end

def current_review
reviews.load.first || reviews.create!
end
Expand Down
5 changes: 5 additions & 0 deletions app/models/planning_application_policy_section.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class PlanningApplicationPolicySection < ApplicationRecord
dependent: :destroy
)

scope :by_id, -> { order(:id) }

accepts_nested_attributes_for(
:comments,
reject_if: :reject_comment?
Expand All @@ -25,6 +27,9 @@ class PlanningApplicationPolicySection < ApplicationRecord
%i[complies does_not_comply to_be_determined].index_with(&:to_s),
default: :to_be_determined

delegate :section, :title, to: :policy_section
delegate :policy_class, to: :policy_section

def set_description
self.description ||= policy_section.description
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/policy_class.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ def menu
pluck(:id, :section, :name)
end
end

def description
"Part #{policy_part_number}, Class #{section} - #{name}"
end
end
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,7 @@ en:
assessment_report_component:
additional_evidence: Summary of additional evidence
application_details: Application details
assessment_against_legislation: Assessment against legislation
assessment_against_policies_and_guidance: Policies and guidance
constraints_including_article: Constraints including Article 4 direction(s)
consultation_documents: Consultation documents
Expand Down Expand Up @@ -2182,6 +2183,8 @@ en:
awaiting_responses: Awaiting responses
cancelled: Cancelled
complete: Completed
complies: Complies
does_not_comply: Does not comply
emailed: Emailed
failed: Failed
granted: To grant
Expand Down Expand Up @@ -2222,6 +2225,7 @@ en:
sending: Sending
submitted: Submitted
supportive: Supportive
to_be_determined: To be determined
to_be_reviewed: To be reviewed
updated: Updated
valid: Valid
Expand Down
Loading

0 comments on commit 40c9560

Please sign in to comment.