@salesforcedevs/dw-components 1.3.104-alpha.0 → 1.3.109

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.104-alpha.0",
3
+ "version": "1.3.109",
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": "e10d764cbe3b3e9956eb47572b4dd3b4bed760e3"
27
+ "gitHead": "bd688e3e86b4d0d9d58765892bbffeec9dce2a1a"
28
28
  }
@@ -118,7 +118,6 @@ export default class CodeSamplesGrid extends LightningElement {
118
118
  this.selectedProductFilter?.forEach((filter) => {
119
119
  track(document, "custEv_filterAbandoned", {
120
120
  click_text: filter,
121
- click_url: filter,
122
121
  element_title: "CodeSamplesGrid",
123
122
  element_type: "filter abandoned",
124
123
  content_category: "filter"
@@ -25,9 +25,7 @@ span {
25
25
  }
26
26
 
27
27
  dx-checkbox,
28
- .privacy-notice,
29
- span.privacy-terms,
30
- span.marketing-terms {
28
+ .privacy-notice {
31
29
  width: 100%;
32
30
  margin-bottom: var(--dx-g-spacing-lg);
33
31
  }
@@ -52,7 +52,7 @@
52
52
  placeholder="Select Country/Region"
53
53
  required
54
54
  value=""
55
- onchange={handleConsent}
55
+ onchange={handleCountryChange}
56
56
  ></dx-select>
57
57
  <dx-input
58
58
  label="Postal Code"
@@ -78,39 +78,26 @@
78
78
  ></dx-input>
79
79
 
80
80
  <dx-checkbox required name="eula" value="accepted">
81
- <span class="legal-terms">{legalText}</span>
81
+ <span lwc:dom="manual" class="legal-terms"></span>
82
82
  </dx-checkbox>
83
-
84
- <template if:false={showMarketingCheckbox}>
85
- <span class="marketing-terms">{marketingText}</span>
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>
101
- <template if:true={showLegalCheckbox}>
102
- <dx-checkbox
103
- class="legal-checkbox privacy-terms"
104
- value={legalCheckbox}
105
- required="true"
106
- >
107
- <span
108
- lwc:dom="manual"
109
- class="legal-checkbox privacy-terms"
110
- ></span>
111
- </dx-checkbox>
83
+ <dx-checkbox
84
+ if:true={showMarketingCheckbox}
85
+ name="opt_in"
86
+ value="False"
87
+ >
88
+ <span lwc:dom="manual" class="marketing-terms"></span>
89
+ </dx-checkbox>
90
+ <dx-checkbox
91
+ if:true={showPrivacyCheckbox}
92
+ required
93
+ name="privacy"
94
+ value="privacy_accepted"
95
+ >
96
+ <span lwc:dom="manual" class="privacy-terms"></span>
97
+ </dx-checkbox>
98
+ <template if:false={showPrivacyCheckbox}>
99
+ <span lwc:dom="manual" class="privacy-terms privacy-notice"></span>
112
100
  </template>
113
-
114
101
  <dx-button
115
102
  class="submit-button"
116
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 & {
@@ -35,21 +34,16 @@ export default class DeSignupForm extends LightningElement {
35
34
  this._roles = toJson(value);
36
35
  }
37
36
 
37
+ @api marketingText: string = "";
38
+ @api privacyText: string = "";
38
39
  @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 _countries: string = "";
44
+ private updateCheckboxLabels = true;
45
+ private _countries: Array<Country>;
45
46
  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
-
53
47
  @track knownDuplicateUsers = [];
54
48
 
55
49
  get usernameError(): string {
@@ -62,6 +56,10 @@ export default class DeSignupForm extends LightningElement {
62
56
  return !this.knownDuplicateUsers.includes(this.username);
63
57
  }
64
58
 
59
+ get showMarketingCheckbox(): boolean {
60
+ return this.country && this.country.showMarketingCheckbox;
61
+ }
62
+
65
63
  get showPrivacyCheckbox(): boolean {
66
64
  return this.country && !!this.country.privacyOptIn;
67
65
  }
@@ -70,17 +68,22 @@ export default class DeSignupForm extends LightningElement {
70
68
  return this.disableSubmit ? "Beep boop processing" : SIGN_UP_LABEL;
71
69
  }
72
70
 
73
- connectedCallback(): void {
74
- this.getCountryList();
75
- }
76
-
77
71
  renderedCallback(): void {
78
- if (!this.hasRendered) {
79
- this.hasRendered = true;
72
+ if (!this.updateCheckboxLabels) {
80
73
  return;
81
74
  }
82
- this.hasRendered = true;
83
- this.updateInnerHtml("span.legal-checkbox", this.privacyText);
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
+ );
84
87
  }
85
88
 
86
89
  handleSubmit(event: Event): void {
@@ -112,8 +115,7 @@ export default class DeSignupForm extends LightningElement {
112
115
  "https://developer.salesforce.com/signup/success",
113
116
  form_country: formData.user.country,
114
117
  form_name: "Dev Edition Signup",
115
- form_primary_product_interest: "Developer Edition",
116
- offer_type: "free trial"
118
+ form_primary_product_interest: "Developer Edition"
117
119
  });
118
120
  window.location.href = "/signup/success";
119
121
  })
@@ -138,6 +140,13 @@ export default class DeSignupForm extends LightningElement {
138
140
  this.username = event.detail;
139
141
  }
140
142
 
143
+ handleCountryChange(event: CustomEvent<{ value: string }>): void {
144
+ this.country = this.countries.find(
145
+ ({ value }) => value === event.detail.value
146
+ );
147
+ this.updateCheckboxLabels = true;
148
+ }
149
+
141
150
  private prepareUserData(): SignupForm | null {
142
151
  const fields = Array.from(
143
152
  this.template.querySelectorAll<HTMLFormElement>(
@@ -149,7 +158,9 @@ export default class DeSignupForm extends LightningElement {
149
158
  value: element.value
150
159
  }));
151
160
 
152
- if (fields.some((field) => !field.valid)) {
161
+ const checkboxes = this.getCheckboxesResult();
162
+
163
+ if (fields.some((field) => !field.valid) || !checkboxes.valid) {
153
164
  return null;
154
165
  }
155
166
 
@@ -158,15 +169,17 @@ export default class DeSignupForm extends LightningElement {
158
169
  userData[field.name] = field.value;
159
170
  });
160
171
 
161
- (userData as UserData).consent = this.showMarketingCheckbox
172
+ (userData as UserData).consent = this.country.showMarketingCheckbox
162
173
  ? "Explicit"
163
- : "Implied";
174
+ : "Implied ";
164
175
  const InfoEmail =
165
- this.showMarketingCheckbox && !this.marketingCheckbox
176
+ this.country.showMarketingCheckbox && !checkboxes.values.opt_in
166
177
  ? "False"
167
178
  : "True";
179
+
168
180
  const formData: SignupForm = {
169
181
  user: userData as UserData,
182
+ eula: checkboxes.values.eula,
170
183
  default_driver: DEFAULT_DRIVER,
171
184
  info_email: InfoEmail
172
185
  };
@@ -174,70 +187,24 @@ export default class DeSignupForm extends LightningElement {
174
187
  return formData;
175
188
  }
176
189
 
177
- handleConsent(countrySelectElement: any) {
178
- countrySelectElement = countrySelectElement.target;
179
- const countryOptions = countrySelectElement.options.find(
180
- (option: any) => option.value === countrySelectElement.value
181
- );
182
- this.marketingCheckbox = false;
183
- this.setLegalAndMarketingData(countryOptions);
184
- }
185
-
186
- handleMarketingCheckbox(marketingCheckbox: any) {
187
- this.marketingCheckbox = marketingCheckbox.target.checked;
188
- }
189
-
190
- setLegalAndMarketingData(countryOptions: CountryOptions) {
191
- // Set the checkbox text
192
- this.setCheckboxTextSet(
193
- countryOptions.marketingText,
194
- countryOptions.legalText
195
- );
196
-
197
- // Toggle visibility of legal/marketing data
198
- this.toggleLegalAndMarketingVisibility(
199
- countryOptions.showMarketingText,
200
- countryOptions.showLegalCheckbox
201
- );
202
- }
203
-
204
- setCheckboxTextSet(marketingText: string, privacyText: string) {
205
- this.privacyText = privacyText;
206
- this.marketingText = marketingText;
207
- }
208
-
209
- toggleLegalAndMarketingVisibility(
210
- showMarketingCheckbox: boolean,
211
- showLegalCheckbox: boolean
212
- ) {
213
- this.showMarketingCheckbox = showMarketingCheckbox;
214
- this.showLegalCheckbox = showLegalCheckbox;
215
- }
216
-
217
- setInnerHtml(element: HTMLElement, value: string) {
218
- // disable lwc warning because text received from json has HTML
219
- // eslint-disable-next-line @lwc/lwc/no-inner-html
220
- element.innerHTML = value;
221
- }
222
-
223
- async getCountryList() {
224
- const errorMsg = "Error while getting county list";
225
-
226
- try {
227
- const res = await fetch(
228
- `${this.drmDomain}/utilities/services/apexrest/countries`
229
- );
190
+ private getCheckboxesResult(): {
191
+ valid: boolean;
192
+ values: { eula: string; opt_in: "true" | "false" };
193
+ } {
194
+ let valid = true;
195
+ const values: { eula: string; opt_in: "true" | "false" } = {
196
+ eula: "",
197
+ opt_in: "false"
198
+ };
230
199
 
231
- if (!res.ok) {
232
- throw new Error(errorMsg);
233
- }
200
+ Array.from(
201
+ this.template.querySelectorAll<HTMLInputElement>("dx-checkbox")
202
+ ).forEach((checkbox) => {
203
+ valid = valid && checkbox.reportValidity();
204
+ values[checkbox.name] = checkbox.checked;
205
+ });
234
206
 
235
- const data = await res.json();
236
- // eslint-disable-next-line @lwc/lwc/no-api-reassignments
237
- this._countries = JSON.stringify(data);
238
- } catch (error) {
239
- console.error(error);
240
- }
207
+ return { valid, values };
241
208
  }
242
209
 
243
210
  private updateInnerHtml(
@@ -20,6 +20,7 @@ export type UserData = {
20
20
 
21
21
  export type SignupForm = {
22
22
  user: UserData;
23
+ eula: string;
23
24
  default_driver: string;
24
25
  info_email: "True" | "False";
25
26
  };
@@ -548,7 +548,6 @@ export default abstract class DocsGrid extends LightningElement {
548
548
  this.selectedProductFilters?.forEach((filter) => {
549
549
  track(document, "custEv_filterAbandoned", {
550
550
  click_text: filter,
551
- click_url: filter,
552
551
  element_title: "docs grid",
553
552
  element_type: "filter abandoned",
554
553
  content_category: "filter"