-
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.
Be able to record that a meeting took place in pre-app
- Loading branch information
1 parent
0390043
commit 8a13e13
Showing
14 changed files
with
246 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
app/components/task_list_items/assessment/meeting_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 TaskListItems | ||
module Assessment | ||
class MeetingComponent < TaskListItems::BaseComponent | ||
def initialize(planning_application:) | ||
@planning_application = planning_application | ||
end | ||
|
||
private | ||
|
||
attr_reader :planning_application | ||
|
||
delegate :meeting, to: :planning_application | ||
|
||
def link_text | ||
"Meeting" | ||
end | ||
|
||
def link_path | ||
if planning_application | ||
planning_application_assessment_meetings_path(@planning_application) | ||
else | ||
new_planning_application_assessment_meeting_path(@planning_application) | ||
end | ||
end | ||
|
||
def status_tag_component | ||
StatusTags::BaseComponent.new( | ||
status: @planning_application.meetings.last.status | ||
) | ||
end | ||
end | ||
end | ||
end |
53 changes: 53 additions & 0 deletions
53
app/controllers/planning_applications/assessment/meetings_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,53 @@ | ||
# frozen_string_literal: true | ||
|
||
module PlanningApplications | ||
module Assessment | ||
class MeetingsController < AuthenticationController | ||
before_action :set_planning_application | ||
before_action :build_meeting, only: %i[new create] | ||
|
||
def index | ||
@meetings = @planning_application.meetings | ||
respond_to do |format| | ||
format.html | ||
end | ||
end | ||
|
||
def show | ||
respond_to do |format| | ||
format.html | ||
end | ||
end | ||
|
||
def new | ||
respond_to do |format| | ||
format.html | ||
end | ||
end | ||
|
||
def create | ||
respond_to do |format| | ||
if @meeting.update(meeting_params) | ||
format.html do | ||
redirect_to planning_application_assessment_tasks_path(@planning_application), notice: t(".success") | ||
end | ||
else | ||
format.html { render :new } | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def meeting_params | ||
params.require(:meeting) | ||
.permit(:occurred_at, :comment) | ||
.merge(created_by: current_user, status: "complete") | ||
end | ||
|
||
def build_meeting | ||
@meeting = @planning_application.meetings.new | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
class Meeting < ApplicationRecord | ||
include DateValidateable | ||
|
||
belongs_to :created_by, class_name: "User" | ||
|
||
belongs_to :planning_application | ||
|
||
validates :status, presence: true | ||
|
||
validates :occurred_at, | ||
presence: true, | ||
date: { | ||
on_or_before: :current | ||
} | ||
|
||
enum :status, %i[ | ||
not_started | ||
complete | ||
].index_with(&:to_s) | ||
|
||
scope :by_created_at_desc, -> { order(created_at: :desc) } | ||
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
18 changes: 18 additions & 0 deletions
18
app/views/planning_applications/assessment/meetings/_form.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,18 @@ | ||
<%= form_with( | ||
model: @meeting, | ||
class: "govuk-!-margin-top-5", | ||
url: planning_application_assessment_meetings_path(@planning_application, @meeting), | ||
method: :post | ||
) do |form| %> | ||
|
||
<%= form.govuk_date_field(:occurred_at, rows: 6, legend: {text: "Meeting date"}) %> | ||
|
||
<%= form.govuk_text_area(:comment, rows: 6, label: {text: "Add notes (optional)"}) %> | ||
|
||
<div class="govuk-button-group govuk-!-padding-top-7"> | ||
<%= form.submit "Save and mark as complete", class: "govuk-button govuk-button--primary" %> | ||
|
||
<%= back_link %> | ||
</div> | ||
</div> | ||
<% end %> |
6 changes: 6 additions & 0 deletions
6
app/views/planning_applications/assessment/meetings/_overview.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,6 @@ | ||
<p class="govuk-body">Response created by: <%= meeting.created_by.name %></p> | ||
<p class="govuk-body">Response created: <%= meeting.created_at.to_fs %></p> | ||
<% if meeting.valid? %> | ||
<p class="govuk-body">Meeting occured at: <%= meeting.occurred_at&.to_date&.to_fs %></p> | ||
<% end %> | ||
<p class="govuk-body">Comment: <%= meeting.comment %></p> |
37 changes: 37 additions & 0 deletions
37
app/views/planning_applications/assessment/meetings/index.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,37 @@ | ||
<% content_for :page_title do %> | ||
Meetings - <%= t("page_title") %> | ||
<% end %> | ||
|
||
<%= render( | ||
partial: "shared/proposal_header", | ||
locals: {heading: "View meetings"} | ||
) %> | ||
|
||
<% if @meetings.any? %> | ||
<h2 class="govuk-heading-m">Meetings</h2> | ||
|
||
<details class="govuk-details govuk-!-padding-top-5" data-module="govuk-details"> | ||
<summary class="govuk-details__summary"> | ||
<span class="govuk-details__summary-text"> | ||
See previous meetings | ||
</span> | ||
</summary> | ||
<div class="govuk-details__text"> | ||
<% @meetings.each do |meeting| %> | ||
<%= render "overview", meeting: meeting %> | ||
<p><%= govuk_link_to "View", planning_application_assessment_meeting_path(@planning_application, meeting) %></p> | ||
<hr> | ||
<% end %> | ||
</div> | ||
</details> | ||
<% else %> | ||
<p class="govuk-body"> | ||
No meetings have been added yet. | ||
</p> | ||
<% end %> | ||
|
||
<%= govuk_link_to "Add new meeting", new_planning_application_assessment_meeting_path(@planning_application) %> | ||
|
||
<div class="govuk-button-group govuk-!-padding-top-7"> | ||
<%= back_link %> | ||
</div> |
23 changes: 23 additions & 0 deletions
23
app/views/planning_applications/assessment/meetings/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,23 @@ | ||
<% content_for :page_title do %> | ||
Meeting - <%= t("page_title") %> | ||
<% end %> | ||
|
||
<%= render( | ||
partial: "shared/assessment_task_breadcrumbs", | ||
locals: {planning_application: @planning_application} | ||
) %> | ||
<% content_for :title, "Meeting" %> | ||
|
||
<%= render( | ||
partial: "shared/proposal_header", | ||
locals: {heading: "Add a meeting"} | ||
) %> | ||
<div class="govuk-warning-text"> | ||
<span class="govuk-warning-text__icon" aria-hidden="true">!</span> | ||
<strong class="govuk-warning-text__text"> | ||
<span class="govuk-visually-hidden">Warning</span> | ||
This is NOT public. | ||
</strong> | ||
</div> | ||
|
||
<%= render "form" %> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateMeetings < ActiveRecord::Migration[7.2] | ||
def change | ||
create_table :meetings do |t| | ||
t.references :created_by, null: false, foreign_key: {to_table: :users}, type: :bigint | ||
t.references :planning_application, foreign_key: true | ||
t.string :status, default: "not_started", null: false | ||
t.text :comment | ||
t.datetime :occurred_at, null: false | ||
|
||
t.timestamps | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
require "rails_helper" | ||
|
||
RSpec.describe Meeting, type: :model do | ||
pending "add some examples to (or delete) #{__FILE__}" | ||
end |