-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bade972
commit 67c7509
Showing
5 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
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 @@ | ||
<% 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 %> |
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,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 |
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
11 changes: 11 additions & 0 deletions
11
app/views/publish/providers/training_partnerships/courses/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,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
52
app/views/publish/providers/training_partnerships/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,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> |