diff --git a/app/components/add_course_button_partnerships.html.erb b/app/components/add_course_button_partnerships.html.erb new file mode 100644 index 0000000000..beaa855073 --- /dev/null +++ b/app/components/add_course_button_partnerships.html.erb @@ -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 %> + +
+

Before adding a course, you need to:

+ +
+<% end %> diff --git a/app/components/add_course_button_partnerships.rb b/app/components/add_course_button_partnerships.rb new file mode 100644 index 0000000000..5a39e807d8 --- /dev/null +++ b/app/components/add_course_button_partnerships.rb @@ -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 diff --git a/app/helpers/navigation_bar_helper.rb b/app/helpers/navigation_bar_helper.rb index ee552a80b1..eeade50f11 100644 --- a/app/helpers/navigation_bar_helper.rb +++ b/app/helpers/navigation_bar_helper.rb @@ -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 diff --git a/app/views/publish/providers/training_partnerships/courses/index.html.erb b/app/views/publish/providers/training_partnerships/courses/index.html.erb new file mode 100644 index 0000000000..363cbadf61 --- /dev/null +++ b/app/views/publish/providers/training_partnerships/courses/index.html.erb @@ -0,0 +1,11 @@ +<% content_for :page_title, @provider.provider_name %> +<%= content_for :before_content, render_breadcrumbs(:training_provider_courses) %> + +

+ Training partner + <%= @training_provider.provider_name %> +

+ +
+ <%= render partial: "publish/courses/course_table", locals: { courses: @courses } %> +
diff --git a/app/views/publish/providers/training_partnerships/index.html.erb b/app/views/publish/providers/training_partnerships/index.html.erb new file mode 100644 index 0000000000..57c95c31dd --- /dev/null +++ b/app/views/publish/providers/training_partnerships/index.html.erb @@ -0,0 +1,52 @@ +<% content_for :page_title, "Training partners" %> +<%= content_for :before_content, render_breadcrumbs(:training_providers) %> + +

+ Training partners +

+ +
+
+ + +
+ + <% unless @training_providers.empty? %> + + <% end %> +