Skip to content

Commit b963d9e

Browse files
authored
Merge pull request #3959 from nhsuk/consent-cards-redesign
Update design of consent responses
2 parents 3f9f924 + bea1841 commit b963d9e

15 files changed

Lines changed: 389 additions & 329 deletions

app/assets/stylesheets/_card.scss

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
}
5050
}
5151

52+
&--offset {
53+
background-color: rgba($color_nhsuk-grey-5, 0.5);
54+
}
55+
5256
&--data {
5357
display: flex;
5458

@@ -132,3 +136,22 @@
132136
color: $nhsuk-link-active-color;
133137
}
134138
}
139+
140+
.app-card--compact {
141+
@include nhsuk-responsive-margin(3, "bottom");
142+
143+
.app-button-group {
144+
gap: nhsuk-spacing(2);
145+
margin-bottom: nhsuk-spacing(1);
146+
margin-top: nhsuk-spacing(-4);
147+
}
148+
149+
.nhsuk-card__heading {
150+
@include nhsuk-responsive-margin(1, "bottom");
151+
}
152+
153+
.nhsuk-card__content {
154+
@include nhsuk-responsive-padding(4);
155+
@include nhsuk-responsive-padding(3, "bottom");
156+
}
157+
}

app/components/app_card_component.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def initialize(
3434
secondary: false,
3535
data: false,
3636
patient: false,
37+
compact: false,
3738
filters: false,
3839
section: false
3940
)
@@ -44,10 +45,11 @@ def initialize(
4445
@secondary = secondary
4546
@data = data
4647
@patient = patient
48+
@compact = compact
4749
@filters = filters
4850
@section = section
4951

50-
@feature = (colour.present? && !data) || filters
52+
@feature = (colour.present? && !data && !compact) || filters
5153
end
5254

5355
private
@@ -64,6 +66,7 @@ def card_classes
6466
("nhsuk-card--secondary" if @secondary),
6567
("app-card--data" if @data),
6668
("app-card--patient" if @patient),
69+
("app-card--compact" if @compact),
6770
("app-filters" if @filters)
6871
].compact.join(" ")
6972
end
@@ -80,7 +83,7 @@ def content_classes
8083
def heading_size
8184
if @data
8285
"xs"
83-
elsif @feature || @secondary || @patient
86+
elsif @feature || @secondary || @patient || @compact
8487
"s"
8588
else
8689
"m"
Lines changed: 46 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,64 @@
11
# frozen_string_literal: true
22

33
class AppConsentCardComponent < ViewComponent::Base
4-
def initialize(patient_session:, programme:)
4+
def initialize(consent, session:)
55
super
66

7-
@patient_session = patient_session
8-
@programme = programme
7+
@consent = consent
8+
@session = session
99
end
1010

11-
attr_reader :patient_session, :programme
12-
13-
delegate :patient, :session, to: :patient_session
14-
15-
def colour
16-
I18n.t(status, scope: %i[status consent colour])
17-
end
18-
19-
def heading
20-
"#{programme.name}: #{I18n.t(status, scope: %i[status consent label])}"
11+
def call
12+
render AppCardComponent.new(**card_options) do |card|
13+
card.with_heading { heading }
14+
govuk_summary_list(rows:)
15+
end
2116
end
2217

23-
def latest_consent_request
24-
@latest_consent_request ||=
25-
patient
26-
.consent_notifications
27-
.request
28-
.has_programme(programme)
29-
.order(sent_at: :desc)
30-
.first
31-
end
18+
private
3219

33-
def consent_status
34-
@consent_status ||= patient.consent_status(programme:)
35-
end
20+
attr_reader :consent, :session
3621

37-
def vaccination_status
38-
@vaccination_status ||= patient.vaccination_status(programme:)
39-
end
22+
delegate :patient, :programme, to: :consent
4023

41-
def can_send_consent_request?
42-
consent_status.no_response? && patient.send_notifications? &&
43-
session.open_for_consent? && patient.parents.any?
24+
def link_to
25+
session_patient_programme_consent_path(session, patient, programme, consent)
4426
end
4527

46-
def who_refused
47-
consents =
48-
patient.consents.where(programme:).not_invalidated.includes(:parent)
28+
def card_options = { link_to:, colour: "offset", compact: true }
4929

50-
ConsentGrouper
51-
.call(consents, programme:)
52-
.find(&:response_refused?)
53-
&.who_responded
30+
def heading
31+
if consent.via_self_consent?
32+
consent.who_responded
33+
else
34+
"#{consent.name} (#{consent.who_responded})"
35+
end
5436
end
5537

56-
delegate :status, to: :consent_status
38+
def rows
39+
[
40+
if (phone = consent.parent&.phone).present?
41+
{ key: { text: "Phone number" }, value: { text: phone } }
42+
end,
43+
if (email = consent.parent&.email).present?
44+
{ key: { text: "Email address" }, value: { text: email } }
45+
end,
46+
{
47+
key: {
48+
text: "Date"
49+
},
50+
value: {
51+
text: consent.responded_at.to_fs(:long)
52+
}
53+
},
54+
{
55+
key: {
56+
text: "Decision"
57+
},
58+
value: {
59+
text: helpers.consent_status_tag(consent)
60+
}
61+
}
62+
].compact
63+
end
5764
end

app/components/app_consent_table_component.html.erb

Lines changed: 0 additions & 30 deletions
This file was deleted.

app/components/app_consent_table_component.rb

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,21 @@
11
# frozen_string_literal: true
22

33
class AppHealthAnswersCardComponent < ViewComponent::Base
4-
erb_template <<-ERB
5-
<%= render AppCardComponent.new do |card| %>
6-
<% card.with_heading { @heading } %>
7-
<dl class="nhsuk-summary-list app-summary-list--full-width">
8-
<% health_answers.each do |question, answers| %>
9-
<div class="nhsuk-summary-list__row">
10-
<dt class="nhsuk-summary-list__key">
11-
<%= question %>
12-
</dt>
13-
<dd class="nhsuk-summary-list__value">
14-
<% answers.each do |answer| %>
15-
<p>
16-
<%= answer[:responder] %> responded: <%= answer[:answer].humanize %><% if answer[:notes].present? %>:<% end %>
17-
</p>
18-
<% if answer[:notes].present? %>
19-
<blockquote><%= answer[:notes] %></blockquote>
20-
<% end %>
21-
<% end %>
22-
</dd>
23-
</div>
24-
<% end %>
25-
</dl>
26-
<% end %>
27-
ERB
28-
294
def initialize(objects, heading: "Answers to health questions")
305
super
316

327
@objects = objects.is_a?(Array) ? objects : [objects]
338
@heading = heading
349
end
3510

36-
def health_answers
37-
ConsolidatedHealthAnswers.new(@objects).to_h
11+
def call
12+
render AppCardComponent.new do |card|
13+
card.with_heading { heading }
14+
render AppHealthAnswersSummaryComponent.new(objects)
15+
end
3816
end
17+
18+
private
19+
20+
attr_reader :objects, :heading
3921
end
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# frozen_string_literal: true
2+
3+
class AppHealthAnswersSummaryComponent < ViewComponent::Base
4+
erb_template <<-ERB
5+
<dl class="nhsuk-summary-list app-summary-list--full-width">
6+
<% health_answers.each do |question, answers| %>
7+
<div class="nhsuk-summary-list__row">
8+
<dt class="nhsuk-summary-list__key">
9+
<%= question %>
10+
</dt>
11+
<dd class="nhsuk-summary-list__value">
12+
<% answers.each do |answer| %>
13+
<p>
14+
<%= answer[:responder] %> responded: <%= answer[:answer].humanize %><% if answer[:notes].present? %>:<% end %>
15+
</p>
16+
<% if answer[:notes].present? %>
17+
<blockquote><%= answer[:notes] %></blockquote>
18+
<% end %>
19+
<% end %>
20+
</dd>
21+
</div>
22+
<% end %>
23+
</dl>
24+
ERB
25+
26+
def initialize(objects)
27+
super
28+
29+
@objects = objects.is_a?(Array) ? objects : [objects]
30+
end
31+
32+
private
33+
34+
attr_reader :objects
35+
36+
def health_answers
37+
ConsolidatedHealthAnswers.new(objects).to_h
38+
end
39+
end

app/components/app_consent_card_component.html.erb renamed to app/components/app_patient_session_consent_component.html.erb

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
<h2 class="nhsuk-heading-m">Consent</h2>
2+
13
<%= render AppCardComponent.new(colour:) do |card| %>
24
<% card.with_heading { heading } %>
35

@@ -36,5 +38,19 @@
3638
<%= render AppGillickAssessmentComponent.new(patient_session:, programme:) %>
3739
<% end %>
3840

39-
<%= render AppConsentTableComponent.new(patient_session:, programme:) %>
41+
<% if consents.any? %>
42+
<h3 class="nhsuk-heading-s">Consent responses</h3>
43+
44+
<% consents.each do |consent| %>
45+
<%= render AppConsentCardComponent.new(consent, session:) %>
46+
<% end %>
47+
<% end %>
48+
49+
<% if show_health_answers? %>
50+
<hr class="nhsuk-section-break nhsuk-section-break--visible nhsuk-section-break--l">
51+
52+
<h3 class="nhsuk-heading-s">All answers to health questions</h3>
53+
54+
<%= render AppHealthAnswersSummaryComponent.new(grouped_consents) %>
55+
<% end %>
4056
<% end %>

0 commit comments

Comments
 (0)