diff --git a/app/forms/assessor_interface/filter_form.rb b/app/forms/assessor_interface/filter_form.rb
index 9be8172860..dedd850a85 100644
--- a/app/forms/assessor_interface/filter_form.rb
+++ b/app/forms/assessor_interface/filter_form.rb
@@ -4,12 +4,13 @@ class AssessorInterface::FilterForm
include ActiveModel::Model
include ActiveRecord::AttributeAssignment
- attr_accessor :assessor_ids,
+ attr_accessor :action_required_by,
+ :assessor_ids,
+ :email,
:location,
:name,
:reference,
- :email,
:statuses,
- :submitted_at_before,
- :submitted_at_after
+ :submitted_at_after,
+ :submitted_at_before
end
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 f2fba4092f..595f6e861b 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
@@ -33,6 +33,12 @@ def country_filter_options
)
end
+ def action_required_by_filter_options
+ ACTION_REQUIRED_BY_OPTIONS.map do |name|
+ action_required_by_filter_entry(name)
+ end
+ end
+
def status_filter_options
STATUS_FILTER_OPTIONS.each_with_object({}) do |(status, substatuses), memo|
memo[status_filter_entry(status)] = substatuses.map do |sub_status|
@@ -43,6 +49,8 @@ def status_filter_options
private
+ ACTION_REQUIRED_BY_OPTIONS = %w[admin assessor external].freeze
+
STATUS_FILTER_OPTIONS = {
preliminary_check: [],
submitted: [],
@@ -71,18 +79,8 @@ def filter_params
(session[:filter_params] || {}).with_indifferent_access
end
- def application_forms_with_pagy
- @application_forms_with_pagy ||=
- pagy(
- ::Filters::Status.apply(
- scope: application_forms_without_status_filter,
- params: filter_params,
- ).order(submitted_at: :asc),
- )
- end
-
- def application_forms_without_status_filter
- @application_forms_without_status_filter ||=
+ def application_forms_without_action_required_by_filter
+ @application_forms_without_action_required_by_filter ||=
begin
filters = [
::Filters::Assessor,
@@ -98,6 +96,39 @@ def application_forms_without_status_filter
end
end
+ def application_forms_without_status_filter
+ @application_forms_without_status_filter ||=
+ ::Filters::ActionRequiredBy.apply(
+ scope: application_forms_without_action_required_by_filter,
+ params: filter_params,
+ )
+ end
+
+ def application_forms_with_pagy
+ @application_forms_with_pagy ||=
+ pagy(
+ ::Filters::Status.apply(
+ scope: application_forms_without_status_filter,
+ params: filter_params,
+ ).order(submitted_at: :asc),
+ )
+ end
+
+ def action_required_by_filter_counts
+ @action_required_by_filter_counts ||=
+ application_forms_without_action_required_by_filter.group(
+ :action_required_by,
+ ).count
+ end
+
+ def action_required_by_filter_entry(name)
+ OpenStruct.new(
+ id: name,
+ label:
+ "#{name.humanize} (#{action_required_by_filter_counts.fetch(name, 0)})",
+ )
+ end
+
def status_filter_counts
@status_filter_counts ||=
begin
diff --git a/app/views/assessor_interface/application_forms/index.html.erb b/app/views/assessor_interface/application_forms/index.html.erb
index 10b918ed3c..8034d3d1da 100644
--- a/app/views/assessor_interface/application_forms/index.html.erb
+++ b/app/views/assessor_interface/application_forms/index.html.erb
@@ -17,10 +17,10 @@
<%= f.govuk_check_boxes_fieldset :assessor_ids, legend: { size: "s" }, small: true do %>
- <%- @view_object.assessor_filter_options.each do |option| -%>
+ <% @view_object.assessor_filter_options.each do |option| %>
<%= f.govuk_check_box :assessor_ids, option.id, label: { text: option.name }, checked: @view_object.filter_form.assessor_ids&.include?(option.id.to_s) %>
- <%- end -%>
- <%- end -%>
+ <% end %>
+ <% end %>
@@ -48,6 +48,14 @@
<% end %>
+
+ <%= f.govuk_check_boxes_fieldset :action_required_by, legend: { size: "s" }, small: true do %>
+ <% @view_object.action_required_by_filter_options.each do |option| %>
+ <%= f.govuk_check_box :action_required_by, option.id, label: { text: option.label }, checked: @view_object.filter_form.action_required_by&.include?(option.id) %>
+ <% end %>
+ <% end %>
+
+
<%= f.govuk_check_boxes_fieldset :statuses, legend: { size: "s" }, small: true do %>
<% @view_object.status_filter_options.each do |option, suboptions| %>
@@ -67,7 +75,7 @@
<% end %>
<% end %>
- <%- end -%>
+ <% end %>
diff --git a/config/locales/components.en.yml b/config/locales/components.en.yml
index 4091fa04e2..399f9249f9 100644
--- a/config/locales/components.en.yml
+++ b/config/locales/components.en.yml
@@ -38,7 +38,7 @@ en:
timeline_entry:
title:
- action_required_by_changed: Workflow changed
+ action_required_by_changed: Action required by changed
assessor_assigned: Assessor assigned
reviewer_assigned: Reviewer assigned
state_changed: Status changed
diff --git a/config/locales/helpers.en.yml b/config/locales/helpers.en.yml
index 16f13346c2..d39d438eb2 100644
--- a/config/locales/helpers.en.yml
+++ b/config/locales/helpers.en.yml
@@ -101,10 +101,10 @@ en:
assessor_interface_create_note_form:
text: Add a note to this application
assessor_interface_filter_form:
+ email: Applicant email
location: Country trained in
name: Applicant name
reference: Application reference number
- email: Applicant email
assessor_interface_professional_standing_request_location_form:
received_options:
true: "Yes"
@@ -277,6 +277,7 @@ en:
scotland_full_registration: Does the applicant have or are they eligible for full registration?
school_details_cannot_be_verified_work_history_checked: Choose the schools that need reference details to be amended
assessor_interface_filter_form:
+ action_required_by: Action required by
assessor_ids: Assessor name
states: Status of application
submitted_at: Created date
diff --git a/spec/support/autoload/page_objects/assessor_interface/applications.rb b/spec/support/autoload/page_objects/assessor_interface/applications.rb
index 5677589240..a45c7b8491 100644
--- a/spec/support/autoload/page_objects/assessor_interface/applications.rb
+++ b/spec/support/autoload/page_objects/assessor_interface/applications.rb
@@ -40,6 +40,11 @@ class Applications < SitePrism::Page
"#assessor_interface_filter_form_submitted_at_before_1i"
end
+ section :action_required_by_filter,
+ "#app-applications-filters-action-required-by" do
+ sections :items, GovukCheckboxItem, ".govuk-checkboxes__item"
+ end
+
section :status_filter, "#app-applications-filters-status" do
sections :statuses, GovukCheckboxItem, ".govuk-checkboxes__item"
end
diff --git a/spec/system/assessor_interface/filtering_application_forms_spec.rb b/spec/system/assessor_interface/filtering_application_forms_spec.rb
index 05f70e14d9..2710466191 100644
--- a/spec/system/assessor_interface/filtering_application_forms_spec.rb
+++ b/spec/system/assessor_interface/filtering_application_forms_spec.rb
@@ -36,6 +36,10 @@
and_i_apply_the_submitted_at_filter
then_i_see_a_list_of_applications_filtered_by_submitted_at
+ when_i_clear_the_filters
+ and_i_apply_the_action_required_by_filter
+ then_i_see_a_list_of_applications_filtered_by_action_required_by
+
when_i_clear_the_filters
and_i_apply_the_status_filter
then_i_see_a_list_of_applications_filtered_by_state
@@ -124,6 +128,24 @@ def then_i_see_a_list_of_applications_filtered_by_submitted_at
expect(applications_page.search_results.first.name.text).to eq("John Smith")
end
+ def and_i_apply_the_action_required_by_filter
+ admin_action_item =
+ applications_page.action_required_by_filter.items.find do |item|
+ item.label.text == "Admin (1)"
+ rescue Capybara::ElementNotFound
+ false
+ end
+ admin_action_item.checkbox.click
+ applications_page.apply_filters.click
+ end
+
+ def then_i_see_a_list_of_applications_filtered_by_action_required_by
+ expect(applications_page.search_results.count).to eq(1)
+ expect(applications_page.search_results.first.name.text).to eq(
+ "Emma Dubois",
+ )
+ end
+
def and_i_apply_the_status_filter
awarded_state =
applications_page.status_filter.statuses.find do |status|
@@ -155,6 +177,7 @@ def application_forms
create(
:application_form,
:submitted,
+ :action_required_by_admin,
region: create(:region, country: create(:country, code: "FR")),
given_names: "Emma",
family_name: "Dubois",
@@ -165,6 +188,7 @@ def application_forms
create(
:application_form,
:submitted,
+ :action_required_by_assessor,
region: create(:region, country: create(:country, code: "ES")),
given_names: "Arnold",
family_name: "Drummond",