@overmap-ai/core 1.0.38 → 1.0.39
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/builder/FieldSectionWithActions.d.ts +1 -0
- package/dist/forms/builder/FieldWithActions.d.ts +0 -1
- package/dist/forms/builder/FieldsEditor.d.ts +5 -1
- package/dist/forms/builder/FormBuilder.d.ts +14 -0
- package/dist/forms/builder/utils.d.ts +0 -2
- package/dist/forms/renderer/FormRenderer/FormRenderer.d.ts +2 -0
- package/dist/forms/renderer/FormSubmissionBrowser/FormSubmissionBrowser.d.ts +1 -1
- package/dist/forms/utils.d.ts +1 -1
- package/dist/overmap-core.js +447 -278
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +447 -278
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/services/ComponentStageService.d.ts +2 -0
- package/dist/sdk/services/UserFormService.d.ts +3 -3
- package/dist/sdk/services/UserFormSubmissionService.d.ts +2 -0
- package/dist/store/slices/componentStageSlice.d.ts +18 -1
- package/dist/store/slices/userFormSlice.d.ts +9 -3
- package/dist/style.css +67 -55
- package/dist/typings/models/base.d.ts +1 -1
- package/dist/typings/models/components.d.ts +1 -0
- package/dist/typings/models/forms.d.ts +3 -0
- package/package.json +2 -2
|
@@ -1673,6 +1673,22 @@ var __publicField = (obj, key, value) => {
|
|
|
1673
1673
|
action.payload.forEach((id) => {
|
|
1674
1674
|
delete state.stages[id];
|
|
1675
1675
|
});
|
|
1676
|
+
},
|
|
1677
|
+
linkStageToForm: (state, action) => {
|
|
1678
|
+
const { stageId, formId: formId2 } = action.payload;
|
|
1679
|
+
const stage = state.stages[stageId];
|
|
1680
|
+
if (!stage) {
|
|
1681
|
+
throw new Error("No stage exists with the id " + stageId);
|
|
1682
|
+
}
|
|
1683
|
+
stage.user_form = formId2;
|
|
1684
|
+
},
|
|
1685
|
+
unlinkStageToForm: (state, action) => {
|
|
1686
|
+
const { stageId } = action.payload;
|
|
1687
|
+
const stage = state.stages[stageId];
|
|
1688
|
+
if (!stage) {
|
|
1689
|
+
throw new Error("No stage exists with the id " + stageId);
|
|
1690
|
+
}
|
|
1691
|
+
delete stage.user_form;
|
|
1676
1692
|
}
|
|
1677
1693
|
}
|
|
1678
1694
|
});
|
|
@@ -1717,7 +1733,22 @@ var __publicField = (obj, key, value) => {
|
|
|
1717
1733
|
return stageIds.map((offline_id) => stageMapping[offline_id]).filter((stage) => !!stage);
|
|
1718
1734
|
})
|
|
1719
1735
|
);
|
|
1720
|
-
const
|
|
1736
|
+
const selectStageFormIdsFromStageIds = restructureCreateSelectorWithArgs(
|
|
1737
|
+
toolkit.createSelector([selectStageMapping, (_state, stageIds) => stageIds], (stageMapping, stageIds) => {
|
|
1738
|
+
const ret = {};
|
|
1739
|
+
for (const stageId of stageIds) {
|
|
1740
|
+
const stage = stageMapping[stageId];
|
|
1741
|
+
if (!stage) {
|
|
1742
|
+
throw new Error("No stage exists with the id " + stageId);
|
|
1743
|
+
}
|
|
1744
|
+
if (stage.user_form) {
|
|
1745
|
+
ret[stageId] = stage.user_form;
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
return ret;
|
|
1749
|
+
})
|
|
1750
|
+
);
|
|
1751
|
+
const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = componentStageSlice.actions;
|
|
1721
1752
|
const componentStageReducer = componentStageSlice.reducer;
|
|
1722
1753
|
const initialState$g = {
|
|
1723
1754
|
componentTypes: {},
|
|
@@ -3013,7 +3044,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3013
3044
|
delete LATEST_REVISION_CACHE[userFormRevision.offline_id];
|
|
3014
3045
|
}
|
|
3015
3046
|
},
|
|
3016
|
-
|
|
3047
|
+
updateOrCreateUserFormSubmission: (state, action) => {
|
|
3017
3048
|
state.submissions[action.payload.offline_id] = action.payload;
|
|
3018
3049
|
},
|
|
3019
3050
|
addUserFormSubmissionAttachment: (state, action) => {
|
|
@@ -3102,7 +3133,7 @@ var __publicField = (obj, key, value) => {
|
|
|
3102
3133
|
addUserForm,
|
|
3103
3134
|
addUserForms,
|
|
3104
3135
|
addUserFormRevisions,
|
|
3105
|
-
|
|
3136
|
+
updateOrCreateUserFormSubmission,
|
|
3106
3137
|
addUserFormSubmissions,
|
|
3107
3138
|
deleteUserFormSubmission,
|
|
3108
3139
|
deleteUserFormSubmissions,
|
|
@@ -3194,7 +3225,6 @@ var __publicField = (obj, key, value) => {
|
|
|
3194
3225
|
const selectSubmissionMapping = (state) => state.userFormReducer.submissions;
|
|
3195
3226
|
const selectSubmissions = toolkit.createSelector([selectSubmissionMapping], (submissions) => Object.values(submissions));
|
|
3196
3227
|
const selectRevisionMapping = (state) => state.userFormReducer.revisions;
|
|
3197
|
-
const selectRevisionAttachmentsMapping = (state) => state.userFormReducer.revisionAttachments;
|
|
3198
3228
|
const selectRevisions = toolkit.createSelector([selectRevisionMapping], (revisions) => Object.values(revisions));
|
|
3199
3229
|
const selectRevisionsForForm = restructureCreateSelectorWithArgs(
|
|
3200
3230
|
toolkit.createSelector([selectRevisions, (_state, formId2) => formId2], (revisions, formId2) => {
|
|
@@ -3237,6 +3267,33 @@ var __publicField = (obj, key, value) => {
|
|
|
3237
3267
|
const selectUserFormMapping = (state) => {
|
|
3238
3268
|
return state.userFormReducer.userForms;
|
|
3239
3269
|
};
|
|
3270
|
+
const selectComponentTypeForm = restructureCreateSelectorWithArgs(
|
|
3271
|
+
toolkit.createSelector(
|
|
3272
|
+
[selectUserFormMapping, (_state, componentTypeId) => componentTypeId],
|
|
3273
|
+
(userForms, componentTypeId) => {
|
|
3274
|
+
return Object.values(userForms).find((userForm) => userForm.component_type === componentTypeId);
|
|
3275
|
+
}
|
|
3276
|
+
)
|
|
3277
|
+
);
|
|
3278
|
+
const selectLatestRevisionsFromComponentTypeIds = restructureCreateSelectorWithArgs(
|
|
3279
|
+
toolkit.createSelector(
|
|
3280
|
+
[
|
|
3281
|
+
selectUserFormMapping,
|
|
3282
|
+
selectRevisionMapping,
|
|
3283
|
+
(_state, componentTypeIds) => componentTypeIds
|
|
3284
|
+
],
|
|
3285
|
+
(userForms, revisions, componentTypeIds) => {
|
|
3286
|
+
const componentTypeIdsSet = new Set(componentTypeIds);
|
|
3287
|
+
const ret = {};
|
|
3288
|
+
for (const form of Object.values(userForms)) {
|
|
3289
|
+
if (form.component_type && componentTypeIdsSet.has(form.component_type)) {
|
|
3290
|
+
ret[form.component_type] = _selectLatestFormRevision(revisions, form.offline_id);
|
|
3291
|
+
}
|
|
3292
|
+
}
|
|
3293
|
+
return ret;
|
|
3294
|
+
}
|
|
3295
|
+
)
|
|
3296
|
+
);
|
|
3240
3297
|
const selectLatestRevisionByFormId = toolkit.createSelector([selectRevisionMapping], (revisions) => {
|
|
3241
3298
|
const latestRevisions = {};
|
|
3242
3299
|
for (const revision of Object.values(revisions)) {
|
|
@@ -3248,22 +3305,12 @@ var __publicField = (obj, key, value) => {
|
|
|
3248
3305
|
}
|
|
3249
3306
|
return latestRevisions;
|
|
3250
3307
|
});
|
|
3251
|
-
const selectAllRevisionAttachmentsByLatestRevisionId = toolkit.createSelector(
|
|
3252
|
-
[selectUserFormMapping, selectRevisionMapping, selectRevisionAttachmentsMapping],
|
|
3253
|
-
(forms, revisions, attachments) => {
|
|
3254
|
-
const mappedAttachments = {};
|
|
3255
|
-
for (const form of Object.values(forms)) {
|
|
3256
|
-
const latestRevision = _selectLatestFormRevision(revisions, form.offline_id);
|
|
3257
|
-
if (attachments[latestRevision.offline_id] !== void 0) {
|
|
3258
|
-
mappedAttachments[latestRevision.offline_id] = attachments[latestRevision.offline_id];
|
|
3259
|
-
}
|
|
3260
|
-
}
|
|
3261
|
-
return mappedAttachments;
|
|
3262
|
-
}
|
|
3263
|
-
);
|
|
3264
3308
|
const selectNumberOfUserForms = toolkit.createSelector([selectUserFormMapping], (userForms) => {
|
|
3265
3309
|
return Object.keys(userForms).length;
|
|
3266
3310
|
});
|
|
3311
|
+
const selectNumberOfGeneralUserForms = toolkit.createSelector([selectUserFormMapping], (userForms) => {
|
|
3312
|
+
return Object.values(userForms).filter((form) => !form.component_type).length;
|
|
3313
|
+
});
|
|
3267
3314
|
const userFormReducer = userFormSlice.reducer;
|
|
3268
3315
|
const initialState$1 = {
|
|
3269
3316
|
emailDomains: {}
|
|
@@ -4629,6 +4676,39 @@ var __publicField = (obj, key, value) => {
|
|
|
4629
4676
|
blocks: [componentStage.offline_id]
|
|
4630
4677
|
});
|
|
4631
4678
|
}
|
|
4679
|
+
async linkForm(stageId, formId2) {
|
|
4680
|
+
const { store } = this.client;
|
|
4681
|
+
store.dispatch(linkStageToForm({ stageId, formId: formId2 }));
|
|
4682
|
+
try {
|
|
4683
|
+
await this.enqueueRequest({
|
|
4684
|
+
description: "Link component stage to form",
|
|
4685
|
+
method: HttpMethod.POST,
|
|
4686
|
+
url: `/components/stages/${stageId}/associate-with-form/`,
|
|
4687
|
+
payload: { user_form: formId2 },
|
|
4688
|
+
blockers: [stageId, formId2],
|
|
4689
|
+
blocks: [stageId]
|
|
4690
|
+
});
|
|
4691
|
+
} catch (e) {
|
|
4692
|
+
store.dispatch(unlinkStageToForm({ stageId }));
|
|
4693
|
+
throw e;
|
|
4694
|
+
}
|
|
4695
|
+
}
|
|
4696
|
+
async unlinkForm(stageId, formId2) {
|
|
4697
|
+
const { store } = this.client;
|
|
4698
|
+
store.dispatch(unlinkStageToForm({ stageId }));
|
|
4699
|
+
try {
|
|
4700
|
+
await this.enqueueRequest({
|
|
4701
|
+
description: "Unlink component stage from form",
|
|
4702
|
+
method: HttpMethod.DELETE,
|
|
4703
|
+
url: `/components/stages/${stageId}/associate-with-form/`,
|
|
4704
|
+
blockers: [stageId, formId2],
|
|
4705
|
+
blocks: [stageId]
|
|
4706
|
+
});
|
|
4707
|
+
} catch (e) {
|
|
4708
|
+
store.dispatch(linkStageToForm({ stageId, formId: formId2 }));
|
|
4709
|
+
throw e;
|
|
4710
|
+
}
|
|
4711
|
+
}
|
|
4632
4712
|
async refreshStore() {
|
|
4633
4713
|
const { store } = this.client;
|
|
4634
4714
|
const result = await this.enqueueRequest({
|
|
@@ -5414,7 +5494,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5414
5494
|
});
|
|
5415
5495
|
});
|
|
5416
5496
|
}
|
|
5417
|
-
async add(state, initialRevision, url, ownerUser, ownerOrganization) {
|
|
5497
|
+
async add(state, initialRevision, url, ownerUser, ownerOrganization, componentTypeId) {
|
|
5418
5498
|
if (!!ownerUser === !!ownerOrganization) {
|
|
5419
5499
|
throw new Error("Exactly one of ownerUser and ownerOrganization must be defined.");
|
|
5420
5500
|
}
|
|
@@ -5432,6 +5512,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5432
5512
|
favorite: true,
|
|
5433
5513
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5434
5514
|
created_by: currentUser.id,
|
|
5515
|
+
...componentTypeId && { component_type: componentTypeId },
|
|
5435
5516
|
...ownerAttrs
|
|
5436
5517
|
};
|
|
5437
5518
|
const { payloadWithoutImage, images } = await separateImageFromFields(offlineRevisionPayload);
|
|
@@ -5451,8 +5532,12 @@ var __publicField = (obj, key, value) => {
|
|
|
5451
5532
|
queryParams: activeWorkspaceId ? {
|
|
5452
5533
|
workspace_id: activeWorkspaceId
|
|
5453
5534
|
} : void 0,
|
|
5454
|
-
payload: {
|
|
5455
|
-
|
|
5535
|
+
payload: {
|
|
5536
|
+
...offlineFormPayload,
|
|
5537
|
+
...componentTypeId && { component_type: componentTypeId },
|
|
5538
|
+
initial_revision: payloadWithoutImage
|
|
5539
|
+
},
|
|
5540
|
+
blockers: componentTypeId ? [componentTypeId] : [],
|
|
5456
5541
|
blocks: [offlineFormPayload.offline_id, payloadWithoutImage.offline_id]
|
|
5457
5542
|
});
|
|
5458
5543
|
const attachImagesPromises = this.getAttachImagePromises(images, offlineRevisionPayload.offline_id);
|
|
@@ -5464,7 +5549,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5464
5549
|
const settledPromise = Promise.all([formPromise, ...attachImagesPromises]).then(() => formPromise);
|
|
5465
5550
|
return [retForm, retRevision, formPromise, settledPromise];
|
|
5466
5551
|
}
|
|
5467
|
-
async addForOrganization(initialRevision) {
|
|
5552
|
+
async addForOrganization(initialRevision, componentTypeId) {
|
|
5468
5553
|
const state = this.client.store.getState();
|
|
5469
5554
|
const activeOrganizationId = state.organizationReducer.activeOrganizationId;
|
|
5470
5555
|
if (!activeOrganizationId) {
|
|
@@ -5475,13 +5560,14 @@ var __publicField = (obj, key, value) => {
|
|
|
5475
5560
|
initialRevision,
|
|
5476
5561
|
`/forms/in-organization/${activeOrganizationId}/`,
|
|
5477
5562
|
void 0,
|
|
5478
|
-
activeOrganizationId
|
|
5563
|
+
activeOrganizationId,
|
|
5564
|
+
componentTypeId
|
|
5479
5565
|
);
|
|
5480
5566
|
}
|
|
5481
|
-
async addForCurrentUser(initialRevision) {
|
|
5567
|
+
async addForCurrentUser(initialRevision, componentTypeId) {
|
|
5482
5568
|
const state = this.client.store.getState();
|
|
5483
5569
|
const currentUser = state.userReducer.currentUser;
|
|
5484
|
-
return await this.add(state, initialRevision, "/forms/my-forms/", currentUser.id);
|
|
5570
|
+
return await this.add(state, initialRevision, "/forms/my-forms/", currentUser.id, void 0, componentTypeId);
|
|
5485
5571
|
}
|
|
5486
5572
|
async createRevision(formId2, revision) {
|
|
5487
5573
|
const offlineRevision = offline(revision);
|
|
@@ -5629,6 +5715,43 @@ var __publicField = (obj, key, value) => {
|
|
|
5629
5715
|
return { payloadWithoutFiles, files };
|
|
5630
5716
|
};
|
|
5631
5717
|
class UserFormSubmissionService extends BaseApiService {
|
|
5718
|
+
constructor() {
|
|
5719
|
+
super(...arguments);
|
|
5720
|
+
// Attach files to submission, after uploading them to S3
|
|
5721
|
+
__publicField(this, "getAttachFilesPromises", (files, payload) => {
|
|
5722
|
+
const { store } = this.client;
|
|
5723
|
+
return Object.entries(files).map(async ([key, fileArray]) => {
|
|
5724
|
+
const attachResults = [];
|
|
5725
|
+
for (const file of fileArray) {
|
|
5726
|
+
const sha1 = await hashFile(file);
|
|
5727
|
+
await this.client.files.addCache(file, sha1);
|
|
5728
|
+
const [fileProps] = await this.client.files.uploadFileToS3(sha1);
|
|
5729
|
+
const submissionAttachmentPayload = offline({
|
|
5730
|
+
...fileProps,
|
|
5731
|
+
submission: payload.offline_id,
|
|
5732
|
+
field_identifier: key
|
|
5733
|
+
});
|
|
5734
|
+
const attach = await this.enqueueRequest({
|
|
5735
|
+
description: "Attach file to form submission",
|
|
5736
|
+
method: HttpMethod.POST,
|
|
5737
|
+
url: `/forms/submission/${payload.offline_id}/attachments/`,
|
|
5738
|
+
payload: submissionAttachmentPayload,
|
|
5739
|
+
blockers: [payload.component, payload.component_stage, payload.issue, payload.form_revision].filter(
|
|
5740
|
+
(x) => x !== void 0
|
|
5741
|
+
),
|
|
5742
|
+
blocks: [submissionAttachmentPayload.offline_id]
|
|
5743
|
+
});
|
|
5744
|
+
const offlinePayload = {
|
|
5745
|
+
...submissionAttachmentPayload,
|
|
5746
|
+
file: URL.createObjectURL(file)
|
|
5747
|
+
};
|
|
5748
|
+
store.dispatch(addUserFormSubmissionAttachment(offlinePayload));
|
|
5749
|
+
attachResults.push(attach);
|
|
5750
|
+
}
|
|
5751
|
+
return attachResults;
|
|
5752
|
+
});
|
|
5753
|
+
});
|
|
5754
|
+
}
|
|
5632
5755
|
add(payload) {
|
|
5633
5756
|
const { store } = this.client;
|
|
5634
5757
|
const state = store.getState();
|
|
@@ -5642,51 +5765,26 @@ var __publicField = (obj, key, value) => {
|
|
|
5642
5765
|
method: HttpMethod.POST,
|
|
5643
5766
|
url: `/forms/revisions/${payload.form_revision}/respond/`,
|
|
5644
5767
|
payload: { ...payloadWithoutFiles, project: activeProjectId },
|
|
5645
|
-
blockers: [payload.issue, payload.component].filter(
|
|
5768
|
+
blockers: [payload.issue, payload.component, payload.component_stage].filter(
|
|
5769
|
+
(x) => x !== void 0
|
|
5770
|
+
),
|
|
5646
5771
|
blocks: [payload.offline_id]
|
|
5647
5772
|
});
|
|
5648
|
-
const attachFilesPromises =
|
|
5649
|
-
|
|
5650
|
-
for (const file of fileArray) {
|
|
5651
|
-
const sha1 = await hashFile(file);
|
|
5652
|
-
await this.client.files.addCache(file, sha1);
|
|
5653
|
-
const [fileProps] = await this.client.files.uploadFileToS3(sha1);
|
|
5654
|
-
const submissionAttachmentPayload = offline({
|
|
5655
|
-
...fileProps,
|
|
5656
|
-
submission: payload.offline_id,
|
|
5657
|
-
field_identifier: key
|
|
5658
|
-
});
|
|
5659
|
-
const attach = await this.enqueueRequest({
|
|
5660
|
-
description: "Attach file to form submission",
|
|
5661
|
-
method: HttpMethod.POST,
|
|
5662
|
-
url: `/forms/submission/${payload.offline_id}/attachments/`,
|
|
5663
|
-
payload: submissionAttachmentPayload,
|
|
5664
|
-
blockers: [payload.component, payload.issue, payload.form_revision].filter(
|
|
5665
|
-
(x) => x !== void 0
|
|
5666
|
-
),
|
|
5667
|
-
blocks: [submissionAttachmentPayload.offline_id]
|
|
5668
|
-
});
|
|
5669
|
-
const offlinePayload = {
|
|
5670
|
-
...submissionAttachmentPayload,
|
|
5671
|
-
file: URL.createObjectURL(file)
|
|
5672
|
-
};
|
|
5673
|
-
store.dispatch(addUserFormSubmissionAttachment(offlinePayload));
|
|
5674
|
-
attachResults.push(attach);
|
|
5675
|
-
}
|
|
5676
|
-
return attachResults;
|
|
5677
|
-
});
|
|
5773
|
+
const attachFilesPromises = this.getAttachFilesPromises(files, payload);
|
|
5774
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
5678
5775
|
const fullOfflineResult = {
|
|
5679
5776
|
...payload,
|
|
5680
5777
|
created_by: state.userReducer.currentUser.id,
|
|
5681
|
-
created_at:
|
|
5778
|
+
created_at: now,
|
|
5779
|
+
updated_at: now
|
|
5682
5780
|
};
|
|
5683
5781
|
const offlineResultWithoutFiles = {
|
|
5684
5782
|
...fullOfflineResult,
|
|
5685
5783
|
...payloadWithoutFiles
|
|
5686
5784
|
};
|
|
5687
|
-
store.dispatch(
|
|
5785
|
+
store.dispatch(updateOrCreateUserFormSubmission(offlineResultWithoutFiles));
|
|
5688
5786
|
void promise.then((result) => {
|
|
5689
|
-
store.dispatch(
|
|
5787
|
+
store.dispatch(updateOrCreateUserFormSubmission(result));
|
|
5690
5788
|
return result;
|
|
5691
5789
|
}).catch(() => {
|
|
5692
5790
|
store.dispatch(deleteUserFormSubmission(payload.offline_id));
|
|
@@ -5694,6 +5792,30 @@ var __publicField = (obj, key, value) => {
|
|
|
5694
5792
|
const settledPromise = Promise.all([promise, ...attachFilesPromises]).then(() => promise);
|
|
5695
5793
|
return [fullOfflineResult, settledPromise];
|
|
5696
5794
|
}
|
|
5795
|
+
update(submission) {
|
|
5796
|
+
const { store } = this.client;
|
|
5797
|
+
const { payloadWithoutFiles, files } = separateFilesFromValues(submission);
|
|
5798
|
+
if (!("created_by" in payloadWithoutFiles) || !("created_at" in payloadWithoutFiles)) {
|
|
5799
|
+
throw new Error("Expected payloadWithoutFiles to have created_by and created_at fields.");
|
|
5800
|
+
}
|
|
5801
|
+
const attachFilesPromises = this.getAttachFilesPromises(files, submission);
|
|
5802
|
+
const fullResult = {
|
|
5803
|
+
...payloadWithoutFiles,
|
|
5804
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5805
|
+
};
|
|
5806
|
+
store.dispatch(updateOrCreateUserFormSubmission(fullResult));
|
|
5807
|
+
const promise = this.enqueueRequest({
|
|
5808
|
+
description: "Patch form submission",
|
|
5809
|
+
method: HttpMethod.PATCH,
|
|
5810
|
+
url: `/forms/submissions/${submission.offline_id}/`,
|
|
5811
|
+
payload: fullResult,
|
|
5812
|
+
blockers: [fullResult.issue, fullResult.component, fullResult.component_stage].filter(
|
|
5813
|
+
(x) => x !== void 0
|
|
5814
|
+
),
|
|
5815
|
+
blocks: [fullResult.offline_id]
|
|
5816
|
+
});
|
|
5817
|
+
return Promise.all([promise, ...attachFilesPromises]).then(() => promise);
|
|
5818
|
+
}
|
|
5697
5819
|
async delete(submissionId) {
|
|
5698
5820
|
const { store } = this.client;
|
|
5699
5821
|
const state = store.getState();
|
|
@@ -5709,7 +5831,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5709
5831
|
});
|
|
5710
5832
|
} catch (e) {
|
|
5711
5833
|
if (submission) {
|
|
5712
|
-
store.dispatch(
|
|
5834
|
+
store.dispatch(updateOrCreateUserFormSubmission(submission));
|
|
5713
5835
|
}
|
|
5714
5836
|
throw e;
|
|
5715
5837
|
}
|
|
@@ -6219,19 +6341,19 @@ var __publicField = (obj, key, value) => {
|
|
|
6219
6341
|
}
|
|
6220
6342
|
return /* @__PURE__ */ jsxRuntime.jsx(OvermapContext.Provider, { value: null, children: ret });
|
|
6221
6343
|
};
|
|
6222
|
-
const description$2 = "
|
|
6223
|
-
const floatingButtonContainer$2 = "
|
|
6224
|
-
const FullScreenImageContainer$2 = "
|
|
6225
|
-
const TopBarContainer$2 = "
|
|
6226
|
-
const fileName$2 = "
|
|
6227
|
-
const longIconButton$2 = "
|
|
6228
|
-
const previewImage$3 = "
|
|
6229
|
-
const FullScreenImage$2 = "
|
|
6230
|
-
const tabsList = "
|
|
6231
|
-
const tabTrigger = "
|
|
6232
|
-
const patchfieldBorder = "
|
|
6233
|
-
const title = "
|
|
6234
|
-
const error = "
|
|
6344
|
+
const description$2 = "_description_1w0fq_1";
|
|
6345
|
+
const floatingButtonContainer$2 = "_floatingButtonContainer_1w0fq_5";
|
|
6346
|
+
const FullScreenImageContainer$2 = "_FullScreenImageContainer_1w0fq_12";
|
|
6347
|
+
const TopBarContainer$2 = "_TopBarContainer_1w0fq_22";
|
|
6348
|
+
const fileName$2 = "_fileName_1w0fq_31";
|
|
6349
|
+
const longIconButton$2 = "_longIconButton_1w0fq_36";
|
|
6350
|
+
const previewImage$3 = "_previewImage_1w0fq_42";
|
|
6351
|
+
const FullScreenImage$2 = "_FullScreenImage_1w0fq_12";
|
|
6352
|
+
const tabsList = "_tabsList_1w0fq_61";
|
|
6353
|
+
const tabTrigger = "_tabTrigger_1w0fq_69";
|
|
6354
|
+
const patchfieldBorder = "_patchfieldBorder_1w0fq_73";
|
|
6355
|
+
const title = "_title_1w0fq_73";
|
|
6356
|
+
const error = "_error_1w0fq_89";
|
|
6235
6357
|
const styles$7 = {
|
|
6236
6358
|
description: description$2,
|
|
6237
6359
|
floatingButtonContainer: floatingButtonContainer$2,
|
|
@@ -6345,14 +6467,14 @@ var __publicField = (obj, key, value) => {
|
|
|
6345
6467
|
}
|
|
6346
6468
|
__publicField(BaseField, "fieldTypeName");
|
|
6347
6469
|
__publicField(BaseField, "fieldTypeDescription");
|
|
6348
|
-
const description$1 = "
|
|
6349
|
-
const floatingButtonContainer$1 = "
|
|
6350
|
-
const FullScreenImageContainer$1 = "
|
|
6351
|
-
const TopBarContainer$1 = "
|
|
6352
|
-
const fileName$1 = "
|
|
6353
|
-
const longIconButton$1 = "
|
|
6354
|
-
const previewImage$2 = "
|
|
6355
|
-
const FullScreenImage$1 = "
|
|
6470
|
+
const description$1 = "_description_10o76_1";
|
|
6471
|
+
const floatingButtonContainer$1 = "_floatingButtonContainer_10o76_5";
|
|
6472
|
+
const FullScreenImageContainer$1 = "_FullScreenImageContainer_10o76_12";
|
|
6473
|
+
const TopBarContainer$1 = "_TopBarContainer_10o76_22";
|
|
6474
|
+
const fileName$1 = "_fileName_10o76_31";
|
|
6475
|
+
const longIconButton$1 = "_longIconButton_10o76_36";
|
|
6476
|
+
const previewImage$2 = "_previewImage_10o76_42";
|
|
6477
|
+
const FullScreenImage$1 = "_FullScreenImage_10o76_12";
|
|
6356
6478
|
const styles$6 = {
|
|
6357
6479
|
description: description$1,
|
|
6358
6480
|
floatingButtonContainer: floatingButtonContainer$1,
|
|
@@ -7614,15 +7736,15 @@ var __publicField = (obj, key, value) => {
|
|
|
7614
7736
|
}
|
|
7615
7737
|
return classes.join(" ");
|
|
7616
7738
|
}
|
|
7617
|
-
const paddingValues = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
|
|
7739
|
+
const paddingValues$1 = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"];
|
|
7618
7740
|
const paddingPropDefs = {
|
|
7619
|
-
p: { type: "enum", values: paddingValues, default: void 0, responsive: true },
|
|
7620
|
-
px: { type: "enum", values: paddingValues, default: void 0, responsive: true },
|
|
7621
|
-
py: { type: "enum", values: paddingValues, default: void 0, responsive: true },
|
|
7622
|
-
pt: { type: "enum", values: paddingValues, default: void 0, responsive: true },
|
|
7623
|
-
pr: { type: "enum", values: paddingValues, default: void 0, responsive: true },
|
|
7624
|
-
pb: { type: "enum", values: paddingValues, default: void 0, responsive: true },
|
|
7625
|
-
pl: { type: "enum", values: paddingValues, default: void 0, responsive: true }
|
|
7741
|
+
p: { type: "enum", values: paddingValues$1, default: void 0, responsive: true },
|
|
7742
|
+
px: { type: "enum", values: paddingValues$1, default: void 0, responsive: true },
|
|
7743
|
+
py: { type: "enum", values: paddingValues$1, default: void 0, responsive: true },
|
|
7744
|
+
pt: { type: "enum", values: paddingValues$1, default: void 0, responsive: true },
|
|
7745
|
+
pr: { type: "enum", values: paddingValues$1, default: void 0, responsive: true },
|
|
7746
|
+
pb: { type: "enum", values: paddingValues$1, default: void 0, responsive: true },
|
|
7747
|
+
pl: { type: "enum", values: paddingValues$1, default: void 0, responsive: true }
|
|
7626
7748
|
};
|
|
7627
7749
|
function extractPaddingProps(props) {
|
|
7628
7750
|
const { p = layoutPropDefs.p.default, px = layoutPropDefs.px.default, py = layoutPropDefs.py.default, pt = layoutPropDefs.pt.default, pr = layoutPropDefs.pr.default, pb = layoutPropDefs.pb.default, pl = layoutPropDefs.pl.default, ...rest } = props;
|
|
@@ -7763,6 +7885,26 @@ var __publicField = (obj, key, value) => {
|
|
|
7763
7885
|
wrap: { type: "enum", values: wrapValues, default: void 0, responsive: true },
|
|
7764
7886
|
gap: { type: "enum", values: gapValues, default: void 0, responsive: true }
|
|
7765
7887
|
};
|
|
7888
|
+
const sides = ["all", "x", "y", "top", "bottom", "left", "right"];
|
|
7889
|
+
const clipValues = ["border-box", "padding-box"];
|
|
7890
|
+
const paddingValues = ["current", "0"];
|
|
7891
|
+
const insetPropDefs = {
|
|
7892
|
+
side: { type: "enum", values: sides, default: "all", responsive: true },
|
|
7893
|
+
clip: { type: "enum", values: clipValues, default: "border-box", responsive: true },
|
|
7894
|
+
p: { type: "enum", values: paddingValues, default: void 0, responsive: true },
|
|
7895
|
+
px: { type: "enum", values: paddingValues, default: void 0, responsive: true },
|
|
7896
|
+
py: { type: "enum", values: paddingValues, default: void 0, responsive: true },
|
|
7897
|
+
pt: { type: "enum", values: paddingValues, default: void 0, responsive: true },
|
|
7898
|
+
pr: { type: "enum", values: paddingValues, default: void 0, responsive: true },
|
|
7899
|
+
pb: { type: "enum", values: paddingValues, default: void 0, responsive: true },
|
|
7900
|
+
pl: { type: "enum", values: paddingValues, default: void 0, responsive: true }
|
|
7901
|
+
};
|
|
7902
|
+
const Inset = React__namespace.forwardRef((props, forwardedRef) => {
|
|
7903
|
+
const { rest: marginRest, ...marginProps } = extractMarginProps(props);
|
|
7904
|
+
const { className, side = insetPropDefs.side.default, clip = insetPropDefs.clip.default, p, px, py, pt, pr, pb, pl, ...insetProps } = marginRest;
|
|
7905
|
+
return React__namespace.createElement("div", { ...insetProps, ref: forwardedRef, className: classNames("rt-Inset", className, withBreakpoints(side, "rt-r-side"), withBreakpoints(clip, "rt-r-clip"), withBreakpoints(p, "rt-r-p"), withBreakpoints(px, "rt-r-px"), withBreakpoints(py, "rt-r-py"), withBreakpoints(pt, "rt-r-pt"), withBreakpoints(pr, "rt-r-pr"), withBreakpoints(pb, "rt-r-pb"), withBreakpoints(pl, "rt-r-pl"), withMarginProps(marginProps)) });
|
|
7906
|
+
});
|
|
7907
|
+
Inset.displayName = "Inset";
|
|
7766
7908
|
const sizes$4 = ["1", "2", "3", "4", "5", "6", "7", "8", "9"];
|
|
7767
7909
|
const headingPropDefs = {
|
|
7768
7910
|
size: { type: "enum", values: sizes$4, default: "6", responsive: true },
|
|
@@ -9054,21 +9196,10 @@ var __publicField = (obj, key, value) => {
|
|
|
9054
9196
|
const makeConditionalSourceFields = (sections, index2) => {
|
|
9055
9197
|
return sections.filter((_, i) => i < index2).flatMap((field) => field.fields);
|
|
9056
9198
|
};
|
|
9057
|
-
const
|
|
9058
|
-
|
|
9059
|
-
};
|
|
9060
|
-
const incrementFieldLabel = (label, takenLabels) => {
|
|
9061
|
-
let count = 1;
|
|
9062
|
-
let newLabel = `${label} (${count})`;
|
|
9063
|
-
while (takenLabels.includes(newLabel)) {
|
|
9064
|
-
newLabel = `${label} (${++count})`;
|
|
9065
|
-
}
|
|
9066
|
-
return newLabel;
|
|
9067
|
-
};
|
|
9068
|
-
const createNewField = (parentPath, index2, initialValues2, values, setFieldValue) => {
|
|
9069
|
-
const { label } = initialValues2;
|
|
9199
|
+
const createNewField = (parentPath, index2, initialValues, values, setFieldValue) => {
|
|
9200
|
+
const { label } = initialValues;
|
|
9070
9201
|
const newField = {
|
|
9071
|
-
...
|
|
9202
|
+
...initialValues,
|
|
9072
9203
|
identifier: makeIdentifier(null, label)
|
|
9073
9204
|
};
|
|
9074
9205
|
const parent = get(values, parentPath);
|
|
@@ -9082,11 +9213,11 @@ var __publicField = (obj, key, value) => {
|
|
|
9082
9213
|
void setFieldValue(parentPath, updatedFields).then();
|
|
9083
9214
|
};
|
|
9084
9215
|
const createNewEmptySection = (index2, values, setFieldValue) => {
|
|
9085
|
-
const
|
|
9216
|
+
const initialValues = {
|
|
9086
9217
|
...emptySection(),
|
|
9087
9218
|
label: ""
|
|
9088
9219
|
};
|
|
9089
|
-
createNewField("fields", index2,
|
|
9220
|
+
createNewField("fields", index2, initialValues, values, setFieldValue);
|
|
9090
9221
|
};
|
|
9091
9222
|
const useFieldReordering = () => {
|
|
9092
9223
|
const { showError } = blocks.useToast();
|
|
@@ -9564,14 +9695,18 @@ var __publicField = (obj, key, value) => {
|
|
|
9564
9695
|
super(options, FieldInputCloner);
|
|
9565
9696
|
}
|
|
9566
9697
|
}
|
|
9567
|
-
const
|
|
9568
|
-
const
|
|
9569
|
-
const
|
|
9570
|
-
const
|
|
9698
|
+
const displayFileContainer = "_displayFileContainer_1vdfw_1";
|
|
9699
|
+
const infoContainer = "_infoContainer_1vdfw_6";
|
|
9700
|
+
const previewImage$1 = "_previewImage_1vdfw_10";
|
|
9701
|
+
const fileSizeText = "_fileSizeText_1vdfw_19";
|
|
9702
|
+
const nameContainer = "_nameContainer_1vdfw_24";
|
|
9703
|
+
const useEllipsis = "_useEllipsis_1vdfw_28";
|
|
9571
9704
|
const styles$4 = {
|
|
9705
|
+
displayFileContainer,
|
|
9706
|
+
infoContainer,
|
|
9572
9707
|
previewImage: previewImage$1,
|
|
9708
|
+
fileSizeText,
|
|
9573
9709
|
nameContainer,
|
|
9574
|
-
hasPreview,
|
|
9575
9710
|
useEllipsis
|
|
9576
9711
|
};
|
|
9577
9712
|
const convertBytesToLargestUnit = (bytes) => {
|
|
@@ -9713,46 +9848,8 @@ var __publicField = (obj, key, value) => {
|
|
|
9713
9848
|
},
|
|
9714
9849
|
[name, resolvedFile]
|
|
9715
9850
|
);
|
|
9716
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
9717
|
-
/* @__PURE__ */ jsxRuntime.
|
|
9718
|
-
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
|
|
9719
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9720
|
-
blocks.IconButton,
|
|
9721
|
-
{
|
|
9722
|
-
variant: "soft",
|
|
9723
|
-
"aria-label": `Download ${name}`,
|
|
9724
|
-
onClick: handleDownload,
|
|
9725
|
-
disabled: !resolvedFile,
|
|
9726
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(DownloadIcon, {})
|
|
9727
|
-
}
|
|
9728
|
-
),
|
|
9729
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9730
|
-
blocks.IconButton,
|
|
9731
|
-
{
|
|
9732
|
-
severity: "info",
|
|
9733
|
-
variant: "soft",
|
|
9734
|
-
"aria-label": `Remove ${name}`,
|
|
9735
|
-
disabled,
|
|
9736
|
-
onClick: onRemove,
|
|
9737
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(Cross1Icon, {})
|
|
9738
|
-
}
|
|
9739
|
-
)
|
|
9740
|
-
] }),
|
|
9741
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
9742
|
-
blocks.Flex,
|
|
9743
|
-
{
|
|
9744
|
-
className: classNames$1(styles$4.nameContainer, { [styles$4.hasPreview]: !!url }),
|
|
9745
|
-
direction: "column",
|
|
9746
|
-
gap: "1",
|
|
9747
|
-
children: [
|
|
9748
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$4.useEllipsis, children: name }),
|
|
9749
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", children: size }),
|
|
9750
|
-
error2 && /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity: "danger", children: error2 })
|
|
9751
|
-
]
|
|
9752
|
-
}
|
|
9753
|
-
)
|
|
9754
|
-
] }),
|
|
9755
|
-
url && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9851
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Card, { className: styles$4.displayFileContainer, size: "1", children: [
|
|
9852
|
+
/* @__PURE__ */ jsxRuntime.jsx(Inset, { clip: "border-box", side: "top", pb: "0", children: url && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
9756
9853
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9757
9854
|
"img",
|
|
9758
9855
|
{
|
|
@@ -9773,8 +9870,38 @@ var __publicField = (obj, key, value) => {
|
|
|
9773
9870
|
setShowPreview
|
|
9774
9871
|
}
|
|
9775
9872
|
)
|
|
9776
|
-
] })
|
|
9777
|
-
|
|
9873
|
+
] }) }),
|
|
9874
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { className: styles$4.infoContainer, children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", width: "100%", children: [
|
|
9875
|
+
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$4.nameContainer, align: "center", gap: "1", grow: "1", children: [
|
|
9876
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { className: styles$4.useEllipsis, size: "1", children: name }),
|
|
9877
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", className: styles$4.fileSizeText, children: `(${size})` }),
|
|
9878
|
+
error2 && /* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { size: "1", severity: "danger", children: error2 })
|
|
9879
|
+
] }),
|
|
9880
|
+
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
|
|
9881
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9882
|
+
blocks.IconButton,
|
|
9883
|
+
{
|
|
9884
|
+
variant: "ghost",
|
|
9885
|
+
"aria-label": `Download ${name}`,
|
|
9886
|
+
onClick: handleDownload,
|
|
9887
|
+
disabled: !resolvedFile,
|
|
9888
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(DownloadIcon, {})
|
|
9889
|
+
}
|
|
9890
|
+
),
|
|
9891
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
9892
|
+
blocks.IconButton,
|
|
9893
|
+
{
|
|
9894
|
+
severity: "info",
|
|
9895
|
+
variant: "ghost",
|
|
9896
|
+
"aria-label": `Remove ${name}`,
|
|
9897
|
+
disabled,
|
|
9898
|
+
onClick: onRemove,
|
|
9899
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(Cross1Icon, {})
|
|
9900
|
+
}
|
|
9901
|
+
)
|
|
9902
|
+
] })
|
|
9903
|
+
] }) })
|
|
9904
|
+
] });
|
|
9778
9905
|
});
|
|
9779
9906
|
DisplayFile.displayName = "DisplayFile";
|
|
9780
9907
|
const emptyUploadField = {
|
|
@@ -10197,10 +10324,12 @@ var __publicField = (obj, key, value) => {
|
|
|
10197
10324
|
};
|
|
10198
10325
|
const useAttachImagesToFormRevisionFields = (revision) => {
|
|
10199
10326
|
const { sdk } = useSDK();
|
|
10200
|
-
const attachments = useAppSelector(selectRevisionAttachments(revision.offline_id));
|
|
10327
|
+
const attachments = useAppSelector(selectRevisionAttachments((revision == null ? void 0 : revision.offline_id) ?? ""));
|
|
10201
10328
|
return React.useMemo(() => {
|
|
10329
|
+
if (!revision || !attachments)
|
|
10330
|
+
return revision;
|
|
10202
10331
|
const revisionCopy = structuredClone(revision);
|
|
10203
|
-
for (const attachment of attachments
|
|
10332
|
+
for (const attachment of attachments) {
|
|
10204
10333
|
const filePromise = sdk.files.fetchFileFromUrl(attachment.file, attachment.file_sha1, attachment.file_name);
|
|
10205
10334
|
let sectionIndex = -1;
|
|
10206
10335
|
let fieldIndex = -1;
|
|
@@ -10232,7 +10361,8 @@ var __publicField = (obj, key, value) => {
|
|
|
10232
10361
|
// if the title isn't provided, hide it by default
|
|
10233
10362
|
hideTitle = !schema.title,
|
|
10234
10363
|
hideDescription,
|
|
10235
|
-
className
|
|
10364
|
+
className,
|
|
10365
|
+
buttonProps
|
|
10236
10366
|
} = props;
|
|
10237
10367
|
const { readonly } = schema.meta;
|
|
10238
10368
|
const formId2 = React.useMemo(() => crypto.randomUUID(), []);
|
|
@@ -10267,8 +10397,8 @@ var __publicField = (obj, key, value) => {
|
|
|
10267
10397
|
] }) }),
|
|
10268
10398
|
inputs,
|
|
10269
10399
|
!readonly && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$6.floatingButtonContainer, align: "center", justify: "end", gap: "2", children: [
|
|
10270
|
-
cancelText && /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, {
|
|
10271
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "submit", disabled: !formik$1.isValid, children: submitText })
|
|
10400
|
+
cancelText && /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { severity: "info", ...buttonProps, type: "button", onClick: onCancel, children: cancelText }),
|
|
10401
|
+
/* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { ...buttonProps, type: "submit", disabled: !formik$1.isValid, children: submitText })
|
|
10272
10402
|
] })
|
|
10273
10403
|
] }) }) });
|
|
10274
10404
|
})
|
|
@@ -10284,6 +10414,9 @@ var __publicField = (obj, key, value) => {
|
|
|
10284
10414
|
);
|
|
10285
10415
|
}
|
|
10286
10416
|
const revisionWithImages = useAttachImagesToFormRevisionFields(revision);
|
|
10417
|
+
if (!revisionWithImages) {
|
|
10418
|
+
throw new Error("Expected revisionWithImages to be defined");
|
|
10419
|
+
}
|
|
10287
10420
|
const schema = React.useMemo(() => {
|
|
10288
10421
|
return formRevisionToSchema(revisionWithImages, { readonly: true });
|
|
10289
10422
|
}, [revisionWithImages]);
|
|
@@ -10340,6 +10473,10 @@ var __publicField = (obj, key, value) => {
|
|
|
10340
10473
|
}, [filter, maxResults, ownerFilter]);
|
|
10341
10474
|
const userForms = useAppSelector(selectFilteredUserForms(ownerFilterOptions)) ?? [];
|
|
10342
10475
|
const userFormMapping = useAppSelector(selectUserFormMapping);
|
|
10476
|
+
const attachableUserForms = userForms.filter((form) => !form.component_type);
|
|
10477
|
+
const attachableUserFormMapping = Object.values(userFormMapping).filter(
|
|
10478
|
+
(form) => !form.component_type
|
|
10479
|
+
);
|
|
10343
10480
|
const handleToggleFavorite = React.useCallback(
|
|
10344
10481
|
(form) => {
|
|
10345
10482
|
if (form.favorite) {
|
|
@@ -10353,7 +10490,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10353
10490
|
const options = React.useMemo(() => {
|
|
10354
10491
|
const state = sdk.store.getState();
|
|
10355
10492
|
const accumulator = {};
|
|
10356
|
-
for (const form of
|
|
10493
|
+
for (const form of attachableUserFormMapping) {
|
|
10357
10494
|
const organization = selectOrganization(form.owner_organization || -1)(state);
|
|
10358
10495
|
if (organization) {
|
|
10359
10496
|
accumulator[`${orgOptionPrefix}${organization.id}`] = organization.name;
|
|
@@ -10364,13 +10501,13 @@ var __publicField = (obj, key, value) => {
|
|
|
10364
10501
|
}
|
|
10365
10502
|
}
|
|
10366
10503
|
return Object.entries(accumulator).map(([value, label]) => ({ itemContent: label, value }));
|
|
10367
|
-
}, [
|
|
10504
|
+
}, [sdk.store, attachableUserFormMapping]);
|
|
10368
10505
|
const handleChange = React.useCallback((e) => {
|
|
10369
10506
|
setFilter(e.currentTarget.value);
|
|
10370
10507
|
}, []);
|
|
10371
|
-
const numberOfForms = useAppSelector(
|
|
10372
|
-
const numberOfHiddenForms = numberOfForms -
|
|
10373
|
-
const overflowMessage =
|
|
10508
|
+
const numberOfForms = useAppSelector(selectNumberOfGeneralUserForms) || 0;
|
|
10509
|
+
const numberOfHiddenForms = numberOfForms - attachableUserForms.length;
|
|
10510
|
+
const overflowMessage = attachableUserForms.length == maxResults && numberOfHiddenForms > 0 ? `Only the first ${maxResults} results are shown (${numberOfHiddenForms} hidden)` : numberOfHiddenForms > 0 && `${numberOfHiddenForms} hidden forms`;
|
|
10374
10511
|
return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { ref, direction: "column", gap: "2", children: [
|
|
10375
10512
|
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "2", grow: "1", children: [
|
|
10376
10513
|
/* @__PURE__ */ jsxRuntime.jsx(Box, { grow: "1", asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(TextField$1.Root, { size: "3", children: /* @__PURE__ */ jsxRuntime.jsx(TextField$1.Input, { placeholder: "Filter", value: filter, onChange: handleChange }) }) }),
|
|
@@ -10385,7 +10522,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10385
10522
|
}
|
|
10386
10523
|
)
|
|
10387
10524
|
] }),
|
|
10388
|
-
|
|
10525
|
+
attachableUserForms.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(blocks.ButtonList.Root, { children: attachableUserForms.map((form) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
10389
10526
|
FormBrowserEntry,
|
|
10390
10527
|
{
|
|
10391
10528
|
...entryProps,
|
|
@@ -10457,7 +10594,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10457
10594
|
submissionsContainer,
|
|
10458
10595
|
stopHorizontalOverflow
|
|
10459
10596
|
};
|
|
10460
|
-
const FormSubmissionBrowserEntry = React.memo(
|
|
10597
|
+
const FormSubmissionBrowserEntry = React.memo((props) => {
|
|
10461
10598
|
var _a2;
|
|
10462
10599
|
const { submission, onSubmissionClick, compact, labelType, rowDecorator } = props;
|
|
10463
10600
|
const currentUser = useAppSelector(selectCurrentUser);
|
|
@@ -10501,11 +10638,12 @@ var __publicField = (obj, key, value) => {
|
|
|
10501
10638
|
}
|
|
10502
10639
|
return row;
|
|
10503
10640
|
});
|
|
10641
|
+
FormSubmissionBrowserEntry.displayName = "FormSubmissionBrowserEntry";
|
|
10504
10642
|
const getCreatedAtOrSubmittedAtDate = (submission) => {
|
|
10505
10643
|
const date = "created_at" in submission ? submission.created_at : submission.submitted_at;
|
|
10506
10644
|
return new Date(date);
|
|
10507
10645
|
};
|
|
10508
|
-
const FormSubmissionBrowser = React.memo(
|
|
10646
|
+
const FormSubmissionBrowser = React.memo((props) => {
|
|
10509
10647
|
const {
|
|
10510
10648
|
formId: formId2,
|
|
10511
10649
|
submissions: propSubmissions,
|
|
@@ -10551,6 +10689,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10551
10689
|
}
|
|
10552
10690
|
);
|
|
10553
10691
|
});
|
|
10692
|
+
FormSubmissionBrowser.displayName = "FormSubmissionBrowser";
|
|
10554
10693
|
const PatchField = React.memo((props) => {
|
|
10555
10694
|
const { name, render } = props;
|
|
10556
10695
|
const { submitForm } = formik.useFormikContext();
|
|
@@ -10574,19 +10713,19 @@ var __publicField = (obj, key, value) => {
|
|
|
10574
10713
|
const PatchFormProvider = React.memo(
|
|
10575
10714
|
React.forwardRef((props, ref) => {
|
|
10576
10715
|
const { children, schema, values, onPatch, onError, requiresDiff = true, onDirtyChange, ...rest } = props;
|
|
10577
|
-
const
|
|
10716
|
+
const initialValues = React.useMemo(() => initialFormValues(schema.fields, values), [schema.fields, values]);
|
|
10578
10717
|
const getDiff = React.useCallback(
|
|
10579
10718
|
(values2) => {
|
|
10580
10719
|
const diff = {};
|
|
10581
10720
|
for (const key in values2) {
|
|
10582
10721
|
const value = values2[key];
|
|
10583
|
-
if (value !==
|
|
10722
|
+
if (value !== initialValues[key] && value !== void 0) {
|
|
10584
10723
|
diff[key] = value;
|
|
10585
10724
|
}
|
|
10586
10725
|
}
|
|
10587
10726
|
return diff;
|
|
10588
10727
|
},
|
|
10589
|
-
[
|
|
10728
|
+
[initialValues]
|
|
10590
10729
|
);
|
|
10591
10730
|
const handlePatch = React.useCallback(
|
|
10592
10731
|
(values2) => {
|
|
@@ -10612,7 +10751,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10612
10751
|
[schema, onDirtyChange, onError, getDiff]
|
|
10613
10752
|
);
|
|
10614
10753
|
const formik$1 = formik.useFormik({
|
|
10615
|
-
initialValues
|
|
10754
|
+
initialValues,
|
|
10616
10755
|
onSubmit: handlePatch,
|
|
10617
10756
|
validate,
|
|
10618
10757
|
// only validate the entire form on submit
|
|
@@ -10630,9 +10769,9 @@ var __publicField = (obj, key, value) => {
|
|
|
10630
10769
|
const { errors, resetForm } = formik$1;
|
|
10631
10770
|
React.useEffect(() => {
|
|
10632
10771
|
if (hasKeys(errors)) {
|
|
10633
|
-
resetForm({ values:
|
|
10772
|
+
resetForm({ values: initialValues, errors: {} });
|
|
10634
10773
|
}
|
|
10635
|
-
}, [errors,
|
|
10774
|
+
}, [errors, initialValues, resetForm]);
|
|
10636
10775
|
return /* @__PURE__ */ jsxRuntime.jsx(formik.FormikProvider, { value: formik$1, children: /* @__PURE__ */ jsxRuntime.jsx("form", { ...rest, ref, onSubmit: formik$1.handleSubmit, onChange: handleChange, children }) });
|
|
10637
10776
|
})
|
|
10638
10777
|
);
|
|
@@ -10740,21 +10879,21 @@ var __publicField = (obj, key, value) => {
|
|
|
10740
10879
|
] });
|
|
10741
10880
|
});
|
|
10742
10881
|
FieldActions.displayName = "FieldActions";
|
|
10743
|
-
const description = "
|
|
10744
|
-
const floatingButtonContainer = "
|
|
10745
|
-
const FullScreenImageContainer = "
|
|
10746
|
-
const TopBarContainer = "
|
|
10747
|
-
const fileName = "
|
|
10748
|
-
const longIconButton = "
|
|
10749
|
-
const previewImage = "
|
|
10750
|
-
const FullScreenImage = "
|
|
10751
|
-
const popoverInputsContainer = "
|
|
10752
|
-
const imageContainer = "
|
|
10753
|
-
const deleteImageButton = "
|
|
10754
|
-
const typeBadge = "
|
|
10755
|
-
const previewInput = "
|
|
10756
|
-
const directInput = "
|
|
10757
|
-
const grow = "
|
|
10882
|
+
const description = "_description_6795p_1";
|
|
10883
|
+
const floatingButtonContainer = "_floatingButtonContainer_6795p_5";
|
|
10884
|
+
const FullScreenImageContainer = "_FullScreenImageContainer_6795p_12";
|
|
10885
|
+
const TopBarContainer = "_TopBarContainer_6795p_22";
|
|
10886
|
+
const fileName = "_fileName_6795p_31";
|
|
10887
|
+
const longIconButton = "_longIconButton_6795p_36";
|
|
10888
|
+
const previewImage = "_previewImage_6795p_42";
|
|
10889
|
+
const FullScreenImage = "_FullScreenImage_6795p_12";
|
|
10890
|
+
const popoverInputsContainer = "_popoverInputsContainer_6795p_61";
|
|
10891
|
+
const imageContainer = "_imageContainer_6795p_65";
|
|
10892
|
+
const deleteImageButton = "_deleteImageButton_6795p_70";
|
|
10893
|
+
const typeBadge = "_typeBadge_6795p_81";
|
|
10894
|
+
const previewInput = "_previewInput_6795p_86";
|
|
10895
|
+
const directInput = "_directInput_6795p_90";
|
|
10896
|
+
const grow = "_grow_6795p_95";
|
|
10758
10897
|
const styles = {
|
|
10759
10898
|
description,
|
|
10760
10899
|
floatingButtonContainer,
|
|
@@ -10836,19 +10975,24 @@ var __publicField = (obj, key, value) => {
|
|
|
10836
10975
|
const { parentPath, index: index2, initial, conditionalSourceFields } = props;
|
|
10837
10976
|
const { values, setFieldValue, errors } = formik.useFormikContext();
|
|
10838
10977
|
const fieldTypeItems = useFieldTypeItems();
|
|
10978
|
+
const containerRef = React.useRef(null);
|
|
10839
10979
|
const RADIX_SM_MIN_WIDTH = 576;
|
|
10840
|
-
const [
|
|
10841
|
-
|
|
10980
|
+
const [isLargeContainer, setIsLargeContainer] = React.useState(
|
|
10981
|
+
containerRef.current && containerRef.current.getBoundingClientRect().width >= RADIX_SM_MIN_WIDTH
|
|
10842
10982
|
);
|
|
10843
10983
|
React.useEffect(() => {
|
|
10844
|
-
const
|
|
10845
|
-
|
|
10846
|
-
|
|
10847
|
-
|
|
10848
|
-
|
|
10849
|
-
|
|
10850
|
-
|
|
10851
|
-
|
|
10984
|
+
const container = containerRef.current;
|
|
10985
|
+
if (container) {
|
|
10986
|
+
const observer = new ResizeObserver((entries) => {
|
|
10987
|
+
if (entries[0]) {
|
|
10988
|
+
setIsLargeContainer(entries[0].contentRect.width >= RADIX_SM_MIN_WIDTH);
|
|
10989
|
+
}
|
|
10990
|
+
});
|
|
10991
|
+
observer.observe(container);
|
|
10992
|
+
return () => {
|
|
10993
|
+
observer.disconnect();
|
|
10994
|
+
};
|
|
10995
|
+
}
|
|
10852
10996
|
}, []);
|
|
10853
10997
|
const [resolvedImage, setResolvedImage] = React.useState(void 0);
|
|
10854
10998
|
const [showImagePreview, setShowImagePreview] = React.useState(false);
|
|
@@ -10925,7 +11069,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10925
11069
|
const fieldObject = fieldCls.getFieldCreationSchema(
|
|
10926
11070
|
`${parentPath}.${index2}`
|
|
10927
11071
|
);
|
|
10928
|
-
if (
|
|
11072
|
+
if (isLargeContainer) {
|
|
10929
11073
|
directlyShownFields2 = [
|
|
10930
11074
|
...directlyShownFields2,
|
|
10931
11075
|
...fieldObject.filter((field) => field.showDirectly).map((field) => field.field)
|
|
@@ -10939,7 +11083,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10939
11083
|
}
|
|
10940
11084
|
}
|
|
10941
11085
|
return [directlyShownFields2, popoverFields2];
|
|
10942
|
-
}, [fieldCls, conditionalSourceFields, parentPath, index2,
|
|
11086
|
+
}, [fieldCls, conditionalSourceFields, parentPath, index2, isLargeContainer]);
|
|
10943
11087
|
const directlyShownInputs = useFieldInputs(directlyShownFields, {
|
|
10944
11088
|
formId,
|
|
10945
11089
|
disabled: false,
|
|
@@ -10959,7 +11103,7 @@ var __publicField = (obj, key, value) => {
|
|
|
10959
11103
|
});
|
|
10960
11104
|
const deserializedField = React.useMemo(() => deserialize(initial), [initial]);
|
|
10961
11105
|
const previewInput2 = useFieldInput(deserializedField, { formId, disabled: true, showInputOnly: true });
|
|
10962
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", grow: "1", children: [
|
|
11106
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { ref: containerRef, align: "center", grow: "1", children: [
|
|
10963
11107
|
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", width: "100%", children: [
|
|
10964
11108
|
fieldCls === FieldSection && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "1", children: [
|
|
10965
11109
|
directlyShownFields.length > 0 && directlyShownInputs,
|
|
@@ -11038,7 +11182,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11038
11182
|
blocks.Input,
|
|
11039
11183
|
{
|
|
11040
11184
|
className: styles.grow,
|
|
11041
|
-
placeholder:
|
|
11185
|
+
placeholder: type === "section" ? "Enter a section label (optional)" : "Enter your question",
|
|
11042
11186
|
value,
|
|
11043
11187
|
onChange: (event) => {
|
|
11044
11188
|
setValue(event.target.value);
|
|
@@ -11061,7 +11205,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11061
11205
|
blocks.TextArea,
|
|
11062
11206
|
{
|
|
11063
11207
|
className: styles.grow,
|
|
11064
|
-
placeholder: `Enter a ${type === "section" ? "section" : "field"} description`,
|
|
11208
|
+
placeholder: `Enter a ${type === "section" ? "section" : "field"} description (optional)`,
|
|
11065
11209
|
value,
|
|
11066
11210
|
onChange: (event) => {
|
|
11067
11211
|
setValue(event.target.value);
|
|
@@ -11081,7 +11225,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11081
11225
|
});
|
|
11082
11226
|
FieldBuilder.displayName = "FieldBuilder";
|
|
11083
11227
|
const FieldWithActions = React.memo((props) => {
|
|
11084
|
-
const { field, index: index2, sectionIndex,
|
|
11228
|
+
const { field, index: index2, sectionIndex, remove: remove2 } = props;
|
|
11085
11229
|
const { setFieldValue, values } = formik.useFormikContext();
|
|
11086
11230
|
const { reorderField } = useFieldReordering();
|
|
11087
11231
|
const { showError } = blocks.useToast();
|
|
@@ -11098,10 +11242,10 @@ var __publicField = (obj, key, value) => {
|
|
|
11098
11242
|
const label = field.label ?? "Unlabelled field";
|
|
11099
11243
|
const duplicatedField = {
|
|
11100
11244
|
...field,
|
|
11101
|
-
label
|
|
11245
|
+
label
|
|
11102
11246
|
};
|
|
11103
11247
|
createNewField(parentPath, index2 + 1, duplicatedField, values, setFieldValue);
|
|
11104
|
-
}, [field,
|
|
11248
|
+
}, [field, parentPath, index2, values, setFieldValue]);
|
|
11105
11249
|
const moveField = React.useCallback(
|
|
11106
11250
|
(direction) => {
|
|
11107
11251
|
const srcSectionIndex = sectionIndex;
|
|
@@ -11183,12 +11327,11 @@ var __publicField = (obj, key, value) => {
|
|
|
11183
11327
|
FieldWithActions.displayName = "FieldWithActions";
|
|
11184
11328
|
const FieldSectionWithActions = React.memo((props) => {
|
|
11185
11329
|
var _a2;
|
|
11186
|
-
const { field, index: sectionIndex, dropState } = props;
|
|
11330
|
+
const { field, index: sectionIndex, dropState, fieldsOnly } = props;
|
|
11187
11331
|
const isDropDisabled = (_a2 = dropState[field.identifier]) == null ? void 0 : _a2.disabled;
|
|
11188
11332
|
const { setFieldValue, values } = formik.useFormikContext();
|
|
11189
11333
|
const alertDialog = blocks.useAlertDialog();
|
|
11190
11334
|
const { reorderSection } = useFieldReordering();
|
|
11191
|
-
const takenFieldLabels = getTakenFieldLabels(values.fields);
|
|
11192
11335
|
const removeSectionConditions = React.useCallback(
|
|
11193
11336
|
(sectionsToUpdate, allSections) => {
|
|
11194
11337
|
for (const section of sectionsToUpdate) {
|
|
@@ -11292,18 +11435,15 @@ var __publicField = (obj, key, value) => {
|
|
|
11292
11435
|
);
|
|
11293
11436
|
const duplicateSection = React.useCallback(() => {
|
|
11294
11437
|
const fieldLabel = field.label ?? "Untitled section";
|
|
11295
|
-
const
|
|
11296
|
-
const newFields = field.fields.map((f) => {
|
|
11297
|
-
const newLabel = incrementFieldLabel(f.label, takenFieldLabels);
|
|
11438
|
+
const newFields = field.fields.map((oldField) => {
|
|
11298
11439
|
return {
|
|
11299
|
-
...
|
|
11300
|
-
|
|
11301
|
-
identifier: makeIdentifier(null, newLabel)
|
|
11440
|
+
...oldField,
|
|
11441
|
+
identifier: makeIdentifier(null, oldField.label)
|
|
11302
11442
|
};
|
|
11303
11443
|
});
|
|
11304
|
-
const duplicatedField = { ...field, label:
|
|
11444
|
+
const duplicatedField = { ...field, label: fieldLabel, fields: newFields };
|
|
11305
11445
|
createNewField("fields", sectionIndex + 1, duplicatedField, values, setFieldValue);
|
|
11306
|
-
}, [field,
|
|
11446
|
+
}, [field, sectionIndex, values, setFieldValue]);
|
|
11307
11447
|
const handleCreateField = React.useCallback(
|
|
11308
11448
|
(type) => {
|
|
11309
11449
|
createNewField(
|
|
@@ -11327,7 +11467,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11327
11467
|
mb: "4",
|
|
11328
11468
|
children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "3", justify: "between", align: "center", children: [
|
|
11329
11469
|
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", grow: "1", children: [
|
|
11330
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldBuilder, { ...editSectionProps }),
|
|
11470
|
+
!fieldsOnly && /* @__PURE__ */ jsxRuntime.jsx(FieldBuilder, { ...editSectionProps }),
|
|
11331
11471
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11332
11472
|
dnd.Droppable,
|
|
11333
11473
|
{
|
|
@@ -11350,8 +11490,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11350
11490
|
sectionIndex,
|
|
11351
11491
|
remove: () => {
|
|
11352
11492
|
removeField(i);
|
|
11353
|
-
}
|
|
11354
|
-
takenLabels: takenFieldLabels
|
|
11493
|
+
}
|
|
11355
11494
|
},
|
|
11356
11495
|
child.identifier
|
|
11357
11496
|
)),
|
|
@@ -11372,7 +11511,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11372
11511
|
}
|
|
11373
11512
|
)
|
|
11374
11513
|
] }),
|
|
11375
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11514
|
+
!fieldsOnly && /* @__PURE__ */ jsxRuntime.jsx(
|
|
11376
11515
|
FieldActions,
|
|
11377
11516
|
{
|
|
11378
11517
|
index: sectionIndex,
|
|
@@ -11449,7 +11588,8 @@ var __publicField = (obj, key, value) => {
|
|
|
11449
11588
|
return [section, i];
|
|
11450
11589
|
}
|
|
11451
11590
|
};
|
|
11452
|
-
const FieldsEditor = React.memo(() => {
|
|
11591
|
+
const FieldsEditor = React.memo((props) => {
|
|
11592
|
+
const { fieldsOnly } = props;
|
|
11453
11593
|
const { values, setFieldValue } = formik.useFormikContext();
|
|
11454
11594
|
const [dropState, dispatch] = React.useReducer(reducer, values.fields, initializer);
|
|
11455
11595
|
const { reorderSection, reorderField } = useFieldReordering();
|
|
@@ -11502,8 +11642,16 @@ var __publicField = (obj, key, value) => {
|
|
|
11502
11642
|
gap: "0",
|
|
11503
11643
|
children: [
|
|
11504
11644
|
values.fields.map((field, index2) => /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
11505
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11506
|
-
|
|
11645
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11646
|
+
FieldSectionWithActions,
|
|
11647
|
+
{
|
|
11648
|
+
field,
|
|
11649
|
+
index: index2,
|
|
11650
|
+
dropState,
|
|
11651
|
+
fieldsOnly
|
|
11652
|
+
}
|
|
11653
|
+
),
|
|
11654
|
+
!fieldsOnly && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11507
11655
|
blocks.Button,
|
|
11508
11656
|
{
|
|
11509
11657
|
className: styles$1.addSectionButton,
|
|
@@ -11526,17 +11674,22 @@ var __publicField = (obj, key, value) => {
|
|
|
11526
11674
|
) }) });
|
|
11527
11675
|
});
|
|
11528
11676
|
FieldsEditor.displayName = "FieldsEditor";
|
|
11529
|
-
const initialValues = {
|
|
11530
|
-
title: "",
|
|
11531
|
-
description: "",
|
|
11532
|
-
fields: [{ ...emptySection(makeIdentifier(null, "")), label: "" }]
|
|
11533
|
-
};
|
|
11534
11677
|
const previewSubmit = () => {
|
|
11535
11678
|
alert("This is a form preview, your data will not be saved.");
|
|
11536
11679
|
};
|
|
11537
11680
|
const FormBuilder = React.memo(
|
|
11538
11681
|
React.forwardRef((props, ref) => {
|
|
11539
|
-
const {
|
|
11682
|
+
const {
|
|
11683
|
+
onCancel,
|
|
11684
|
+
onSave,
|
|
11685
|
+
revision,
|
|
11686
|
+
initialTitle,
|
|
11687
|
+
showExplainerText = true,
|
|
11688
|
+
showFormTitle = true,
|
|
11689
|
+
fieldsOnly = false,
|
|
11690
|
+
showTabs = true,
|
|
11691
|
+
tabsListClassName
|
|
11692
|
+
} = props;
|
|
11540
11693
|
const { showError } = blocks.useToast();
|
|
11541
11694
|
const validate = React.useCallback(
|
|
11542
11695
|
(form) => {
|
|
@@ -11582,8 +11735,17 @@ var __publicField = (obj, key, value) => {
|
|
|
11582
11735
|
},
|
|
11583
11736
|
[showError]
|
|
11584
11737
|
);
|
|
11738
|
+
const initialValues = React.useMemo(
|
|
11739
|
+
() => ({
|
|
11740
|
+
title: initialTitle ?? "",
|
|
11741
|
+
description: "",
|
|
11742
|
+
fields: [{ ...emptySection(makeIdentifier(null, "")), label: "" }]
|
|
11743
|
+
}),
|
|
11744
|
+
[initialTitle]
|
|
11745
|
+
);
|
|
11746
|
+
const revisionWithImages = useAttachImagesToFormRevisionFields(revision);
|
|
11585
11747
|
const formik$1 = formik.useFormik({
|
|
11586
|
-
initialValues: wrapRootFieldsWithFieldSection(
|
|
11748
|
+
initialValues: wrapRootFieldsWithFieldSection(revisionWithImages) ?? initialValues,
|
|
11587
11749
|
validate,
|
|
11588
11750
|
onSubmit: onSave,
|
|
11589
11751
|
validateOnChange: false,
|
|
@@ -11591,7 +11753,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11591
11753
|
});
|
|
11592
11754
|
const previewSchema = React.useMemo(() => formRevisionToSchema(formik$1.values), [formik$1.values]);
|
|
11593
11755
|
return /* @__PURE__ */ jsxRuntime.jsx(Tabs.Root, { ref, defaultValue: "edit", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
|
|
11594
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Tabs.List, { className: styles$7.tabsList, children: [
|
|
11756
|
+
showTabs && /* @__PURE__ */ jsxRuntime.jsxs(Tabs.List, { className: classNames$1(styles$7.tabsList, tabsListClassName), children: [
|
|
11595
11757
|
/* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { className: styles$7.tabTrigger, value: "edit", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
|
|
11596
11758
|
/* @__PURE__ */ jsxRuntime.jsx(Pencil1Icon, {}),
|
|
11597
11759
|
"Edit"
|
|
@@ -11602,7 +11764,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11602
11764
|
] }) })
|
|
11603
11765
|
] }),
|
|
11604
11766
|
/* @__PURE__ */ jsxRuntime.jsxs(Tabs.Content, { value: "edit", children: [
|
|
11605
|
-
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Text, { children: [
|
|
11767
|
+
showExplainerText && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Text, { children: [
|
|
11606
11768
|
"Create your form using various field types. Sections can be",
|
|
11607
11769
|
" ",
|
|
11608
11770
|
/* @__PURE__ */ jsxRuntime.jsx("strong", { children: "conditionally rendered" }),
|
|
@@ -11612,60 +11774,62 @@ var __publicField = (obj, key, value) => {
|
|
|
11612
11774
|
] }),
|
|
11613
11775
|
/* @__PURE__ */ jsxRuntime.jsx(blocks.Flex, { asChild: true, direction: "column", gap: "2", mt: "3", children: /* @__PURE__ */ jsxRuntime.jsxs("form", { id: formId, onSubmit: formik$1.handleSubmit, children: [
|
|
11614
11776
|
/* @__PURE__ */ jsxRuntime.jsxs(formik.FormikProvider, { value: formik$1, children: [
|
|
11615
|
-
/* @__PURE__ */ jsxRuntime.
|
|
11616
|
-
|
|
11617
|
-
|
|
11618
|
-
|
|
11619
|
-
|
|
11620
|
-
|
|
11621
|
-
|
|
11622
|
-
|
|
11623
|
-
|
|
11624
|
-
|
|
11625
|
-
|
|
11626
|
-
|
|
11627
|
-
|
|
11628
|
-
|
|
11629
|
-
|
|
11630
|
-
|
|
11631
|
-
|
|
11632
|
-
|
|
11633
|
-
|
|
11634
|
-
|
|
11635
|
-
|
|
11636
|
-
|
|
11637
|
-
|
|
11638
|
-
|
|
11639
|
-
|
|
11640
|
-
|
|
11641
|
-
|
|
11642
|
-
|
|
11643
|
-
|
|
11644
|
-
|
|
11645
|
-
|
|
11646
|
-
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
|
|
11653
|
-
|
|
11654
|
-
|
|
11655
|
-
|
|
11656
|
-
|
|
11657
|
-
|
|
11658
|
-
|
|
11659
|
-
|
|
11777
|
+
showFormTitle && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
11778
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11779
|
+
PatchField,
|
|
11780
|
+
{
|
|
11781
|
+
name: "title",
|
|
11782
|
+
render: ({ setValue, value, meta }) => /* @__PURE__ */ jsxRuntime.jsx(InputWithHelpText, { severity: "danger", helpText: meta.error ?? null, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
11783
|
+
blocks.Input,
|
|
11784
|
+
{
|
|
11785
|
+
className: classNames$1(styles$7.title, {
|
|
11786
|
+
[styles$7.error]: meta.error
|
|
11787
|
+
}),
|
|
11788
|
+
placeholder: "Form title",
|
|
11789
|
+
value,
|
|
11790
|
+
onChange: (event) => {
|
|
11791
|
+
setValue(event.target.value);
|
|
11792
|
+
},
|
|
11793
|
+
maxLength: 100,
|
|
11794
|
+
showInputLength: false,
|
|
11795
|
+
variant: "ghost",
|
|
11796
|
+
size: "large"
|
|
11797
|
+
}
|
|
11798
|
+
) })
|
|
11799
|
+
}
|
|
11800
|
+
),
|
|
11801
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11802
|
+
PatchField,
|
|
11803
|
+
{
|
|
11804
|
+
name: "description",
|
|
11805
|
+
render: ({ setValue, value }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
11806
|
+
blocks.TextArea,
|
|
11807
|
+
{
|
|
11808
|
+
className: styles$7.description,
|
|
11809
|
+
placeholder: "Explain the purpose of this form",
|
|
11810
|
+
value,
|
|
11811
|
+
onChange: (event) => {
|
|
11812
|
+
setValue(event.target.value);
|
|
11813
|
+
},
|
|
11814
|
+
resize: "vertical",
|
|
11815
|
+
maxLength: 1e3,
|
|
11816
|
+
showInputLength: false,
|
|
11817
|
+
variant: "ghost"
|
|
11818
|
+
}
|
|
11819
|
+
)
|
|
11820
|
+
}
|
|
11821
|
+
)
|
|
11822
|
+
] }),
|
|
11823
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldsEditor, { fieldsOnly }),
|
|
11660
11824
|
/* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { severity: "danger", size: "1", children: typeof formik$1.errors.fields === "string" && formik$1.errors.fields })
|
|
11661
11825
|
] }),
|
|
11662
11826
|
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$7.floatingButtonContainer, align: "center", justify: "end", gap: "2", children: [
|
|
11663
|
-
/* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", variant: "solid", severity: "info", onClick: onCancel, children: "Cancel" }),
|
|
11827
|
+
onCancel && /* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "button", variant: "solid", severity: "info", onClick: onCancel, children: "Cancel" }),
|
|
11664
11828
|
/* @__PURE__ */ jsxRuntime.jsx(blocks.Button, { type: "submit", children: "Save form" })
|
|
11665
11829
|
] })
|
|
11666
11830
|
] }) })
|
|
11667
11831
|
] }),
|
|
11668
|
-
/* @__PURE__ */ jsxRuntime.jsx(Tabs.Content, { value: "preview", children: /* @__PURE__ */ jsxRuntime.jsx(FormRenderer, { schema: previewSchema, onSubmit: previewSubmit }) })
|
|
11832
|
+
/* @__PURE__ */ jsxRuntime.jsx(Tabs.Content, { value: "preview", children: /* @__PURE__ */ jsxRuntime.jsx(FormRenderer, { schema: previewSchema, onSubmit: previewSubmit, hideTitle: !showFormTitle }) })
|
|
11669
11833
|
] }) });
|
|
11670
11834
|
})
|
|
11671
11835
|
);
|
|
@@ -11816,7 +11980,6 @@ var __publicField = (obj, key, value) => {
|
|
|
11816
11980
|
exports2.addUserFormRevision = addUserFormRevision;
|
|
11817
11981
|
exports2.addUserFormRevisionAttachment = addUserFormRevisionAttachment;
|
|
11818
11982
|
exports2.addUserFormRevisions = addUserFormRevisions;
|
|
11819
|
-
exports2.addUserFormSubmission = addUserFormSubmission;
|
|
11820
11983
|
exports2.addUserFormSubmissionAttachment = addUserFormSubmissionAttachment;
|
|
11821
11984
|
exports2.addUserFormSubmissions = addUserFormSubmissions;
|
|
11822
11985
|
exports2.addUserForms = addUserForms;
|
|
@@ -11901,6 +12064,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11901
12064
|
exports2.issueReducer = issueReducer;
|
|
11902
12065
|
exports2.issueSlice = issueSlice;
|
|
11903
12066
|
exports2.issueToSearchResult = issueToSearchResult;
|
|
12067
|
+
exports2.linkStageToForm = linkStageToForm;
|
|
11904
12068
|
exports2.literalToCoordinates = literalToCoordinates;
|
|
11905
12069
|
exports2.logOnlyOnce = logOnlyOnce;
|
|
11906
12070
|
exports2.makeClient = makeClient;
|
|
@@ -11977,7 +12141,6 @@ var __publicField = (obj, key, value) => {
|
|
|
11977
12141
|
exports2.selectActiveWorkspace = selectActiveWorkspace;
|
|
11978
12142
|
exports2.selectActiveWorkspaceId = selectActiveWorkspaceId;
|
|
11979
12143
|
exports2.selectAllAttachments = selectAllAttachments;
|
|
11980
|
-
exports2.selectAllRevisionAttachmentsByLatestRevisionId = selectAllRevisionAttachmentsByLatestRevisionId;
|
|
11981
12144
|
exports2.selectAppearance = selectAppearance;
|
|
11982
12145
|
exports2.selectCategories = selectCategories;
|
|
11983
12146
|
exports2.selectCategoriesOfWorkspace = selectCategoriesOfWorkspace;
|
|
@@ -11991,6 +12154,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11991
12154
|
exports2.selectCompletedStages = selectCompletedStages;
|
|
11992
12155
|
exports2.selectComponent = selectComponent;
|
|
11993
12156
|
exports2.selectComponentType = selectComponentType;
|
|
12157
|
+
exports2.selectComponentTypeForm = selectComponentTypeForm;
|
|
11994
12158
|
exports2.selectComponentTypeFromComponent = selectComponentTypeFromComponent;
|
|
11995
12159
|
exports2.selectComponentTypeFromComponents = selectComponentTypeFromComponents;
|
|
11996
12160
|
exports2.selectComponentTypes = selectComponentTypes;
|
|
@@ -12028,10 +12192,12 @@ var __publicField = (obj, key, value) => {
|
|
|
12028
12192
|
exports2.selectLatestFormRevision = selectLatestFormRevision;
|
|
12029
12193
|
exports2.selectLatestRetryTime = selectLatestRetryTime;
|
|
12030
12194
|
exports2.selectLatestRevisionByFormId = selectLatestRevisionByFormId;
|
|
12195
|
+
exports2.selectLatestRevisionsFromComponentTypeIds = selectLatestRevisionsFromComponentTypeIds;
|
|
12031
12196
|
exports2.selectMainWorkspace = selectMainWorkspace;
|
|
12032
12197
|
exports2.selectMapStyle = selectMapStyle;
|
|
12033
12198
|
exports2.selectNumberOfComponentTypesMatchingCaseInsensitiveName = selectNumberOfComponentTypesMatchingCaseInsensitiveName;
|
|
12034
12199
|
exports2.selectNumberOfComponentsOfComponentType = selectNumberOfComponentsOfComponentType;
|
|
12200
|
+
exports2.selectNumberOfGeneralUserForms = selectNumberOfGeneralUserForms;
|
|
12035
12201
|
exports2.selectNumberOfUserForms = selectNumberOfUserForms;
|
|
12036
12202
|
exports2.selectOrganization = selectOrganization;
|
|
12037
12203
|
exports2.selectOrganizationAccess = selectOrganizationAccess;
|
|
@@ -12065,6 +12231,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12065
12231
|
exports2.selectSortedOrganizationUsers = selectSortedOrganizationUsers;
|
|
12066
12232
|
exports2.selectSortedProjectUsers = selectSortedProjectUsers;
|
|
12067
12233
|
exports2.selectSortedProjects = selectSortedProjects;
|
|
12234
|
+
exports2.selectStageFormIdsFromStageIds = selectStageFormIdsFromStageIds;
|
|
12068
12235
|
exports2.selectStageMapping = selectStageMapping;
|
|
12069
12236
|
exports2.selectStages = selectStages;
|
|
12070
12237
|
exports2.selectStagesFromComponentType = selectStagesFromComponentType;
|
|
@@ -12140,11 +12307,13 @@ var __publicField = (obj, key, value) => {
|
|
|
12140
12307
|
exports2.unfavoriteForm = unfavoriteForm;
|
|
12141
12308
|
exports2.unhideAllCategories = unhideAllCategories;
|
|
12142
12309
|
exports2.unhideCategory = unhideCategory;
|
|
12310
|
+
exports2.unlinkStageToForm = unlinkStageToForm;
|
|
12143
12311
|
exports2.updateActiveOrganization = updateActiveOrganization;
|
|
12144
12312
|
exports2.updateAttachment = updateAttachment;
|
|
12145
12313
|
exports2.updateComponent = updateComponent;
|
|
12146
12314
|
exports2.updateIssue = updateIssue;
|
|
12147
12315
|
exports2.updateOrCreateProject = updateOrCreateProject;
|
|
12316
|
+
exports2.updateOrCreateUserFormSubmission = updateOrCreateUserFormSubmission;
|
|
12148
12317
|
exports2.updateOrganizationAccess = updateOrganizationAccess;
|
|
12149
12318
|
exports2.updateProjectAccess = updateProjectAccess;
|
|
12150
12319
|
exports2.updateStages = updateStages;
|