diff --git a/app/forms/assessor_interface/filter_form.rb b/app/forms/assessor_interface/filter_form.rb
index 9be8172860..fc6261a786 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 :actionable_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..25ad4f4c54 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,10 @@ def country_filter_options
)
end
+ def actionable_by_filter_options
+ ACTIONABLE_BY_OPTIONS.map { |name| actionable_by_filter_entry(name) }
+ 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 +47,8 @@ def status_filter_options
private
+ ACTIONABLE_BY_OPTIONS = %w[admin assessor nobody].freeze
+
STATUS_FILTER_OPTIONS = {
preliminary_check: [],
submitted: [],
@@ -71,18 +77,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_actionable_by_filter
+ @application_forms_without_actionable_by_filter ||=
begin
filters = [
::Filters::Assessor,
@@ -98,6 +94,45 @@ def application_forms_without_status_filter
end
end
+ def application_forms_without_status_filter
+ @application_forms_without_status_filter ||=
+ ::Filters::ActionableBy.apply(
+ scope: application_forms_without_actionable_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 actionable_by_filter_counts
+ @actionable_by_filter_counts ||=
+ application_forms_without_actionable_by_filter.group(:actionable_by).count
+ end
+
+ def actionable_by_filter_entry(name)
+ readable_name =
+ if name == "admin"
+ "Admin action"
+ elsif name == "assessor"
+ "Assessor action"
+ else
+ "No action"
+ end
+
+ OpenStruct.new(
+ id: name,
+ label: "#{readable_name} (#{actionable_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..625070766d 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 :actionable_by, legend: { size: "s" }, small: true do %>
+ <% @view_object.actionable_by_filter_options.each do |option| %>
+ <%= f.govuk_check_box :actionable_by, option.id, label: { text: option.label }, checked: @view_object.filter_form.actionable_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/helpers.en.yml b/config/locales/helpers.en.yml
index e8d53d8203..c962561678 100644
--- a/config/locales/helpers.en.yml
+++ b/config/locales/helpers.en.yml
@@ -103,10 +103,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"
@@ -279,6 +279,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:
+ actionable_by: Workflow
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..f781e30921 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 :actionable_by_filter,
+ "#app-applications-filters-actionable-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..911c08ecf4 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_actionable_by_filter
+ then_i_see_a_list_of_applications_filtered_by_actionable_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_actionable_by_filter
+ admin_action_item =
+ applications_page.actionable_by_filter.items.find do |item|
+ item.label.text == "Admin action (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_actionable_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,
+ :actionable_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,
+ :actionable_by_assessor,
region: create(:region, country: create(:country, code: "ES")),
given_names: "Arnold",
family_name: "Drummond",