@salesforcedevs/dw-components 1.3.100 → 1.3.105-alpha.0
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": "1.3.
|
|
3
|
+
"version": "1.3.105-alpha.0",
|
|
4
4
|
"description": "Lightning web components for https://developer.salesforce.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"@types/setimmediate": "^1.0.2",
|
|
25
25
|
"setimmediate": "^1.0.5"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "22cde8b5972d7ef34581c5c10547c8a25da9bfd4"
|
|
28
28
|
}
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
placeholder="Select Country/Region"
|
|
53
53
|
required
|
|
54
54
|
value=""
|
|
55
|
-
onchange={
|
|
55
|
+
onchange={handleConsent}
|
|
56
56
|
></dx-select>
|
|
57
57
|
<dx-input
|
|
58
58
|
label="Postal Code"
|
|
@@ -80,24 +80,33 @@
|
|
|
80
80
|
<dx-checkbox required name="eula" value="accepted">
|
|
81
81
|
<span lwc:dom="manual" class="legal-terms"></span>
|
|
82
82
|
</dx-checkbox>
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
name="opt_in"
|
|
86
|
-
value="False"
|
|
87
|
-
>
|
|
83
|
+
|
|
84
|
+
<template if:false={showMarketingCheckbox}>
|
|
88
85
|
<span lwc:dom="manual" class="marketing-terms"></span>
|
|
89
|
-
</
|
|
86
|
+
</template>
|
|
87
|
+
<template if:true={showMarketingCheckbox}>
|
|
88
|
+
<dx-checkbox
|
|
89
|
+
name="marketingCheckbox"
|
|
90
|
+
class="marketing-terms"
|
|
91
|
+
value="false"
|
|
92
|
+
onchange={handleMarketingCheckbox}
|
|
93
|
+
>
|
|
94
|
+
<span>{marketingText}</span>
|
|
95
|
+
</dx-checkbox>
|
|
96
|
+
</template>
|
|
97
|
+
|
|
98
|
+
<template if:false={showLegalCheckbox}>
|
|
99
|
+
<span lwc:dom="manual" class="legal-checkbox privacy-terms"></span>
|
|
100
|
+
</template>
|
|
90
101
|
<dx-checkbox
|
|
91
|
-
if:true={
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
102
|
+
if:true={showLegalCheckbox}
|
|
103
|
+
class="privacy-terms"
|
|
104
|
+
value={legalCheckbox}
|
|
105
|
+
required="true"
|
|
95
106
|
>
|
|
96
|
-
<span lwc:dom="manual" class="privacy-terms"></span>
|
|
107
|
+
<span lwc:dom="manual" class="legal-checkbox privacy-terms"></span>
|
|
97
108
|
</dx-checkbox>
|
|
98
|
-
|
|
99
|
-
<span lwc:dom="manual" class="privacy-terms privacy-notice"></span>
|
|
100
|
-
</template>
|
|
109
|
+
|
|
101
110
|
<dx-button
|
|
102
111
|
class="submit-button"
|
|
103
112
|
disabled={disableSubmit}
|
|
@@ -2,6 +2,7 @@ import { LightningElement, api, track } from "lwc";
|
|
|
2
2
|
import { toJson } from "dxUtils/normalizers";
|
|
3
3
|
import { track as trackGtm } from "dxUtils/analytics";
|
|
4
4
|
import { submitForm, ErrorCode, SignupForm, UserData } from "./submitForm";
|
|
5
|
+
import { CountryOptions } from "typings/custom";
|
|
5
6
|
|
|
6
7
|
type SelectOption = { value: string; label: string };
|
|
7
8
|
type Country = SelectOption & {
|
|
@@ -34,16 +35,21 @@ export default class DeSignupForm extends LightningElement {
|
|
|
34
35
|
this._roles = toJson(value);
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
@api marketingText: string = "";
|
|
38
|
-
@api privacyText: string = "";
|
|
39
38
|
@api legalText: string = "";
|
|
39
|
+
@api drmDomain: string = "https://drm.my.salesforce-sites.com";
|
|
40
40
|
|
|
41
41
|
private country: Country = null;
|
|
42
42
|
private disableSubmit = false;
|
|
43
43
|
private username = "";
|
|
44
|
-
private
|
|
45
|
-
private _countries: Array<Country>;
|
|
44
|
+
private _countries: string = "";
|
|
46
45
|
private _roles: Array<SelectOption>;
|
|
46
|
+
private showMarketingCheckbox: boolean = false;
|
|
47
|
+
private marketingCheckbox: boolean = false;
|
|
48
|
+
private marketingText: string = "";
|
|
49
|
+
private showLegalCheckbox: boolean = false;
|
|
50
|
+
private privacyText: string = "";
|
|
51
|
+
private hasRendered = false;
|
|
52
|
+
|
|
47
53
|
@track knownDuplicateUsers = [];
|
|
48
54
|
|
|
49
55
|
get usernameError(): string {
|
|
@@ -56,10 +62,6 @@ export default class DeSignupForm extends LightningElement {
|
|
|
56
62
|
return !this.knownDuplicateUsers.includes(this.username);
|
|
57
63
|
}
|
|
58
64
|
|
|
59
|
-
get showMarketingCheckbox(): boolean {
|
|
60
|
-
return this.country && this.country.showMarketingCheckbox;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
65
|
get showPrivacyCheckbox(): boolean {
|
|
64
66
|
return this.country && !!this.country.privacyOptIn;
|
|
65
67
|
}
|
|
@@ -68,22 +70,18 @@ export default class DeSignupForm extends LightningElement {
|
|
|
68
70
|
return this.disableSubmit ? "Beep boop processing" : SIGN_UP_LABEL;
|
|
69
71
|
}
|
|
70
72
|
|
|
73
|
+
connectedCallback(): void {
|
|
74
|
+
this.getCountryList();
|
|
75
|
+
}
|
|
76
|
+
|
|
71
77
|
renderedCallback(): void {
|
|
72
|
-
if (!this.
|
|
78
|
+
if (!this.hasRendered) {
|
|
79
|
+
this.hasRendered = true;
|
|
73
80
|
return;
|
|
74
81
|
}
|
|
75
|
-
|
|
76
|
-
this.
|
|
77
|
-
|
|
78
|
-
this.updateInnerHtml(
|
|
79
|
-
"span.marketing-terms",
|
|
80
|
-
this.marketingText,
|
|
81
|
-
this.showMarketingCheckbox
|
|
82
|
-
) ||
|
|
83
|
-
this.updateInnerHtml(
|
|
84
|
-
"span.privacy-terms",
|
|
85
|
-
this.country?.privacyText || this.privacyText
|
|
86
|
-
);
|
|
82
|
+
this.updateInnerHtml("span.legal-terms", this.legalText);
|
|
83
|
+
this.updateInnerHtml("span.marketing-terms", this.marketingText);
|
|
84
|
+
this.updateInnerHtml("span.legal-checkbox", this.privacyText);
|
|
87
85
|
}
|
|
88
86
|
|
|
89
87
|
handleSubmit(event: Event): void {
|
|
@@ -141,13 +139,6 @@ export default class DeSignupForm extends LightningElement {
|
|
|
141
139
|
this.username = event.detail;
|
|
142
140
|
}
|
|
143
141
|
|
|
144
|
-
handleCountryChange(event: CustomEvent<{ value: string }>): void {
|
|
145
|
-
this.country = this.countries.find(
|
|
146
|
-
({ value }) => value === event.detail.value
|
|
147
|
-
);
|
|
148
|
-
this.updateCheckboxLabels = true;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
142
|
private prepareUserData(): SignupForm | null {
|
|
152
143
|
const fields = Array.from(
|
|
153
144
|
this.template.querySelectorAll<HTMLFormElement>(
|
|
@@ -159,9 +150,7 @@ export default class DeSignupForm extends LightningElement {
|
|
|
159
150
|
value: element.value
|
|
160
151
|
}));
|
|
161
152
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if (fields.some((field) => !field.valid) || !checkboxes.valid) {
|
|
153
|
+
if (fields.some((field) => !field.valid)) {
|
|
165
154
|
return null;
|
|
166
155
|
}
|
|
167
156
|
|
|
@@ -170,17 +159,15 @@ export default class DeSignupForm extends LightningElement {
|
|
|
170
159
|
userData[field.name] = field.value;
|
|
171
160
|
});
|
|
172
161
|
|
|
173
|
-
(userData as UserData).consent = this.
|
|
162
|
+
(userData as UserData).consent = this.showMarketingCheckbox
|
|
174
163
|
? "Explicit"
|
|
175
|
-
: "Implied
|
|
164
|
+
: "Implied";
|
|
176
165
|
const InfoEmail =
|
|
177
|
-
this.
|
|
166
|
+
this.showMarketingCheckbox && !this.marketingCheckbox
|
|
178
167
|
? "False"
|
|
179
168
|
: "True";
|
|
180
|
-
|
|
181
169
|
const formData: SignupForm = {
|
|
182
170
|
user: userData as UserData,
|
|
183
|
-
eula: checkboxes.values.eula,
|
|
184
171
|
default_driver: DEFAULT_DRIVER,
|
|
185
172
|
info_email: InfoEmail
|
|
186
173
|
};
|
|
@@ -188,24 +175,72 @@ export default class DeSignupForm extends LightningElement {
|
|
|
188
175
|
return formData;
|
|
189
176
|
}
|
|
190
177
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
};
|
|
178
|
+
handleConsent(countrySelectElement: any) {
|
|
179
|
+
countrySelectElement = countrySelectElement.target;
|
|
180
|
+
const countryOptions = countrySelectElement.options.find(
|
|
181
|
+
(option: any) => option.value === countrySelectElement.value
|
|
182
|
+
);
|
|
183
|
+
this.marketingCheckbox = false;
|
|
184
|
+
this.setLegalAndMarketingData(countryOptions);
|
|
185
|
+
}
|
|
200
186
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
valid = valid && checkbox.reportValidity();
|
|
205
|
-
values[checkbox.name] = checkbox.checked;
|
|
206
|
-
});
|
|
187
|
+
handleMarketingCheckbox(marketingCheckbox: any) {
|
|
188
|
+
this.marketingCheckbox = marketingCheckbox.target.checked;
|
|
189
|
+
}
|
|
207
190
|
|
|
208
|
-
|
|
191
|
+
setLegalAndMarketingData(countryOptions: CountryOptions) {
|
|
192
|
+
// Set the checkbox text
|
|
193
|
+
this.setCheckboxTextSet(
|
|
194
|
+
countryOptions.marketingText,
|
|
195
|
+
countryOptions.learnMore
|
|
196
|
+
? `${countryOptions.legalText} </br> ${countryOptions.learnMore}`
|
|
197
|
+
: countryOptions.legalText
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
// Toggle visibility of legal/marketing data
|
|
201
|
+
this.toggleLegalAndMarketingVisibility(
|
|
202
|
+
countryOptions.showMarketingText,
|
|
203
|
+
countryOptions.showLegalCheckbox
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
setCheckboxTextSet(marketingText: string, privacyText: string) {
|
|
208
|
+
this.marketingText = marketingText;
|
|
209
|
+
this.privacyText = privacyText;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
toggleLegalAndMarketingVisibility(
|
|
213
|
+
showMarketingCheckbox: boolean,
|
|
214
|
+
showLegalCheckbox: boolean
|
|
215
|
+
) {
|
|
216
|
+
this.showMarketingCheckbox = showMarketingCheckbox;
|
|
217
|
+
this.showLegalCheckbox = showLegalCheckbox;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
setInnerHtml(element: HTMLElement, value: string) {
|
|
221
|
+
// disable lwc warning because text received from json has HTML
|
|
222
|
+
// eslint-disable-next-line @lwc/lwc/no-inner-html
|
|
223
|
+
element.innerHTML = value;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async getCountryList() {
|
|
227
|
+
const errorMsg = "Error while getting county list";
|
|
228
|
+
|
|
229
|
+
try {
|
|
230
|
+
const res = await fetch(
|
|
231
|
+
`${this.drmDomain}/utilities/services/apexrest/countries`
|
|
232
|
+
);
|
|
233
|
+
|
|
234
|
+
if (!res.ok) {
|
|
235
|
+
throw new Error(errorMsg);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
const data = await res.json();
|
|
239
|
+
// eslint-disable-next-line @lwc/lwc/no-api-reassignments
|
|
240
|
+
this._countries = JSON.stringify(data);
|
|
241
|
+
} catch (error) {
|
|
242
|
+
console.error(error);
|
|
243
|
+
}
|
|
209
244
|
}
|
|
210
245
|
|
|
211
246
|
private updateInnerHtml(
|