Skip to content

Commit

Permalink
Wrap claims filter form into a reusable component
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitemaeric authored and dp-daly committed Dec 10, 2024
1 parent 1192b71 commit de7895e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/components/claims/claim/filter_form_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
</div>
<% end %>

<%= content_tag(:div, class: "app-filter__option", data: { controller: @statuses.length > 5 ? "filter-search" : nil }) do %>
<div class="app-filter__option" data-controller="filter-search">
<%= form.govuk_check_boxes_fieldset(
:statuses,
legend: {
Expand Down
7 changes: 4 additions & 3 deletions app/components/claims/claim/filter_form_component.rb
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
class Claims::Claim::FilterFormComponent < ApplicationComponent
def initialize(
filter_form:,
academic_years: AcademicYear.where(id: Claims::ClaimWindow.select(:academic_year_id)).order_by_date,
statuses: Claims::Claim.statuses.values.without(*Claims::Claim::DRAFT_STATUSES.map(&:to_s)),
academic_years: AcademicYear.where(id: Claims::ClaimWindow.select(:academic_year_id)).order_by_date,
providers: Claims::Provider.all,
schools: Claims::School.all,
classes: [],
html_attributes: {}
)
super(classes:, html_attributes:)

@filter_form = filter_form
@academic_years = academic_years
@statuses = statuses
@schools = Claims::School.all
@academic_years = academic_years
@providers = providers
@schools = schools
end

private
Expand Down
4 changes: 4 additions & 0 deletions app/views/claims/support/claims/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

<%= govuk_button_link_to t(".download_csv"), download_csv_claims_support_claims_path(**request.query_parameters), class: "govuk-button" %>

<div>
<button class="govuk-button govuk-button--secondary show-filter-button" type="button" data-action="click->filter#open"><%= t("show_filter") %></button>
</div>

<%= render Claims::Claim::FilterFormComponent.new(filter_form:) do %>
<% if @claims.any? %>
<div class="govuk-!-margin-bottom-2">
Expand Down

0 comments on commit de7895e

Please sign in to comment.