@salesforcedevs/dw-components 0.64.4 → 0.64.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dw-components",
|
|
3
|
-
"version": "0.64.
|
|
3
|
+
"version": "0.64.5",
|
|
4
4
|
"description": "Lightning web components for https://developer.salesforce.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -23,5 +23,5 @@
|
|
|
23
23
|
"@types/lodash.orderby": "^4.6.7",
|
|
24
24
|
"@types/lodash.uniqby": "^4.7.7"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "8540b5a441e6b34529a1b40693e712a88f4a8a3a"
|
|
27
27
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
>
|
|
7
7
|
<slot name="form-heading">
|
|
8
8
|
<h4 class="newsletter-form-heading dx-text-heading-8">
|
|
9
|
-
Sign up now to receive
|
|
9
|
+
Sign up now to receive developer updates.
|
|
10
10
|
</h4>
|
|
11
11
|
</slot>
|
|
12
12
|
<dx-input
|
|
@@ -52,13 +52,7 @@
|
|
|
52
52
|
required="true"
|
|
53
53
|
></dx-select>
|
|
54
54
|
<template if:true={checkboxTextSet}>
|
|
55
|
-
<
|
|
56
|
-
<dx-checkbox
|
|
57
|
-
class="marketing-checkbox"
|
|
58
|
-
value={marketingText}
|
|
59
|
-
label={marketingText}
|
|
60
|
-
></dx-checkbox>
|
|
61
|
-
</template>
|
|
55
|
+
<p class="marketing-text">{marketingText}</p>
|
|
62
56
|
<p class="legal-text" lwc:dom="manual"></p>
|
|
63
57
|
<template if:true={showLegalCheckbox}>
|
|
64
58
|
<dx-checkbox
|
|
@@ -25,7 +25,6 @@ export default class Form extends LightningElement {
|
|
|
25
25
|
|
|
26
26
|
private showLegalText: boolean = false;
|
|
27
27
|
private showLegalCheckbox: boolean = false;
|
|
28
|
-
private showMarketingCheckbox: boolean = false;
|
|
29
28
|
private legalText: string = "";
|
|
30
29
|
private marketingText: string | null = null;
|
|
31
30
|
private hasRendered: boolean = false;
|
|
@@ -81,12 +80,14 @@ export default class Form extends LightningElement {
|
|
|
81
80
|
e.preventDefault();
|
|
82
81
|
|
|
83
82
|
const allFormElements = Array.from(
|
|
84
|
-
this.template.querySelectorAll(
|
|
83
|
+
this.template.querySelectorAll<HTMLFormElement>(
|
|
84
|
+
"dx-input, dx-select, dx-checkbox"
|
|
85
|
+
)
|
|
85
86
|
);
|
|
86
87
|
|
|
87
88
|
const legalCheckboxElement = this.template.querySelector(
|
|
88
89
|
"dx-checkbox.legal-checkbox"
|
|
89
|
-
);
|
|
90
|
+
) as HTMLFormElement;
|
|
90
91
|
|
|
91
92
|
if (legalCheckboxElement) {
|
|
92
93
|
allFormElements.push(legalCheckboxElement);
|
|
@@ -115,20 +116,13 @@ export default class Form extends LightningElement {
|
|
|
115
116
|
}
|
|
116
117
|
|
|
117
118
|
getFormData() {
|
|
118
|
-
const marketingConsented = this.template.querySelector(
|
|
119
|
-
"dx-checkbox.marketing-checkbox"
|
|
120
|
-
)?.checked;
|
|
121
119
|
const date = new Date().toISOString();
|
|
122
120
|
|
|
123
121
|
return {
|
|
124
|
-
InfoEmail:
|
|
122
|
+
InfoEmail: true,
|
|
125
123
|
"First Name": this.firstName,
|
|
126
124
|
"Last Name": this.lastName,
|
|
127
|
-
Consent:
|
|
128
|
-
? "Explicit"
|
|
129
|
-
: this.showMarketingCheckbox
|
|
130
|
-
? ""
|
|
131
|
-
: "Implied",
|
|
125
|
+
Consent: "Implied",
|
|
132
126
|
"Email Status Update": date,
|
|
133
127
|
email: this.email,
|
|
134
128
|
Country: this.country,
|
|
@@ -140,7 +134,9 @@ export default class Form extends LightningElement {
|
|
|
140
134
|
async sendFormData() {
|
|
141
135
|
const formData = this.getFormData();
|
|
142
136
|
const errorMsg = "Error while subscribing to newsletter";
|
|
143
|
-
const submitButtonEl = this.template.querySelector(
|
|
137
|
+
const submitButtonEl = this.template.querySelector(
|
|
138
|
+
".form-submit"
|
|
139
|
+
) as HTMLFormElement;
|
|
144
140
|
|
|
145
141
|
submitButtonEl.setAttribute("disabled", "true");
|
|
146
142
|
submitButtonEl.textContent = "...Processing request";
|
|
@@ -169,8 +165,10 @@ export default class Form extends LightningElement {
|
|
|
169
165
|
|
|
170
166
|
window.location.assign("/newsletter/success");
|
|
171
167
|
} catch (error) {
|
|
172
|
-
submitButtonEl
|
|
173
|
-
|
|
168
|
+
if (submitButtonEl) {
|
|
169
|
+
submitButtonEl.setAttribute("disabled", "false");
|
|
170
|
+
submitButtonEl.textContent = "Subscribe Now";
|
|
171
|
+
}
|
|
174
172
|
console.error(error);
|
|
175
173
|
}
|
|
176
174
|
}
|
|
@@ -178,7 +176,7 @@ export default class Form extends LightningElement {
|
|
|
178
176
|
handleConsent(countrySelectElement: any) {
|
|
179
177
|
if (this.checkboxTextSet) {
|
|
180
178
|
const countryOptions = countrySelectElement.options.find(
|
|
181
|
-
(option) => option.value === countrySelectElement.value
|
|
179
|
+
(option: any) => option.value === countrySelectElement.value
|
|
182
180
|
);
|
|
183
181
|
|
|
184
182
|
this.setLegalAndMarketingData(countryOptions);
|
|
@@ -200,8 +198,7 @@ export default class Form extends LightningElement {
|
|
|
200
198
|
// Toggle visibility of legal/marketing data
|
|
201
199
|
this.toggleLegalAndMarketingVisibility(
|
|
202
200
|
countryOptions.showLegalText,
|
|
203
|
-
countryOptions.showLegalCheckbox
|
|
204
|
-
countryOptions.showMarketingCheckbox
|
|
201
|
+
countryOptions.showLegalCheckbox
|
|
205
202
|
);
|
|
206
203
|
|
|
207
204
|
// Grab the legal text paragraph element and set inner html (this is due to text having html elements in the string)
|
|
@@ -222,12 +219,10 @@ export default class Form extends LightningElement {
|
|
|
222
219
|
|
|
223
220
|
toggleLegalAndMarketingVisibility(
|
|
224
221
|
showLegalText: boolean,
|
|
225
|
-
showLegalCheckbox: boolean
|
|
226
|
-
showMarketingCheckbox: boolean
|
|
222
|
+
showLegalCheckbox: boolean
|
|
227
223
|
) {
|
|
228
224
|
this.showLegalText = showLegalText;
|
|
229
225
|
this.showLegalCheckbox = showLegalCheckbox;
|
|
230
|
-
this.showMarketingCheckbox = showMarketingCheckbox;
|
|
231
226
|
}
|
|
232
227
|
|
|
233
228
|
setInnerHtml(element: HTMLElement, value: string) {
|