Skip to content

Commit 70963d1

Browse files
authored
Merge branch 'main' into configure-config-hosts
2 parents aef3525 + 7fafb07 commit 70963d1

File tree

50 files changed

+552
-554
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+552
-554
lines changed

Gemfile.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ GEM
109109
public_suffix (>= 2.0.2, < 6.0)
110110
ast (2.4.3)
111111
aws-eventstream (1.4.0)
112-
aws-partitions (1.1190.0)
112+
aws-partitions (1.1196.0)
113113
aws-sdk-cloudwatch (1.125.0)
114114
aws-sdk-core (~> 3, >= 3.239.1)
115115
aws-sigv4 (~> 1.5)
116116
aws-sdk-codepipeline (1.109.0)
117117
aws-sdk-core (~> 3, >= 3.239.1)
118118
aws-sigv4 (~> 1.5)
119-
aws-sdk-core (3.239.2)
119+
aws-sdk-core (3.240.0)
120120
aws-eventstream (~> 1, >= 1.3.0)
121121
aws-partitions (~> 1, >= 1.992.0)
122122
aws-sigv4 (~> 1.9)
@@ -127,7 +127,7 @@ GEM
127127
aws-sdk-kms (1.118.0)
128128
aws-sdk-core (~> 3, >= 3.239.1)
129129
aws-sigv4 (~> 1.5)
130-
aws-sdk-s3 (1.205.0)
130+
aws-sdk-s3 (1.208.0)
131131
aws-sdk-core (~> 3, >= 3.234.0)
132132
aws-sdk-kms (~> 1)
133133
aws-sigv4 (~> 1.5)
@@ -156,7 +156,7 @@ GEM
156156
ice_nine (~> 0.11.0)
157157
thread_safe (~> 0.3, >= 0.3.1)
158158
base64 (0.3.0)
159-
bigdecimal (3.3.1)
159+
bigdecimal (4.0.1)
160160
bootsnap (1.19.0)
161161
msgpack (~> 1.2)
162162
brakeman (7.1.1)
@@ -600,12 +600,12 @@ CHECKSUMS
600600
addressable (2.8.6) sha256=798f6af3556641a7619bad1dce04cdb6eb44b0216a991b0396ea7339276f2b47
601601
ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
602602
aws-eventstream (1.4.0) sha256=116bf85c436200d1060811e6f5d2d40c88f65448f2125bc77ffce5121e6e183b
603-
aws-partitions (1.1190.0) sha256=3e21ce1c99329a96fb71419a5d92d0cece5b276a9f47bc91d6a1290450fb3669
603+
aws-partitions (1.1196.0) sha256=1a62cf7f1298f785bf9fca59ab77f3ceb49dd73bcc547c877236905887c35564
604604
aws-sdk-cloudwatch (1.125.0) sha256=2ff95a362fc2b539936b61e07669ca882939f24487b09e24e794d8c792613793
605605
aws-sdk-codepipeline (1.109.0) sha256=15c0bd0e1e50cc689dbb7394e81e0df1bef7f5e5086340a8ba789027bc3d650c
606-
aws-sdk-core (3.239.2) sha256=a6801845ee0bdb061a3f9fb488136f3a585d51ff05b77063a9e228c9539cf239
606+
aws-sdk-core (3.240.0) sha256=86b63890525caaf56702972e2669b30ec89230c2b45f12c88290ee678d8d189e
607607
aws-sdk-kms (1.118.0) sha256=c9c751596d4f1502adac857c90010f00a9a52370b78e170acb198af7fa716fbd
608-
aws-sdk-s3 (1.205.0) sha256=dcffbd495dfd2d6ba5bc86e7b0c58facb982aae298b328e5f199ece38dea2ee9
608+
aws-sdk-s3 (1.208.0) sha256=3fce13500171bae425ffb0fd30f4caef081c5e9780714ac3484b48e0a1797d6d
609609
aws-sdk-sesv2 (1.88.0) sha256=e227bba17217613a99b22524eebea6ea91b7d7407631e4734e07f5bafb9c985d
610610
aws-sdk-sqs (1.107.0) sha256=437ab2b6fdb23eec551038a1c79d9e686a222fef7e38d4318e93b9a74295b50e
611611
aws-sdk-sts (1.12.0) sha256=9bbd64223dd2423540291d9faaac4a169ace8cfe123b1075c9a127fcd65e061f
@@ -614,7 +614,7 @@ CHECKSUMS
614614
axe-core-rspec (4.11.0) sha256=3c3e3ef3863d9f5243e056b7da328932c0b6682dda299bb4bd74d760641486d7
615615
axiom-types (0.1.1) sha256=c1ff113f3de516fa195b2db7e0a9a95fd1b08475a502ff660d04507a09980383
616616
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
617-
bigdecimal (3.3.1) sha256=eaa01e228be54c4f9f53bf3cc34fe3d5e845c31963e7fcc5bedb05a4e7d52218
617+
bigdecimal (4.0.1) sha256=8b07d3d065a9f921c80ceaea7c9d4ae596697295b584c296fe599dd0ad01c4a7
618618
bootsnap (1.19.0) sha256=d3e54558c1a9ea10cb095eb1eb8e921ae83fd4d5764b8809f63aec18ce9f60b5
619619
brakeman (7.1.1) sha256=629426b5d6496c75e3ffa2299e1ab1bb3ba721fea03d8808414c083660439498
620620
builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div class="govuk-grid-row">
2+
<div class="<%= full_width? ? 'govuk-grid-column-full' : 'govuk-grid-column-two-thirds-from-desktop' %>">
3+
<% if rows %>
4+
<%= govuk_summary_list(rows: rows) %>
5+
<% end %>
6+
</div>
7+
</div>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
module CheckYourAnswersComponent
2+
class View < ApplicationComponent
3+
def initialize(form:, steps:, mode:)
4+
@form = form
5+
@steps = steps
6+
@mode = mode
7+
super()
8+
end
9+
10+
def rows
11+
@rows ||= @steps.flat_map { |step| step_to_row(step) }
12+
end
13+
14+
def full_width?
15+
@steps.any? { |step| step.question.has_long_answer? }
16+
end
17+
18+
private
19+
20+
def step_to_row(step)
21+
question_name = step.question.question_text_for_check_your_answers
22+
row = row(question_name:, answer: step.show_answer, change_link: change_link(step))
23+
return row unless is_selection_with_none_of_the_above_answer?(step)
24+
25+
none_of_the_above_answer_row = none_of_the_above_answer_row(step)
26+
[row, none_of_the_above_answer_row]
27+
end
28+
29+
def none_of_the_above_answer_row(step)
30+
question_name = step.question.none_of_the_above_question_text
31+
answer = step.question.none_of_the_above_answer
32+
row(question_name:, answer:, change_link: change_link(step))
33+
end
34+
35+
def row(question_name:, answer:, change_link:)
36+
{
37+
key: { text: helpers.sanitize(question_name) },
38+
value: { text: answer_text(answer) },
39+
actions: [{ text: I18n.t("govuk_components.govuk_summary_list.change"), href: change_link, visually_hidden_text: helpers.strip_tags(question_name) }],
40+
}
41+
end
42+
43+
def is_selection_with_none_of_the_above_answer?(step)
44+
step.question.try(:show_none_of_the_above_question?)
45+
end
46+
47+
def answer_text(answer)
48+
HtmlMarkdownSanitizer.new.format_paragraphs(answer.presence || I18n.t("form.check_your_answers.not_completed"))
49+
end
50+
51+
def change_link(step)
52+
if step.repeatable? && step.show_answer.present?
53+
change_add_another_answer_path(mode: @mode, form_id: @form.id, form_slug: @form.form_slug, page_slug: step.id)
54+
else
55+
form_change_answer_path(mode: @mode, form_id: @form.id, form_slug: @form.form_slug, page_slug: step.id)
56+
end
57+
end
58+
end
59+
end

app/components/question/base.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
module Question
22
class Base < ApplicationComponent
3-
attr_accessor :form_builder, :question, :extra_question_text_suffix, :hint_id
3+
attr_accessor :form_builder, :question, :mode, :hint_id
44

5-
def initialize(form_builder:, question:, extra_question_text_suffix:)
5+
def initialize(form_builder:, question:, mode:)
66
@form_builder = form_builder
77
@question = question
8-
@extra_question_text_suffix = extra_question_text_suffix
8+
@mode = mode
99
@hint_id = question.hint_text.present? ? "govuk-address-hint" : ""
1010
super()
1111
end
1212

1313
def question_text_with_extra_suffix
14-
[CGI.escapeHTML(question.question_text_with_optional_suffix), extra_question_text_suffix].compact_blank.join(" ").html_safe
14+
helpers.question_text_with_hidden_mode(question.question_text_with_optional_suffix, mode)
1515
end
1616

1717
def hint_text

app/components/question/file_remove_component/view.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
module Question::FileRemoveComponent
44
class View < Question::Base
5-
def initialize(question:, extra_question_text_suffix:, remove_file_url:, remove_input:)
5+
def initialize(question:, mode:, remove_file_url:, remove_input:)
66
@remove_file_url = remove_file_url
77
@remove_input = remove_input
8-
super(form_builder: nil, question:, extra_question_text_suffix:)
8+
super(form_builder: nil, question:, mode:)
99
end
1010
end
1111
end

app/components/question/file_review_component/view.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
module Question::FileReviewComponent
44
class View < Question::Base
5-
def initialize(question:, extra_question_text_suffix:, remove_file_confirmation_url:)
5+
def initialize(question:, mode:, remove_file_confirmation_url:)
66
@remove_file_confirmation_url = remove_file_confirmation_url
7-
super(form_builder: nil, question:, extra_question_text_suffix:)
7+
super(form_builder: nil, question:, mode:)
88
end
99
end
1010
end

app/components/question/selection_component/view.rb

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,10 @@ def none_of_the_above_checkbox
5656

5757
def none_of_the_above_question_field
5858
if question.has_none_of_the_above_question?
59-
form_builder.govuk_text_field :none_of_the_above_answer, label: { text: none_of_the_above_question_text }, width: "three-quarters"
59+
form_builder.govuk_text_field :none_of_the_above_answer, label: { text: question.none_of_the_above_question_text }, width: "three-quarters"
6060
end
6161
end
6262

63-
def none_of_the_above_question_text
64-
none_of_the_above_question = question.answer_settings.none_of_the_above_question
65-
return none_of_the_above_question.question_text if none_of_the_above_question.is_optional != "true"
66-
67-
"#{none_of_the_above_question.question_text} #{I18n.t('page.optional')}"
68-
end
69-
7063
def radio_button_options
7164
question.answer_settings.selection_options.map.with_index do |option, index|
7265
form_builder.govuk_radio_button :selection, option.name, label: { text: option.name }, link_errors: index.zero?

app/controllers/forms/check_your_answers_controller.rb

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -57,43 +57,18 @@ def submit_answers
5757

5858
private
5959

60-
def step_to_row(step)
61-
question_name = step.question.question_text_for_check_your_answers
62-
{
63-
key: { text: helpers.sanitize(question_name) },
64-
value: { text: step.show_answer },
65-
actions: [{ text: I18n.t("govuk_components.govuk_summary_list.change"), href: change_link(step), visually_hidden_text: helpers.strip_tags(question_name) }],
66-
}
67-
end
68-
69-
def change_link(step)
70-
return change_add_another_answer_path(@form.id, @form.form_slug, step.id) if step.repeatable? && step.show_answer.present?
71-
72-
form_change_answer_path(@form.id, @form.form_slug, step.id)
73-
end
74-
75-
def check_your_answers_rows
76-
current_context.completed_steps.map { |step| step_to_row(step) }
77-
end
78-
79-
def answers_need_full_width
80-
@full_width = current_context.completed_steps.any? { |step| step.question.has_long_answer? }
81-
end
82-
8360
def email_confirmation_input_params
8461
params.require(:email_confirmation_input).permit(:send_confirmation, :confirmation_email_address, :confirmation_email_reference)
8562
end
8663

8764
def setup_check_your_answers
8865
@back_link = back_link
89-
@rows = check_your_answers_rows
66+
@steps = current_context.completed_steps
9067
@form_submit_path = form_submit_answers_path
9168

9269
unless mode.preview?
9370
EventLogger.log_form_event("check_answers")
9471
end
95-
96-
answers_need_full_width
9772
end
9873

9974
def back_link

app/helpers/application_helper.rb

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,8 @@ def form_title(page_name:, form_name:, mode:, error: false)
1919
"#{t('page_titles.error_prefix') if error}#{page_name}#{mode_string} - #{form_name}"
2020
end
2121

22-
def hidden_text_mode(mode)
23-
return "" unless mode.preview?
24-
25-
mode_name = if mode.preview_draft?
26-
"draft"
27-
elsif mode.preview_archived?
28-
"archived"
29-
elsif mode.preview_live?
30-
"live"
31-
end
32-
"<span class='govuk-visually-hidden'>&nbsp;#{t("page.#{mode_name}_preview".to_s)}</span>".html_safe
22+
def question_text_with_hidden_mode(question_text, mode)
23+
[CGI.escapeHTML(question_text), hidden_text_mode(mode)].compact_blank.join(" ").html_safe
3324
end
3425

3526
def format_paragraphs(text)
@@ -70,4 +61,17 @@ def init_autocomplete_script
7061
def join_title_elements(title_elements)
7162
title_elements.compact.join(" – ")
7263
end
64+
65+
def hidden_text_mode(mode)
66+
return "" unless mode.preview?
67+
68+
mode_name = if mode.preview_draft?
69+
"draft"
70+
elsif mode.preview_archived?
71+
"archived"
72+
elsif mode.preview_live?
73+
"live"
74+
end
75+
"<span class='govuk-visually-hidden'>&nbsp;#{t("page.#{mode_name}_preview")}</span>".html_safe
76+
end
7377
end

app/models/question/selection.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,21 @@ def autocomplete_component?
5555
answer_settings.selection_options.count > 30
5656
end
5757

58+
def show_none_of_the_above_question?
59+
has_none_of_the_above_question? && none_of_the_above_selected?
60+
end
61+
5862
def has_none_of_the_above_question?
5963
none_of_the_above_question.present?
6064
end
6165

66+
def none_of_the_above_question_text
67+
return nil unless has_none_of_the_above_question?
68+
return none_of_the_above_question.question_text if none_of_the_above_question.is_optional != "true"
69+
70+
"#{none_of_the_above_question.question_text} #{I18n.t('page.optional')}"
71+
end
72+
6273
private
6374

6475
def clear_none_of_the_above_answer_if_not_selected

0 commit comments

Comments
 (0)