From f1da22f8782e8554a913789b3f14554b388bc6eb Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Thu, 3 Oct 2024 14:23:36 +0100 Subject: [PATCH 1/2] Allow setting the number of claims to allocate Updates the admin UI providing a select box for allocating a specific number of claims. --- .../admin/claims/_allocations_form.html.erb | 12 ++++---- .../admin/admin_claim_allocation_spec.rb | 30 +++++++++++++++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/app/views/admin/claims/_allocations_form.html.erb b/app/views/admin/claims/_allocations_form.html.erb index f3bb44304a..b4e2b24d1b 100644 --- a/app/views/admin/claims/_allocations_form.html.erb +++ b/app/views/admin/claims/_allocations_form.html.erb @@ -1,9 +1,6 @@ -<% allocate_claim_count = @claims.where(assigned_to: nil).count > 25 ? 25 : @claims.where(assigned_to: nil).size %> -

Allocate claims

<%= form_with url: admin_bulk_allocate_path, method: :patch do |form| %> - <%= form.hidden_field :allocate_claim_count, value: allocate_claim_count %>
<%= form.select :allocate_to_policy, options_for_select(Policies.options_for_select, params[:policy]), {include_blank: "All"}, class: "govuk-select" %>
+
+ + <%= form.select :allocate_claim_count, options_for_select([5, 10, 25], params[:allocate_claim_count] || 25), {}, class: "govuk-select" %> +
-
Default: 25
- <%= form.submit "Allocate claims", class: "govuk-button govuk-button--secondary", id: :allocate, disabled: allocate_claim_count.zero? %> + <%= form.submit "Allocate claims", class: "govuk-button govuk-button--secondary admin-filter-group__button", id: :allocate, disabled: @claims.where(assigned_to: nil).count.zero? %>
diff --git a/spec/features/admin/admin_claim_allocation_spec.rb b/spec/features/admin/admin_claim_allocation_spec.rb index 3386e7e2d3..46f7ca6261 100644 --- a/spec/features/admin/admin_claim_allocation_spec.rb +++ b/spec/features/admin/admin_claim_allocation_spec.rb @@ -152,6 +152,36 @@ expect(page).to have_button "Allocate claims", disabled: false end + scenario "assign 5 claims to one Claim's checker" do + click_on "View claims" + + expect(@submitted_claims.size).to eq 40 + + select "Frank Yee", from: "allocate_to_team_member" + select "All", from: "allocate_to_policy" + select "10", from: "allocate_claim_count" + + click_on "Allocate claims" + + within(".govuk-flash__notice") do + expect(page).to have_text I18n.t( + "admin.allocations.bulk_allocate.success", + quantity: 10, + pluralized_or_singular_claim: "claims", + allocate_to_policy: "", + dfe_user: frank.full_name.titleize + ).squeeze(" ") + end + + @submitted_claims[0..9].each do |claim| + expect(claim.reload.assigned_to.full_name).to eq "Frank Yee" + end + + @submitted_claims[10..].each do |claim| + expect(claim.reload.assigned_to).to be_nil + end + end + scenario "assign outstanding 10 claims when 25 already allocated" do @submitted_claims.slice(0..24).each do |claim| claim.assigned_to = @signed_in_user From b11140fcfc1ffefb753e617e65875ced1c608c0f Mon Sep 17 00:00:00 2001 From: Richard Lynch Date: Thu, 3 Oct 2024 16:10:54 +0100 Subject: [PATCH 2/2] Use form builder Updates the view to use govuk form builder --- .../admin/claims/_allocations_form.html.erb | 45 +++++++++---------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/app/views/admin/claims/_allocations_form.html.erb b/app/views/admin/claims/_allocations_form.html.erb index b4e2b24d1b..6012ef013a 100644 --- a/app/views/admin/claims/_allocations_form.html.erb +++ b/app/views/admin/claims/_allocations_form.html.erb @@ -1,32 +1,27 @@

Allocate claims

-<%= form_with url: admin_bulk_allocate_path, method: :patch do |form| %> +<%= form_with url: admin_bulk_allocate_path, method: :patch, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |form| %>
-
- - <%= form.select :allocate_to_team_member, options_for_select(DfeSignIn::User.options_for_select, params[:allocate_to_team_member]), {}, class: "govuk-select" %> -
-
- - <%= form.select :allocate_to_policy, options_for_select(Policies.options_for_select, params[:policy]), {include_blank: "All"}, class: "govuk-select" %> -
-
- - <%= form.select :allocate_claim_count, options_for_select([5, 10, 25], params[:allocate_claim_count] || 25), {}, class: "govuk-select" %> -
+ <%= form.govuk_select( + :allocate_to_team_member, + options_for_select(DfeSignIn::User.options_for_select, params[:allocate_to_team_member]), + label: { text: "Team members:" } + ) %> -
- <%= form.submit "Allocate claims", class: "govuk-button govuk-button--secondary admin-filter-group__button", id: :allocate, disabled: @claims.where(assigned_to: nil).count.zero? %> -
+ <%= form.govuk_select( + :allocate_to_policy, + options_for_select(Policies.options_for_select, params[:policy]), + options: { include_blank: "All" }, + label: { text: "Policy:" } + ) %> -
- <%= form.submit "Unallocate claims", class: "govuk-button govuk-button--secondary admin-filter-group__button", id: :unallocate, formaction: admin_bulk_deallocate_path %> -
+ <%= form.govuk_select( + :allocate_claim_count, + options_for_select([5, 10, 25], params[:allocate_claim_count] || 25), + label: { text: "Number of claims:" } + ) %> + + <%= form.submit "Allocate claims", class: "govuk-button govuk-button--secondary", id: :allocate, disabled: @claims.where(assigned_to: nil).count.zero? %> + <%= form.submit "Unallocate claims", class: "govuk-button govuk-button--secondary", id: :unallocate, formaction: admin_bulk_deallocate_path %>
<% end %>