@overmap-ai/core 1.0.38-component-fields.8 → 1.0.38-component-fields.10
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/FieldsEditor.d.ts +5 -1
- package/dist/forms/builder/FormBuilder.d.ts +10 -2
- package/dist/overmap-core.js +70 -19
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +70 -19
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/services/UserFormService.d.ts +2 -2
- package/dist/store/slices/userFormSlice.d.ts +5 -0
- package/dist/typings/models/forms.d.ts +1 -0
- package/package.json +1 -1
|
@@ -3287,6 +3287,24 @@ var __publicField = (obj, key, value) => {
|
|
|
3287
3287
|
}
|
|
3288
3288
|
)
|
|
3289
3289
|
);
|
|
3290
|
+
const selectLatestRevisionsForComponentStageForms = restructureCreateSelectorWithArgs(
|
|
3291
|
+
toolkit.createSelector(
|
|
3292
|
+
[
|
|
3293
|
+
selectUserFormMapping,
|
|
3294
|
+
selectRevisionMapping,
|
|
3295
|
+
(_state, componentStageId) => componentStageId
|
|
3296
|
+
],
|
|
3297
|
+
(userForms, revisions, componentStageId) => {
|
|
3298
|
+
const latestRevisions = [];
|
|
3299
|
+
for (const form of Object.values(userForms)) {
|
|
3300
|
+
if (form.component_stage === componentStageId) {
|
|
3301
|
+
latestRevisions.push(_selectLatestFormRevision(revisions, form.offline_id));
|
|
3302
|
+
}
|
|
3303
|
+
}
|
|
3304
|
+
return latestRevisions;
|
|
3305
|
+
}
|
|
3306
|
+
)
|
|
3307
|
+
);
|
|
3290
3308
|
const selectLatestRevisionByFormId = toolkit.createSelector([selectRevisionMapping], (revisions) => {
|
|
3291
3309
|
const latestRevisions = {};
|
|
3292
3310
|
for (const revision of Object.values(revisions)) {
|
|
@@ -5464,10 +5482,13 @@ var __publicField = (obj, key, value) => {
|
|
|
5464
5482
|
});
|
|
5465
5483
|
});
|
|
5466
5484
|
}
|
|
5467
|
-
async add(state, initialRevision, url, ownerUser, ownerOrganization,
|
|
5485
|
+
async add(state, initialRevision, url, ownerUser, ownerOrganization, componentTypeId, componentStageId) {
|
|
5468
5486
|
if (!!ownerUser === !!ownerOrganization) {
|
|
5469
5487
|
throw new Error("Exactly one of ownerUser and ownerOrganization must be defined.");
|
|
5470
5488
|
}
|
|
5489
|
+
if (componentTypeId && componentStageId) {
|
|
5490
|
+
throw new Error("At most one of componentTypeId and componentStageId should be defined.");
|
|
5491
|
+
}
|
|
5471
5492
|
const ownerAttrs = {
|
|
5472
5493
|
owner_user: ownerUser,
|
|
5473
5494
|
owner_organization: ownerOrganization
|
|
@@ -5482,7 +5503,8 @@ var __publicField = (obj, key, value) => {
|
|
|
5482
5503
|
favorite: true,
|
|
5483
5504
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5484
5505
|
created_by: currentUser.id,
|
|
5485
|
-
...
|
|
5506
|
+
...componentTypeId && { component_type: componentTypeId },
|
|
5507
|
+
...componentStageId && { component_stage: componentStageId },
|
|
5486
5508
|
...ownerAttrs
|
|
5487
5509
|
};
|
|
5488
5510
|
const { payloadWithoutImage, images } = await separateImageFromFields(offlineRevisionPayload);
|
|
@@ -5504,10 +5526,11 @@ var __publicField = (obj, key, value) => {
|
|
|
5504
5526
|
} : void 0,
|
|
5505
5527
|
payload: {
|
|
5506
5528
|
...offlineFormPayload,
|
|
5507
|
-
...
|
|
5529
|
+
...componentTypeId && { component_type: componentTypeId },
|
|
5530
|
+
...componentStageId && { component_stage: componentStageId },
|
|
5508
5531
|
initial_revision: payloadWithoutImage
|
|
5509
5532
|
},
|
|
5510
|
-
blockers: [],
|
|
5533
|
+
blockers: [componentTypeId, componentStageId].filter((x) => x !== void 0),
|
|
5511
5534
|
blocks: [offlineFormPayload.offline_id, payloadWithoutImage.offline_id]
|
|
5512
5535
|
});
|
|
5513
5536
|
const attachImagesPromises = this.getAttachImagePromises(images, offlineRevisionPayload.offline_id);
|
|
@@ -5519,7 +5542,7 @@ var __publicField = (obj, key, value) => {
|
|
|
5519
5542
|
const settledPromise = Promise.all([formPromise, ...attachImagesPromises]).then(() => formPromise);
|
|
5520
5543
|
return [retForm, retRevision, formPromise, settledPromise];
|
|
5521
5544
|
}
|
|
5522
|
-
async addForOrganization(initialRevision,
|
|
5545
|
+
async addForOrganization(initialRevision, componentTypeId, componentStageId) {
|
|
5523
5546
|
const state = this.client.store.getState();
|
|
5524
5547
|
const activeOrganizationId = state.organizationReducer.activeOrganizationId;
|
|
5525
5548
|
if (!activeOrganizationId) {
|
|
@@ -5531,13 +5554,22 @@ var __publicField = (obj, key, value) => {
|
|
|
5531
5554
|
`/forms/in-organization/${activeOrganizationId}/`,
|
|
5532
5555
|
void 0,
|
|
5533
5556
|
activeOrganizationId,
|
|
5534
|
-
|
|
5557
|
+
componentTypeId,
|
|
5558
|
+
componentStageId
|
|
5535
5559
|
);
|
|
5536
5560
|
}
|
|
5537
|
-
async addForCurrentUser(initialRevision,
|
|
5561
|
+
async addForCurrentUser(initialRevision, componentTypeId, componentStageId) {
|
|
5538
5562
|
const state = this.client.store.getState();
|
|
5539
5563
|
const currentUser = state.userReducer.currentUser;
|
|
5540
|
-
return await this.add(
|
|
5564
|
+
return await this.add(
|
|
5565
|
+
state,
|
|
5566
|
+
initialRevision,
|
|
5567
|
+
"/forms/my-forms/",
|
|
5568
|
+
currentUser.id,
|
|
5569
|
+
void 0,
|
|
5570
|
+
componentTypeId,
|
|
5571
|
+
componentStageId
|
|
5572
|
+
);
|
|
5541
5573
|
}
|
|
5542
5574
|
async createRevision(formId2, revision) {
|
|
5543
5575
|
const offlineRevision = offline(revision);
|
|
@@ -11233,7 +11265,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11233
11265
|
FieldWithActions.displayName = "FieldWithActions";
|
|
11234
11266
|
const FieldSectionWithActions = React.memo((props) => {
|
|
11235
11267
|
var _a2;
|
|
11236
|
-
const { field, index: sectionIndex, dropState } = props;
|
|
11268
|
+
const { field, index: sectionIndex, dropState, fieldsOnly } = props;
|
|
11237
11269
|
const isDropDisabled = (_a2 = dropState[field.identifier]) == null ? void 0 : _a2.disabled;
|
|
11238
11270
|
const { setFieldValue, values } = formik.useFormikContext();
|
|
11239
11271
|
const alertDialog = blocks.useAlertDialog();
|
|
@@ -11373,7 +11405,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11373
11405
|
mb: "4",
|
|
11374
11406
|
children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { gap: "3", justify: "between", align: "center", children: [
|
|
11375
11407
|
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", grow: "1", children: [
|
|
11376
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldBuilder, { ...editSectionProps }),
|
|
11408
|
+
!fieldsOnly && /* @__PURE__ */ jsxRuntime.jsx(FieldBuilder, { ...editSectionProps }),
|
|
11377
11409
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11378
11410
|
dnd.Droppable,
|
|
11379
11411
|
{
|
|
@@ -11417,7 +11449,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11417
11449
|
}
|
|
11418
11450
|
)
|
|
11419
11451
|
] }),
|
|
11420
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11452
|
+
!fieldsOnly && /* @__PURE__ */ jsxRuntime.jsx(
|
|
11421
11453
|
FieldActions,
|
|
11422
11454
|
{
|
|
11423
11455
|
index: sectionIndex,
|
|
@@ -11494,7 +11526,8 @@ var __publicField = (obj, key, value) => {
|
|
|
11494
11526
|
return [section, i];
|
|
11495
11527
|
}
|
|
11496
11528
|
};
|
|
11497
|
-
const FieldsEditor = React.memo(() => {
|
|
11529
|
+
const FieldsEditor = React.memo((props) => {
|
|
11530
|
+
const { fieldsOnly } = props;
|
|
11498
11531
|
const { values, setFieldValue } = formik.useFormikContext();
|
|
11499
11532
|
const [dropState, dispatch] = React.useReducer(reducer, values.fields, initializer);
|
|
11500
11533
|
const { reorderSection, reorderField } = useFieldReordering();
|
|
@@ -11547,8 +11580,16 @@ var __publicField = (obj, key, value) => {
|
|
|
11547
11580
|
gap: "0",
|
|
11548
11581
|
children: [
|
|
11549
11582
|
values.fields.map((field, index2) => /* @__PURE__ */ jsxRuntime.jsxs(React.Fragment, { children: [
|
|
11550
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11551
|
-
|
|
11583
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11584
|
+
FieldSectionWithActions,
|
|
11585
|
+
{
|
|
11586
|
+
field,
|
|
11587
|
+
index: index2,
|
|
11588
|
+
dropState,
|
|
11589
|
+
fieldsOnly
|
|
11590
|
+
}
|
|
11591
|
+
),
|
|
11592
|
+
!fieldsOnly && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
11552
11593
|
blocks.Button,
|
|
11553
11594
|
{
|
|
11554
11595
|
className: styles$1.addSectionButton,
|
|
@@ -11576,7 +11617,16 @@ var __publicField = (obj, key, value) => {
|
|
|
11576
11617
|
};
|
|
11577
11618
|
const FormBuilder = React.memo(
|
|
11578
11619
|
React.forwardRef((props, ref) => {
|
|
11579
|
-
const {
|
|
11620
|
+
const {
|
|
11621
|
+
onCancel,
|
|
11622
|
+
onSave,
|
|
11623
|
+
revision,
|
|
11624
|
+
initialTitle,
|
|
11625
|
+
showExplainerText = true,
|
|
11626
|
+
showFormTitle = true,
|
|
11627
|
+
fieldsOnly = false,
|
|
11628
|
+
showTabs = true
|
|
11629
|
+
} = props;
|
|
11580
11630
|
const { showError } = blocks.useToast();
|
|
11581
11631
|
const validate = React.useCallback(
|
|
11582
11632
|
(form) => {
|
|
@@ -11639,7 +11689,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11639
11689
|
});
|
|
11640
11690
|
const previewSchema = React.useMemo(() => formRevisionToSchema(formik$1.values), [formik$1.values]);
|
|
11641
11691
|
return /* @__PURE__ */ jsxRuntime.jsx(Tabs.Root, { ref, defaultValue: "edit", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { direction: "column", gap: "2", children: [
|
|
11642
|
-
/* @__PURE__ */ jsxRuntime.jsxs(Tabs.List, { className: styles$7.tabsList, children: [
|
|
11692
|
+
showTabs && /* @__PURE__ */ jsxRuntime.jsxs(Tabs.List, { className: styles$7.tabsList, children: [
|
|
11643
11693
|
/* @__PURE__ */ jsxRuntime.jsx(Tabs.Trigger, { className: styles$7.tabTrigger, value: "edit", children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
|
|
11644
11694
|
/* @__PURE__ */ jsxRuntime.jsx(Pencil1Icon, {}),
|
|
11645
11695
|
"Edit"
|
|
@@ -11660,7 +11710,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11660
11710
|
] }),
|
|
11661
11711
|
/* @__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: [
|
|
11662
11712
|
/* @__PURE__ */ jsxRuntime.jsxs(formik.FormikProvider, { value: formik$1, children: [
|
|
11663
|
-
|
|
11713
|
+
showFormTitle && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
11664
11714
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
11665
11715
|
PatchField,
|
|
11666
11716
|
{
|
|
@@ -11706,7 +11756,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11706
11756
|
}
|
|
11707
11757
|
)
|
|
11708
11758
|
] }),
|
|
11709
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldsEditor, {}),
|
|
11759
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldsEditor, { fieldsOnly }),
|
|
11710
11760
|
/* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { severity: "danger", size: "1", children: typeof formik$1.errors.fields === "string" && formik$1.errors.fields })
|
|
11711
11761
|
] }),
|
|
11712
11762
|
/* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { className: styles$7.floatingButtonContainer, align: "center", justify: "end", gap: "2", children: [
|
|
@@ -11715,7 +11765,7 @@ var __publicField = (obj, key, value) => {
|
|
|
11715
11765
|
] })
|
|
11716
11766
|
] }) })
|
|
11717
11767
|
] }),
|
|
11718
|
-
/* @__PURE__ */ jsxRuntime.jsx(Tabs.Content, { value: "preview", children: /* @__PURE__ */ jsxRuntime.jsx(FormRenderer, { schema: previewSchema, onSubmit: previewSubmit, hideTitle:
|
|
11768
|
+
/* @__PURE__ */ jsxRuntime.jsx(Tabs.Content, { value: "preview", children: /* @__PURE__ */ jsxRuntime.jsx(FormRenderer, { schema: previewSchema, onSubmit: previewSubmit, hideTitle: !showFormTitle }) })
|
|
11719
11769
|
] }) });
|
|
11720
11770
|
})
|
|
11721
11771
|
);
|
|
@@ -12079,6 +12129,7 @@ var __publicField = (obj, key, value) => {
|
|
|
12079
12129
|
exports2.selectLatestFormRevision = selectLatestFormRevision;
|
|
12080
12130
|
exports2.selectLatestRetryTime = selectLatestRetryTime;
|
|
12081
12131
|
exports2.selectLatestRevisionByFormId = selectLatestRevisionByFormId;
|
|
12132
|
+
exports2.selectLatestRevisionsForComponentStageForms = selectLatestRevisionsForComponentStageForms;
|
|
12082
12133
|
exports2.selectLatestRevisionsForComponentTypeForms = selectLatestRevisionsForComponentTypeForms;
|
|
12083
12134
|
exports2.selectLatestRevisionsFromComponentTypeIds = selectLatestRevisionsFromComponentTypeIds;
|
|
12084
12135
|
exports2.selectMainWorkspace = selectMainWorkspace;
|