@overmap-ai/core 1.0.38-component-fields.32 → 1.0.38-component-fields.33
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/forms/utils.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ import { UserFormRevision } from "../typings";
|
|
|
6
6
|
export declare const hasKeys: (errors: object) => boolean;
|
|
7
7
|
export declare const validateForm: (schema: ISchema, form: Form | FormikUserFormRevision) => FormikErrors<Form> | FormikErrors<import('./builder/typings').NewForm> | undefined;
|
|
8
8
|
export declare const initialFormValues: (fields: BaseFormElement[], values: Form) => Form;
|
|
9
|
-
export declare const useAttachImagesToFormRevisionFields: (revision: UserFormRevision) => UserFormRevision;
|
|
9
|
+
export declare const useAttachImagesToFormRevisionFields: (revision: UserFormRevision | undefined) => UserFormRevision | undefined;
|
package/dist/overmap-core.js
CHANGED
|
@@ -3216,7 +3216,6 @@ const selectUserForm = (formId2) => (state) => {
|
|
|
3216
3216
|
const selectSubmissionMapping = (state) => state.userFormReducer.submissions;
|
|
3217
3217
|
const selectSubmissions = createSelector([selectSubmissionMapping], (submissions) => Object.values(submissions));
|
|
3218
3218
|
const selectRevisionMapping = (state) => state.userFormReducer.revisions;
|
|
3219
|
-
const selectRevisionAttachmentsMapping = (state) => state.userFormReducer.revisionAttachments;
|
|
3220
3219
|
const selectRevisions = createSelector([selectRevisionMapping], (revisions) => Object.values(revisions));
|
|
3221
3220
|
const selectRevisionsForForm = restructureCreateSelectorWithArgs(
|
|
3222
3221
|
createSelector([selectRevisions, (_state, formId2) => formId2], (revisions, formId2) => {
|
|
@@ -3329,19 +3328,6 @@ const selectLatestRevisionByFormId = createSelector([selectRevisionMapping], (re
|
|
|
3329
3328
|
}
|
|
3330
3329
|
return latestRevisions;
|
|
3331
3330
|
});
|
|
3332
|
-
const selectAllRevisionAttachmentsByLatestRevisionId = createSelector(
|
|
3333
|
-
[selectUserFormMapping, selectRevisionMapping, selectRevisionAttachmentsMapping],
|
|
3334
|
-
(forms, revisions, attachments) => {
|
|
3335
|
-
const mappedAttachments = {};
|
|
3336
|
-
for (const form of Object.values(forms)) {
|
|
3337
|
-
const latestRevision = _selectLatestFormRevision(revisions, form.offline_id);
|
|
3338
|
-
if (attachments[latestRevision.offline_id] !== void 0) {
|
|
3339
|
-
mappedAttachments[latestRevision.offline_id] = attachments[latestRevision.offline_id];
|
|
3340
|
-
}
|
|
3341
|
-
}
|
|
3342
|
-
return mappedAttachments;
|
|
3343
|
-
}
|
|
3344
|
-
);
|
|
3345
3331
|
const selectNumberOfUserForms = createSelector([selectUserFormMapping], (userForms) => {
|
|
3346
3332
|
return Object.keys(userForms).length;
|
|
3347
3333
|
});
|
|
@@ -10371,10 +10357,12 @@ const initialFormValues = (fields, values) => {
|
|
|
10371
10357
|
};
|
|
10372
10358
|
const useAttachImagesToFormRevisionFields = (revision) => {
|
|
10373
10359
|
const { sdk } = useSDK();
|
|
10374
|
-
const attachments = useAppSelector(selectRevisionAttachments(revision.offline_id));
|
|
10360
|
+
const attachments = useAppSelector(selectRevisionAttachments((revision == null ? void 0 : revision.offline_id) ?? ""));
|
|
10375
10361
|
return useMemo(() => {
|
|
10362
|
+
if (!revision || !attachments)
|
|
10363
|
+
return revision;
|
|
10376
10364
|
const revisionCopy = structuredClone(revision);
|
|
10377
|
-
for (const attachment of attachments
|
|
10365
|
+
for (const attachment of attachments) {
|
|
10378
10366
|
const filePromise = sdk.files.fetchFileFromUrl(attachment.file, attachment.file_sha1, attachment.file_name);
|
|
10379
10367
|
let sectionIndex = -1;
|
|
10380
10368
|
let fieldIndex = -1;
|
|
@@ -10459,6 +10447,9 @@ const FormSubmissionViewer = memo(
|
|
|
10459
10447
|
);
|
|
10460
10448
|
}
|
|
10461
10449
|
const revisionWithImages = useAttachImagesToFormRevisionFields(revision);
|
|
10450
|
+
if (!revisionWithImages) {
|
|
10451
|
+
throw new Error("Expected revisionWithImages to be defined");
|
|
10452
|
+
}
|
|
10462
10453
|
const schema = useMemo(() => {
|
|
10463
10454
|
return formRevisionToSchema(revisionWithImages, { readonly: true });
|
|
10464
10455
|
}, [revisionWithImages]);
|
|
@@ -11784,8 +11775,9 @@ const FormBuilder = memo(
|
|
|
11784
11775
|
}),
|
|
11785
11776
|
[initialTitle]
|
|
11786
11777
|
);
|
|
11778
|
+
const revisionWithImages = useAttachImagesToFormRevisionFields(revision);
|
|
11787
11779
|
const formik = useFormik({
|
|
11788
|
-
initialValues: wrapRootFieldsWithFieldSection(
|
|
11780
|
+
initialValues: wrapRootFieldsWithFieldSection(revisionWithImages) ?? initialValues,
|
|
11789
11781
|
validate,
|
|
11790
11782
|
onSubmit: onSave,
|
|
11791
11783
|
validateOnChange: false,
|
|
@@ -12183,7 +12175,6 @@ export {
|
|
|
12183
12175
|
selectActiveWorkspace,
|
|
12184
12176
|
selectActiveWorkspaceId,
|
|
12185
12177
|
selectAllAttachments,
|
|
12186
|
-
selectAllRevisionAttachmentsByLatestRevisionId,
|
|
12187
12178
|
selectAppearance,
|
|
12188
12179
|
selectCategories,
|
|
12189
12180
|
selectCategoriesOfWorkspace,
|