@salesforcedevs/dw-components 1.3.120-alpha.0 → 1.3.121-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 +2 -3
- package/src/modules/dw/contentArchive/utils.ts +1 -1
- package/src/modules/dw/deSignupForm/deSignupForm.css +1 -3
- package/src/modules/dw/deSignupForm/deSignupForm.html +17 -26
- package/src/modules/dw/deSignupForm/deSignupForm.ts +67 -93
- package/src/modules/dw/deSignupForm/submitForm.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dw-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.121-alpha.0",
|
|
4
4
|
"description": "Lightning web components for https://developer.salesforce.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -23,6 +23,5 @@
|
|
|
23
23
|
"@types/lodash.uniqby": "^4.7.7",
|
|
24
24
|
"@types/setimmediate": "^1.0.2",
|
|
25
25
|
"setimmediate": "^1.0.5"
|
|
26
|
-
}
|
|
27
|
-
"gitHead": "e10d764cbe3b3e9956eb47572b4dd3b4bed760e3"
|
|
26
|
+
}
|
|
28
27
|
}
|
|
@@ -10,7 +10,7 @@ import altData from "./altData.js";
|
|
|
10
10
|
let postsController: AbortController | null = null;
|
|
11
11
|
let filtersController: AbortController | null = null;
|
|
12
12
|
|
|
13
|
-
const ARCHIVE_BASE_URL = "https://developer.salesforce.com/blogs/wp-json/wp/v2";
|
|
13
|
+
const ARCHIVE_BASE_URL = "https://staging.developer.salesforce.com/blogs/wp-json/wp/v2";
|
|
14
14
|
const ARCHIVE_CONTENT_URL = `${ARCHIVE_BASE_URL}/latest-post-per-site`;
|
|
15
15
|
const ARCHIVE_FILTER_LIST_URL = `${ARCHIVE_BASE_URL}/archives-filters?order=DESC`;
|
|
16
16
|
export const PER_PAGE_COUNT = 10;
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
options={countries}
|
|
52
52
|
placeholder="Select Country/Region"
|
|
53
53
|
required
|
|
54
|
-
value=
|
|
55
|
-
onchange={
|
|
54
|
+
value=""
|
|
55
|
+
onchange={handleCountryChange}
|
|
56
56
|
></dx-select>
|
|
57
57
|
<dx-input
|
|
58
58
|
label="Postal Code"
|
|
@@ -77,36 +77,27 @@
|
|
|
77
77
|
onchange={handleUsernameChange}
|
|
78
78
|
></dx-input>
|
|
79
79
|
|
|
80
|
-
<dx-checkbox required name="eula" value="accepted"
|
|
80
|
+
<dx-checkbox required name="eula" value="accepted">
|
|
81
81
|
<span lwc:dom="manual" class="legal-terms"></span>
|
|
82
82
|
</dx-checkbox>
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
<dx-checkbox
|
|
84
|
+
if:true={showMarketingCheckbox}
|
|
85
|
+
name="opt_in"
|
|
86
|
+
value="False"
|
|
87
|
+
>
|
|
85
88
|
<span lwc:dom="manual" class="marketing-terms"></span>
|
|
86
|
-
</
|
|
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>
|
|
89
|
+
</dx-checkbox>
|
|
101
90
|
<dx-checkbox
|
|
102
|
-
if:true={
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
91
|
+
if:true={showPrivacyCheckbox}
|
|
92
|
+
required
|
|
93
|
+
name="privacy"
|
|
94
|
+
value="privacy_accepted"
|
|
106
95
|
>
|
|
107
|
-
<span lwc:dom="manual" class="
|
|
96
|
+
<span lwc:dom="manual" class="privacy-terms"></span>
|
|
108
97
|
</dx-checkbox>
|
|
109
|
-
|
|
98
|
+
<template if:false={showPrivacyCheckbox}>
|
|
99
|
+
<span lwc:dom="manual" class="privacy-terms privacy-notice"></span>
|
|
100
|
+
</template>
|
|
110
101
|
<dx-button
|
|
111
102
|
class="submit-button"
|
|
112
103
|
disabled={disableSubmit}
|
|
@@ -2,7 +2,6 @@ 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";
|
|
6
5
|
|
|
7
6
|
type SelectOption = { value: string; label: string };
|
|
8
7
|
type Country = SelectOption & {
|
|
@@ -17,6 +16,15 @@ const DUPLICATE_USERNAME_MESSAGE =
|
|
|
17
16
|
const SIGN_UP_LABEL = "Sign me Up";
|
|
18
17
|
|
|
19
18
|
export default class DeSignupForm extends LightningElement {
|
|
19
|
+
@api
|
|
20
|
+
get countries() {
|
|
21
|
+
return this._countries;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
set countries(value) {
|
|
25
|
+
this._countries = toJson(value);
|
|
26
|
+
}
|
|
27
|
+
|
|
20
28
|
@api
|
|
21
29
|
get roles() {
|
|
22
30
|
return this._roles;
|
|
@@ -25,20 +33,17 @@ export default class DeSignupForm extends LightningElement {
|
|
|
25
33
|
set roles(value) {
|
|
26
34
|
this._roles = toJson(value);
|
|
27
35
|
}
|
|
28
|
-
|
|
29
|
-
@api
|
|
36
|
+
|
|
37
|
+
@api marketingText: string = "";
|
|
38
|
+
@api privacyText: string = "";
|
|
30
39
|
@api legalText: string = "";
|
|
31
40
|
|
|
32
41
|
private country: Country = null;
|
|
33
42
|
private disableSubmit = false;
|
|
34
43
|
private username = "";
|
|
44
|
+
private updateCheckboxLabels = true;
|
|
45
|
+
private _countries: Array<Country>;
|
|
35
46
|
private _roles: Array<SelectOption>;
|
|
36
|
-
private showMarketingCheckbox: boolean = false;
|
|
37
|
-
private marketingCheckbox: boolean = false;
|
|
38
|
-
private marketingText: string = "";
|
|
39
|
-
private showLegalCheckbox: boolean = false;
|
|
40
|
-
private privacyText: string = "";
|
|
41
|
-
|
|
42
47
|
@track knownDuplicateUsers = [];
|
|
43
48
|
|
|
44
49
|
get usernameError(): string {
|
|
@@ -51,18 +56,34 @@ export default class DeSignupForm extends LightningElement {
|
|
|
51
56
|
return !this.knownDuplicateUsers.includes(this.username);
|
|
52
57
|
}
|
|
53
58
|
|
|
54
|
-
get
|
|
55
|
-
return this.
|
|
59
|
+
get showMarketingCheckbox(): boolean {
|
|
60
|
+
return this.country && this.country.showMarketingCheckbox;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
get showPrivacyCheckbox(): boolean {
|
|
64
|
+
return this.country && !!this.country.privacyOptIn;
|
|
56
65
|
}
|
|
57
66
|
|
|
58
|
-
|
|
59
|
-
this.
|
|
67
|
+
get buttonLabel(): string {
|
|
68
|
+
return this.disableSubmit ? "Beep boop processing" : SIGN_UP_LABEL;
|
|
60
69
|
}
|
|
61
70
|
|
|
62
71
|
renderedCallback(): void {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
72
|
+
if (!this.updateCheckboxLabels) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
this.updateCheckboxLabels =
|
|
77
|
+
this.updateInnerHtml("span.legal-terms", this.legalText) ||
|
|
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
|
+
);
|
|
66
87
|
}
|
|
67
88
|
|
|
68
89
|
handleSubmit(event: Event): void {
|
|
@@ -120,6 +141,13 @@ export default class DeSignupForm extends LightningElement {
|
|
|
120
141
|
this.username = event.detail;
|
|
121
142
|
}
|
|
122
143
|
|
|
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
|
+
|
|
123
151
|
private prepareUserData(): SignupForm | null {
|
|
124
152
|
const fields = Array.from(
|
|
125
153
|
this.template.querySelectorAll<HTMLFormElement>(
|
|
@@ -131,14 +159,9 @@ export default class DeSignupForm extends LightningElement {
|
|
|
131
159
|
value: element.value
|
|
132
160
|
}));
|
|
133
161
|
|
|
134
|
-
|
|
135
|
-
Array.from(
|
|
136
|
-
this.template.querySelectorAll<HTMLInputElement>("dx-checkbox")
|
|
137
|
-
).forEach((checkbox) => {
|
|
138
|
-
validCheckboxes = validCheckboxes && checkbox.reportValidity();
|
|
139
|
-
});
|
|
162
|
+
const checkboxes = this.getCheckboxesResult();
|
|
140
163
|
|
|
141
|
-
if (fields.some((field) => !field.valid) || !
|
|
164
|
+
if (fields.some((field) => !field.valid) || !checkboxes.valid) {
|
|
142
165
|
return null;
|
|
143
166
|
}
|
|
144
167
|
|
|
@@ -147,15 +170,17 @@ export default class DeSignupForm extends LightningElement {
|
|
|
147
170
|
userData[field.name] = field.value;
|
|
148
171
|
});
|
|
149
172
|
|
|
150
|
-
(userData as UserData).consent = this.showMarketingCheckbox
|
|
173
|
+
(userData as UserData).consent = this.country.showMarketingCheckbox
|
|
151
174
|
? "Explicit"
|
|
152
|
-
: "Implied";
|
|
175
|
+
: "Implied ";
|
|
153
176
|
const InfoEmail =
|
|
154
|
-
this.showMarketingCheckbox && !
|
|
177
|
+
this.country.showMarketingCheckbox && !checkboxes.values.opt_in
|
|
155
178
|
? "False"
|
|
156
179
|
: "True";
|
|
180
|
+
|
|
157
181
|
const formData: SignupForm = {
|
|
158
182
|
user: userData as UserData,
|
|
183
|
+
eula: checkboxes.values.eula,
|
|
159
184
|
default_driver: DEFAULT_DRIVER,
|
|
160
185
|
info_email: InfoEmail
|
|
161
186
|
};
|
|
@@ -163,75 +188,24 @@ export default class DeSignupForm extends LightningElement {
|
|
|
163
188
|
return formData;
|
|
164
189
|
}
|
|
165
190
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
handleMarketingCheckbox(marketingCheckbox: any) {
|
|
177
|
-
this.marketingCheckbox = marketingCheckbox.target.checked;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
setLegalAndMarketingData(countryOptions: CountryOptions) {
|
|
181
|
-
// Set the checkbox text
|
|
182
|
-
this.setCheckboxTextSet(
|
|
183
|
-
countryOptions.marketingText,
|
|
184
|
-
countryOptions.learnMore
|
|
185
|
-
? `${countryOptions.legalText} </br> ${countryOptions.learnMore}`
|
|
186
|
-
: countryOptions.legalText
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
// Toggle visibility of legal/marketing data
|
|
190
|
-
this.toggleLegalAndMarketingVisibility(
|
|
191
|
-
countryOptions.showMarketingText,
|
|
192
|
-
countryOptions.showLegalCheckbox
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
setCheckboxTextSet(marketingText: string, privacyText: string) {
|
|
197
|
-
this.marketingText = marketingText;
|
|
198
|
-
this.privacyText = privacyText;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
toggleLegalAndMarketingVisibility(
|
|
202
|
-
showMarketingCheckbox: boolean,
|
|
203
|
-
showLegalCheckbox: boolean
|
|
204
|
-
) {
|
|
205
|
-
this.showMarketingCheckbox = showMarketingCheckbox;
|
|
206
|
-
this.showLegalCheckbox = showLegalCheckbox;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
setInnerHtml(element: HTMLElement, value: string) {
|
|
210
|
-
// disable lwc warning because text received from json has HTML
|
|
211
|
-
// eslint-disable-next-line @lwc/lwc/no-inner-html
|
|
212
|
-
element.innerHTML = value;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
async getCountryList() {
|
|
216
|
-
if (!this.drmDomain) {
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
219
|
-
const errorMsg = "Error while getting county list";
|
|
220
|
-
try {
|
|
221
|
-
const res = await fetch(
|
|
222
|
-
`${this.drmDomain}/utilities/services/apexrest/countries`
|
|
223
|
-
);
|
|
191
|
+
private getCheckboxesResult(): {
|
|
192
|
+
valid: boolean;
|
|
193
|
+
values: { eula: string; opt_in: "true" | "false" };
|
|
194
|
+
} {
|
|
195
|
+
let valid = true;
|
|
196
|
+
const values: { eula: string; opt_in: "true" | "false" } = {
|
|
197
|
+
eula: "",
|
|
198
|
+
opt_in: "false"
|
|
199
|
+
};
|
|
224
200
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
201
|
+
Array.from(
|
|
202
|
+
this.template.querySelectorAll<HTMLInputElement>("dx-checkbox")
|
|
203
|
+
).forEach((checkbox) => {
|
|
204
|
+
valid = valid && checkbox.reportValidity();
|
|
205
|
+
values[checkbox.name] = checkbox.checked;
|
|
206
|
+
});
|
|
228
207
|
|
|
229
|
-
|
|
230
|
-
// eslint-disable-next-line @lwc/lwc/no-api-reassignments
|
|
231
|
-
this.countries = JSON.stringify(data);
|
|
232
|
-
} catch (error) {
|
|
233
|
-
console.error(error);
|
|
234
|
-
}
|
|
208
|
+
return { valid, values };
|
|
235
209
|
}
|
|
236
210
|
|
|
237
211
|
private updateInnerHtml(
|