@salesforcedevs/dw-components 1.3.121-alpha.0 → 1.3.124
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/LICENSE +12 -0
- package/package.json +3 -2
- package/src/modules/dw/contentArchive/utils.ts +1 -1
- package/src/modules/dw/deSignupForm/deSignupForm.css +3 -1
- package/src/modules/dw/deSignupForm/deSignupForm.html +26 -17
- package/src/modules/dw/deSignupForm/deSignupForm.ts +99 -67
- package/src/modules/dw/deSignupForm/submitForm.ts +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Copyright (c) 2020, Salesforce.com, Inc.
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
+
|
|
6
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
+
|
|
8
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
+
|
|
10
|
+
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
+
|
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dw-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.124",
|
|
4
4
|
"description": "Lightning web components for https://developer.salesforce.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -23,5 +23,6 @@
|
|
|
23
23
|
"@types/lodash.uniqby": "^4.7.7",
|
|
24
24
|
"@types/setimmediate": "^1.0.2",
|
|
25
25
|
"setimmediate": "^1.0.5"
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
|
+
"gitHead": "e5c300ce9253e9982f78d0588c037427f3fd0541"
|
|
27
28
|
}
|
|
@@ -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://
|
|
13
|
+
const ARCHIVE_BASE_URL = "https://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={country}
|
|
55
|
+
onchange={handleConsent}
|
|
56
56
|
></dx-select>
|
|
57
57
|
<dx-input
|
|
58
58
|
label="Postal Code"
|
|
@@ -77,27 +77,36 @@
|
|
|
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" if:true={legalText}>
|
|
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 & {
|
|
@@ -16,15 +17,6 @@ const DUPLICATE_USERNAME_MESSAGE =
|
|
|
16
17
|
const SIGN_UP_LABEL = "Sign me Up";
|
|
17
18
|
|
|
18
19
|
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
|
-
|
|
28
20
|
@api
|
|
29
21
|
get roles() {
|
|
30
22
|
return this._roles;
|
|
@@ -33,17 +25,27 @@ export default class DeSignupForm extends LightningElement {
|
|
|
33
25
|
set roles(value) {
|
|
34
26
|
this._roles = toJson(value);
|
|
35
27
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
@api
|
|
29
|
+
get countries() {
|
|
30
|
+
return this._countries;
|
|
31
|
+
}
|
|
32
|
+
set countries(value) {
|
|
33
|
+
this._countries = value;
|
|
34
|
+
}
|
|
35
|
+
@api drmDomain: string = "";
|
|
39
36
|
@api legalText: string = "";
|
|
40
37
|
|
|
41
38
|
private country: Country = null;
|
|
39
|
+
private _countries: string = "";
|
|
42
40
|
private disableSubmit = false;
|
|
43
41
|
private username = "";
|
|
44
|
-
private updateCheckboxLabels = true;
|
|
45
|
-
private _countries: Array<Country>;
|
|
46
42
|
private _roles: Array<SelectOption>;
|
|
43
|
+
private showMarketingCheckbox: boolean = false;
|
|
44
|
+
private marketingCheckbox: boolean = false;
|
|
45
|
+
private marketingText: string = "";
|
|
46
|
+
private showLegalCheckbox: boolean = false;
|
|
47
|
+
private privacyText: string = "";
|
|
48
|
+
|
|
47
49
|
@track knownDuplicateUsers = [];
|
|
48
50
|
|
|
49
51
|
get usernameError(): string {
|
|
@@ -56,34 +58,18 @@ export default class DeSignupForm extends LightningElement {
|
|
|
56
58
|
return !this.knownDuplicateUsers.includes(this.username);
|
|
57
59
|
}
|
|
58
60
|
|
|
59
|
-
get showMarketingCheckbox(): boolean {
|
|
60
|
-
return this.country && this.country.showMarketingCheckbox;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
get showPrivacyCheckbox(): boolean {
|
|
64
|
-
return this.country && !!this.country.privacyOptIn;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
61
|
get buttonLabel(): string {
|
|
68
62
|
return this.disableSubmit ? "Beep boop processing" : SIGN_UP_LABEL;
|
|
69
63
|
}
|
|
70
64
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
65
|
+
connectedCallback(): void {
|
|
66
|
+
this.getCountryList();
|
|
67
|
+
}
|
|
75
68
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
this.marketingText,
|
|
81
|
-
this.showMarketingCheckbox
|
|
82
|
-
) ||
|
|
83
|
-
this.updateInnerHtml(
|
|
84
|
-
"span.privacy-terms",
|
|
85
|
-
this.country?.privacyText || this.privacyText
|
|
86
|
-
);
|
|
69
|
+
renderedCallback(): void {
|
|
70
|
+
this.updateInnerHtml("span.legal-terms", this.legalText);
|
|
71
|
+
this.updateInnerHtml("span.marketing-terms", this.marketingText);
|
|
72
|
+
this.updateInnerHtml("span.legal-checkbox", this.privacyText);
|
|
87
73
|
}
|
|
88
74
|
|
|
89
75
|
handleSubmit(event: Event): void {
|
|
@@ -141,13 +127,6 @@ export default class DeSignupForm extends LightningElement {
|
|
|
141
127
|
this.username = event.detail;
|
|
142
128
|
}
|
|
143
129
|
|
|
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
130
|
private prepareUserData(): SignupForm | null {
|
|
152
131
|
const fields = Array.from(
|
|
153
132
|
this.template.querySelectorAll<HTMLFormElement>(
|
|
@@ -159,9 +138,14 @@ export default class DeSignupForm extends LightningElement {
|
|
|
159
138
|
value: element.value
|
|
160
139
|
}));
|
|
161
140
|
|
|
162
|
-
|
|
141
|
+
let validCheckboxes = true;
|
|
142
|
+
Array.from(
|
|
143
|
+
this.template.querySelectorAll<HTMLInputElement>("dx-checkbox")
|
|
144
|
+
).forEach((checkbox) => {
|
|
145
|
+
validCheckboxes = validCheckboxes && checkbox.reportValidity();
|
|
146
|
+
});
|
|
163
147
|
|
|
164
|
-
if (fields.some((field) => !field.valid) || !
|
|
148
|
+
if (fields.some((field) => !field.valid) || !validCheckboxes) {
|
|
165
149
|
return null;
|
|
166
150
|
}
|
|
167
151
|
|
|
@@ -170,17 +154,15 @@ export default class DeSignupForm extends LightningElement {
|
|
|
170
154
|
userData[field.name] = field.value;
|
|
171
155
|
});
|
|
172
156
|
|
|
173
|
-
(userData as UserData).consent = this.
|
|
157
|
+
(userData as UserData).consent = this.showMarketingCheckbox
|
|
174
158
|
? "Explicit"
|
|
175
|
-
: "Implied
|
|
159
|
+
: "Implied";
|
|
176
160
|
const InfoEmail =
|
|
177
|
-
this.
|
|
161
|
+
this.showMarketingCheckbox && !this.marketingCheckbox
|
|
178
162
|
? "False"
|
|
179
163
|
: "True";
|
|
180
|
-
|
|
181
164
|
const formData: SignupForm = {
|
|
182
165
|
user: userData as UserData,
|
|
183
|
-
eula: checkboxes.values.eula,
|
|
184
166
|
default_driver: DEFAULT_DRIVER,
|
|
185
167
|
info_email: InfoEmail
|
|
186
168
|
};
|
|
@@ -188,24 +170,74 @@ export default class DeSignupForm extends LightningElement {
|
|
|
188
170
|
return formData;
|
|
189
171
|
}
|
|
190
172
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
173
|
+
handleConsent(countrySelectElement: any) {
|
|
174
|
+
this.country = countrySelectElement.target.value;
|
|
175
|
+
countrySelectElement = countrySelectElement.target;
|
|
176
|
+
const countryOptions = countrySelectElement.options.find(
|
|
177
|
+
(option: any) => option.value === countrySelectElement.value
|
|
178
|
+
);
|
|
179
|
+
this.setLegalAndMarketingData(countryOptions);
|
|
180
|
+
this.marketingCheckbox = false;
|
|
181
|
+
}
|
|
200
182
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
183
|
+
handleMarketingCheckbox(marketingCheckbox: any) {
|
|
184
|
+
this.marketingCheckbox = marketingCheckbox.target.checked;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
setLegalAndMarketingData(countryOptions: CountryOptions) {
|
|
188
|
+
// Set the checkbox text
|
|
189
|
+
this.setCheckboxTextSet(
|
|
190
|
+
countryOptions.marketingText,
|
|
191
|
+
countryOptions.learnMore
|
|
192
|
+
? `${countryOptions.legalText} </br> ${countryOptions.learnMore}`
|
|
193
|
+
: countryOptions.legalText
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
// Toggle visibility of legal/marketing data
|
|
197
|
+
this.toggleLegalAndMarketingVisibility(
|
|
198
|
+
countryOptions.showMarketingText,
|
|
199
|
+
countryOptions.showLegalCheckbox
|
|
200
|
+
);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
setCheckboxTextSet(marketingText: string, privacyText: string) {
|
|
204
|
+
this.marketingText = marketingText;
|
|
205
|
+
this.privacyText = privacyText;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
toggleLegalAndMarketingVisibility(
|
|
209
|
+
showMarketingCheckbox: boolean,
|
|
210
|
+
showLegalCheckbox: boolean
|
|
211
|
+
) {
|
|
212
|
+
this.showMarketingCheckbox = showMarketingCheckbox;
|
|
213
|
+
this.showLegalCheckbox = showLegalCheckbox;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
setInnerHtml(element: HTMLElement, value: string) {
|
|
217
|
+
// disable lwc warning because text received from json has HTML
|
|
218
|
+
// eslint-disable-next-line @lwc/lwc/no-inner-html
|
|
219
|
+
element.innerHTML = value;
|
|
220
|
+
}
|
|
207
221
|
|
|
208
|
-
|
|
222
|
+
async getCountryList() {
|
|
223
|
+
if (!this.drmDomain) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const errorMsg = "Error while getting country list";
|
|
227
|
+
try {
|
|
228
|
+
const res = await fetch(
|
|
229
|
+
`${this.drmDomain}/utilities/services/apexrest/countries`
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
if (!res.ok) {
|
|
233
|
+
throw new Error(errorMsg);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const data = await res.json();
|
|
237
|
+
this._countries = JSON.stringify(data);
|
|
238
|
+
} catch (error) {
|
|
239
|
+
console.error(error);
|
|
240
|
+
}
|
|
209
241
|
}
|
|
210
242
|
|
|
211
243
|
private updateInnerHtml(
|