Skip to content

Commit

Permalink
Consolidate options forms
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie authored and JamieCleare2525 committed Apr 12, 2024
1 parent d0b9577 commit 9fdd528
Show file tree
Hide file tree
Showing 18 changed files with 198 additions and 402 deletions.
2 changes: 1 addition & 1 deletion app/components/options_form_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
legend: {
text: t(
".legend",
record_count: records.count,
results_count: records.count,
search_param:,
),
size: "l",
Expand Down
16 changes: 6 additions & 10 deletions app/components/options_form_component.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
class OptionsFormComponent < ApplicationComponent
OPTIONS_PER_PAGE = 15

attr_reader :model, :url, :search_param, :records,
attr_reader :model, :url, :search_param, :records, :records_klass,
:back_link, :scope, :input_field_name, :title

def initialize(
model:,
url:,
search_param:,
records:,
records_klass:,
back_link:,
scope:,
input_field_name:,
title:,
input_field_name: :id,
title: I18n.t("components.options_form_component.add_organisation"),
classes: [],
html_attributes: {}
)
Expand All @@ -22,6 +23,7 @@ def initialize(
@url = url
@search_param = search_param
@records = records
@records_klass = records_klass.to_s.downcase
@back_link = back_link
@scope = scope
@input_field_name = input_field_name
Expand All @@ -32,7 +34,7 @@ def form_description
if records.count > OPTIONS_PER_PAGE
t(
"components.options_form_component.paginated_form_description_html",
record_count: OPTIONS_PER_PAGE,
results_count: OPTIONS_PER_PAGE,
klass: records_klass,
link_to: govuk_link_to(
t("components.options_form_component.narrow_your_search"),
Expand All @@ -52,10 +54,4 @@ def form_description
)
end
end

private

def records_klass
@records_klass ||= records.base_class.to_s.downcase
end
end
51 changes: 0 additions & 51 deletions app/components/provider_options_form_component.html.erb

This file was deleted.

46 changes: 0 additions & 46 deletions app/components/provider_options_form_component.rb

This file was deleted.

51 changes: 0 additions & 51 deletions app/components/school_options_form_component.html.erb

This file was deleted.

46 changes: 0 additions & 46 deletions app/components/school_options_form_component.rb

This file was deleted.

6 changes: 4 additions & 2 deletions app/views/claims/support/schools/school_options.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
<% end %>

<div class="govuk-width-container">
<%= render SchoolOptionsFormComponent.new(
<%= render OptionsFormComponent.new(
model: school_form,
scope: :school,
url: check_school_option_claims_support_schools_path,
search_param:,
schools:,
records: schools,
records_klass: "school",
back_link: new_claims_support_school_path,
) %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
<% end %>

<div class="govuk-width-container">
<%= render ProviderOptionsFormComponent.new(
<%= render OptionsFormComponent.new(
model: provider_form,
scope: :provider,
url: check_provider_option_placements_support_providers_path,
search_param:,
providers:,
records: providers,
records_klass: "provider",
back_link: new_placements_support_provider_path,
) %>

Expand Down
6 changes: 4 additions & 2 deletions app/views/placements/support/schools/school_options.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
<% end %>

<div class="govuk-width-container">
<%= render SchoolOptionsFormComponent.new(
<%= render OptionsFormComponent.new(
model: school_form,
scope: :school,
url: check_school_option_placements_support_schools_path,
search_param:,
schools:,
records: schools,
records_klass: "school",
back_link: new_placements_support_school_path,
) %>

Expand Down
26 changes: 0 additions & 26 deletions config/locales/en/components.yml

This file was deleted.

11 changes: 11 additions & 0 deletions config/locales/en/components/options_form_component.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
en:
components:
options_form_component:
add_organisation: Add organisation
continue: Continue
paginated_form_description_html: Showing the first %{results_count} results. %{link_to} if the %{klass} you’re looking for is not listed.
form_description_html: "%{link_to} if the %{klass} you’re looking for is not listed."
change_your_search: Change your search
narrow_your_search: Try narrowing down your search
no_results: No results found for '%{search_param}'
legend: "%{results_count} results found for '%{search_param}'"
11 changes: 0 additions & 11 deletions config/locales/en/components/school_options_form_component.yml

This file was deleted.

Loading

0 comments on commit 9fdd528

Please sign in to comment.