@oneblink/apps-react 13.0.0-beta.1 → 13.0.0-beta.11
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/dist/OneBlinkFormBase.d.ts +23 -3
- package/dist/OneBlinkFormBase.js +351 -193
- package/dist/OneBlinkFormBase.js.map +1 -1
- package/dist/OneBlinkReadOnlyForm.d.ts +17 -7
- package/dist/OneBlinkReadOnlyForm.js +24 -8
- package/dist/OneBlinkReadOnlyForm.js.map +1 -1
- package/dist/apps/approvals-service.d.ts +2 -60
- package/dist/apps/approvals-service.js +1 -181
- package/dist/apps/approvals-service.js.map +1 -1
- package/dist/apps/services/api/submissions.d.ts +3 -2
- package/dist/apps/services/api/submissions.js +3 -6
- package/dist/apps/services/api/submissions.js.map +1 -1
- package/dist/apps/submission-service.d.ts +11 -5
- package/dist/apps/submission-service.js +9 -4
- package/dist/apps/submission-service.js.map +1 -1
- package/dist/components/renderer/LookupButton.d.ts +1 -2
- package/dist/components/renderer/LookupButton.js +7 -6
- package/dist/components/renderer/LookupButton.js.map +1 -1
- package/dist/components/renderer/LookupNotification.js +31 -24
- package/dist/components/renderer/LookupNotification.js.map +1 -1
- package/dist/components/renderer/OneBlinkFormElements.d.ts +5 -7
- package/dist/components/renderer/OneBlinkFormElements.js +10 -35
- package/dist/components/renderer/OneBlinkFormElements.js.map +1 -1
- package/dist/components/renderer/PageFormElements.js +8 -3
- package/dist/components/renderer/PageFormElements.js.map +1 -1
- package/dist/components/renderer/ReverseGeocode.js +6 -11
- package/dist/components/renderer/ReverseGeocode.js.map +1 -1
- package/dist/form-elements/FormElementABN.js +1 -1
- package/dist/form-elements/FormElementABN.js.map +1 -1
- package/dist/form-elements/FormElementBSB.js +1 -1
- package/dist/form-elements/FormElementBSB.js.map +1 -1
- package/dist/form-elements/FormElementBarcodeScanner.js +1 -1
- package/dist/form-elements/FormElementBarcodeScanner.js.map +1 -1
- package/dist/form-elements/FormElementCalculation.js +1 -0
- package/dist/form-elements/FormElementCalculation.js.map +1 -1
- package/dist/form-elements/FormElementCheckBoxes.js +1 -1
- package/dist/form-elements/FormElementCheckBoxes.js.map +1 -1
- package/dist/form-elements/FormElementDate.js +1 -1
- package/dist/form-elements/FormElementDate.js.map +1 -1
- package/dist/form-elements/FormElementDateTime.js +1 -1
- package/dist/form-elements/FormElementDateTime.js.map +1 -1
- package/dist/form-elements/FormElementEmail.js +1 -1
- package/dist/form-elements/FormElementEmail.js.map +1 -1
- package/dist/form-elements/FormElementForm.d.ts +8 -9
- package/dist/form-elements/FormElementForm.js +4 -3
- package/dist/form-elements/FormElementForm.js.map +1 -1
- package/dist/form-elements/FormElementLookupButton.js +4 -3
- package/dist/form-elements/FormElementLookupButton.js.map +1 -1
- package/dist/form-elements/FormElementNumber.js +1 -1
- package/dist/form-elements/FormElementNumber.js.map +1 -1
- package/dist/form-elements/FormElementRepeatableSet.d.ts +4 -4
- package/dist/form-elements/FormElementRepeatableSet.js +6 -4
- package/dist/form-elements/FormElementRepeatableSet.js.map +1 -1
- package/dist/form-elements/FormElementSection.d.ts +3 -3
- package/dist/form-elements/FormElementSection.js +2 -2
- package/dist/form-elements/FormElementSection.js.map +1 -1
- package/dist/form-elements/FormElementSelect.js +1 -1
- package/dist/form-elements/FormElementSelect.js.map +1 -1
- package/dist/form-elements/FormElementSummary.js +2 -0
- package/dist/form-elements/FormElementSummary.js.map +1 -1
- package/dist/form-elements/FormElementTelephone.js +1 -1
- package/dist/form-elements/FormElementTelephone.js.map +1 -1
- package/dist/form-elements/FormElementText.js +1 -1
- package/dist/form-elements/FormElementText.js.map +1 -1
- package/dist/form-elements/FormElementTextarea.js +1 -1
- package/dist/form-elements/FormElementTextarea.js.map +1 -1
- package/dist/form-elements/FormElementTime.js +1 -1
- package/dist/form-elements/FormElementTime.js.map +1 -1
- package/dist/hooks/useAreLookupsDisallowed.d.ts +2 -0
- package/dist/hooks/useAreLookupsDisallowed.js +12 -0
- package/dist/hooks/useAreLookupsDisallowed.js.map +1 -0
- package/dist/hooks/useEditableFormElementIds.d.ts +3 -0
- package/dist/hooks/useEditableFormElementIds.js +6 -0
- package/dist/hooks/useEditableFormElementIds.js.map +1 -0
- package/dist/hooks/useFormElementOptions.js +2 -0
- package/dist/hooks/useFormElementOptions.js.map +1 -1
- package/dist/hooks/useFormIsDirty.d.ts +56 -0
- package/dist/hooks/useFormIsDirty.js +121 -0
- package/dist/hooks/useFormIsDirty.js.map +1 -0
- package/dist/hooks/useFormSubmissionAttempt.d.ts +88 -0
- package/dist/hooks/useFormSubmissionAttempt.js +103 -0
- package/dist/hooks/useFormSubmissionAttempt.js.map +1 -0
- package/dist/hooks/useFormSubmissionAutoSaveState.d.ts +2 -9
- package/dist/hooks/useFormSubmissionAutoSaveState.js +4 -2
- package/dist/hooks/useFormSubmissionAutoSaveState.js.map +1 -1
- package/dist/hooks/useFormValidation.d.ts +1 -1
- package/dist/hooks/useFormValidation.js +2 -1
- package/dist/hooks/useFormValidation.js.map +1 -1
- package/dist/hooks/useInjectPages.d.ts +2 -1
- package/dist/hooks/useInjectPages.js.map +1 -1
- package/dist/hooks/useIsFormElementReadOnly.d.ts +2 -0
- package/dist/hooks/useIsFormElementReadOnly.js +13 -0
- package/dist/hooks/useIsFormElementReadOnly.js.map +1 -0
- package/dist/hooks/useLookupNotification.d.ts +23 -2
- package/dist/hooks/useLookupNotification.js +2 -1
- package/dist/hooks/useLookupNotification.js.map +1 -1
- package/dist/hooks/useLookups.d.ts +3 -3
- package/dist/hooks/useLookups.js +7 -4
- package/dist/hooks/useLookups.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/services/form-validation/extensions.d.ts +2 -1
- package/dist/services/form-validation/extensions.js +2 -1
- package/dist/services/form-validation/extensions.js.map +1 -1
- package/dist/services/form-validation/validateSubmission.d.ts +2 -1
- package/dist/services/form-validation/validateSubmission.js +14 -9
- package/dist/services/form-validation/validateSubmission.js.map +1 -1
- package/dist/services/getFlowInstanceNodesWithMeta.d.ts +70 -0
- package/dist/services/getFlowInstanceNodesWithMeta.js +247 -0
- package/dist/services/getFlowInstanceNodesWithMeta.js.map +1 -0
- package/dist/types/form.d.ts +17 -3
- package/dist/types/form.js.map +1 -1
- package/dist/utils/read-only-form-elements.d.ts +37 -0
- package/dist/utils/read-only-form-elements.js +63 -0
- package/dist/utils/read-only-form-elements.js.map +1 -0
- package/package.json +4 -3
- package/dist/services/isElementReadOnlyForAudience.d.ts +0 -20
- package/dist/services/isElementReadOnlyForAudience.js +0 -46
- package/dist/services/isElementReadOnlyForAudience.js.map +0 -1
- package/dist/services/resolveFormElementReadOnly.d.ts +0 -10
- package/dist/services/resolveFormElementReadOnly.js +0 -17
- package/dist/services/resolveFormElementReadOnly.js.map +0 -1
|
@@ -23,12 +23,13 @@ export declare function uploadFormSubmissionEdit({ submission, definition, submi
|
|
|
23
23
|
}): Promise<import("@oneblink/storage/dist/http-handlers/types").OneBlinkResponse<{
|
|
24
24
|
formSubmissionEditId: string;
|
|
25
25
|
}>>;
|
|
26
|
-
export declare function downloadFormSubmission({ formId, submissionId, abortSignal, versionId, }: {
|
|
26
|
+
export declare function downloadFormSubmission({ formId, submissionId, abortSignal, versionId, asSubmitted, }: {
|
|
27
27
|
formId: number;
|
|
28
28
|
submissionId: string;
|
|
29
29
|
abortSignal?: AbortSignal;
|
|
30
30
|
versionId?: string;
|
|
31
|
+
asSubmitted?: boolean;
|
|
31
32
|
}): Promise<{
|
|
32
33
|
data: SubmissionTypes.S3SubmissionData;
|
|
33
|
-
versionId: string;
|
|
34
|
+
versionId: string | undefined;
|
|
34
35
|
}>;
|
|
@@ -127,12 +127,13 @@ export async function uploadFormSubmissionEdit({ submission, definition, submiss
|
|
|
127
127
|
throw handleError(error);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
export async function downloadFormSubmission({ formId, submissionId, abortSignal, versionId, }) {
|
|
130
|
+
export async function downloadFormSubmission({ formId, submissionId, abortSignal, versionId, asSubmitted, }) {
|
|
131
131
|
try {
|
|
132
132
|
console.log('Attempting to download form submission data:', {
|
|
133
133
|
formId,
|
|
134
134
|
submissionId,
|
|
135
135
|
versionId,
|
|
136
|
+
asSubmitted,
|
|
136
137
|
});
|
|
137
138
|
const oneblinkDownloader = generateOneBlinkDownloader();
|
|
138
139
|
const result = await oneblinkDownloader.downloadSubmission({
|
|
@@ -140,17 +141,13 @@ export async function downloadFormSubmission({ formId, submissionId, abortSignal
|
|
|
140
141
|
submissionId,
|
|
141
142
|
abortSignal,
|
|
142
143
|
versionId,
|
|
144
|
+
asSubmitted,
|
|
143
145
|
});
|
|
144
146
|
if (!result) {
|
|
145
147
|
throw new OneBlinkAppsError("This submission has been removed based on your administrator's retention policy.", {
|
|
146
148
|
title: 'Submission Data Unavailable',
|
|
147
149
|
});
|
|
148
150
|
}
|
|
149
|
-
if (!result.versionId) {
|
|
150
|
-
throw new OneBlinkAppsError('The submission version could not be determined. Please reload and try again.', {
|
|
151
|
-
title: 'Submission Version Unavailable',
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
151
|
return {
|
|
155
152
|
data: result.data,
|
|
156
153
|
versionId: result.versionId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submissions.js","sourceRoot":"","sources":["../../../../src/apps/services/api/submissions.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,6BAA6B,CAAA;AAC3D,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,wBAAwB,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,0BAA0B,MAAM,+BAA+B,CAAA;AAGtE,MAAM,kBAAk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AAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;gBACzD,SAAS,EAAE,IAAI;aAChB,CACF,CAAA;QACH,CAAC;QAED,IAAI,KAAK,YAAY,oBAAoB,EAAE,CAAC;YAC1C,QAAQ,KAAK,CAAC,cAAc,EAAE,CAAC;gBAC7B,KAAK,GAAG,CAAC,CAAC,CAAC;oBACT,MAAM,IAAI,iBAAiB,CACzB,gGAAgG,EAChG;wBACE,aAAa,EAAE,KAAK;wBACpB,aAAa,EAAE,IAAI;wBACnB,cAAc,EAAE,KAAK,CAAC,cAAc;qBACrC,CACF,CAAA;gBACH,CAAC;gBACD,KAAK,GAAG,CAAC,CAAC,CAAC;oBACT,MAAM,IAAI,iBAAiB,CACzB,mHAAmH,EACnH;wBACE,aAAa,EAAE,KAAK;wBACpB,qBAAqB,EAAE,IAAI;wBAC3B,cAAc,EAAE,KAAK,CAAC,cAAc;qBACrC,CACF,CAAA;gBACH,CAAC;gBACD,KAAK,GAAG,CAAC;gBACT,KAAK,GAAG,CAAC,CAAC,CAAC;oBACT,MAAM,IAAI,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE;wBACzC,KAAK,EAAE,iBAAiB;wBACxB,cAAc,EAAE,KAAK,CAAC,cAAc;qBACrC,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,IAAI,iBAAiB,CACzB,gFAAgF,EAChF;YACE,aAAa,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YACzD,cAAc,EACZ,KAAK,YAAY,oBAAoB;gBACnC,CAAC,CAAC,KAAK,CAAC,cAAc;gBACtB,CAAC,CAAC,SAAS;SAChB,CACF,CAAA;IACH,CAAC;AACH,CAAC","sourcesContent":["import OneBlinkAppsError from '../errors/oneBlinkAppsError'\nimport Sentry from '../../Sentry'\nimport { isOffline } from '../../offline-service'\nimport { getDeviceInformation } from '../getDeviceInformation'\nimport { FormSubmission, ProgressListener } from '../../types/submissions'\nimport { getUserToken } from '../user-token'\nimport generateOneBlinkUploader from '../generateOneBlinkUploader'\nimport { OneBlinkStorageError } from '@oneblink/storage'\nimport generateOneBlinkDownloader from '../generateOneBlinkDownloader'\nimport { FormTypes, SubmissionTypes } from '@oneblink/types'\n\nconst getBadRequestError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(error.message, {\n title: 'Invalid Submission',\n httpStatusCode: error.httpStatusCode,\n })\n}\nconst getUnauthenticatedError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(\n 'The form you are attempting to complete requires authentication. Please login and try again.',\n {\n requiresLogin: true,\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n },\n )\n}\nconst getUnauthorisedError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(\n 'You do not have access to complete this form. Please contact your administrator to gain the correct level of access.',\n {\n requiresAccessRequest: true,\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n },\n )\n}\nconst getNotFoundError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(\n 'We could not find the form you are looking for. Please contact your administrator to ensure your form configuration has been completed successfully.',\n {\n title: 'Unknown Form',\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n },\n )\n}\nconst getDefaultError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n },\n )\n}\n\nconst handleError = (error: OneBlinkStorageError) => {\n if (/Failed to fetch/.test((error as Error).message)) {\n throw new OneBlinkAppsError(\n 'We encountered a network related issue. Please ensure you are connected to the internet before trying again. If the problem persists, contact your administrator.',\n {\n title: 'Connectivity Issues',\n originalError: error as Error,\n isOffline: true,\n },\n )\n }\n switch (error.httpStatusCode) {\n case 400: {\n return getBadRequestError(error)\n }\n case 401: {\n return getUnauthenticatedError(error)\n }\n case 403: {\n return getUnauthorisedError(error)\n }\n case 404: {\n return getNotFoundError(error)\n }\n case 409: {\n return new OneBlinkAppsError(error.message, {\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n conflict: error.conflict,\n })\n }\n default: {\n return getDefaultError(error)\n }\n }\n}\n\nexport async function uploadFormSubmission(\n formSubmission: FormSubmission,\n /**\n * The date and time (in ISO format) the form was completed I.e. when the user\n * clicked the submit button\n */\n completionTimestamp: string,\n onProgress?: ProgressListener,\n abortSignal?: AbortSignal,\n) {\n try {\n const oneblinkUploader = generateOneBlinkUploader()\n\n const userToken = getUserToken()\n\n console.log('Uploading submission')\n return await oneblinkUploader.uploadSubmission({\n completionTimestamp,\n submission: formSubmission.submission,\n definition: formSubmission.definition,\n device: getDeviceInformation(),\n userToken: userToken || undefined,\n previousFormSubmissionApprovalId:\n formSubmission.previousFormSubmissionApprovalId,\n jobId: formSubmission.jobId || undefined,\n formsAppId: formSubmission.formsAppId,\n externalId: formSubmission.externalId || undefined,\n taskId: formSubmission.taskCompletion?.task.taskId || undefined,\n taskActionId: formSubmission.taskCompletion?.taskAction.taskActionId,\n taskGroupInstanceId:\n formSubmission.taskCompletion?.taskGroupInstance?.taskGroupInstanceId,\n taskCompletionTimestamp: formSubmission.taskCompletion?.completedAt,\n taskIsAdhoc: formSubmission.taskCompletion?.isAdhoc,\n recaptchas: formSubmission.recaptchas,\n onProgress,\n abortSignal,\n formSubmissionDraftId: formSubmission.formSubmissionDraftId,\n })\n } catch (error) {\n throw handleError(error as OneBlinkStorageError)\n }\n}\n\nexport async function uploadFormSubmissionEdit({\n submission,\n definition,\n submissionId,\n context,\n editedS3ObjectVersionId,\n onProgress,\n abortSignal,\n}: {\n submission: SubmissionTypes.NewS3SubmissionData['submission']\n definition: FormTypes.Form\n submissionId: string\n context: SubmissionTypes.FormSubmissionMetaEditContext\n editedS3ObjectVersionId: string\n onProgress?: ProgressListener\n abortSignal?: AbortSignal\n}) {\n try {\n const oneblinkUploader = generateOneBlinkUploader()\n return await oneblinkUploader.uploadFormSubmissionEdit({\n submission,\n definition,\n device: getDeviceInformation(),\n completionTimestamp: new Date().toISOString(),\n submissionId,\n context,\n editedS3ObjectVersionId,\n onProgress,\n abortSignal,\n })\n } catch (error) {\n throw handleError(error as OneBlinkStorageError)\n }\n}\n\nexport async function downloadFormSubmission({\n formId,\n submissionId,\n abortSignal,\n versionId,\n}: {\n formId: number\n submissionId: string\n abortSignal?: AbortSignal\n versionId?: string\n}) {\n try {\n console.log('Attempting to download form submission data:', {\n formId,\n submissionId,\n versionId,\n })\n const oneblinkDownloader = generateOneBlinkDownloader()\n const result = await oneblinkDownloader.downloadSubmission({\n formId,\n submissionId,\n abortSignal,\n versionId,\n })\n if (!result) {\n throw new OneBlinkAppsError(\n \"This submission has been removed based on your administrator's retention policy.\",\n {\n title: 'Submission Data Unavailable',\n },\n )\n }\n if (!result.versionId) {\n throw new OneBlinkAppsError(\n 'The submission version could not be determined. Please reload and try again.',\n {\n title: 'Submission Version Unavailable',\n },\n )\n }\n return {\n data: result.data,\n versionId: result.versionId,\n }\n } catch (error) {\n console.error('Error retrieving form submission data', error)\n\n if (error instanceof OneBlinkAppsError) {\n throw error\n }\n\n Sentry.captureException(error)\n\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error instanceof Error ? error : undefined,\n isOffline: true,\n },\n )\n }\n\n if (error instanceof OneBlinkStorageError) {\n switch (error.httpStatusCode) {\n case 401: {\n throw new OneBlinkAppsError(\n 'The submission you are attempting to view requires authentication. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.httpStatusCode,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to submission data. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.httpStatusCode,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.httpStatusCode,\n })\n }\n }\n }\n\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error instanceof Error ? error : undefined,\n httpStatusCode:\n error instanceof OneBlinkStorageError\n ? error.httpStatusCode\n : undefined,\n },\n )\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"submissions.js","sourceRoot":"","sources":["../../../../src/apps/services/api/submissions.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,6BAA6B,CAAA;AAC3D,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AACjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAC5C,OAAO,wBAAwB,MAAM,6BAA6B,CAAA;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,0BAA0B,MAAM,+BAA+B,CAAA;AAGtE,MAAM,kBAAkB,GAAG,CAAC,KAA2B,EAAE,EAAE;IACzD,OAAO,IAAI,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE;QAC1C,KAAK,EAAE,oBAAoB;QAC3B,cAAc,EAAE,KAAK,CAAC,cAAc;KACrC,CAAC,CAAA;AACJ,CAAC,CAAA;AACD,MAAM,uBAAuB,GAAG,CAAC,KAA2B,EAAE,EAAE;IAC9D,OAAO,IAAI,iBAAiB,CAC1B,8FAA8F,EAC9F;QACE,aAAa,EAAE,IAAI;QACnB,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,KAAK,CAAC,cAAc;KACrC,CACF,CAAA;AACH,CAAC,CAAA;AACD,MAAM,oBAAoB,GAAG,CAAC,KAA2B,EAAE,EAAE;IAC3D,OAAO,IAAI,iBAAiB,CAC1B,sHAAsH,EACtH;QACE,qBAAqB,EAAE,IAAI;QAC3B,aAAa,EAAE,KAAK;QACpB,cAAc,EAAE,KAAK,CAAC,cAAc;KACrC,CACF,CAAA;AACH,CAAC,CAAA;AAC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EAAE,KAAK,CAAC,cAAc;qBACrC,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,MAAM,IAAI,iBAAiB,CACzB,gFAAgF,EAChF;YACE,aAAa,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;YACzD,cAAc,EACZ,KAAK,YAAY,oBAAoB;gBACnC,CAAC,CAAC,KAAK,CAAC,cAAc;gBACtB,CAAC,CAAC,SAAS;SAChB,CACF,CAAA;IACH,CAAC;AACH,CAAC","sourcesContent":["import OneBlinkAppsError from '../errors/oneBlinkAppsError'\nimport Sentry from '../../Sentry'\nimport { isOffline } from '../../offline-service'\nimport { getDeviceInformation } from '../getDeviceInformation'\nimport { FormSubmission, ProgressListener } from '../../types/submissions'\nimport { getUserToken } from '../user-token'\nimport generateOneBlinkUploader from '../generateOneBlinkUploader'\nimport { OneBlinkStorageError } from '@oneblink/storage'\nimport generateOneBlinkDownloader from '../generateOneBlinkDownloader'\nimport { FormTypes, SubmissionTypes } from '@oneblink/types'\n\nconst getBadRequestError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(error.message, {\n title: 'Invalid Submission',\n httpStatusCode: error.httpStatusCode,\n })\n}\nconst getUnauthenticatedError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(\n 'The form you are attempting to complete requires authentication. Please login and try again.',\n {\n requiresLogin: true,\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n },\n )\n}\nconst getUnauthorisedError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(\n 'You do not have access to complete this form. Please contact your administrator to gain the correct level of access.',\n {\n requiresAccessRequest: true,\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n },\n )\n}\nconst getNotFoundError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(\n 'We could not find the form you are looking for. Please contact your administrator to ensure your form configuration has been completed successfully.',\n {\n title: 'Unknown Form',\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n },\n )\n}\nconst getDefaultError = (error: OneBlinkStorageError) => {\n return new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n },\n )\n}\n\nconst handleError = (error: OneBlinkStorageError) => {\n if (/Failed to fetch/.test((error as Error).message)) {\n throw new OneBlinkAppsError(\n 'We encountered a network related issue. Please ensure you are connected to the internet before trying again. If the problem persists, contact your administrator.',\n {\n title: 'Connectivity Issues',\n originalError: error as Error,\n isOffline: true,\n },\n )\n }\n switch (error.httpStatusCode) {\n case 400: {\n return getBadRequestError(error)\n }\n case 401: {\n return getUnauthenticatedError(error)\n }\n case 403: {\n return getUnauthorisedError(error)\n }\n case 404: {\n return getNotFoundError(error)\n }\n case 409: {\n return new OneBlinkAppsError(error.message, {\n originalError: error,\n httpStatusCode: error.httpStatusCode,\n conflict: error.conflict,\n })\n }\n default: {\n return getDefaultError(error)\n }\n }\n}\n\nexport async function uploadFormSubmission(\n formSubmission: FormSubmission,\n /**\n * The date and time (in ISO format) the form was completed I.e. when the user\n * clicked the submit button\n */\n completionTimestamp: string,\n onProgress?: ProgressListener,\n abortSignal?: AbortSignal,\n) {\n try {\n const oneblinkUploader = generateOneBlinkUploader()\n\n const userToken = getUserToken()\n\n console.log('Uploading submission')\n return await oneblinkUploader.uploadSubmission({\n completionTimestamp,\n submission: formSubmission.submission,\n definition: formSubmission.definition,\n device: getDeviceInformation(),\n userToken: userToken || undefined,\n previousFormSubmissionApprovalId:\n formSubmission.previousFormSubmissionApprovalId,\n jobId: formSubmission.jobId || undefined,\n formsAppId: formSubmission.formsAppId,\n externalId: formSubmission.externalId || undefined,\n taskId: formSubmission.taskCompletion?.task.taskId || undefined,\n taskActionId: formSubmission.taskCompletion?.taskAction.taskActionId,\n taskGroupInstanceId:\n formSubmission.taskCompletion?.taskGroupInstance?.taskGroupInstanceId,\n taskCompletionTimestamp: formSubmission.taskCompletion?.completedAt,\n taskIsAdhoc: formSubmission.taskCompletion?.isAdhoc,\n recaptchas: formSubmission.recaptchas,\n onProgress,\n abortSignal,\n formSubmissionDraftId: formSubmission.formSubmissionDraftId,\n })\n } catch (error) {\n throw handleError(error as OneBlinkStorageError)\n }\n}\n\nexport async function uploadFormSubmissionEdit({\n submission,\n definition,\n submissionId,\n context,\n editedS3ObjectVersionId,\n onProgress,\n abortSignal,\n}: {\n submission: SubmissionTypes.NewS3SubmissionData['submission']\n definition: FormTypes.Form\n submissionId: string\n context: SubmissionTypes.FormSubmissionMetaEditContext\n editedS3ObjectVersionId: string\n onProgress?: ProgressListener\n abortSignal?: AbortSignal\n}) {\n try {\n const oneblinkUploader = generateOneBlinkUploader()\n return await oneblinkUploader.uploadFormSubmissionEdit({\n submission,\n definition,\n device: getDeviceInformation(),\n completionTimestamp: new Date().toISOString(),\n submissionId,\n context,\n editedS3ObjectVersionId,\n onProgress,\n abortSignal,\n })\n } catch (error) {\n throw handleError(error as OneBlinkStorageError)\n }\n}\n\nexport async function downloadFormSubmission({\n formId,\n submissionId,\n abortSignal,\n versionId,\n asSubmitted,\n}: {\n formId: number\n submissionId: string\n abortSignal?: AbortSignal\n versionId?: string\n asSubmitted?: boolean\n}) {\n try {\n console.log('Attempting to download form submission data:', {\n formId,\n submissionId,\n versionId,\n asSubmitted,\n })\n const oneblinkDownloader = generateOneBlinkDownloader()\n const result = await oneblinkDownloader.downloadSubmission({\n formId,\n submissionId,\n abortSignal,\n versionId,\n asSubmitted,\n })\n if (!result) {\n throw new OneBlinkAppsError(\n \"This submission has been removed based on your administrator's retention policy.\",\n {\n title: 'Submission Data Unavailable',\n },\n )\n }\n return {\n data: result.data,\n versionId: result.versionId,\n }\n } catch (error) {\n console.error('Error retrieving form submission data', error)\n\n if (error instanceof OneBlinkAppsError) {\n throw error\n }\n\n Sentry.captureException(error)\n\n if (isOffline()) {\n throw new OneBlinkAppsError(\n 'You are currently offline, please connect to the internet and try again',\n {\n originalError: error instanceof Error ? error : undefined,\n isOffline: true,\n },\n )\n }\n\n if (error instanceof OneBlinkStorageError) {\n switch (error.httpStatusCode) {\n case 401: {\n throw new OneBlinkAppsError(\n 'The submission you are attempting to view requires authentication. Please login and try again.',\n {\n originalError: error,\n requiresLogin: true,\n httpStatusCode: error.httpStatusCode,\n },\n )\n }\n case 403: {\n throw new OneBlinkAppsError(\n 'You do not have access to submission data. Please contact your administrator to gain the correct level of access.',\n {\n originalError: error,\n requiresAccessRequest: true,\n httpStatusCode: error.httpStatusCode,\n },\n )\n }\n case 400:\n case 404: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.httpStatusCode,\n })\n }\n }\n }\n\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error instanceof Error ? error : undefined,\n httpStatusCode:\n error instanceof OneBlinkStorageError\n ? error.httpStatusCode\n : undefined,\n },\n )\n }\n}\n"]}
|
|
@@ -214,17 +214,23 @@ declare function executePostSubmissionAction(submissionResult: FormSubmissionRes
|
|
|
214
214
|
* })
|
|
215
215
|
* ```
|
|
216
216
|
*
|
|
217
|
-
* @param
|
|
218
|
-
* @param
|
|
219
|
-
* @param
|
|
217
|
+
* @param options
|
|
218
|
+
* @param options.formId
|
|
219
|
+
* @param options.submissionId
|
|
220
|
+
* @param options.abortSignal
|
|
221
|
+
* @param options.versionId
|
|
222
|
+
* @param options.asSubmitted
|
|
220
223
|
* @returns
|
|
221
224
|
*/
|
|
222
|
-
declare function getSubmissionData({ formId, submissionId, abortSignal, }: {
|
|
225
|
+
declare function getSubmissionData({ formId, submissionId, abortSignal, versionId, asSubmitted, }: {
|
|
223
226
|
formId: number;
|
|
224
227
|
submissionId: string;
|
|
225
228
|
abortSignal?: AbortSignal;
|
|
229
|
+
versionId?: string;
|
|
230
|
+
/** Download the submission data as it was originally submitted. */
|
|
231
|
+
asSubmitted?: boolean;
|
|
226
232
|
}): Promise<{
|
|
227
233
|
data: SubmissionTypes.S3SubmissionData;
|
|
228
|
-
versionId: string;
|
|
234
|
+
versionId: string | undefined;
|
|
229
235
|
}>;
|
|
230
236
|
export { submit, executePostSubmissionAction, executeCancelAction, goBackOrCloseWindow, getPendingQueueSubmissions, deletePendingQueueSubmission, editPendingQueueSubmission, cancelEditingPendingQueueSubmission, registerPendingQueueListener, processPendingQueue, BaseFormSubmission, NewDraftSubmission, NewFormSubmission, DraftSubmissionInput, DraftSubmission, FormSubmission, FormSubmissionResult, PendingFormSubmission, SubmissionParams, registerPendingQueueAttachmentProgressListener, registerPendingQueueProgressListener, ProgressListener, ProgressListenerEvent, PendingQueueListener, PendingQueueAction, getSubmissionData, uploadFormSubmissionEdit, getPostSubmissionAttachments, };
|
|
@@ -409,16 +409,21 @@ async function executeAction(submissionResult, { action, redirectUrl, onRedirect
|
|
|
409
409
|
* })
|
|
410
410
|
* ```
|
|
411
411
|
*
|
|
412
|
-
* @param
|
|
413
|
-
* @param
|
|
414
|
-
* @param
|
|
412
|
+
* @param options
|
|
413
|
+
* @param options.formId
|
|
414
|
+
* @param options.submissionId
|
|
415
|
+
* @param options.abortSignal
|
|
416
|
+
* @param options.versionId
|
|
417
|
+
* @param options.asSubmitted
|
|
415
418
|
* @returns
|
|
416
419
|
*/
|
|
417
|
-
async function getSubmissionData({ formId, submissionId, abortSignal, }) {
|
|
420
|
+
async function getSubmissionData({ formId, submissionId, abortSignal, versionId, asSubmitted, }) {
|
|
418
421
|
return await downloadFormSubmission({
|
|
419
422
|
formId,
|
|
420
423
|
submissionId,
|
|
421
424
|
abortSignal,
|
|
425
|
+
versionId,
|
|
426
|
+
asSubmitted,
|
|
422
427
|
});
|
|
423
428
|
}
|
|
424
429
|
export { submit, executePostSubmissionAction, executeCancelAction, goBackOrCloseWindow, getPendingQueueSubmissions, deletePendingQueueSubmission, editPendingQueueSubmission, cancelEditingPendingQueueSubmission, registerPendingQueueListener, processPendingQueue, registerPendingQueueAttachmentProgressListener, registerPendingQueueProgressListener, getSubmissionData, uploadFormSubmissionEdit, getPostSubmissionAttachments, };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submission-service.js","sourceRoot":"","sources":["../../src/apps/submission-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,4BAA4B,EAC5B,mCAAmC,EACnC,4BAA4B,EAC5B,0BAA0B,EAC1B,8CAA8C,EAC9C,oCAAoC,EACpC,oCAAoC,EACpC,4BAA4B,GAG7B,MAAM,0BAA0B,CAAA;AACjC,OAAO,sCAAsC,MAAM,mDAAmD,CAAA;AAEtG,OAAO,MAAM,MAAM,UAAU,CAAA;AAC7B,OAAO,qBAAqB,MAAM,kCAAkC,CAAA;AACpE,OAAO,UAIN,MAAM,mBAAmB,CAAA;AAW1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,4BAA4B,MAAM,gDAAgD,CAAA;AAEzF,IAAI,yBAAyB,GAAG,KAAK,CAAA;AAErC;;;;;;;;;;;GAWG;AACH,KAAK,UAAU,mBAAmB,CAAC,EACjC,6BAA6B,EAC7B,yBAAyB,GAI1B;IACC,IAAI,yBAAyB,EAAE,CAAC;QAC9B,OAAM;IACR,CAAC;IACD,yBAAyB,GAAG,IAAI,CAAA;IAEhC,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAA;IACtD,MAAM,uBAAuB,GAAG,MAAM,0BAA0B,EAAE,CAAA;IAElE,OAAO,CAAC,GAAG,CACT,SAAS,uBAAuB,CAAC,MAAM,sCAAsC,CAC9E,CAAA;IACD,KAAK,MAAM,sBAAsB,IAAI,uBAAu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oCAAoC,EAKpC,iBAAiB,EACjB,wBAAwB,EACxB,4BAA4B,GAC7B,CAAA","sourcesContent":["import { isOffline } from './offline-service'\nimport { getFormsKeyId, isLoggedIn } from './auth-service'\nimport {\n registerPendingQueueListener,\n getPendingQueueSubmissions,\n updatePendingQueueSubmission,\n cancelEditingPendingQueueSubmission,\n deletePendingQueueSubmission,\n editPendingQueueSubmission,\n registerPendingQueueAttachmentProgressListener,\n registerPendingQueueProgressListener,\n executePendingQueueProgressListeners,\n removePendingQueueSubmission,\n PendingQueueListener,\n PendingQueueAction,\n} from './services/pending-queue'\nimport replaceInjectablesWithSubmissionValues from './services/replaceInjectablesWithSubmissionValues'\nimport { FormTypes, SubmissionTypes } from '@oneblink/types'\nimport Sentry from './Sentry'\nimport prepareSubmissionData from './services/prepareSubmissionData'\nimport submitForm, {\n SubmissionParams,\n ProgressListener,\n ProgressListenerEvent,\n} from './services/submit'\nimport {\n PendingFormSubmission,\n FormSubmission,\n FormSubmissionResult,\n BaseFormSubmission,\n NewDraftSubmission,\n NewFormSubmission,\n DraftSubmission,\n DraftSubmissionInput,\n} from './types/submissions'\nimport { deleteAutoSaveData } from './auto-save-service'\nimport {\n downloadFormSubmission,\n uploadFormSubmissionEdit,\n} from './services/api/submissions'\nimport { getSubmissionAttachmentDetails } from './attachments-service'\nimport getPostSubmissionAttachments from './services/api/post-submission-attachment-urls'\n\nlet _isProcessingPendingQueue = false\n\n/**\n * Force processing the pending queue. This must be called to process the\n * pending queue and is best used when the application comes back online.\n *\n * ### Example\n *\n * ```js\n * await submissionService.processPendingQueue()\n * ```\n *\n * @returns\n */\nasync function processPendingQueue({\n shouldRunExternalIdGeneration,\n shouldRunServerValidation,\n}: {\n shouldRunExternalIdGeneration: boolean\n shouldRunServerValidation: boolean\n}): Promise<void> {\n if (_isProcessingPendingQueue) {\n return\n }\n _isProcessingPendingQueue = true\n\n console.log('Checking pending queue for submissions.')\n const pendingQueueSubmissions = await getPendingQueueSubmissions()\n\n console.log(\n `Found ${pendingQueueSubmissions.length} submission(s) in the pending queue.`,\n )\n for (const pendingQueueSubmission of pendingQueueSubmissions) {\n if (isOffline()) {\n console.log(\n 'Application is offline, leaving submission in the pending queue:',\n pendingQueueSubmission,\n )\n continue\n }\n\n if (pendingQueueSubmission.isEditing) {\n console.log(\n 'submission is being edited, leaving submission in the pending queue:',\n pendingQueueSubmission,\n )\n continue\n }\n\n if (\n pendingQueueSubmission.definition.isAuthenticated &&\n !isLoggedIn() &&\n !getFormsKeyId()\n ) {\n console.log(\n 'Authentication is required for this form but the user does not have a valid token, leaving submission in the pending queue:',\n pendingQueueSubmission,\n )\n continue\n }\n\n try {\n console.log(\n 'Attempting to process submission from pending queue:',\n pendingQueueSubmission,\n )\n\n pendingQueueSubmission.isSubmitting = true\n pendingQueueSubmission.error = undefined\n await updatePendingQueueSubmission(\n pendingQueueSubmission.pendingTimestamp,\n pendingQueueSubmission,\n 'SUBMIT_STARTED',\n )\n\n const preparedSubmission = await prepareSubmissionData(\n pendingQueueSubmission,\n )\n pendingQueueSubmission.submission = {\n ...preparedSubmission,\n }\n const attachments = getSubmissionAttachmentDetails(\n pendingQueueSubmission.definition.elements,\n pendingQueueSubmission.submission,\n )\n const failedAttachments = attachments.filter(\n (attachment) => attachment.value.type === 'ERROR',\n )\n if (failedAttachments.length) {\n throw new Error(\n `Failed to upload ${failedAttachments.length} attachment${\n failedAttachments.length > 1 ? 's' : ''\n }.`,\n )\n }\n await submitWithCompletionTimestamp({\n isPendingQueueEnabled: true,\n formSubmission: pendingQueueSubmission,\n onProgress: (event) => {\n executePendingQueueProgressListeners({\n ...event,\n pendingTimestamp: pendingQueueSubmission.pendingTimestamp,\n })\n },\n shouldRunExternalIdGeneration,\n shouldRunServerValidation,\n paymentFormUrl: undefined,\n paymentReceiptUrl: undefined,\n completionTimestamp: pendingQueueSubmission.pendingTimestamp,\n })\n\n await removePendingQueueSubmission(\n pendingQueueSubmission.pendingTimestamp,\n 'SUBMIT_SUCCEEDED',\n )\n\n console.log(\n 'Successfully processed submission from the pending queue',\n pendingQueueSubmission,\n )\n } catch (error) {\n Sentry.captureException(error)\n console.error('Error processing submission from the pending queue', error)\n pendingQueueSubmission.isSubmitting = false\n if ((error as Error).message) {\n pendingQueueSubmission.error = (error as Error).message\n } else {\n pendingQueueSubmission.error =\n 'An unknown error has occurred, which has prevented your Form from submitting. Please try again, or contact your Administrator if the problem persists.'\n }\n await updatePendingQueueSubmission(\n pendingQueueSubmission.pendingTimestamp,\n pendingQueueSubmission,\n 'SUBMIT_FAILED',\n )\n }\n }\n\n console.log(\n 'Finished attempting to processing submissions in the pending queue.',\n )\n _isProcessingPendingQueue = false\n}\n\n/**\n * Submit a FormSubmission. Offline submissions will be added to a pending queue\n * and be processed using the `processPendingQueue()` function. FormSubmissions\n * with payment submission events will return the FormSubmissionResult with a\n * `payment` property set, this should be used to redirect the user to the\n * payment URL. Will also handle cleaning up auto save data (if the\n * `autoSaveKey` property is passed), locally stored drafts and prefill data.\n *\n * ### Example\n *\n * ```js\n * const formSubmission = {\n * formsAppId: 1,\n * submission: {\n * form: 'data',\n * goes: 'here',\n * },\n * definition: OneBlinkForm,\n * captchaTokens: [],\n * formSubmissionDraftId: '2974602c-2c5b-4b46-b086-87ee9b2aa233',\n * jobId: 'bb37d1da-9cda-4950-a36a-22f58b25de3a',\n * preFillFormDataId: '7763f828-4aaf-49dc-9c1b-e2eeea8fa990',\n * externalId: 'external-id-set-by-developer',\n * }\n *\n * // Pass paymentReceiptUrl if submission may require a payment\n * const paymentReceiptUrl = `${window.location.origin}/payment-receipt`\n *\n * // Pass schedulingBookingUrlConfiguration if submission utilise scheduling\n * const schedulingBookingUrlConfiguration = {\n * schedulingBookingUrl: 'https://my-website.com/booking',\n * schedulingRescheduleUrl: 'https://my-website.com/reschedule',\n * schedulingCancelUrl: 'https://my-website.com/cancel',\n * }\n * const submissionResult = await submissionService.submit({\n * formSubmission,\n * paymentReceiptUrl,\n * schedulingBookingUrlConfiguration,\n * })\n *\n * if (submissionResult.scheduling) {\n * // Redirect user to booking form\n * window.location.href = submissionResult.scheduling.bookingUrl\n * return\n * }\n *\n * if (submissionResult.payment) {\n * // Redirect user to payment form\n * window.location.href = submissionResult.payment.hostedFormUrl\n * return\n * }\n *\n * if (submissionResult.isOffline) {\n * if (submissionResult.isInPendingQueue) {\n * // Display message to user that the submission\n * // has been added to the pending queue\n * } else {\n * // Display message to user that this submission can\n * // not be processed while offline (most likely because it requires a payment)\n * }\n * return\n * }\n *\n * // submissionResult.submissionId and submissionResult.submissionTimestamp\n * // will be set if the submission was successful\n * ```\n *\n * @param params\n * @returns\n */\nasync function submit(\n params: SubmissionParams & {\n autoSaveKey?: string\n },\n): Promise<FormSubmissionResult> {\n return await submitWithCompletionTimestamp({\n ...params,\n completionTimestamp: new Date().toISOString(),\n })\n}\n\nasync function submitWithCompletionTimestamp({\n autoSaveKey,\n ...params\n}: SubmissionParams & {\n autoSaveKey?: string\n completionTimestamp: string\n}): Promise<FormSubmissionResult> {\n const formSubmissionResult = await submitForm(params)\n if (typeof autoSaveKey === 'string') {\n try {\n await deleteAutoSaveData(params.formSubmission.definition.id, autoSaveKey)\n } catch (error) {\n console.warn('Error removing auto save data: ', error)\n Sentry.captureException(error)\n }\n }\n return formSubmissionResult\n}\n\nasync function closeWindow(): Promise<void> {\n // @ts-expect-error\n if (window.cordova && window.cordova.plugins.exit) {\n // @ts-expect-error\n window.cordova.plugins.exit()\n return\n }\n\n window.close()\n\n // If the browser has not closed after timeout,\n // we throw an error to display to the user\n return new Promise((resolve, reject) => {\n setTimeout(() => {\n console.log('Could not close as window was not opened using JavaScript')\n reject(\n new Error(\n 'We were unable to close your browser, could you please close it manually for us?',\n ),\n )\n }, 500)\n })\n}\n\n/**\n * Go back in the browser history or attempts to close the browser tab if there\n * is no history.\n *\n * ### Example\n *\n * ```js\n * try {\n * await submissionService.goBackOrCloseWindow()\n * } catch (error) {\n * // Handle error while closing browser tab.\n * // Display message to user to close it manually\n * }\n * ```\n *\n * @returns\n */\nasync function goBackOrCloseWindow(): Promise<void> {\n if (window.history.length <= 1) {\n return closeWindow()\n } else {\n window.history.back()\n }\n}\n\n/**\n * Action to cancel completing a form, currently goes back in the browser\n * history or attempts to close the browser tab if there is no history.\n *\n * ### Example\n *\n * ```js\n * const options = {\n * definition: OneBlinkForm,\n * externalId: 'external-id-set-by-developer',\n * }\n * // Only used for relative URLs\n * const pushRelativePath = (path) => {\n * window.location.href = path\n * }\n * // Only used for aboslute URLS\n * const replaceAbsolutePath = window.location.replace\n *\n * try {\n * await submissionService.executeCancelAction(options, {\n * onRedirectToRelativeUrl: pushRelativePath,\n * onRedirectToAbsoluteUrl: replaceAbsolutePath,\n * })\n * } catch (error) {\n * // Handle error while closing browser tab.\n * // Display message to user to close it manually\n * }\n * ```\n *\n * @param options\n * @param redirectConfig\n */\nasync function executeCancelAction(\n formSubmissionResultOptions: {\n definition: FormTypes.Form\n externalId: string | null\n taskCompletion?: FormSubmissionResult['taskCompletion']\n },\n {\n onRedirectToRelativeUrl,\n onRedirectToAbsoluteUrl,\n }: {\n onRedirectToRelativeUrl: (url: string) => void\n onRedirectToAbsoluteUrl: (url: string) => void\n },\n): Promise<void> {\n const formSubmissionResult: FormSubmissionResult = {\n ...formSubmissionResultOptions,\n formsAppId: NaN,\n formSubmissionDraftId: undefined,\n jobId: undefined,\n externalId: undefined,\n preFillFormDataId: null,\n recaptchas: [],\n submission: {},\n isInPendingQueue: false,\n isOffline: false,\n payment: null,\n scheduling: null,\n submissionId: null,\n submissionTimestamp: null,\n isUploadingAttachments: false,\n }\n\n let cancelAction = formSubmissionResult.definition.cancelAction\n let cancelRedirectUrl = formSubmissionResult.definition.cancelRedirectUrl\n\n if (formSubmissionResult.taskCompletion) {\n cancelAction = 'URL'\n cancelRedirectUrl = formSubmissionResult.taskCompletion.redirectUrl\n }\n\n await executeAction(formSubmissionResult, {\n action: cancelAction,\n redirectUrl: cancelRedirectUrl,\n onRedirectToRelativeUrl,\n onRedirectToAbsoluteUrl,\n })\n}\n\n/**\n * Execute the post submission action for a form after a successful form\n * submission.\n *\n * ### Example\n *\n * ```js\n * const formSubmissionResult = {\n * submissionId: '89c6e98e-f56f-45fc-84fe-c4fc62331d34',\n * submissionTimestamp: '2020-07-29T01:03:26.573Z'\n * formsAppId: 1,\n * submission: {\n * form: 'data',\n * goes: 'here'\n * },\n * definition: OneBlinkForm,\n * payment: {\n * hostedFormUrl: 'https://payment.com/transaction'\n * },\n * formSubmissionDraftId: '2974602c-2c5b-4b46-b086-87ee9b2aa233',\n * jobId: 'bb37d1da-9cda-4950-a36a-22f58b25de3a',\n * preFillFormDataId: '7763f828-4aaf-49dc-9c1b-e2eeea8fa990',\n * externalId: 'external-id-set-by-developer',\n * }\n * // Only used for relative URLs\n * const pushRelativePath = (path) => {\n * window.location.href = path\n * }\n * // Only used for aboslute URLS\n * const replaceAbsolutePath = window.location.replace\n *\n * try {\n * await submissionService.executePostSubmissionAction(formSubmissionResult, {\n * onRedirectToRelativeUrl: pushRelativePath,\n * onRedirectToAbsoluteUrl: replaceAbsolutePath,\n * })\n * } catch (error) {\n * // Handle error while closing browser tab.\n * // Display message to user to close it manually\n * }\n * ```\n *\n * @param submissionResult\n * @param redirectConfig\n */\nasync function executePostSubmissionAction(\n submissionResult: FormSubmissionResult,\n {\n onRedirectToRelativeUrl,\n onRedirectToAbsoluteUrl,\n }: {\n onRedirectToRelativeUrl: (url: string) => void\n onRedirectToAbsoluteUrl: (url: string) => void\n },\n): Promise<void> {\n console.log('Attempting to run post submission action')\n let postSubmissionAction = submissionResult.definition.postSubmissionAction\n let redirectUrl = submissionResult.definition.redirectUrl\n\n if (submissionResult.scheduling) {\n postSubmissionAction = 'URL'\n redirectUrl = submissionResult.scheduling.bookingUrl\n } else if (submissionResult.payment) {\n postSubmissionAction = 'URL'\n redirectUrl = submissionResult.payment.hostedFormUrl\n } else if (submissionResult.taskCompletion) {\n postSubmissionAction = 'URL'\n redirectUrl = submissionResult.taskCompletion.redirectUrl\n }\n\n await executeAction(submissionResult, {\n action: postSubmissionAction,\n redirectUrl,\n onRedirectToRelativeUrl,\n onRedirectToAbsoluteUrl,\n })\n}\n\nasync function executeAction(\n submissionResult: FormSubmissionResult,\n {\n action,\n redirectUrl,\n onRedirectToRelativeUrl,\n onRedirectToAbsoluteUrl,\n }: {\n action: FormTypes.FormPostSubmissionAction\n redirectUrl: string | undefined\n onRedirectToRelativeUrl: (url: string) => void\n onRedirectToAbsoluteUrl: (url: string) => void\n },\n): Promise<void> {\n switch (action) {\n case 'CLOSE':\n return closeWindow()\n case 'FORMS_LIBRARY': {\n if (window.location.pathname === '/') {\n onRedirectToAbsoluteUrl(window.location.origin)\n } else {\n onRedirectToRelativeUrl('/')\n }\n break\n }\n case 'URL': {\n const newUrl = replaceInjectablesWithSubmissionValues(\n redirectUrl || '/',\n submissionResult,\n ).text\n // Relative URLs can be navigated to internally\n if (newUrl[0] === '/') {\n onRedirectToRelativeUrl(newUrl)\n return\n }\n\n onRedirectToAbsoluteUrl(newUrl)\n\n // If we are in cordova land, we will navigate\n // back to the home screen after redirect\n if (window.cordova) {\n // Wait a couple of seconds to ensure the browser has\n // been opened before navigating away from form.\n setTimeout(() => {\n onRedirectToRelativeUrl('/')\n }, 2000)\n }\n break\n }\n case 'BACK':\n default: {\n // if there's no post submission action for some reason, use prev. logic...\n return goBackOrCloseWindow()\n }\n }\n}\n\n/**\n * Retrieve submission data for a known formId and submissionId\n *\n * #### Example\n *\n * ```js\n * const formId = 1\n * const submissionId = 'fba95b9d-5a9c-463d-ab68-867f431e4120'\n * const credentials = await formSubmissionService.getSubmissionData({\n * formId,\n * submissionId,\n * })\n * ```\n *\n * @param formId\n * @param submissionId\n * @param abortSignal\n * @returns\n */\nasync function getSubmissionData({\n formId,\n submissionId,\n abortSignal,\n}: {\n formId: number\n submissionId: string\n abortSignal?: AbortSignal\n}): Promise<{\n data: SubmissionTypes.S3SubmissionData\n versionId: string\n}> {\n return await downloadFormSubmission({\n formId,\n submissionId,\n abortSignal,\n })\n}\n\nexport {\n submit,\n executePostSubmissionAction,\n executeCancelAction,\n goBackOrCloseWindow,\n getPendingQueueSubmissions,\n deletePendingQueueSubmission,\n editPendingQueueSubmission,\n cancelEditingPendingQueueSubmission,\n registerPendingQueueListener,\n processPendingQueue,\n BaseFormSubmission,\n NewDraftSubmission,\n NewFormSubmission,\n DraftSubmissionInput,\n DraftSubmission,\n FormSubmission,\n FormSubmissionResult,\n PendingFormSubmission,\n SubmissionParams,\n registerPendingQueueAttachmentProgressListener,\n registerPendingQueueProgressListener,\n ProgressListener,\n ProgressListenerEvent,\n PendingQueueListener,\n PendingQueueAction,\n getSubmissionData,\n uploadFormSubmissionEdit,\n getPostSubmissionAttachments,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"submission-service.js","sourceRoot":"","sources":["../../src/apps/submission-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC1D,OAAO,EACL,4BAA4B,EAC5B,0BAA0B,EAC1B,4BAA4B,EAC5B,mCAAmC,EACnC,4BAA4B,EAC5B,0BAA0B,EAC1B,8CAA8C,EAC9C,oCAAoC,EACpC,oCAAoC,EACpC,4BAA4B,GAG7B,MAAM,0BAA0B,CAAA;AACjC,OAAO,sCAAsC,MAAM,mDAAmD,CAAA;AAEtG,OAAO,MAAM,MAAM,UAAU,CAAA;AAC7B,OAAO,qBAAqB,MAAM,kCAAkC,CAAA;AACpE,OAAO,UAIN,MAAM,mBAAmB,CAAA;AAW1B,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,EACL,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,4BAA4B,CAAA;AACnC,OAAO,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAA;AACtE,OAAO,4BAA4B,MAAM,gDAAgD,CAAA;AAEzF,IAAI,y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AAA;QAC9B,CAAC;IACH,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,KAAK,UAAU,iBAAiB,CAAC,EAC/B,MAAM,EACN,YAAY,EACZ,WAAW,EACX,SAAS,EACT,WAAW,GAQZ;IAIC,OAAO,MAAM,sBAAsB,CAAC;QAClC,MAAM;QACN,YAAY;QACZ,WAAW;QACX,SAAS;QACT,WAAW;KACZ,CAAC,CAAA;AACJ,CAAC;AAED,OAAO,EACL,MAAM,EACN,2BAA2B,EAC3B,mBAAmB,EACnB,mBAAmB,EACnB,0BAA0B,EAC1B,4BAA4B,EAC5B,0BAA0B,EAC1B,mCAAmC,EACnC,4BAA4B,EAC5B,mBAAmB,EAUnB,8CAA8C,EAC9C,oCAAoC,EAKpC,iBAAiB,EACjB,wBAAwB,EACxB,4BAA4B,GAC7B,CAAA","sourcesContent":["import { isOffline } from './offline-service'\nimport { getFormsKeyId, isLoggedIn } from './auth-service'\nimport {\n registerPendingQueueListener,\n getPendingQueueSubmissions,\n updatePendingQueueSubmission,\n cancelEditingPendingQueueSubmission,\n deletePendingQueueSubmission,\n editPendingQueueSubmission,\n registerPendingQueueAttachmentProgressListener,\n registerPendingQueueProgressListener,\n executePendingQueueProgressListeners,\n removePendingQueueSubmission,\n PendingQueueListener,\n PendingQueueAction,\n} from './services/pending-queue'\nimport replaceInjectablesWithSubmissionValues from './services/replaceInjectablesWithSubmissionValues'\nimport { FormTypes, SubmissionTypes } from '@oneblink/types'\nimport Sentry from './Sentry'\nimport prepareSubmissionData from './services/prepareSubmissionData'\nimport submitForm, {\n SubmissionParams,\n ProgressListener,\n ProgressListenerEvent,\n} from './services/submit'\nimport {\n PendingFormSubmission,\n FormSubmission,\n FormSubmissionResult,\n BaseFormSubmission,\n NewDraftSubmission,\n NewFormSubmission,\n DraftSubmission,\n DraftSubmissionInput,\n} from './types/submissions'\nimport { deleteAutoSaveData } from './auto-save-service'\nimport {\n downloadFormSubmission,\n uploadFormSubmissionEdit,\n} from './services/api/submissions'\nimport { getSubmissionAttachmentDetails } from './attachments-service'\nimport getPostSubmissionAttachments from './services/api/post-submission-attachment-urls'\n\nlet _isProcessingPendingQueue = false\n\n/**\n * Force processing the pending queue. This must be called to process the\n * pending queue and is best used when the application comes back online.\n *\n * ### Example\n *\n * ```js\n * await submissionService.processPendingQueue()\n * ```\n *\n * @returns\n */\nasync function processPendingQueue({\n shouldRunExternalIdGeneration,\n shouldRunServerValidation,\n}: {\n shouldRunExternalIdGeneration: boolean\n shouldRunServerValidation: boolean\n}): Promise<void> {\n if (_isProcessingPendingQueue) {\n return\n }\n _isProcessingPendingQueue = true\n\n console.log('Checking pending queue for submissions.')\n const pendingQueueSubmissions = await getPendingQueueSubmissions()\n\n console.log(\n `Found ${pendingQueueSubmissions.length} submission(s) in the pending queue.`,\n )\n for (const pendingQueueSubmission of pendingQueueSubmissions) {\n if (isOffline()) {\n console.log(\n 'Application is offline, leaving submission in the pending queue:',\n pendingQueueSubmission,\n )\n continue\n }\n\n if (pendingQueueSubmission.isEditing) {\n console.log(\n 'submission is being edited, leaving submission in the pending queue:',\n pendingQueueSubmission,\n )\n continue\n }\n\n if (\n pendingQueueSubmission.definition.isAuthenticated &&\n !isLoggedIn() &&\n !getFormsKeyId()\n ) {\n console.log(\n 'Authentication is required for this form but the user does not have a valid token, leaving submission in the pending queue:',\n pendingQueueSubmission,\n )\n continue\n }\n\n try {\n console.log(\n 'Attempting to process submission from pending queue:',\n pendingQueueSubmission,\n )\n\n pendingQueueSubmission.isSubmitting = true\n pendingQueueSubmission.error = undefined\n await updatePendingQueueSubmission(\n pendingQueueSubmission.pendingTimestamp,\n pendingQueueSubmission,\n 'SUBMIT_STARTED',\n )\n\n const preparedSubmission = await prepareSubmissionData(\n pendingQueueSubmission,\n )\n pendingQueueSubmission.submission = {\n ...preparedSubmission,\n }\n const attachments = getSubmissionAttachmentDetails(\n pendingQueueSubmission.definition.elements,\n pendingQueueSubmission.submission,\n )\n const failedAttachments = attachments.filter(\n (attachment) => attachment.value.type === 'ERROR',\n )\n if (failedAttachments.length) {\n throw new Error(\n `Failed to upload ${failedAttachments.length} attachment${\n failedAttachments.length > 1 ? 's' : ''\n }.`,\n )\n }\n await submitWithCompletionTimestamp({\n isPendingQueueEnabled: true,\n formSubmission: pendingQueueSubmission,\n onProgress: (event) => {\n executePendingQueueProgressListeners({\n ...event,\n pendingTimestamp: pendingQueueSubmission.pendingTimestamp,\n })\n },\n shouldRunExternalIdGeneration,\n shouldRunServerValidation,\n paymentFormUrl: undefined,\n paymentReceiptUrl: undefined,\n completionTimestamp: pendingQueueSubmission.pendingTimestamp,\n })\n\n await removePendingQueueSubmission(\n pendingQueueSubmission.pendingTimestamp,\n 'SUBMIT_SUCCEEDED',\n )\n\n console.log(\n 'Successfully processed submission from the pending queue',\n pendingQueueSubmission,\n )\n } catch (error) {\n Sentry.captureException(error)\n console.error('Error processing submission from the pending queue', error)\n pendingQueueSubmission.isSubmitting = false\n if ((error as Error).message) {\n pendingQueueSubmission.error = (error as Error).message\n } else {\n pendingQueueSubmission.error =\n 'An unknown error has occurred, which has prevented your Form from submitting. Please try again, or contact your Administrator if the problem persists.'\n }\n await updatePendingQueueSubmission(\n pendingQueueSubmission.pendingTimestamp,\n pendingQueueSubmission,\n 'SUBMIT_FAILED',\n )\n }\n }\n\n console.log(\n 'Finished attempting to processing submissions in the pending queue.',\n )\n _isProcessingPendingQueue = false\n}\n\n/**\n * Submit a FormSubmission. Offline submissions will be added to a pending queue\n * and be processed using the `processPendingQueue()` function. FormSubmissions\n * with payment submission events will return the FormSubmissionResult with a\n * `payment` property set, this should be used to redirect the user to the\n * payment URL. Will also handle cleaning up auto save data (if the\n * `autoSaveKey` property is passed), locally stored drafts and prefill data.\n *\n * ### Example\n *\n * ```js\n * const formSubmission = {\n * formsAppId: 1,\n * submission: {\n * form: 'data',\n * goes: 'here',\n * },\n * definition: OneBlinkForm,\n * captchaTokens: [],\n * formSubmissionDraftId: '2974602c-2c5b-4b46-b086-87ee9b2aa233',\n * jobId: 'bb37d1da-9cda-4950-a36a-22f58b25de3a',\n * preFillFormDataId: '7763f828-4aaf-49dc-9c1b-e2eeea8fa990',\n * externalId: 'external-id-set-by-developer',\n * }\n *\n * // Pass paymentReceiptUrl if submission may require a payment\n * const paymentReceiptUrl = `${window.location.origin}/payment-receipt`\n *\n * // Pass schedulingBookingUrlConfiguration if submission utilise scheduling\n * const schedulingBookingUrlConfiguration = {\n * schedulingBookingUrl: 'https://my-website.com/booking',\n * schedulingRescheduleUrl: 'https://my-website.com/reschedule',\n * schedulingCancelUrl: 'https://my-website.com/cancel',\n * }\n * const submissionResult = await submissionService.submit({\n * formSubmission,\n * paymentReceiptUrl,\n * schedulingBookingUrlConfiguration,\n * })\n *\n * if (submissionResult.scheduling) {\n * // Redirect user to booking form\n * window.location.href = submissionResult.scheduling.bookingUrl\n * return\n * }\n *\n * if (submissionResult.payment) {\n * // Redirect user to payment form\n * window.location.href = submissionResult.payment.hostedFormUrl\n * return\n * }\n *\n * if (submissionResult.isOffline) {\n * if (submissionResult.isInPendingQueue) {\n * // Display message to user that the submission\n * // has been added to the pending queue\n * } else {\n * // Display message to user that this submission can\n * // not be processed while offline (most likely because it requires a payment)\n * }\n * return\n * }\n *\n * // submissionResult.submissionId and submissionResult.submissionTimestamp\n * // will be set if the submission was successful\n * ```\n *\n * @param params\n * @returns\n */\nasync function submit(\n params: SubmissionParams & {\n autoSaveKey?: string\n },\n): Promise<FormSubmissionResult> {\n return await submitWithCompletionTimestamp({\n ...params,\n completionTimestamp: new Date().toISOString(),\n })\n}\n\nasync function submitWithCompletionTimestamp({\n autoSaveKey,\n ...params\n}: SubmissionParams & {\n autoSaveKey?: string\n completionTimestamp: string\n}): Promise<FormSubmissionResult> {\n const formSubmissionResult = await submitForm(params)\n if (typeof autoSaveKey === 'string') {\n try {\n await deleteAutoSaveData(params.formSubmission.definition.id, autoSaveKey)\n } catch (error) {\n console.warn('Error removing auto save data: ', error)\n Sentry.captureException(error)\n }\n }\n return formSubmissionResult\n}\n\nasync function closeWindow(): Promise<void> {\n // @ts-expect-error\n if (window.cordova && window.cordova.plugins.exit) {\n // @ts-expect-error\n window.cordova.plugins.exit()\n return\n }\n\n window.close()\n\n // If the browser has not closed after timeout,\n // we throw an error to display to the user\n return new Promise((resolve, reject) => {\n setTimeout(() => {\n console.log('Could not close as window was not opened using JavaScript')\n reject(\n new Error(\n 'We were unable to close your browser, could you please close it manually for us?',\n ),\n )\n }, 500)\n })\n}\n\n/**\n * Go back in the browser history or attempts to close the browser tab if there\n * is no history.\n *\n * ### Example\n *\n * ```js\n * try {\n * await submissionService.goBackOrCloseWindow()\n * } catch (error) {\n * // Handle error while closing browser tab.\n * // Display message to user to close it manually\n * }\n * ```\n *\n * @returns\n */\nasync function goBackOrCloseWindow(): Promise<void> {\n if (window.history.length <= 1) {\n return closeWindow()\n } else {\n window.history.back()\n }\n}\n\n/**\n * Action to cancel completing a form, currently goes back in the browser\n * history or attempts to close the browser tab if there is no history.\n *\n * ### Example\n *\n * ```js\n * const options = {\n * definition: OneBlinkForm,\n * externalId: 'external-id-set-by-developer',\n * }\n * // Only used for relative URLs\n * const pushRelativePath = (path) => {\n * window.location.href = path\n * }\n * // Only used for aboslute URLS\n * const replaceAbsolutePath = window.location.replace\n *\n * try {\n * await submissionService.executeCancelAction(options, {\n * onRedirectToRelativeUrl: pushRelativePath,\n * onRedirectToAbsoluteUrl: replaceAbsolutePath,\n * })\n * } catch (error) {\n * // Handle error while closing browser tab.\n * // Display message to user to close it manually\n * }\n * ```\n *\n * @param options\n * @param redirectConfig\n */\nasync function executeCancelAction(\n formSubmissionResultOptions: {\n definition: FormTypes.Form\n externalId: string | null\n taskCompletion?: FormSubmissionResult['taskCompletion']\n },\n {\n onRedirectToRelativeUrl,\n onRedirectToAbsoluteUrl,\n }: {\n onRedirectToRelativeUrl: (url: string) => void\n onRedirectToAbsoluteUrl: (url: string) => void\n },\n): Promise<void> {\n const formSubmissionResult: FormSubmissionResult = {\n ...formSubmissionResultOptions,\n formsAppId: NaN,\n formSubmissionDraftId: undefined,\n jobId: undefined,\n externalId: undefined,\n preFillFormDataId: null,\n recaptchas: [],\n submission: {},\n isInPendingQueue: false,\n isOffline: false,\n payment: null,\n scheduling: null,\n submissionId: null,\n submissionTimestamp: null,\n isUploadingAttachments: false,\n }\n\n let cancelAction = formSubmissionResult.definition.cancelAction\n let cancelRedirectUrl = formSubmissionResult.definition.cancelRedirectUrl\n\n if (formSubmissionResult.taskCompletion) {\n cancelAction = 'URL'\n cancelRedirectUrl = formSubmissionResult.taskCompletion.redirectUrl\n }\n\n await executeAction(formSubmissionResult, {\n action: cancelAction,\n redirectUrl: cancelRedirectUrl,\n onRedirectToRelativeUrl,\n onRedirectToAbsoluteUrl,\n })\n}\n\n/**\n * Execute the post submission action for a form after a successful form\n * submission.\n *\n * ### Example\n *\n * ```js\n * const formSubmissionResult = {\n * submissionId: '89c6e98e-f56f-45fc-84fe-c4fc62331d34',\n * submissionTimestamp: '2020-07-29T01:03:26.573Z'\n * formsAppId: 1,\n * submission: {\n * form: 'data',\n * goes: 'here'\n * },\n * definition: OneBlinkForm,\n * payment: {\n * hostedFormUrl: 'https://payment.com/transaction'\n * },\n * formSubmissionDraftId: '2974602c-2c5b-4b46-b086-87ee9b2aa233',\n * jobId: 'bb37d1da-9cda-4950-a36a-22f58b25de3a',\n * preFillFormDataId: '7763f828-4aaf-49dc-9c1b-e2eeea8fa990',\n * externalId: 'external-id-set-by-developer',\n * }\n * // Only used for relative URLs\n * const pushRelativePath = (path) => {\n * window.location.href = path\n * }\n * // Only used for aboslute URLS\n * const replaceAbsolutePath = window.location.replace\n *\n * try {\n * await submissionService.executePostSubmissionAction(formSubmissionResult, {\n * onRedirectToRelativeUrl: pushRelativePath,\n * onRedirectToAbsoluteUrl: replaceAbsolutePath,\n * })\n * } catch (error) {\n * // Handle error while closing browser tab.\n * // Display message to user to close it manually\n * }\n * ```\n *\n * @param submissionResult\n * @param redirectConfig\n */\nasync function executePostSubmissionAction(\n submissionResult: FormSubmissionResult,\n {\n onRedirectToRelativeUrl,\n onRedirectToAbsoluteUrl,\n }: {\n onRedirectToRelativeUrl: (url: string) => void\n onRedirectToAbsoluteUrl: (url: string) => void\n },\n): Promise<void> {\n console.log('Attempting to run post submission action')\n let postSubmissionAction = submissionResult.definition.postSubmissionAction\n let redirectUrl = submissionResult.definition.redirectUrl\n\n if (submissionResult.scheduling) {\n postSubmissionAction = 'URL'\n redirectUrl = submissionResult.scheduling.bookingUrl\n } else if (submissionResult.payment) {\n postSubmissionAction = 'URL'\n redirectUrl = submissionResult.payment.hostedFormUrl\n } else if (submissionResult.taskCompletion) {\n postSubmissionAction = 'URL'\n redirectUrl = submissionResult.taskCompletion.redirectUrl\n }\n\n await executeAction(submissionResult, {\n action: postSubmissionAction,\n redirectUrl,\n onRedirectToRelativeUrl,\n onRedirectToAbsoluteUrl,\n })\n}\n\nasync function executeAction(\n submissionResult: FormSubmissionResult,\n {\n action,\n redirectUrl,\n onRedirectToRelativeUrl,\n onRedirectToAbsoluteUrl,\n }: {\n action: FormTypes.FormPostSubmissionAction\n redirectUrl: string | undefined\n onRedirectToRelativeUrl: (url: string) => void\n onRedirectToAbsoluteUrl: (url: string) => void\n },\n): Promise<void> {\n switch (action) {\n case 'CLOSE':\n return closeWindow()\n case 'FORMS_LIBRARY': {\n if (window.location.pathname === '/') {\n onRedirectToAbsoluteUrl(window.location.origin)\n } else {\n onRedirectToRelativeUrl('/')\n }\n break\n }\n case 'URL': {\n const newUrl = replaceInjectablesWithSubmissionValues(\n redirectUrl || '/',\n submissionResult,\n ).text\n // Relative URLs can be navigated to internally\n if (newUrl[0] === '/') {\n onRedirectToRelativeUrl(newUrl)\n return\n }\n\n onRedirectToAbsoluteUrl(newUrl)\n\n // If we are in cordova land, we will navigate\n // back to the home screen after redirect\n if (window.cordova) {\n // Wait a couple of seconds to ensure the browser has\n // been opened before navigating away from form.\n setTimeout(() => {\n onRedirectToRelativeUrl('/')\n }, 2000)\n }\n break\n }\n case 'BACK':\n default: {\n // if there's no post submission action for some reason, use prev. logic...\n return goBackOrCloseWindow()\n }\n }\n}\n\n/**\n * Retrieve submission data for a known formId and submissionId\n *\n * #### Example\n *\n * ```js\n * const formId = 1\n * const submissionId = 'fba95b9d-5a9c-463d-ab68-867f431e4120'\n * const credentials = await formSubmissionService.getSubmissionData({\n * formId,\n * submissionId,\n * })\n * ```\n *\n * @param options\n * @param options.formId\n * @param options.submissionId\n * @param options.abortSignal\n * @param options.versionId\n * @param options.asSubmitted\n * @returns\n */\nasync function getSubmissionData({\n formId,\n submissionId,\n abortSignal,\n versionId,\n asSubmitted,\n}: {\n formId: number\n submissionId: string\n abortSignal?: AbortSignal\n versionId?: string\n /** Download the submission data as it was originally submitted. */\n asSubmitted?: boolean\n}): Promise<{\n data: SubmissionTypes.S3SubmissionData\n versionId: string | undefined\n}> {\n return await downloadFormSubmission({\n formId,\n submissionId,\n abortSignal,\n versionId,\n asSubmitted,\n })\n}\n\nexport {\n submit,\n executePostSubmissionAction,\n executeCancelAction,\n goBackOrCloseWindow,\n getPendingQueueSubmissions,\n deletePendingQueueSubmission,\n editPendingQueueSubmission,\n cancelEditingPendingQueueSubmission,\n registerPendingQueueListener,\n processPendingQueue,\n BaseFormSubmission,\n NewDraftSubmission,\n NewFormSubmission,\n DraftSubmissionInput,\n DraftSubmission,\n FormSubmission,\n FormSubmissionResult,\n PendingFormSubmission,\n SubmissionParams,\n registerPendingQueueAttachmentProgressListener,\n registerPendingQueueProgressListener,\n ProgressListener,\n ProgressListenerEvent,\n PendingQueueListener,\n PendingQueueAction,\n getSubmissionData,\n uploadFormSubmissionEdit,\n getPostSubmissionAttachments,\n}\n"]}
|
|
@@ -2,13 +2,12 @@ import * as React from 'react';
|
|
|
2
2
|
import { EnvironmentTypes } from '@oneblink/types';
|
|
3
3
|
type Props = {
|
|
4
4
|
value: unknown | undefined;
|
|
5
|
-
readOnly: boolean;
|
|
6
5
|
validationMessage: string | undefined;
|
|
7
6
|
hasMarginTop?: boolean;
|
|
8
7
|
isInputButton?: boolean;
|
|
9
8
|
lookupButtonConfig?: EnvironmentTypes.ButtonConfiguration;
|
|
10
9
|
overrideRequiredMessage: string | undefined;
|
|
11
10
|
};
|
|
12
|
-
declare function LookupButton({ value,
|
|
11
|
+
declare function LookupButton({ value, validationMessage, hasMarginTop, isInputButton, lookupButtonConfig, overrideRequiredMessage, }: Props): import("react/jsx-runtime").JSX.Element | null;
|
|
13
12
|
declare const _default: React.MemoExoticComponent<typeof LookupButton>;
|
|
14
13
|
export default _default;
|
|
@@ -4,9 +4,9 @@ import clsx from 'clsx';
|
|
|
4
4
|
import useLookupNotification from '../../hooks/useLookupNotification';
|
|
5
5
|
import { generateLookupValidationMessage } from '../../services/form-validation/validators';
|
|
6
6
|
import MaterialIcon from '../MaterialIcon';
|
|
7
|
-
function LookupButton({ value,
|
|
7
|
+
function LookupButton({ value, validationMessage, hasMarginTop, isInputButton, lookupButtonConfig, overrideRequiredMessage, }) {
|
|
8
8
|
var _a, _b;
|
|
9
|
-
const { isLookup, onLookup,
|
|
9
|
+
const { isLookup, onLookup, isLookupRequestInFlight, isLoading, allowLookupOnEmptyValue, areLookupsDisallowed, } = useLookupNotification(value);
|
|
10
10
|
if (!isLookup) {
|
|
11
11
|
return null;
|
|
12
12
|
}
|
|
@@ -17,10 +17,11 @@ function LookupButton({ value, readOnly, validationMessage, hasMarginTop, isInpu
|
|
|
17
17
|
'ob-button': !isInputButton,
|
|
18
18
|
'has-margin-top-8': hasMarginTop,
|
|
19
19
|
}), onClick: () => onLookup(), disabled:
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
// Deliberately not the element's own `readOnly` flag: a locked field
|
|
21
|
+
// populated by a previous lookup still needs its button to run the
|
|
22
|
+
// next lookup in the chain.
|
|
23
|
+
areLookupsDisallowed ||
|
|
24
|
+
isLookupRequestInFlight ||
|
|
24
25
|
isLoading ||
|
|
25
26
|
(isEmptyValue && !allowLookupOnEmptyValue) ||
|
|
26
27
|
(!isEmptyValue &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LookupButton.js","sourceRoot":"","sources":["../../../src/components/renderer/LookupButton.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,qBAAqB,MAAM,mCAAmC,CAAA;AACrE,OAAO,EAAE,+BAA+B,EAAE,MAAM,2CAA2C,CAAA;AAE3F,OAAO,YAAY,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"LookupButton.js","sourceRoot":"","sources":["../../../src/components/renderer/LookupButton.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,qBAAqB,MAAM,mCAAmC,CAAA;AACrE,OAAO,EAAE,+BAA+B,EAAE,MAAM,2CAA2C,CAAA;AAE3F,OAAO,YAAY,MAAM,iBAAiB,CAAA;AAW1C,SAAS,YAAY,CAAC,EACpB,KAAK,EACL,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,kBAAkB,EAClB,uBAAuB,GACjB;;IACN,MAAM,EACJ,QAAQ,EACR,QAAQ,EACR,uBAAuB,EACvB,SAAS,EACT,uBAAuB,EACvB,oBAAoB,GACrB,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAA;IAChC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,YAAY,GAAG,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,CAAA;IAE1D,MAAM,MAAM,GAAG,CACb,kBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,IAAI,CACb,2DAA2D,EAC3D;YACE,YAAY,EAAE,SAAS;YACvB,gBAAgB,EAAE,aAAa;YAC/B,WAAW,EAAE,CAAC,aAAa;YAC3B,kBAAkB,EAAE,YAAY;SACjC,CACF,EACD,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,EAAE,EACzB,QAAQ;QACN,qEAAqE;QACrE,mEAAmE;QACnE,4BAA4B;QAC5B,oBAAoB;YACpB,uBAAuB;YACvB,SAAS;YACT,CAAC,YAAY,IAAI,CAAC,uBAAuB,CAAC;YAC1C,CAAC,CAAC,YAAY;gBACZ,CAAC,CAAC,iBAAiB;gBACnB,iBAAiB;oBACf,+BAA+B,CAC7B,kBAAkB,EAClB,uBAAuB,CACxB,CAAC,aAGP,aAAa,IAAI,gBAAa,EAC/B,eAAM,SAAS,EAAC,MAAM,YACpB,KAAC,YAAY,cAAE,MAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,IAAI,mCAAI,QAAQ,GAAgB,GAC9D,EACP,gBAAM,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS,uBACtD,MAAA,kBAAkB,aAAlB,kBAAkB,uBAAlB,kBAAkB,CAAE,KAAK,mCAAI,QAAQ,IACvC,IACA,CACV,CAAA;IAED,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,cAAK,SAAS,EAAC,SAAS,YAAE,MAAM,GAAO,CAAA;IAChD,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED,eAAe,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport clsx from 'clsx'\nimport useLookupNotification from '../../hooks/useLookupNotification'\nimport { generateLookupValidationMessage } from '../../services/form-validation/validators'\nimport { EnvironmentTypes } from '@oneblink/types'\nimport MaterialIcon from '../MaterialIcon'\n\ntype Props = {\n value: unknown | undefined\n validationMessage: string | undefined\n hasMarginTop?: boolean\n isInputButton?: boolean\n lookupButtonConfig?: EnvironmentTypes.ButtonConfiguration\n overrideRequiredMessage: string | undefined\n}\n\nfunction LookupButton({\n value,\n validationMessage,\n hasMarginTop,\n isInputButton,\n lookupButtonConfig,\n overrideRequiredMessage,\n}: Props) {\n const {\n isLookup,\n onLookup,\n isLookupRequestInFlight,\n isLoading,\n allowLookupOnEmptyValue,\n areLookupsDisallowed,\n } = useLookupNotification(value)\n if (!isLookup) {\n return null\n }\n\n const isEmptyValue = value === undefined || value === null\n\n const button = (\n <button\n type=\"button\"\n className={clsx(\n 'button is-primary ob-lookup__button cypress-lookup-button',\n {\n 'is-loading': isLoading,\n 'is-input-addon': isInputButton,\n 'ob-button': !isInputButton,\n 'has-margin-top-8': hasMarginTop,\n },\n )}\n onClick={() => onLookup()}\n disabled={\n // Deliberately not the element's own `readOnly` flag: a locked field\n // populated by a previous lookup still needs its button to run the\n // next lookup in the chain.\n areLookupsDisallowed ||\n isLookupRequestInFlight ||\n isLoading ||\n (isEmptyValue && !allowLookupOnEmptyValue) ||\n (!isEmptyValue &&\n !!validationMessage &&\n validationMessage !==\n generateLookupValidationMessage(\n lookupButtonConfig,\n overrideRequiredMessage,\n ))\n }\n >\n {isInputButton && <span></span>}\n <span className=\"icon\">\n <MaterialIcon>{lookupButtonConfig?.icon ?? 'search'}</MaterialIcon>\n </span>\n <span className={isInputButton ? 'is-hidden-mobile' : undefined}>\n {lookupButtonConfig?.label ?? 'Lookup'}\n </span>\n </button>\n )\n\n if (isInputButton) {\n return <div className=\"control\">{button}</div>\n }\n\n return button\n}\n\nexport default React.memo(LookupButton)\n"]}
|
|
@@ -10,12 +10,10 @@ import { LookupNotificationContext, } from '../../hooks/useLookupNotification';
|
|
|
10
10
|
import useFormDefinition from '../../hooks/useFormDefinition';
|
|
11
11
|
import useInjectPages from '../../hooks/useInjectPages';
|
|
12
12
|
import useFormSubmissionModel from '../../hooks/useFormSubmissionModelContext';
|
|
13
|
-
import useFormIsReadOnly from '../../hooks/useFormIsReadOnly';
|
|
14
13
|
import useIsMounted from '../../hooks/useIsMounted';
|
|
15
14
|
import useFormElementLookups from '../../hooks/useFormElementLookups';
|
|
16
15
|
import mergeExecutedLookups from '../../utils/merge-executed-lookups';
|
|
17
|
-
import
|
|
18
|
-
import isElementReadOnlyForAudience from '../../services/isElementReadOnlyForAudience';
|
|
16
|
+
import useAreLookupsDisallowed from '../../hooks/useAreLookupsDisallowed';
|
|
19
17
|
import ErrorMessage from '../messages/ErrorMessage';
|
|
20
18
|
import MaterialIcon from '../MaterialIcon';
|
|
21
19
|
function LookupNotificationComponent({ autoLookupValue, stringifyAutoLookupValue, element, onLookup, children, }) {
|
|
@@ -29,11 +27,16 @@ function LookupNotificationComponent({ autoLookupValue, stringifyAutoLookupValue
|
|
|
29
27
|
const [hasLookupFailed, setHasLookupFailed] = React.useState(false);
|
|
30
28
|
const [hasLookupSucceeded, setHasLookupSucceeded] = React.useState(false);
|
|
31
29
|
const [isCancellable, setIsCancellable] = React.useState(false);
|
|
32
|
-
const [
|
|
30
|
+
const [isLookupRequestInFlight, setIsLookupRequestInFlight] = React.useState(false);
|
|
33
31
|
const [lookupErrorHTML, setLookupErrorHTML] = React.useState(null);
|
|
34
32
|
const { formSubmissionModel: model } = useFormSubmissionModel();
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
// Definition-level `readOnly` must not suppress lookups for a submitter:
|
|
34
|
+
// prefills and defaults still need to populate related fields, and a locked
|
|
35
|
+
// field can still be the input to a chained lookup. Approver locks and a
|
|
36
|
+
// fully read-only form are different: re-running a lookup from an existing
|
|
37
|
+
// submitted value could overwrite persisted answers merely by opening the
|
|
38
|
+
// review.
|
|
39
|
+
const areLookupsDisallowed = useAreLookupsDisallowed(element);
|
|
37
40
|
const formElementElementLookup = React.useMemo(() => {
|
|
38
41
|
return formElementLookups.find(({ id }) => element.isElementLookup && id === element.elementLookupId);
|
|
39
42
|
}, [element.elementLookupId, element.isElementLookup, formElementLookups]);
|
|
@@ -53,11 +56,11 @@ function LookupNotificationComponent({ autoLookupValue, stringifyAutoLookupValue
|
|
|
53
56
|
((formElementElementLookup === null || formElementElementLookup === void 0 ? void 0 : formElementElementLookup.type) !== 'STATIC_DATA' &&
|
|
54
57
|
(formElementElementLookup === null || formElementElementLookup === void 0 ? void 0 : formElementElementLookup.excludeDefinition)));
|
|
55
58
|
}, [formElementDataLookup, formElementElementLookup]);
|
|
56
|
-
const mergeLookupData = React.useCallback(({ newValue, dataLookupResult, elementLookupResult, executedLookup, }) => {
|
|
59
|
+
const mergeLookupData = React.useCallback(({ newValue, dataLookupResult, elementLookupResult, executedLookup, isDerivedChange, }) => {
|
|
57
60
|
const executedLookupResult = executedLookup === null || executedLookup === void 0 ? void 0 : executedLookup[element.name];
|
|
58
61
|
if (elementLookupResult && executedLookupResult !== false) {
|
|
59
62
|
if (elementLookupResult[0] && elementLookupResult[0].type === 'page') {
|
|
60
|
-
injectPagesAfter(element, elementLookupResult, dataLookupResult);
|
|
63
|
+
injectPagesAfter(element, elementLookupResult, dataLookupResult, { isDerivedChange });
|
|
61
64
|
return;
|
|
62
65
|
}
|
|
63
66
|
}
|
|
@@ -97,21 +100,15 @@ function LookupNotificationComponent({ autoLookupValue, stringifyAutoLookupValue
|
|
|
97
100
|
},
|
|
98
101
|
}),
|
|
99
102
|
};
|
|
100
|
-
});
|
|
103
|
+
}, { isDerivedChange });
|
|
101
104
|
}, [element, injectPagesAfter, onLookup]);
|
|
102
105
|
const isNotStaticLookup = React.useMemo(() => {
|
|
103
106
|
return ((formElementDataLookup && formElementDataLookup.type !== 'STATIC_DATA') ||
|
|
104
107
|
(formElementElementLookup &&
|
|
105
108
|
formElementElementLookup.type !== 'STATIC_DATA'));
|
|
106
109
|
}, [formElementDataLookup, formElementElementLookup]);
|
|
107
|
-
const triggerLookup = React.useCallback(async ({ newValue, abortController, continueLookupOnAbort }) => {
|
|
108
|
-
|
|
109
|
-
// submitter: prefills and defaults still need to populate related
|
|
110
|
-
// fields. Approver locks are different. Re-running a lookup from an
|
|
111
|
-
// existing submitted value could overwrite persisted answers merely by
|
|
112
|
-
// opening the review, so only approver-editable elements may run one.
|
|
113
|
-
if (formIsReadOnly ||
|
|
114
|
-
isElementReadOnlyForAudience(element, audience)) {
|
|
110
|
+
const triggerLookup = React.useCallback(async ({ newValue, abortController, continueLookupOnAbort, isDerivedChange, }) => {
|
|
111
|
+
if (areLookupsDisallowed) {
|
|
115
112
|
return;
|
|
116
113
|
}
|
|
117
114
|
setIsLookingUp(true);
|
|
@@ -119,7 +116,7 @@ function LookupNotificationComponent({ autoLookupValue, stringifyAutoLookupValue
|
|
|
119
116
|
setHasLookupFailed(true);
|
|
120
117
|
return;
|
|
121
118
|
}
|
|
122
|
-
|
|
119
|
+
setIsLookupRequestInFlight(true);
|
|
123
120
|
setIsCancellable(false);
|
|
124
121
|
setHasLookupFailed(false);
|
|
125
122
|
setHasLookupSucceeded(false);
|
|
@@ -152,6 +149,7 @@ function LookupNotificationComponent({ autoLookupValue, stringifyAutoLookupValue
|
|
|
152
149
|
dataLookupResult: dataLookupResult,
|
|
153
150
|
elementLookupResult: elementLookupResult,
|
|
154
151
|
executedLookup: { [element.name]: true },
|
|
152
|
+
isDerivedChange,
|
|
155
153
|
});
|
|
156
154
|
if (isMounted.current) {
|
|
157
155
|
setHasLookupSucceeded(true);
|
|
@@ -180,6 +178,7 @@ function LookupNotificationComponent({ autoLookupValue, stringifyAutoLookupValue
|
|
|
180
178
|
dataLookupResult: {},
|
|
181
179
|
elementLookupResult: [],
|
|
182
180
|
executedLookup: { [element.name]: false },
|
|
181
|
+
isDerivedChange,
|
|
183
182
|
});
|
|
184
183
|
setLookupErrorHTML(typeof error === 'string'
|
|
185
184
|
? error
|
|
@@ -188,18 +187,17 @@ function LookupNotificationComponent({ autoLookupValue, stringifyAutoLookupValue
|
|
|
188
187
|
finally {
|
|
189
188
|
clearTimeout(isCancellableTimeout);
|
|
190
189
|
if (isMounted.current) {
|
|
191
|
-
|
|
190
|
+
setIsLookupRequestInFlight(false);
|
|
192
191
|
setOnCancelLookup(undefined);
|
|
193
192
|
}
|
|
194
193
|
}
|
|
195
194
|
}, [
|
|
196
|
-
audience,
|
|
197
195
|
definition,
|
|
198
196
|
element,
|
|
199
197
|
excludeDefinition,
|
|
200
198
|
formElementDataLookup,
|
|
201
199
|
formElementElementLookup,
|
|
202
|
-
|
|
200
|
+
areLookupsDisallowed,
|
|
203
201
|
isMounted,
|
|
204
202
|
isNotStaticLookup,
|
|
205
203
|
isOffline,
|
|
@@ -237,6 +235,7 @@ function LookupNotificationComponent({ autoLookupValue, stringifyAutoLookupValue
|
|
|
237
235
|
newValue: autoLookupValue,
|
|
238
236
|
abortController,
|
|
239
237
|
continueLookupOnAbort: true,
|
|
238
|
+
isDerivedChange: true,
|
|
240
239
|
});
|
|
241
240
|
return () => {
|
|
242
241
|
abortController.abort();
|
|
@@ -257,12 +256,20 @@ function LookupNotificationComponent({ autoLookupValue, stringifyAutoLookupValue
|
|
|
257
256
|
}, [autoLookupValue, triggerLookup]);
|
|
258
257
|
const contextValue = React.useMemo(() => ({
|
|
259
258
|
isLookup: true,
|
|
260
|
-
|
|
259
|
+
isLookupRequestInFlight,
|
|
261
260
|
isLoading,
|
|
262
261
|
onLookup: triggerLookup,
|
|
263
262
|
allowLookupOnEmptyValue: runLookupOnClear,
|
|
264
263
|
isLookingUp,
|
|
265
|
-
|
|
264
|
+
areLookupsDisallowed,
|
|
265
|
+
}), [
|
|
266
|
+
isLookupRequestInFlight,
|
|
267
|
+
isLoading,
|
|
268
|
+
runLookupOnClear,
|
|
269
|
+
triggerLookup,
|
|
270
|
+
isLookingUp,
|
|
271
|
+
areLookupsDisallowed,
|
|
272
|
+
]);
|
|
266
273
|
return (_jsxs(LookupNotificationContext.Provider, { value: contextValue, children: [children, loadError && (_jsx(ErrorMessage, { title: "Error Loading Configuration", onTryAgain: onTryAgain, children: _jsx("span", { className: "cypress-lookup-notification-loading-error", children: loadError.message }) })), _jsx("div", { className: clsx('ob-lookup__notification', {
|
|
267
274
|
'is-looking-up': isLookingUp,
|
|
268
275
|
'is-extended': hasLookupFailed || (isCancellable && !hasLookupSucceeded),
|
|
@@ -274,7 +281,7 @@ function LookupNotificationComponent({ autoLookupValue, stringifyAutoLookupValue
|
|
|
274
281
|
dangerouslySetInnerHTML: {
|
|
275
282
|
__html: lookupErrorHTML || '',
|
|
276
283
|
} }), autoLookupValue !== undefined &&
|
|
277
|
-
autoLookupValue !== null && (_jsxs("button", { type: "button", className: clsx('fade-in button is-primary ob-lookup__retry-button cypress-retry-lookup-button has-margin-top-8'), onClick: () => retryLookup(), disabled:
|
|
284
|
+
autoLookupValue !== null && (_jsxs("button", { type: "button", className: clsx('fade-in button is-primary ob-lookup__retry-button cypress-retry-lookup-button has-margin-top-8'), onClick: () => retryLookup(), disabled: isLookupRequestInFlight || isLoading, "aria-label": "lookup-retry-button", children: [_jsx("span", {}), _jsx("span", { className: "icon", children: _jsx(MaterialIcon, { className: "refresh", children: "refresh" }) }), _jsx("span", { children: "\u00A0Retry Lookup" })] }))] })) })] })), hasLookupSucceeded && (_jsx(_Fragment, { children: _jsx(MaterialIcon, { className: "has-text-success fade-in", role: "status", "aria-label": "lookup successful", children: "check_circle_outline" }) })), !hasLookupSucceeded && !hasLookupFailed && _jsx(OnLoading, { small: true }), isCancellable && !hasLookupSucceeded && !hasLookupFailed && (_jsxs("div", { className: "has-margin-top-5 fade-in", role: "alert", children: [_jsx("p", { children: "Taking longer than expected?" }), _jsx("button", { type: "button", className: "button has-margin-top-8", onClick: onCancelLookup, children: "Cancel" })] }))] }) })] }));
|
|
278
285
|
}
|
|
279
286
|
export default function LookupNotification(props) {
|
|
280
287
|
if (props.element.isDataLookup || props.element.isElementLookup) {
|