Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 92 additions & 7 deletions app/components/schools/ect_training_details_component.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module Schools
class ECTTrainingDetailsComponent < ApplicationComponent
include ProgrammeHelper
include TeacherHelper
include ECTHelper

NOT_AVAILABLE = "Not available"
YET_TO_BE_REPORTED = "Yet to be reported by the lead provider"
Expand All @@ -13,21 +15,104 @@ def initialize(ect_at_school_period:, training_period:)
@training_period = training_period
end

def render? = @training_period.present?
def render?
ect_at_school_period.present? && training_period.present?
end

def call
tag.section(id: "training-details") do
safe_join([
tag.h2("Training details", class: "govuk-heading-m"),
training_details_body
])
end
end

private

def training_details_body
return withdrawn_training_details if withdrawn?

govuk_summary_list(rows:)
end

def withdrawn?
training_period&.training_status == :withdrawn
end

def withdrawn_training_details
safe_join([
tag.h2("Training details", class: "govuk-heading-m"),
govuk_summary_list(rows:)
withdrawn_intro_paragraph,
select_lead_provider_paragraph,
change_to_school_led_paragraph
])
end

private
def withdrawn_intro_paragraph
tag.p(
withdrawn_training_details_message,
class: "govuk-body govuk-!-margin-top-2"
)
end

def select_lead_provider_paragraph
ect_name = teacher_full_name(ect_at_school_period.teacher)

tag.p(
safe_join([
"You can ".html_safe,
govuk_link_to(
"select a lead provider",
schools_ects_change_lead_provider_wizard_edit_path(ect_at_school_period),
no_visited_state: true
),
" for #{ect_name} if they will be continuing provider-led training.".html_safe
]),
class: "govuk-body"
)
end

def change_to_school_led_paragraph
tag.p(
safe_join([
"You can tell us if they are ".html_safe,
govuk_link_to(
"changing their programme type to school-led",
schools_ects_change_training_programme_wizard_edit_path(ect_at_school_period),
no_visited_state: true
),
".".html_safe
]),
class: "govuk-body"
)
end

def withdrawn_training_details_message
lead_provider_name = withdrawn_lead_provider_name
subject = lead_provider_name.presence || "The lead provider"
verb = lead_provider_name.present? ? "have" : "has"
ect_name = teacher_full_name(ect_at_school_period.teacher)

"#{subject} #{verb} told us that #{ect_name} is no longer training with them. Contact them if you think this is an error."
end

def withdrawn_lead_provider_name
current_training_period = training_period
return nil if current_training_period.blank?

if current_training_period.only_expression_of_interest?
expression_of_interest = current_training_period.expression_of_interest
lead_provider = expression_of_interest&.lead_provider
lead_provider&.name
else
current_training_period.lead_provider_name
end
end

def rows
base_rows = [training_programme_row]

if training_period.provider_led_training_programme?
if training_period&.provider_led_training_programme?
base_rows << lead_provider_row
base_rows << delivery_partner_row
end
Expand All @@ -42,7 +127,7 @@ def training_programme_row
actions: [{
text: "Change",
visually_hidden_text: "training programme",
href: schools_ects_change_training_programme_wizard_edit_path(@ect_at_school_period),
href: schools_ects_change_training_programme_wizard_edit_path(ect_at_school_period),
classes: "govuk-link--no-visited-state"
}]
}
Expand All @@ -55,7 +140,7 @@ def lead_provider_row
actions: [{
text: "Change",
visually_hidden_text: "lead provider",
href: schools_ects_change_lead_provider_wizard_edit_path(@ect_at_school_period),
href: schools_ects_change_lead_provider_wizard_edit_path(ect_at_school_period),
classes: "govuk-link--no-visited-state"
}]
}
Expand Down
3 changes: 3 additions & 0 deletions app/components/schools/ects/listing_card_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
</h3>
</div>
<div class="govuk-summary-card__content">
<% if withdrawn? %>
<%= govuk_warning_text(text: withdrawn_warning_text) %>
<% end %>
<div class="govuk-grid-row">
<div class='govuk-grid-column-one-half'>
<%= govuk_summary_list(borders: false, rows: left_rows) %>
Expand Down
94 changes: 94 additions & 0 deletions app/components/schools/ects/listing_card_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,74 @@ def initialize(teacher:, ect_at_school_period:, training_period:, current_school

private

def withdrawn_warning_text
safe_join([
"Tell us if #{teacher_full_name(teacher)} will be ",
govuk_link_to(
"continuing their training or if they have left your school.",
"#{schools_ect_path(ect_at_school_period)}#training-details",
no_visited_state: true
)
])
end

def withdrawn_message_text
lead_provider_name = training_period_lead_provider_name(training_period)
subject = lead_provider_name.presence || "The lead provider"
verb = lead_provider_name.present? ? "have" : "has"

"#{subject} #{verb} told us that #{teacher_full_name(teacher)} is no longer training with them. Contact them if you think this is an error."
end

def deferred_message_text
lead_provider_name = lead_provider_name_for_message
subject = lead_provider_name.presence || "The lead provider"
verb = lead_provider_name.present? ? "have" : "has"

"#{subject} #{verb} told us that #{teacher_full_name(teacher)}'s training is paused. Contact them if you think this is an error."
end

def lead_provider_name_for_message
return nil if training_period.blank?

if training_period_only_expression_of_interest?
latest_eoi_lead_provider_name(ect_at_school_period)
else
latest_lead_provider_name(ect_at_school_period)
end
end

def withdrawn?
training_period&.training_status == :withdrawn
end

def deferred?
training_period&.training_status == :deferred
end

def leaving_school?
current_school && ect_at_school_period.leaving_reported_for_school?(current_school)
end

def exempt?
ect_at_school_period.teacher.trs_induction_status == "Exempt"
end

def mentor_required_for_card?
mentor_required?(ect_at_school_period, current_school:)
end

def show_lead_provider_delivery_partner_rows?
!withdrawn?
end

def appropriate_body_row
{ key: { text: "Appropriate body" }, value: { text: ect_at_school_period.school_reported_appropriate_body_name } }
end

def delivery_partner_row
return if training_period&.school_led_training_programme?
return unless show_lead_provider_delivery_partner_rows?

{
key: { text: "Delivery partner" },
Expand All @@ -30,6 +92,7 @@ def delivery_partner_row

def lead_provider_row
return if training_period&.school_led_training_programme?
return unless show_lead_provider_delivery_partner_rows?

{
key: { text: "Lead provider" },
Expand Down Expand Up @@ -82,12 +145,43 @@ def start_date_row
end

def status_row
return normal_status_row if leaving_school? || exempt?
return status_override_row if withdrawn? || deferred? || mentor_required_for_card?

normal_status_row
end

def normal_status_row
{ key: { text: "Status" }, value: { text: ect_status(ect_at_school_period, current_school:) } }
end

def trn_row
{ key: { text: "TRN" }, value: { text: teacher.trn } }
end

def status_override
return ["Action required", "red", withdrawn_message_text] if withdrawn?
return ["Training paused", "orange", deferred_message_text] if deferred?
return ["Action required", "red", "A mentor needs to be assigned to #{teacher_full_name(teacher)}."] if mentor_required_for_card?

nil
end

def status_override_row
tag_text, colour, message = status_override

{
key: { text: "Status" },
value: {
text: safe_join(
[
govuk_tag(text: tag_text, colour:),
content_tag(:p, message, class: "govuk-body govuk-!-margin-top-2")
]
)
}
}
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,49 @@
<% row.with_key { "Name" } %>
<% row.with_value { teacher_full_name(@ect.teacher) } %>
<% row.with_action(
text: 'Change',
text: "Change",
href: schools_ects_change_name_wizard_edit_path(@ect),
classes: 'govuk-link--no-visited-state',
visually_hidden_text: 'name')
%>
classes: "govuk-link--no-visited-state",
visually_hidden_text: "name"
) %>
<% end %>

<% list.with_row do |row| %>
<% row.with_key { "Email address" } %>
<% row.with_value { @ect.email } %>
<% row.with_action(
text: "Change",
visually_hidden_text: "email address",
href: schools_ects_change_email_address_wizard_edit_path(@ect),
classes: "govuk-link--no-visited-state"
) %>
text: "Change",
visually_hidden_text: "email address",
href: schools_ects_change_email_address_wizard_edit_path(@ect),
classes: "govuk-link--no-visited-state"
) %>
<% end %>

<% list.with_row do |row| %>
<% row.with_key { "Mentor" } %>
<% row.with_value { ect_mentor_details(@ect) } %>
<% if current_mentor.present? %>
<% row.with_action(
text: "Change",
visually_hidden_text: "mentor",
href: schools_ects_change_mentor_wizard_edit_path(@ect),
classes: "govuk-link--no-visited-state"
) %>
text: "Change",
visually_hidden_text: "mentor",
href: schools_ects_change_mentor_wizard_edit_path(@ect),
classes: "govuk-link--no-visited-state"
) %>
<% end %>
<% end %>

<% list.with_row do |row| %>
<% row.with_key { "Status" } %>
<% row.with_value { ect_status(@ect, current_school: @current_school) } %>
<% row.with_value do %>
<% if show_withdrawn_or_deferred_status? %>
<%= withdrawn_or_deferred_tag %>
<p class="govuk-body govuk-!-margin-top-2">
<%= withdrawn_or_deferred_message_text %>
</p>
<% else %>
<%= ect_status(@ect, current_school: @current_school) %>
<% end %>
<% end %>
<% end %>

<% list.with_row do |row| %>
Expand All @@ -50,10 +59,10 @@
<% row.with_key { "Working pattern" } %>
<% row.with_value { @ect.working_pattern&.humanize } %>
<% row.with_action(
text: "Change",
visually_hidden_text: "working pattern",
href: schools_ects_change_working_pattern_wizard_edit_path(@ect),
classes: "govuk-link--no-visited-state"
) %>
text: "Change",
visually_hidden_text: "working pattern",
href: schools_ects_change_working_pattern_wizard_edit_path(@ect),
classes: "govuk-link--no-visited-state"
) %>
<% end %>
<% end %>
Loading