Skip to content

Commit

Permalink
Split verification in to two pages
Browse files Browse the repository at this point in the history
If the admin decides that the LoPS is not acceptable, and they'd like to
send this to review, we've decided to split this in to two pages so the
internal notes appears on its own page.
  • Loading branch information
thomasleese committed Nov 8, 2023
1 parent 244b18a commit 3cf63c3
Show file tree
Hide file tree
Showing 29 changed files with 389 additions and 141 deletions.
5 changes: 5 additions & 0 deletions app/assets/stylesheets/application.sass.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,8 @@ ul.autocomplete__menu {
.govuk-inset-text .govuk-details {
margin-bottom: 0;
}

.app-table__center {
text-align: center;
vertical-align: middle;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ def edit

@professional_standing_request =
assessment.professional_standing_request if assessment.professional_standing_request.verify_failed?

render layout: "full_from_desktop"
end

def update
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ module AssessorInterface
class ProfessionalStandingRequestsController < BaseController
before_action :set_variables

def show
before_action do
authorize [:assessor_interface, professional_standing_request]
end

def show
render layout: "full_from_desktop"
end

def edit_locate
authorize [:assessor_interface, professional_standing_request]

@form =
ProfessionalStandingRequestLocationForm.new(
requestable:,
Expand All @@ -24,8 +24,6 @@ def edit_locate
end

def update_locate
authorize [:assessor_interface, professional_standing_request]

@form =
ProfessionalStandingRequestLocationForm.new(
location_form_params.merge(requestable:, user: current_staff),
Expand All @@ -39,8 +37,6 @@ def update_locate
end

def edit_request
authorize [:assessor_interface, professional_standing_request]

@form =
RequestableRequestForm.new(
requestable:,
Expand All @@ -50,8 +46,6 @@ def edit_request
end

def update_request
authorize [:assessor_interface, professional_standing_request]

@form =
RequestableRequestForm.new(
requestable:,
Expand All @@ -74,8 +68,6 @@ def update_request
end

def edit_review
authorize [:assessor_interface, professional_standing_request]

@form =
RequestableReviewForm.new(
requestable:,
Expand All @@ -86,8 +78,6 @@ def edit_review
end

def update_review
authorize [:assessor_interface, professional_standing_request]

@form =
RequestableReviewForm.new(
review_form_params.merge(requestable:, user: current_staff),
Expand All @@ -106,23 +96,55 @@ def update_review
end

def edit_verify
authorize [:assessor_interface, professional_standing_request]

@form =
RequestableVerifyForm.new(
RequestableVerifyPassedForm.new(
requestable:,
user: current_staff,
passed: requestable.verify_passed,
note: requestable.verify_note,
)
end

def update_verify
authorize [:assessor_interface, professional_standing_request]
@form =
RequestableVerifyPassedForm.new(
verify_passed_form_params.merge(requestable:, user: current_staff),
)

if @form.save
if @form.passed
redirect_to [
:assessor_interface,
application_form,
assessment,
:professional_standing_request,
]
else
redirect_to [
:verify_failed,
:assessor_interface,
application_form,
assessment,
:professional_standing_request,
]
end
else
render :edit_verify, status: :unprocessable_entity
end
end

def edit_verify_failed
@form =
RequestableVerifyForm.new(
verify_form_params.merge(requestable:, user: current_staff),
RequestableVerifyFailedForm.new(
requestable:,
user: current_staff,
note: requestable.verify_note,
)
end

def update_verify_failed
@form =
RequestableVerifyFailedForm.new(
verify_failed_form_params.merge(requestable:, user: current_staff),
)

if @form.save
Expand All @@ -133,7 +155,7 @@ def update_verify
:professional_standing_request,
]
else
render :edit_verify, status: :unprocessable_entity
render :edit_verify_failed, status: :unprocessable_entity
end
end

Expand All @@ -158,9 +180,14 @@ def review_form_params
)
end

def verify_form_params
params.require(:assessor_interface_requestable_verify_form).permit(
def verify_passed_form_params
params.require(:assessor_interface_requestable_verify_passed_form).permit(
:passed,
)
end

def verify_failed_form_params
params.require(:assessor_interface_requestable_verify_failed_form).permit(
:note,
)
end
Expand Down
20 changes: 20 additions & 0 deletions app/forms/assessor_interface/requestable_verify_failed_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

class AssessorInterface::RequestableVerifyFailedForm
include ActiveModel::Model
include ActiveModel::Attributes

attr_accessor :requestable, :user
validates :requestable, :user, presence: true

attribute :note, :string
validates :note, presence: true

def save
return false if invalid?

VerifyRequestable.call(requestable:, user:, passed: false, note:)

true
end
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class AssessorInterface::RequestableVerifyForm
class AssessorInterface::RequestableVerifyPassedForm
include ActiveModel::Model
include ActiveModel::Attributes

Expand All @@ -10,14 +10,12 @@ class AssessorInterface::RequestableVerifyForm
attribute :passed, :boolean
validates :passed, inclusion: [true, false]

attribute :note, :string
validates :note, presence: true, if: -> { passed == false }

def save
return false if invalid?

ReceiveRequestable.call(requestable:, user:) unless requestable.received?
VerifyRequestable.call(requestable:, user:, passed:, note:)

VerifyRequestable.call(requestable:, user:, passed:, note: "") if passed

true
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ def update_verify?

alias_method :edit_verify?, :update_verify?

def update_verify_failed?
user.verify_permission
end

alias_method :edit_verify_failed?, :update_verify_failed?

def update_review?
user.assess_permission
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
<% content_for :back_link_url, assessor_interface_application_form_path(@view_object.application_form) %>

<% if @view_object.assessment.review? %>
<%= govuk_panel(title_text: "Application sent for review") %>
<h1 class="govuk-heading-xl">Application sent for review</h1>
<% elsif @view_object.application_form.waiting_on? %>
<%= govuk_panel(title_text: "Reference requests sent successfully") %>
<h1 class="govuk-heading-xl">Reference requests sent successfully</h1>
<% elsif @view_object.application_form.awarded? %>
<%= govuk_panel(text: "QTS application #{@view_object.application_form.reference} has been awarded") %>
<% else %>
<%= govuk_panel(title_text: "QTS application #{@view_object.application_form.reference} has been #{@view_object.status.downcase}") %>
<h1 class="govuk-heading-xl">QTS application <%= @view_object.application_form.reference %> has been <%= @view_object.status.downcase %></h1>
<% end %>

<% if @view_object.assessment.review? %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,28 @@

<p class="govuk-body">The following verification tasks have been flagged for review:</p>

<%= govuk_table do |table|
if @professional_standing_request.present?
table.with_caption(text: "LoPS")
table.with_head do |head|
head.with_row do |row|
row.with_cell(text: "Internal note")
row.with_cell(text: "Status")
end
end
table.with_body do |body|
body.with_row do |row|
row.with_cell { simple_format @professional_standing_request.verify_note }
row.with_cell { render(StatusTag::Component.new(@professional_standing_request.status)) }
end
end
end
end %>
<% if @professional_standing_request.present? %>
<table class="govuk-table">
<thead class="govuk-table__head">
<tr class="govuk-table__row">
<th class="govuk-table__header ">LoPS</th>
<th scope="col" class="govuk-table__header"></th>
</tr>
</thead>
<tbody>
<tr class="govuk-table__row">
<td class="govuk-table__cell">
<p><%= region_teaching_authority_name(@application_form.region).upcase_first %></p>
<h3 class="govuk-heading-s">Internal note</h3>
<%= simple_format @professional_standing_request.verify_note %>
</td>

<td class="govuk-table__cell app-table__center">
<%= render(StatusTag::Component.new(@professional_standing_request.status)) %>
</td>
</tr>
</tbody>
</table>
<% end %>

<%= govuk_button_to "Continue", [:assessor_interface, @application_form, @assessment, :assessment_recommendation_review], method: :put %>
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@

<h1 class="govuk-heading-xl">Record LoPS response</h1>

<%= f.govuk_radio_buttons_fieldset :passed, legend: { text: "Does the response confirm that the LoPS is valid?" } do %>
<%= f.govuk_radio_button :passed, :true, label: { text: "Yes, mark as completed" }, link_errors: true %>
<%= f.govuk_radio_button :passed, :false, label: { text: "No, send for review" } do %>
<%= f.govuk_text_area :note, label: { text: "Internal note: briefly explain to the assessor why you are sending this LoPS for review." } %>
<% end %>
<% end %>
<%= f.govuk_collection_radio_buttons :passed, %i[true false], :itself,
legend: { text: "Does the response confirm that the LoPS is valid?" } %>

<%= f.govuk_submit do %>
<%= govuk_link_to "Cancel", [:assessor_interface, @application_form] %>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<% content_for :page_title, "#{"Error: " if @form.errors.any?}Record LoPS response" %>
<% content_for :back_link_url, assessor_interface_application_form_path(@application_form) %>

<%= form_with model: @form, url: [:verify_failed, :assessor_interface, @application_form, @assessment, :professional_standing_request] do |f| %>
<%= f.govuk_error_summary %>

<h1 class="govuk-heading-xl">Record LoPS response</h1>

<p class="govuk-body">You have opted to send this LoPS for review.</p>

<%= f.govuk_text_area :note, label: { text: "Internal note: briefly explain to the assessor why you are sending this LoPS for review." } %>

<%= f.govuk_submit do %>
<%= govuk_link_to "Cancel", [:assessor_interface, @application_form] %>
<% end %>
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@
status: @professional_standing_request.requested? ? "completed" : "not_started"
},
{
name: "Record LoPS verification",
link: [
:verify,
:assessor_interface,
@application_form,
@assessment,
:professional_standing_request
],
status: @professional_standing_request.status,
name: "Record LoPS response",
link: if @professional_standing_request.requested?
[
:verify,
:assessor_interface,
@application_form,
@assessment,
:professional_standing_request
]
end,
status: @professional_standing_request.requested? ? @professional_standing_request.status : "cannot_start"
}
],
}
Expand Down
8 changes: 5 additions & 3 deletions config/locales/assessor_interface.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,14 @@ en:
inclusion: Select whether you are satisfied with the request
note:
blank: Enter why you are not satisfied
assessor_interface/requestable_verify_form:
assessor_interface/requestable_verify_failed_form:
attributes:
passed:
inclusion: Select whether you are satisfied with the request
note:
blank: Enter why you are not satisfied
assessor_interface/requestable_verify_passed_form:
attributes:
passed:
inclusion: Select whether you are satisfied with the request
assessor_interface/select_qualifications_form:
attributes:
qualification_ids:
Expand Down
6 changes: 3 additions & 3 deletions config/locales/helpers.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@ en:
passed_options:
true: "Yes"
false: "No"
assessor_interface_requestable_verify_form:
assessor_interface_requestable_verify_passed_form:
passed_options:
true: "Yes"
false: "No"
true: "Yes, mark as completed"
false: "No, send for review"
assessor_interface_verify_professional_standing_form:
verify_professional_standing_options:
true: Yes, verify LoPS
Expand Down
4 changes: 4 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@
post "review", to: "professional_standing_requests#update_review"
get "verify", to: "professional_standing_requests#edit_verify"
post "verify", to: "professional_standing_requests#update_verify"
get "verify-failed",
to: "professional_standing_requests#edit_verify_failed"
post "verify-failed",
to: "professional_standing_requests#update_verify_failed"
end
end

Expand Down
Loading

0 comments on commit 3cf63c3

Please sign in to comment.