@salesforcedevs/dw-components 1.3.212-canary.0 → 1.3.213
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
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.213",
|
|
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": "916a9fae83496670e57a7796725213c8cc8186a0"
|
|
27
28
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
communicate-step-changes="true"
|
|
5
5
|
force-initially-visible={forceInitiallyVisible}
|
|
6
6
|
initial-step-index={initialStepIndex}
|
|
7
|
+
lwc:ref="stepSequence"
|
|
7
8
|
onstepsequencechange={handleStepSequenceChange}
|
|
8
9
|
optimize-position-after-animation="true"
|
|
9
10
|
session-storage-id={sessionStorageId}
|
|
@@ -4,6 +4,8 @@ import { getListWithUuids } from "dxUtils/list";
|
|
|
4
4
|
import { toJson } from "dxUtils/normalizers";
|
|
5
5
|
import J2sCardSequenceStep from "dw/j2sCardSequenceStep";
|
|
6
6
|
|
|
7
|
+
const DRM_SUCCESS_STRING = "success";
|
|
8
|
+
|
|
7
9
|
export type StepDatum = {
|
|
8
10
|
bodyHtml?:
|
|
9
11
|
| string
|
|
@@ -79,8 +81,8 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
79
81
|
_recaptchaResetTimeoutId: number | null = null;
|
|
80
82
|
_stepsData: StepDatum[] = [];
|
|
81
83
|
@api drmDomain: string = "https://drm.my.salesforce-sites.com";
|
|
82
|
-
@api
|
|
83
|
-
"https://
|
|
84
|
+
@api drmHandlerBaseUrl: string =
|
|
85
|
+
"https://dev1-infta-proxy.us-w2.cloudhub.io";
|
|
84
86
|
@api tbidApiBaseUrl: string | undefined;
|
|
85
87
|
@api useHistory: boolean = false;
|
|
86
88
|
|
|
@@ -128,6 +130,14 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
128
130
|
return Boolean(this.tbidUserInfo);
|
|
129
131
|
}
|
|
130
132
|
|
|
133
|
+
private get drmEmailUrl() {
|
|
134
|
+
return `${this.drmHandlerBaseUrl}/getEmail`;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private get formHandlerUrl() {
|
|
138
|
+
return `${this.drmHandlerBaseUrl}/form_handler`;
|
|
139
|
+
}
|
|
140
|
+
|
|
131
141
|
private get formIncomingUserInfo() {
|
|
132
142
|
if (!this.tbidUserInfo) {
|
|
133
143
|
return {} as DrmFormData;
|
|
@@ -141,8 +151,8 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
141
151
|
Company__c: this.tbidUserInfo.custom_attributes?.CompanyName,
|
|
142
152
|
MailingCountry: this.tbidUserInfo.custom_attributes?.Country,
|
|
143
153
|
MailingState: this.tbidUserInfo.address?.region,
|
|
144
|
-
RelationshipToSalesforce:
|
|
145
|
-
?.RelationshipToSalesforce
|
|
154
|
+
RelationshipToSalesforce:
|
|
155
|
+
this.tbidUserInfo.custom_attributes?.RelationshipToSalesforce
|
|
146
156
|
};
|
|
147
157
|
|
|
148
158
|
// Return above object but only with keys that have a truthy value, and with any URI-encoded values decoded
|
|
@@ -219,18 +229,16 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
219
229
|
|
|
220
230
|
renderedCallback() {
|
|
221
231
|
if (!this.isLoading) {
|
|
222
|
-
(
|
|
223
|
-
"dx-step-sequence"
|
|
224
|
-
) as unknown) as StepSequence)?.remeasureSteps();
|
|
232
|
+
(this.refs.stepSequence as StepSequence)?.remeasureSteps();
|
|
225
233
|
}
|
|
226
234
|
|
|
227
235
|
if (
|
|
228
236
|
this.formSubmissionFailureState &&
|
|
229
237
|
this.stepsData[this.currentSequenceStep].formData
|
|
230
238
|
) {
|
|
231
|
-
const j2sCardStep =
|
|
239
|
+
const j2sCardStep = this.template.querySelectorAll(
|
|
232
240
|
"dw-j2s-card-sequence-step"
|
|
233
|
-
) as unknown
|
|
241
|
+
) as unknown as J2sCardSequenceStep[];
|
|
234
242
|
j2sCardStep[this.currentSequenceStep]?.notifyFormSubmitFailure(
|
|
235
243
|
this.formSubmissionFailureState
|
|
236
244
|
);
|
|
@@ -285,14 +293,14 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
285
293
|
}
|
|
286
294
|
|
|
287
295
|
async handleFormSubmit({ detail: formData }: CustomEvent<DrmFormData>) {
|
|
288
|
-
if (!this.
|
|
296
|
+
if (!this.formHandlerUrl || !this.isLoggedIn) {
|
|
289
297
|
return;
|
|
290
298
|
}
|
|
291
299
|
|
|
292
300
|
this._isFormSubmitting = true;
|
|
293
301
|
|
|
294
302
|
try {
|
|
295
|
-
const res = await fetch(this.
|
|
303
|
+
const res = await fetch(this.formHandlerUrl, {
|
|
296
304
|
method: "POST",
|
|
297
305
|
headers: {
|
|
298
306
|
"Content-Type": "application/json",
|
|
@@ -308,7 +316,7 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
308
316
|
if (res.ok) {
|
|
309
317
|
const resData = await res.json();
|
|
310
318
|
const resOutput = resData.handlePostRequestOutput || resData;
|
|
311
|
-
if (resOutput?.status ===
|
|
319
|
+
if (resOutput?.status === DRM_SUCCESS_STRING) {
|
|
312
320
|
this.dispatchEvent(
|
|
313
321
|
new CustomEvent("registration", {
|
|
314
322
|
bubbles: true,
|
|
@@ -374,9 +382,7 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
374
382
|
if (andStoreIndex) {
|
|
375
383
|
this.initialStepIndex = stepIndex; // update sessionStorage value
|
|
376
384
|
}
|
|
377
|
-
(
|
|
378
|
-
"dx-step-sequence"
|
|
379
|
-
) as unknown) as StepSequence)?.jumpToStep(stepIndex);
|
|
385
|
+
(this.refs.stepSequence as StepSequence)?.jumpToStep(stepIndex);
|
|
380
386
|
}
|
|
381
387
|
|
|
382
388
|
private async getCountryList() {
|
|
@@ -409,7 +415,16 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
409
415
|
try {
|
|
410
416
|
const res = await fetch(`${this.tbidApiBaseUrl}/userinfo`);
|
|
411
417
|
if (res.ok) {
|
|
412
|
-
|
|
418
|
+
const userInfo = await res.json();
|
|
419
|
+
const emailOverride = await this.getDrmEmailOverride(
|
|
420
|
+
userInfo?.user_id
|
|
421
|
+
);
|
|
422
|
+
this.tbidUserInfo = !emailOverride
|
|
423
|
+
? userInfo
|
|
424
|
+
: {
|
|
425
|
+
...userInfo,
|
|
426
|
+
email: emailOverride
|
|
427
|
+
};
|
|
413
428
|
this.selectedCountry = this.formIncomingUserInfo.MailingCountry;
|
|
414
429
|
}
|
|
415
430
|
} catch (ex) {
|
|
@@ -424,4 +439,30 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
424
439
|
|
|
425
440
|
this._isTbidLoading = false;
|
|
426
441
|
}
|
|
442
|
+
|
|
443
|
+
private async getDrmEmailOverride(
|
|
444
|
+
tbid: string
|
|
445
|
+
): Promise<string | undefined> {
|
|
446
|
+
let resolvedEmail = "";
|
|
447
|
+
|
|
448
|
+
if (!tbid) {
|
|
449
|
+
return resolvedEmail;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
try {
|
|
453
|
+
const res = await fetch(`${this.drmEmailUrl}?tbid=${tbid}`);
|
|
454
|
+
if (res.ok) {
|
|
455
|
+
const resData = await res.json();
|
|
456
|
+
if (resData.message === DRM_SUCCESS_STRING) {
|
|
457
|
+
resolvedEmail = resData.Email;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
} catch (ex) {
|
|
461
|
+
console.warn(
|
|
462
|
+
`Could not fetch email address from DRM, defaulting to TBID info. (Exception: ${ex})`
|
|
463
|
+
);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return resolvedEmail;
|
|
467
|
+
}
|
|
427
468
|
}
|