diff --git a/app/components/application_form_search_result/component.html.erb b/app/components/application_form_search_result/component.html.erb index 5c55981449..e328956e8a 100644 --- a/app/components/application_form_search_result/component.html.erb +++ b/app/components/application_form_search_result/component.html.erb @@ -1,6 +1,9 @@
  • <%= govuk_link_to full_name, href %> + <% if unsuitable %> + <%= govuk_tag(text: "Flagged for suitablilty", colour: "red") %> + <% end %>

    <%= render(DescriptionList::Component.new( diff --git a/app/components/application_form_search_result/component.rb b/app/components/application_form_search_result/component.rb index 2862a547d6..0c7f629aff 100644 --- a/app/components/application_form_search_result/component.rb +++ b/app/components/application_form_search_result/component.rb @@ -2,10 +2,11 @@ module ApplicationFormSearchResult class Component < ViewComponent::Base - def initialize(application_form, current_staff:) + def initialize(application_form, current_staff:, unsuitable:) super @application_form = application_form @current_staff = current_staff + @unsuitable = unsuitable end def full_name @@ -26,6 +27,8 @@ def summary_rows ) end + attr_reader :unsuitable + private attr_reader :application_form, :current_staff diff --git a/app/view_objects/assessor_interface/application_forms_index_view_object.rb b/app/view_objects/assessor_interface/application_forms_index_view_object.rb index ec8d783d99..9eb6dba333 100644 --- a/app/view_objects/assessor_interface/application_forms_index_view_object.rb +++ b/app/view_objects/assessor_interface/application_forms_index_view_object.rb @@ -48,6 +48,11 @@ def stage_filter_options STAGE_FILTER_OPTIONS.map { |name| stage_filter_entry(name) } end + def flag_as_unsuitable?(application_form) + suitability_active? && + suitability_matcher.flag_as_unsuitable?(application_form:) + end + private ACTION_REQUIRED_BY_OPTIONS = %w[admin assessor external].freeze @@ -142,4 +147,12 @@ def stage_filter_entry(name) end attr_reader :params, :session + + def suitability_active? + @suitability_active ||= FeatureFlags::FeatureFlag.active?(:suitability) + end + + def suitability_matcher + @suitability_matcher ||= SuitabilityMatcher.new + end end diff --git a/app/views/assessor_interface/application_forms/index.html.erb b/app/views/assessor_interface/application_forms/index.html.erb index de26e255e4..8d2bab93a9 100644 --- a/app/views/assessor_interface/application_forms/index.html.erb +++ b/app/views/assessor_interface/application_forms/index.html.erb @@ -76,7 +76,7 @@ <% if (records = @view_object.application_forms_records).present? %> diff --git a/spec/components/application_form_search_result_component_spec.rb b/spec/components/application_form_search_result_component_spec.rb index 51616fcbf8..58fefc5fdb 100644 --- a/spec/components/application_form_search_result_component_spec.rb +++ b/spec/components/application_form_search_result_component_spec.rb @@ -4,7 +4,9 @@ RSpec.describe ApplicationFormSearchResult::Component, type: :component do subject(:component) do - render_inline(described_class.new(application_form, current_staff:)) + render_inline( + described_class.new(application_form, current_staff:, unsuitable: false), + ) end let(:application_form) do diff --git a/spec/view_objects/assessor_interface/application_forms_index_view_object_spec.rb b/spec/view_objects/assessor_interface/application_forms_index_view_object_spec.rb index bd679c8431..0510fb650e 100644 --- a/spec/view_objects/assessor_interface/application_forms_index_view_object_spec.rb +++ b/spec/view_objects/assessor_interface/application_forms_index_view_object_spec.rb @@ -8,13 +8,9 @@ let(:params) { {} } let(:session) { {} } - before do - FeatureFlags::FeatureFlag.activate(:suitability) - end + before { FeatureFlags::FeatureFlag.activate(:suitability) } - after do - FeatureFlags::FeatureFlag.deactivate(:suitability) - end + after { FeatureFlags::FeatureFlag.deactivate(:suitability) } describe "#application_forms_pagy" do subject(:application_forms_pagy) { view_object.application_forms_pagy } diff --git a/spec/view_objects/assessor_interface/application_forms_show_view_object_spec.rb b/spec/view_objects/assessor_interface/application_forms_show_view_object_spec.rb index b52a88cfab..f883d436cc 100644 --- a/spec/view_objects/assessor_interface/application_forms_show_view_object_spec.rb +++ b/spec/view_objects/assessor_interface/application_forms_show_view_object_spec.rb @@ -10,6 +10,10 @@ ) end + before { FeatureFlags::FeatureFlag.activate(:suitability) } + + after { FeatureFlags::FeatureFlag.deactivate(:suitability) } + let(:params) { {} } let(:current_staff) { create(:staff) }