Skip to content

Commit e8b99a9

Browse files
authored
Merge pull request #5202 from nhsuk/patient-search-form-component-erb
Split template out of `AppPatientSearchFormComponent`
2 parents ec2b067 + 1effdfe commit e8b99a9

2 files changed

Lines changed: 227 additions & 230 deletions

File tree

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
<%= form_with url:, method: :get, builder: GOVUKDesignSystemFormBuilder::FormBuilder do |f| %>
2+
<%= render AppCardComponent.new(filters: true) do |card| %>
3+
<% card.with_heading(level: heading_level) { "Find children" } %>
4+
5+
<div class="app-search-input" role="search">
6+
<%= f.govuk_text_field :q,
7+
value: form.q,
8+
label: { text: "Search", class: "nhsuk-u-visually-hidden" },
9+
autocomplete: "off",
10+
class: "app-search-input__input" %>
11+
12+
<button class="nhsuk-button app-button--icon app-search-input__submit" data-module="nhsuk-button" type="submit">
13+
<svg class="nhsuk-icon nhsuk-icon--search" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="16" height="16" focusable="false" role="img" aria-label="Search">
14+
<title>Search</title>
15+
<path d="m20.7 19.3-4.1-4.1a7 7 0 1 0-1.4 1.4l4 4.1a1 1 0 0 0 1.5 0c.4-.4.4-1 0-1.4ZM6 11a5 5 0 1 1 10 0 5 5 0 0 1-10 0Z"/>
16+
</svg>
17+
</button>
18+
</div>
19+
20+
<% if programmes.size > 1 %>
21+
<%= f.govuk_check_boxes_fieldset :programme_types,
22+
legend: { text: "Programme", size: "s" },
23+
small: true do %>
24+
<% programmes.each do |programme| %>
25+
<%= f.govuk_check_box :programme_types,
26+
programme.type,
27+
checked: form.programme_types&.include?(programme.type),
28+
label: { text: programme.name } %>
29+
<% end %>
30+
<% end %>
31+
<% end %>
32+
33+
<% if tallying_enabled? && (show_still_to_vaccinate || show_eligible_children) %>
34+
<%= f.govuk_check_boxes_fieldset :show_only,
35+
multiple: true,
36+
legend: { text: "Show only", size: "s" },
37+
small: true do %>
38+
<% if show_still_to_vaccinate %>
39+
<%= f.govuk_check_box :still_to_vaccinate,
40+
1, 0,
41+
checked: form.still_to_vaccinate,
42+
multiple: false,
43+
link_errors: true,
44+
label: { text: "Still to vaccinate" },
45+
hint: { text: "With consent, not refused vaccine, not vaccinated yet" } %>
46+
<% end %>
47+
<% if show_eligible_children %>
48+
<%= f.govuk_check_box :eligible_children,
49+
1, 0,
50+
checked: form.eligible_children,
51+
multiple: false,
52+
link_errors: true,
53+
label: { text: "Eligible this academic year and not vaccinated elsewhere" } %>
54+
<% end %>
55+
<% end %>
56+
<% end %>
57+
58+
<% if consent_statuses.any? %>
59+
<%= f.govuk_check_boxes_fieldset :consent_statuses,
60+
legend: { text: "Consent status", size: "s" },
61+
small: true do %>
62+
<% consent_statuses.each do |status| %>
63+
<%= f.govuk_check_box :consent_statuses,
64+
status,
65+
checked: form.consent_statuses&.include?(status),
66+
label: { text: t(status, scope: %i[status consent label]) } %>
67+
<% end %>
68+
<% end %>
69+
<% end %>
70+
71+
<% if triage_statuses.any? %>
72+
<%= f.govuk_radio_buttons_fieldset :triage_status,
73+
legend: { text: "Triage status", size: "s" },
74+
small: true do %>
75+
<%= f.govuk_radio_button :triage_status, "", checked: form.triage_status.blank?, label: { text: "Any" } %>
76+
<% triage_statuses.each do |status| %>
77+
<%= f.govuk_radio_button :triage_status,
78+
status,
79+
checked: form.triage_status == status,
80+
label: { text: t(status, scope: %i[status triage label]) } %>
81+
<% end %>
82+
<% end %>
83+
<% end %>
84+
85+
<% if registration_statuses.any? %>
86+
<%= f.govuk_radio_buttons_fieldset :registration_status,
87+
legend: { text: "Registration status", size: "s" },
88+
small: true do %>
89+
<%= f.govuk_radio_button :registration_status, "", checked: form.registration_status.blank?, label: { text: "Any" } %>
90+
<% registration_statuses.each do |status| %>
91+
<%= f.govuk_radio_button :registration_status,
92+
status,
93+
checked: form.registration_status == status,
94+
label: { text: t(status, scope: %i[status registration label]) } %>
95+
<% end %>
96+
<% end %>
97+
<% end %>
98+
99+
<% if vaccination_statuses.any? %>
100+
<%= f.govuk_radio_buttons_fieldset :vaccination_status,
101+
legend: { text: "Programme status", size: "s" },
102+
small: true do %>
103+
<%= f.govuk_radio_button :vaccination_status, "", checked: form.vaccination_status.blank?, label: { text: "Any" } %>
104+
105+
<% vaccination_statuses.each do |status| %>
106+
<%= f.govuk_radio_button :vaccination_status,
107+
status,
108+
checked: form.vaccination_status == status,
109+
label: { text: t(status, scope: %i[status vaccination label]) } %>
110+
<% end %>
111+
<% end %>
112+
<% end %>
113+
114+
<% if patient_specific_direction_statuses.any? %>
115+
<%= f.govuk_radio_buttons_fieldset :patient_specific_direction_status,
116+
legend: { text: "PSD status", size: "s" },
117+
small: true do %>
118+
<%= f.govuk_radio_button :patient_specific_direction_status, "", checked: form.patient_specific_direction_status.blank?, label: { text: "Any" } %>
119+
120+
<% patient_specific_direction_statuses.each do |status| %>
121+
<%= f.govuk_radio_button :patient_specific_direction_status,
122+
status,
123+
checked: form.patient_specific_direction_status == status,
124+
label: { text: t(status, scope: %i[status patient_specific_direction label]) } %>
125+
<% end %>
126+
<% end %>
127+
<% end %>
128+
129+
<% if vaccine_criterias.any? %>
130+
<%= f.govuk_radio_buttons_fieldset :vaccine_criteria,
131+
legend: { text: "Vaccine type", size: "s" },
132+
small: true do %>
133+
<%= f.govuk_radio_button :vaccine_criteria, "", checked: form.vaccine_criteria.blank?, label: { text: "Any" } %>
134+
135+
<% vaccine_criterias.each do |vaccine_criteria| %>
136+
<%= f.govuk_radio_button :vaccine_criteria,
137+
vaccine_criteria,
138+
checked: form.vaccine_criteria == vaccine_criteria,
139+
label: { text: t(vaccine_criteria, scope: "vaccine_criteria") } %>
140+
<% end %>
141+
<% end %>
142+
<% end %>
143+
144+
<% if year_groups.any? %>
145+
<%= f.govuk_check_boxes_fieldset :year_groups,
146+
legend: { text: "Year group", size: "s" },
147+
small: true do %>
148+
<% year_groups.each do |year_group| %>
149+
<%= f.govuk_check_box :year_groups,
150+
year_group,
151+
checked: form.year_groups&.include?(year_group),
152+
label: { text: format_year_group(year_group) } %>
153+
<% end %>
154+
<% end %>
155+
<% end %>
156+
157+
<%= govuk_details(summary_text: "Advanced filters", open: open_details?) do %>
158+
<div class="nhsuk-form-group">
159+
<fieldset class="nhsuk-fieldset">
160+
<legend class="nhsuk-fieldset__legend nhsuk-fieldset__legend--s">Date of birth</legend>
161+
<div class="nhsuk-date-input">
162+
<div class="nhsuk-date-input__item">
163+
<%= f.govuk_number_field :date_of_birth_day,
164+
value: form.date_of_birth_day,
165+
label: { text: "Day" },
166+
width: 2 %>
167+
</div>
168+
<div class="nhsuk-date-input__item">
169+
<%= f.govuk_number_field :date_of_birth_month,
170+
value: form.date_of_birth_month,
171+
label: { text: "Month" },
172+
width: 2 %>
173+
</div>
174+
<div class="nhsuk-date-input__item">
175+
<%= f.govuk_number_field :date_of_birth_year,
176+
value: form.date_of_birth_year,
177+
label: { text: "Year" },
178+
width: 4 %>
179+
</div>
180+
</div>
181+
</fieldset>
182+
</div>
183+
184+
<%= f.govuk_check_boxes_fieldset :show_only,
185+
multiple: false,
186+
legend: { text: "Show only", size: "s" },
187+
small: true do %>
188+
<%= f.govuk_check_box :archived,
189+
1, 0,
190+
checked: form.archived,
191+
multiple: false,
192+
link_errors: true,
193+
label: { text: "Archived records" } %>
194+
195+
<%= f.govuk_check_box :missing_nhs_number,
196+
1, 0,
197+
checked: form.missing_nhs_number,
198+
multiple: false,
199+
link_errors: true,
200+
label: { text: "Children missing an NHS number" } %>
201+
202+
<% if show_aged_out_of_programmes %>
203+
<%= f.govuk_check_box :aged_out_of_programmes,
204+
1, 0,
205+
checked: form.aged_out_of_programmes,
206+
multiple: false,
207+
link_errors: true,
208+
label: { text: "Children aged out of programmes" } %>
209+
<% end %>
210+
<% end %>
211+
212+
<% if show_buttons_in_details? %>
213+
<div class="nhsuk-button-group">
214+
<%= f.govuk_submit "Update results", secondary: true, class: "app-button--small" %>
215+
<%= govuk_button_link_to "Clear filters", clear_filters_path, secondary: true, class: "app-button--small" %>
216+
</div>
217+
<% end %>
218+
<% end %>
219+
220+
<% unless show_buttons_in_details? %>
221+
<div class="nhsuk-button-group">
222+
<%= f.govuk_submit "Update results", secondary: true, class: "app-button--small" %>
223+
<%= govuk_button_link_to "Clear filters", clear_filters_path, secondary: true, class: "app-button--small" %>
224+
</div>
225+
<% end %>
226+
<% end %>
227+
<% end %>

0 commit comments

Comments
 (0)