|
1 | 1 | # frozen_string_literal: true
|
2 | 2 |
|
3 | 3 | class AppParentSummaryComponent < ViewComponent::Base
|
4 |
| - def initialize( |
5 |
| - parent_relationship:, |
6 |
| - change_links: {}, |
7 |
| - show_name_and_relationship: false |
8 |
| - ) |
| 4 | + def initialize(parent_relationship:, change_links: {}) |
9 | 5 | super
|
10 | 6 |
|
11 | 7 | @parent_relationship = parent_relationship
|
12 | 8 | @parent = parent_relationship.parent
|
13 | 9 | @patient = parent_relationship.patient
|
14 | 10 |
|
15 | 11 | @change_links = change_links
|
16 |
| - |
17 |
| - @show_name_and_relationship = show_name_and_relationship |
18 | 12 | end
|
19 | 13 |
|
20 | 14 | def call
|
21 | 15 | govuk_summary_list do |summary_list|
|
22 |
| - if @show_name_and_relationship |
23 |
| - summary_list.with_row do |row| |
24 |
| - row.with_key { "Name" } |
| 16 | + summary_list.with_row do |row| |
| 17 | + row.with_key { "Name" } |
25 | 18 |
|
26 |
| - if @parent.full_name.present? |
27 |
| - row.with_value { @parent.full_name } |
28 |
| - if (href = @change_links[:name]) |
29 |
| - row.with_action( |
30 |
| - text: "Change", |
31 |
| - href:, |
32 |
| - visually_hidden_text: "name" |
33 |
| - ) |
34 |
| - end |
35 |
| - elsif (href = @change_links[:name]) |
36 |
| - row.with_value { govuk_link_to("Add name", href) } |
37 |
| - else |
38 |
| - row.with_value { "Not provided" } |
| 19 | + if @parent.full_name.present? |
| 20 | + row.with_value { @parent.full_name } |
| 21 | + if (href = @change_links[:name]) |
| 22 | + row.with_action(text: "Change", href:, visually_hidden_text: "name") |
39 | 23 | end
|
| 24 | + elsif (href = @change_links[:name]) |
| 25 | + row.with_value { govuk_link_to("Add name", href) } |
| 26 | + else |
| 27 | + row.with_value { "Not provided" } |
40 | 28 | end
|
| 29 | + end |
41 | 30 |
|
42 |
| - summary_list.with_row do |row| |
43 |
| - row.with_key { "Relationship" } |
44 |
| - row.with_value { @parent_relationship.label } |
45 |
| - if (href = @change_links[:relationship]) |
46 |
| - row.with_action( |
47 |
| - text: "Change", |
48 |
| - href:, |
49 |
| - visually_hidden_text: "relationship" |
50 |
| - ) |
51 |
| - end |
| 31 | + summary_list.with_row do |row| |
| 32 | + row.with_key { "Relationship" } |
| 33 | + row.with_value { @parent_relationship.label } |
| 34 | + if (href = @change_links[:relationship]) |
| 35 | + row.with_action( |
| 36 | + text: "Change", |
| 37 | + href:, |
| 38 | + visually_hidden_text: "relationship" |
| 39 | + ) |
52 | 40 | end
|
53 | 41 | end
|
54 | 42 |
|
|
0 commit comments