Skip to content

Commit

Permalink
Training partnerships views
Browse files Browse the repository at this point in the history
  • Loading branch information
inulty-dfe committed Jan 22, 2025
1 parent bade972 commit 67c7509
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 0 deletions.
23 changes: 23 additions & 0 deletions app/components/add_course_button_partnerships.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<% if required_organisation_details_present? %>
<%= govuk_button_link_to(
"Add course",
new_publish_provider_recruitment_cycle_course_path(
provider_code: provider.provider_code,
recruitment_cycle_year: provider.recruitment_cycle_year
),
class: "govuk-!-margin-bottom-6"
) %>

<% else %>

<div class="govuk-inset-text">
<p class="govuk-body">Before adding a course, you need to:</p>
<ul class="govuk-list govuk-list--bullet">
<% incomplete_sections.each do |section| %>
<li>
<%= govuk_link_to(section.name, section.path) %>
</li>
<% end %>
</ul>
</div>
<% end %>
69 changes: 69 additions & 0 deletions app/components/add_course_button_partnerships.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# frozen_string_literal: true

class AddCourseButtonPartnerships < ViewComponent::Base
include RecruitmentCycleHelper
attr_reader :provider

Section = Struct.new(:name, :path, keyword_init: true)

def initialize(provider:)
@provider = provider
super
end

private

def incomplete_sections
incomplete_sections_hash.keys.select { |section| send(section) }.map do |section|
Section.new(name: "add #{incomplete_section_article(section)} #{incomplete_section_label_suffix(section)}", path: incomplete_sections_hash[section])
end
end

def incomplete_sections_hash
{
site_not_present?: publish_provider_recruitment_cycle_schools_path(provider.provider_code, provider.recruitment_cycle_year),
accredited_partner_not_present?: publish_provider_recruitment_cycle_accredited_partnerships_path(provider.provider_code, provider.recruitment_cycle_year)
}
end

def incomplete_section_label_suffix(section)
labels = {
accredited_partner_not_present?: 'accredited partner',
site_not_present?: 'school'
}

labels[section]
end

def required_organisation_details_present?
accredited_partner_present? && site_present?
end

def accredited_partner_present?
return true if accredited_provider?

provider.accredited_partners.any?
end

def site_present?
provider.sites.any?
end

def accredited_partner_not_present?
return false if provider.accredited_provider?

!accredited_partner_present?
end

def site_not_present?
!site_present?
end

def accredited_provider?
provider.accredited_provider?
end

def incomplete_section_article(section)
incomplete_section_label_suffix(section) == 'accredited partner' ? 'an' : 'a'
end
end
2 changes: 2 additions & 0 deletions app/helpers/navigation_bar_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ def navigation_items(provider)
def partnership_link(provider)
if Settings.features.provider_partnerships && !provider.accredited?
{ name: t('navigation_bar.accredited_partnerships'), url: publish_provider_recruitment_cycle_accredited_partnerships_path(provider.provider_code, provider.recruitment_cycle_year) }
elsif Settings.features.provider_partnerships && provider.accredited?
{ name: t('navigation_bar.training_partners'), url: publish_provider_recruitment_cycle_training_partnerships_path(provider.provider_code, provider.recruitment_cycle_year) }
elsif provider.accredited?
{ name: t('navigation_bar.training_partners'), url: publish_provider_recruitment_cycle_training_providers_path(provider.provider_code, provider.recruitment_cycle_year) }
else
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<% content_for :page_title, @provider.provider_name %>
<%= content_for :before_content, render_breadcrumbs(:training_provider_courses) %>

<h1 class="govuk-heading-l">
<span class="govuk-caption-l">Training partner</span>
<%= @training_provider.provider_name %>
</h1>

<section data-qa="courses__table-section">
<%= render partial: "publish/courses/course_table", locals: { courses: @courses } %>
</section>
52 changes: 52 additions & 0 deletions app/views/publish/providers/training_partnerships/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<% content_for :page_title, "Training partners" %>
<%= content_for :before_content, render_breadcrumbs(:training_providers) %>

<h1 class="govuk-heading-l">
Training partners
</h1>

<div class="govuk-grid-row">
<div class="govuk-grid-column-two-thirds">

<ul class="govuk-list" data-qa="provider__training_providers_list">
<% @training_providers.each do |training_provider| %>
<li data-qa="training_provider">
<h3 class="govuk-heading-s">
<%= govuk_link_to(
training_provider.provider_name,
publish_provider_recruitment_cycle_training_provider_courses_path(
@provider.provider_code,
@provider.recruitment_cycle_year,
training_provider.provider_code
),
class: "govuk-!-font-weight-bold",
data: { qa: "training_provider_name" }
) %>
<span class="govuk-hint govuk-!-display-inline" data-qa="course_count">
<%= pluralize(@course_counts[training_provider.provider_code], "course") %>
</span>
</h3>
</li>
<% end %>
</ul>
</div>

<% unless @training_providers.empty? %>
<aside class="govuk-grid-column-one-third">
<div class="app-status-box" data-qa="download-section">
<h2 class="govuk-heading-m">Download</h2>
<p class="govuk-body">Export all the courses you’re the accredited provider for.</p>
<p class="govuk-body">
<%= govuk_link_to(
"Download as a CSV file",
download_training_providers_courses_publish_provider_recruitment_cycle_path(
@provider.provider_code,
@provider.recruitment_cycle_year,
format: :csv
)
) %>
</p>
</div>
</aside>
<% end %>
</div>

0 comments on commit 67c7509

Please sign in to comment.