@@ -24,6 +24,19 @@ def values_with_welsh_content
2424 rows
2525 end
2626
27+ def values_with_welsh_content2
28+ rows = [ ]
29+
30+ rows . push ( page_heading_row ) if @step . respond_to? ( :page_heading ) && @step . page_heading . present?
31+ rows . push ( guidance_markdown_row ) if @step . respond_to? ( :guidance_markdown ) && @step . guidance_markdown . present?
32+ rows . push ( question_text_row ) if @step . page_heading . present?
33+ rows . push ( hint_row ) if @step . hint_text . present?
34+ rows . concat ( selection_rows ) if @step . answer_type == "selection"
35+ rows . concat ( route_rows ) if @step . routing_conditions . present?
36+
37+ rows
38+ end
39+
2740 def untranslated_content
2841 return text_row if @step . answer_type == "text"
2942 return date_row if @step . answer_type == "date"
@@ -37,7 +50,7 @@ def route_content
3750 conditions_for_step . map do |condition |
3851 welsh_condition = welsh_condition_from_id ( condition . id )
3952 condition_data = {
40- answer_value : condition . answer_value ,
53+ answer_value : format_answer_value ( condition . answer_value ) ,
4154 answer_value_cy : welsh_answer_value ( welsh_condition ) ,
4255 goto_page : print_goto_page ( condition , @steps ) ,
4356 goto_page_cy : print_goto_page ( welsh_condition , @welsh_steps ) ,
@@ -118,6 +131,115 @@ def selection_rows
118131 rows
119132 end
120133
134+ def route_rows
135+ [ [ I18n . t ( "page_conditions.route2" , count : number_of_routes ) , routes_value ( @step . routing_conditions ) , welsh_routes_value ( @step . routing_conditions ) ] ]
136+ end
137+
138+ def number_of_routes
139+ if @step . routing_conditions . length == 1
140+ 1
141+ else
142+ answer_value_groups ( @step . routing_conditions ) . length
143+ end
144+ end
145+
146+ def routes_value ( conditions )
147+ if conditions . first . answer_value . present?
148+ print_routes ( conditions )
149+ else
150+ print_unconditional_route ( conditions . first )
151+ end
152+ end
153+
154+ def welsh_routes_value ( conditions )
155+ if conditions . first . answer_value . present?
156+ print_welsh_routes ( conditions )
157+ else
158+ print_welsh_unconditional_route ( conditions . first )
159+ end
160+ end
161+
162+ def print_routes ( conditions )
163+ answer_value_groups = answer_value_groups ( conditions )
164+ answer_value_groups . map { |goto_page_id , condition_group |
165+ if goto_page_id . nil?
166+ caption = content_tag ( :p , I18n . t ( "page_conditions.go_to_the_end" ) )
167+ else
168+ goto_question = @steps . find { |page | page . id == condition_group . first . goto_page_id }
169+ goto_page_question_text = ActionController ::Base . helpers . sanitize ( goto_question . question_text )
170+ goto_page_question_number = @steps . find_index ( goto_question ) + 1
171+
172+ caption = content_tag ( :p , I18n . t ( "page_conditions.go_to_page" , goto_page_question_number :, goto_page_question_text :) )
173+ end
174+
175+ answer_values = condition_group . map { |condition | "‘#{ format_answer_value ( condition . answer_value ) } ’" }
176+ formatted_list = html_unordered_list2 ( answer_values )
177+ safe_join ( [ caption , formatted_list ] )
178+ } . join . html_safe
179+ end
180+
181+ def print_welsh_routes ( conditions )
182+ answer_value_groups = answer_value_groups ( conditions )
183+ answer_value_groups . map { |goto_page_id , condition_group |
184+ if goto_page_id . nil?
185+ caption = content_tag ( :p , I18n . t ( "page_conditions.go_to_the_end" ) )
186+ else
187+ welsh_goto_question = welsh_step_from_id ( condition_group . first . goto_page_id )
188+ welsh_goto_page_question_text = ActionController ::Base . helpers . sanitize ( welsh_goto_question . question_text )
189+ goto_page_question_number = @welsh_steps . find_index ( welsh_goto_question ) + 1
190+
191+ caption = content_tag ( :p , I18n . t ( "page_conditions.go_to_page" , goto_page_question_number :, goto_page_question_text : welsh_goto_page_question_text ) )
192+ end
193+
194+ answer_values = condition_group . map do |condition |
195+ welsh_condition = welsh_condition_from_id ( condition . id )
196+ "‘#{ format_answer_value ( welsh_answer_value2 ( welsh_condition ) ) } ’"
197+ end
198+
199+ formatted_list = html_unordered_list2 ( answer_values )
200+ safe_join ( [ caption , formatted_list ] )
201+ } . join . html_safe
202+ end
203+
204+ def print_unconditional_route ( condition )
205+ if condition . skip_to_end
206+ I18n . t ( "page_conditions.unconditional_skip_to_end_of_form" ) . html_safe
207+ else
208+ goto_question = @steps . find { |page | page . id == condition . goto_page_id }
209+ goto_page_question_text = ActionController ::Base . helpers . sanitize ( goto_question . question_text )
210+ goto_page_question_number = @steps . find_index ( goto_question ) + 1
211+
212+ I18n . t ( "page_conditions.unconditional_go_to_page" , goto_page_question_number :, goto_page_question_text :) . html_safe
213+ end
214+ end
215+
216+ def print_welsh_unconditional_route ( condition )
217+ if condition . skip_to_end
218+ I18n . t ( "page_conditions.unconditional_skip_to_end_of_form" ) . html_safe
219+ else
220+ welsh_goto_question = welsh_step_from_id ( condition . goto_page_id )
221+ welsh_goto_page_question_text = ActionController ::Base . helpers . sanitize ( welsh_goto_question . question_text )
222+ goto_page_question_number = @welsh_steps . find_index ( welsh_goto_question ) + 1
223+
224+ I18n . t ( "page_conditions.unconditional_go_to_page" , goto_page_question_number :, goto_page_question_text : welsh_goto_page_question_text ) . html_safe
225+ end
226+ end
227+
228+ def answer_value_groups ( conditions )
229+ answer_order = @step . answer_settings &.selection_options &.map ( &:value ) || [ ]
230+
231+ conditions . group_by ( &:goto_page_id ) . map { |goto_page_id , condition_group |
232+ goto_page_position = @steps . find_index { |page | page . id == goto_page_id } + 1 unless goto_page_id . nil?
233+ sorted_condition_group = condition_group . in_order_of ( :answer_value , answer_order , filter : false )
234+ [ goto_page_position , sorted_condition_group ]
235+ } . sort_by { |goto_page_position , _ | goto_page_position || Float ::INFINITY }
236+ end
237+
238+ def format_answer_value ( answer_value )
239+ answer_value = I18n . t ( "page_conditions.none_of_the_above" ) if answer_value == Condition ::NONE_OF_THE_ABOVE
240+ ActionController ::Base . helpers . sanitize ( answer_value )
241+ end
242+
121243 def selection_answer_type
122244 return I18n . t ( "step_summary_card.selection_type.default" ) unless @step . answer_settings . only_one_option == "true"
123245
@@ -128,7 +250,7 @@ def selection_list
128250 return @step . show_selection_options unless @step . answer_settings . selection_options . length >= 1
129251
130252 options = @step . answer_settings . selection_options . map ( &:name )
131- options << I18n . t ( "step_summary_card.selection_type.none_of_the_above" ) if @step . is_optional?
253+ options << I18n . t ( "step_summary_card.selection_type.none_of_the_above.en " ) if @step . is_optional?
132254 formatted_list = html_unordered_list ( options )
133255
134256 if options . length > 10
@@ -137,7 +259,7 @@ def selection_list
137259 . with_content ( formatted_list )
138260 . call
139261 else
140- caption = content_tag ( :p , I18n . t ( "page_settings_summary.selection.options_count" , number_of_options : options . length ) , class : "govuk-body-s" )
262+ caption = content_tag ( :p , I18n . t ( "page_settings_summary.selection.options_count" , number_of_options : options . length ) )
141263 safe_join ( [ caption , formatted_list ] )
142264 end
143265 end
@@ -146,7 +268,7 @@ def selection_list_cy
146268 return welsh_step . show_selection_options unless welsh_step . answer_settings . selection_options . length >= 1
147269
148270 options = welsh_step . answer_settings . selection_options . map ( &:name )
149- options << I18n . t ( "step_summary_card.selection_type.none_of_the_above" ) if welsh_step . is_optional?
271+ options << I18n . t ( "step_summary_card.selection_type.none_of_the_above.cy " ) if welsh_step . is_optional?
150272 formatted_list = html_unordered_list ( options )
151273
152274 if options . length > 10
@@ -155,7 +277,7 @@ def selection_list_cy
155277 . with_content ( formatted_list )
156278 . call
157279 else
158- caption = content_tag ( :p , I18n . t ( "page_settings_summary.selection.options_count" , number_of_options : options . length ) , class : "govuk-body-s" )
280+ caption = content_tag ( :p , I18n . t ( "page_settings_summary.selection.options_count" , number_of_options : options . length ) )
159281 safe_join ( [ caption , formatted_list ] )
160282 end
161283 end
@@ -245,6 +367,10 @@ def html_unordered_list(list_items)
245367 content_tag ( :ul , html_list_item ( list_items ) , class : [ "govuk-list" , "govuk-list--bullet" ] )
246368 end
247369
370+ def html_unordered_list2 ( list_items )
371+ content_tag ( :ul , html_list_item ( list_items ) , class : [ "govuk-list" , "govuk-list--bullet govuk-!-static-margin-bottom-4" ] )
372+ end
373+
248374 def html_list_item ( item )
249375 item . map { |i | content_tag ( :li , i ) } . join . html_safe
250376 end
@@ -293,6 +419,16 @@ def print_check_page(condition, steps)
293419 def welsh_answer_value ( welsh_condition )
294420 return nil if welsh_condition . answer_value . blank?
295421
422+ return I18n . t ( "step_summary_card.selection_type.none_of_the_above.cy" ) if welsh_condition . answer_value == Condition ::NONE_OF_THE_ABOVE
423+
296424 @welsh_steps . find { |step | step . id == welsh_condition . check_page_id } . answer_settings . selection_options . find { |option | option . value == welsh_condition . answer_value } . name
297425 end
426+
427+ def welsh_answer_value2 ( welsh_condition )
428+ return nil if welsh_condition . answer_value . blank?
429+
430+ return I18n . t ( "step_summary_card.selection_type.none_of_the_above.cy" ) if welsh_condition . answer_value == Condition ::NONE_OF_THE_ABOVE
431+
432+ @welsh_steps . find { |step | step . id == welsh_condition . routing_page_id } . answer_settings . selection_options . find { |option | option . value == welsh_condition . answer_value } . name
433+ end
298434end
0 commit comments