FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Add post and phone checkboxes to email-prefs (#19414) · devhttps/frontend@0f14485 · GitHub

Commit 0f14485

Browse files
authored andcommitted
Add post and phone checkboxes to email-prefs (guardian#19414)
* Add post and phone checkboxes to email-prefs * fix horizontal line * Add Optout Boxes to email prefs and consent journeys * Add Optout Boxes to email prefs and consent journeys * Make opt outs a consent * Final Wording changes, updated identity model library * Do not select opt-outs when selecting all * Upgrade to underscore optouts * Update non electronic consent preamble * Typo: we let you know by post or telephone, not post or a telphone
1 parent 91c05ce commit 0f14485

13 files changed

Lines changed: 161 additions & 75 deletions

File tree

‎identity/app/controllers/editprofile/ConsentsJourney.scala‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ trait ConsentsJourney
4848
returnUrlForm.bindFromRequest.fold(
4949
formWithErrors => Future.successful(BadRequest(Json.toJson(formWithErrors.errors.toList))),
5050
returnUrl => {
51-
val newConsents = if (request.user.consents.isEmpty) Consent.defaultConsents else request.user.consents
51+
val newConsents = if (request.user.consents.isEmpty) Consent.defaultConsents else Consent.addNewDefaults(request.user.consents)
5252
identityApiClient.saveUser(
5353
request.user.id,
5454
UserUpdateDTO(consents = Some(newConsents), statusFields = Some(StatusFields(hasRepermissioned = Some(true)))),

‎identity/app/form/PrivacyMapping.scala‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class PrivacyMapping extends UserFormMapping[PrivacyFormData] {
3434
protected def toUserFormData(userDO: User): PrivacyFormData =
3535
PrivacyFormData(userDO)
3636

37-
protected lazy val idapiErrorContextToFormFieldKeyMap = Map(
37+
protected lazy val idapiErrorContextToFormFieldKeyMap = Map(
3838
"statusFields.receiveGnmMarketing" -> "receiveGnmMarketing",
3939
"statusFields.receive3rdPartyMarketing" -> "receive3rdPartyMarketing",
4040
"statusFields.allowThirdPartyProfiling" -> "allowThirdPartyProfiling"

‎identity/app/utils/ConsentOrder.scala‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ object ConsentOrder {
1313
"holidays",
1414
"events",
1515
"offers",
16-
"post",
17-
"phone",
16+
"post_optout",
17+
"phone_optout",
1818
"sms"
1919
)
2020

@@ -27,7 +27,11 @@ object ConsentOrder {
2727
*/
2828
def userWithOrderedConsents(userDO: User, consentHint: Option[String]): User = {
2929
val consentsToReorder =
30-
if (userDO.consents.isEmpty) Consent.defaultConsents else userDO.consents
30+
if (userDO.consents.isEmpty)
31+
Consent.defaultConsents
32+
else
33+
// handle any default consents that may have been added since this user was created.
34+
Consent.addNewDefaults(userDO.consents)
3135

3236
userDO.copy(consents = hintedConsents(orderedConsents(consentsToReorder), consentHint))
3337
}

‎identity/app/views/consentJourney.scala.html‎

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -48,28 +48,28 @@ <h3 class="manage-account__switch-title">&nbsp;</h3>
4848
}
4949
}
5050

51-
@channelStepContent = {
52-
<form action="@idUrlBuilder.buildUrl("/privacy/edit", idRequest)" class="js-manage-account__check-allCheckbox__ignore" role="main" method="post">
53-
@views.html.helper.CSRF.formField
54-
<div class="manage-account__switches manage-account__switches--single-column">
55-
<ul>
56-
@helper.repeatWithIndex(forms.privacyForm("consents"), min=1) { (consentField, index) =>
57-
@if(isSmsChannel(consentField, user)) {
58-
<li>
59-
@fragments.consentSwitch(consentField = consentField, skin = skin)(messages)
60-
</li>
61-
}
62-
}
63-
</ul>
64-
</div>
65-
</form>
51+
@smsStepContent = {
52+
@views.html.profile.smsConsent(idUrlBuilder, idRequest, forms.privacyForm, user)(request, messages)
53+
}
54+
55+
@smsStep = @{
56+
ConsentStep(
57+
name = "sms",
58+
title = "SMS updates",
59+
content = smsStepContent,
60+
show = true
61+
)
62+
}
63+
64+
@nonElectronicOptOutContent = {
65+
@views.html.profile.nonElectronicOptOut(idUrlBuilder, idRequest, forms.privacyForm, user)(request, messages)
6666
}
6767

68-
@channelStep = @{
68+
@nonElectronicOptOutStep = @{
6969
ConsentStep(
70-
name = "channels",
70+
name = "nonElectronicOptOut",
7171
title = "How else can we get in touch with you?",
72-
content = channelStepContent,
72+
content = nonElectronicOptOutContent,
7373
show = true
7474
)
7575
}
@@ -186,7 +186,8 @@ <h3 class="manage-account__switch-title">&nbsp;</h3>
186186
@defaultJourney = @{List(
187187
emailRepermissionStep,
188188
marketingConsentStep,
189-
channelStep
189+
smsStep,
190+
nonElectronicOptOutStep
190191
)}
191192

192193
@confirmModal = {

‎identity/app/views/fragments/consentSwitch.scala.html‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
@* Product consent switch/checkbox *@
66

7-
@(consentField: Field, highlighted: Boolean = false, skin: Option[String] = None)(messages: play.api.i18n.Messages)
7+
@(consentField: Field, highlighted: Boolean = false, skin: Option[String] = None, boldTitle: Boolean = true)(messages: play.api.i18n.Messages)
88

99
@getConsentText(consentField: Field) = @{
1010
Consent.wording(
@@ -26,5 +26,6 @@
2626
field = consentField("consented"),
2727
extraFields = consentHiddenFormFields,
2828
highlighted = highlighted,
29-
skin = skin
29+
skin = skin,
30+
boldTitle = boldTitle
3031
)(nonInputFields, messages)

‎identity/app/views/fragments/form/switch.scala.html‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
extraFields: List[Html] = Nil,
1111
footer: Option[Html] = None,
1212
highlighted: Boolean = false,
13-
skin: Option[String] = None
13+
skin: Option[String] = None,
14+
boldTitle: Boolean = true
1415
)(implicit handler: views.html.helper.FieldConstructor, messages: play.api.i18n.Messages)
1516

1617

@@ -27,15 +28,24 @@
2728
<div class="manage-account__switch-content">
2829
@fragments.form.checkbox(field, Checkbox(field).args:_*)
2930
<div class="manage-account__switch-checkbox"></div>
30-
<h3 class="manage-account__switch-title">
31-
@title
32-
@if(subheading){
33-
<em>@subheading</em>
34-
}
35-
</h3>
31+
@if(boldTitle) {
32+
<h3 class="manage-account__switch-title">
33+
@title
34+
@if(subheading) {
35+
<em>@subheading</em>
36+
}
37+
</h3>
38+
} else {
39+
<p class="manage-account__switch-copy">
40+
@title
41+
@if(subheading) {
42+
<em>@subheading</em>
43+
}
44+
</p>
45+
}
3646
@if(description) {
3747
<p class="manage-account__switch-copy">
38-
@description
48+
@description.map(Html(_))
3949
</p>
4050
}
4151

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
@import _root_.form.IdFormHelpers.nonInputFields
2+
@import views.support.fragment.ConsentChannel._
3+
@import views.support.fragment.Switch._
4+
5+
@(
6+
idUrlBuilder: services.IdentityUrlBuilder,
7+
idRequest: services.IdentityRequest,
8+
privacyForm: Form[_root_.form.PrivacyFormData],
9+
user: com.gu.identity.model.User,
10+
)(implicit request: RequestHeader, messages: play.api.i18n.Messages)
11+
<form method="post" action="@idUrlBuilder.buildUrl("/privacy/edit", idRequest)" novalidate>
12+
@views.html.helper.CSRF.formField
13+
<div class="manage-account__switches manage-account__switches--single-column js-manage-account__check-allCheckbox__ignore">
14+
15+
<p class="identity-title-explainer">From time to time we’d love to be able to update you about the products and services that you’ve selected above by post or telephone.</p>
16+
<p class="identity-title-explainer">Please tick the boxes below to let us know if you <b>do not wish to receive</b> these.</p>
17+
18+
<ul>
19+
@helper.repeatWithIndex(privacyForm("consents"), min=1){ (consentField, index) =>
20+
@if(isOptOutChannel(consentField, user)) {
21+
<li>
22+
@fragments.consentSwitch(consentField, boldTitle = false)(messages)
23+
</li>
24+
}
25+
}
26+
</ul>
27+
</div>
28+
</form>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
@import _root_.form.IdFormHelpers.nonInputFields
2+
@import views.support.fragment.ConsentChannel._
3+
@import views.support.fragment.Switch._
4+
5+
@(
6+
idUrlBuilder: services.IdentityUrlBuilder,
7+
idRequest: services.IdentityRequest,
8+
privacyForm: Form[_root_.form.PrivacyFormData],
9+
user: com.gu.identity.model.User
10+
)(implicit request: RequestHeader, messages: play.api.i18n.Messages)
11+
<fieldset class="fieldset fieldset--manage-account-noborder">
12+
<div class="fieldset__heading">
13+
<h2 class="form__heading">SMS updates</h2>
14+
</div>
15+
<div class="fieldset__fields">
16+
@views.html.profile.smsConsent(idUrlBuilder, idRequest, privacyForm, user)(request, messages)
17+
</div>
18+
</fieldset>
19+
<fieldset class="fieldset">
20+
<div class="fieldset__heading">
21+
<h2 class="form__heading">How else can we get in touch with you?</h2>
22+
</div>
23+
<div class="fieldset__fields">
24+
@views.html.profile.nonElectronicOptOut(idUrlBuilder, idRequest, privacyForm, user)(request, messages)
25+
</div>
26+
</fieldset>

‎identity/app/views/profile/privacyForm.scala.html‎

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,6 @@ <h2 class="form__heading">What can we tell you about?</h2>
7676
</form>
7777
}
7878

79-
@channelConsentForm = {
80-
<form method="post" action="@idUrlBuilder.buildUrl("/privacy/edit", idRequest)" novalidate>
81-
@views.html.helper.CSRF.formField
82-
<div class="manage-account__switches">
83-
<ul>
84-
@helper.repeatWithIndex(privacyForm("consents"), min=1) { (consentField, index) =>
85-
@if(isSmsChannel(consentField, user)) {
86-
<li>
87-
@fragments.consentSwitch(consentField)(messages)
88-
</li>
89-
}
90-
}
91-
</ul>
92-
</div>
93-
</form>
94-
}
95-
9679
@if(consentsUpdated) {
9780
<div class="form__success">
9881
<h2>Thank you</h2>
@@ -110,19 +93,6 @@ <h2>Thank you</h2>
11093
@* CHANNELS *@
11194
<hr class="manage-account-divider" />
11295

113-
<fieldset class="fieldset fieldset--manage-account-noborder">
114-
<div class="fieldset__heading">
115-
<h2 class="form__heading">How else can we get in touch with you?</h2>
116-
</div>
117-
<div class="fieldset__fields">
118-
@if(channelsProvidedBy(user).nonEmpty) {
119-
@channelConsentForm
120-
} else {
121-
<p class="identity-title-explainer">
122-
Update your <a class="u-underline" href="@idUrlBuilder.buildUrl(controllers.editprofile.routes.EditProfileController.displayAccountForm.url, idRequest)" data-link-name="identity : email : add-channel-info">account details</a> with your phone number to be able to opt in to receiving SMS communications from the Guardian.
123-
</p>
124-
}
125-
</div>
126-
</fieldset>
96+
@views.html.profile.otherChannels(idUrlBuilder, idRequest, privacyForm, user)(request, messages)
12797

12898
@registrationFooter(idRequest, idUrlBuilder)
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
@import _root_.form.IdFormHelpers.nonInputFields
2+
@import views.support.fragment.ConsentChannel._
3+
@import views.support.fragment.Switch._
4+
5+
@(
6+
idUrlBuilder: services.IdentityUrlBuilder,
7+
idRequest: services.IdentityRequest,
8+
privacyForm: Form[_root_.form.PrivacyFormData],
9+
user: com.gu.identity.model.User,
10+
)(implicit request: RequestHeader, messages: play.api.i18n.Messages)
11+
<form method="post" action="@idUrlBuilder.buildUrl("/privacy/edit", idRequest)" novalidate>
12+
@views.html.helper.CSRF.formField
13+
<div class="manage-account__switches manage-account__switches--single-column">
14+
<ul>
15+
@helper.repeatWithIndex(privacyForm("consents"), min=1) { (consentField, index) =>
16+
@if(isSmsChannel(consentField, user)) {
17+
<li>
18+
@fragments.form.switch(
19+
title = "",
20+
subheading = None,
21+
description = Some("I would like to receive updates about the Guardian products and services I’ve selected above <b>by SMS</b> (text messages)."),
22+
behaviour = ConsentSwitch,
23+
field = consentField("consented"),
24+
extraFields = List("actor","id","version","timestamp","privacyPolicyVersion").map { field => fragments.form.hidden(consentField(field)) }
25+
)(nonInputFields, messages)
26+
</li>
27+
}
28+
}
29+
</ul>
30+
</div>
31+
</form>

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL