@overmap-ai/core 1.0.38-component-fields.9 → 1.0.38-component-fields.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/overmap-core.js +53 -37
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +53 -37
- 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 +6 -2
- package/dist/typings/models/forms.d.ts +1 -0
- package/package.json +1 -1
package/dist/overmap-core.js
CHANGED
|
@@ -3241,31 +3241,11 @@ const selectSubmissionsForComponent = restructureCreateSelectorWithArgs(
|
|
|
3241
3241
|
const selectUserFormMapping = (state) => {
|
|
3242
3242
|
return state.userFormReducer.userForms;
|
|
3243
3243
|
};
|
|
3244
|
-
const
|
|
3244
|
+
const selectComponentTypeForm = restructureCreateSelectorWithArgs(
|
|
3245
3245
|
createSelector(
|
|
3246
3246
|
[selectUserFormMapping, (_state, componentTypeId) => componentTypeId],
|
|
3247
3247
|
(userForms, componentTypeId) => {
|
|
3248
|
-
return Object.values(userForms).
|
|
3249
|
-
return userForm.component_type === componentTypeId;
|
|
3250
|
-
});
|
|
3251
|
-
}
|
|
3252
|
-
)
|
|
3253
|
-
);
|
|
3254
|
-
const selectLatestRevisionsForComponentTypeForms = restructureCreateSelectorWithArgs(
|
|
3255
|
-
createSelector(
|
|
3256
|
-
[
|
|
3257
|
-
selectUserFormMapping,
|
|
3258
|
-
selectRevisionMapping,
|
|
3259
|
-
(_state, componentTypeId) => componentTypeId
|
|
3260
|
-
],
|
|
3261
|
-
(userForms, revisions, componentTypeId) => {
|
|
3262
|
-
const latestRevisions = [];
|
|
3263
|
-
for (const form of Object.values(userForms)) {
|
|
3264
|
-
if (form.component_type === componentTypeId) {
|
|
3265
|
-
latestRevisions.push(_selectLatestFormRevision(revisions, form.offline_id));
|
|
3266
|
-
}
|
|
3267
|
-
}
|
|
3268
|
-
return latestRevisions;
|
|
3248
|
+
return Object.values(userForms).find((userForm) => userForm.component_type === componentTypeId);
|
|
3269
3249
|
}
|
|
3270
3250
|
)
|
|
3271
3251
|
);
|
|
@@ -3291,6 +3271,24 @@ const selectLatestRevisionsFromComponentTypeIds = restructureCreateSelectorWithA
|
|
|
3291
3271
|
}
|
|
3292
3272
|
)
|
|
3293
3273
|
);
|
|
3274
|
+
const selectLatestRevisionsForComponentStageForms = restructureCreateSelectorWithArgs(
|
|
3275
|
+
createSelector(
|
|
3276
|
+
[
|
|
3277
|
+
selectUserFormMapping,
|
|
3278
|
+
selectRevisionMapping,
|
|
3279
|
+
(_state, componentStageId) => componentStageId
|
|
3280
|
+
],
|
|
3281
|
+
(userForms, revisions, componentStageId) => {
|
|
3282
|
+
const latestRevisions = [];
|
|
3283
|
+
for (const form of Object.values(userForms)) {
|
|
3284
|
+
if (form.component_stage === componentStageId) {
|
|
3285
|
+
latestRevisions.push(_selectLatestFormRevision(revisions, form.offline_id));
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
return latestRevisions;
|
|
3289
|
+
}
|
|
3290
|
+
)
|
|
3291
|
+
);
|
|
3294
3292
|
const selectLatestRevisionByFormId = createSelector([selectRevisionMapping], (revisions) => {
|
|
3295
3293
|
const latestRevisions = {};
|
|
3296
3294
|
for (const revision of Object.values(revisions)) {
|
|
@@ -5468,10 +5466,13 @@ class UserFormService extends BaseApiService {
|
|
|
5468
5466
|
});
|
|
5469
5467
|
});
|
|
5470
5468
|
}
|
|
5471
|
-
async add(state, initialRevision, url, ownerUser, ownerOrganization,
|
|
5469
|
+
async add(state, initialRevision, url, ownerUser, ownerOrganization, componentTypeId, componentStageId) {
|
|
5472
5470
|
if (!!ownerUser === !!ownerOrganization) {
|
|
5473
5471
|
throw new Error("Exactly one of ownerUser and ownerOrganization must be defined.");
|
|
5474
5472
|
}
|
|
5473
|
+
if (componentTypeId && componentStageId) {
|
|
5474
|
+
throw new Error("At most one of componentTypeId and componentStageId should be defined.");
|
|
5475
|
+
}
|
|
5475
5476
|
const ownerAttrs = {
|
|
5476
5477
|
owner_user: ownerUser,
|
|
5477
5478
|
owner_organization: ownerOrganization
|
|
@@ -5486,7 +5487,8 @@ class UserFormService extends BaseApiService {
|
|
|
5486
5487
|
favorite: true,
|
|
5487
5488
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5488
5489
|
created_by: currentUser.id,
|
|
5489
|
-
...
|
|
5490
|
+
...componentTypeId && { component_type: componentTypeId },
|
|
5491
|
+
...componentStageId && { component_stage: componentStageId },
|
|
5490
5492
|
...ownerAttrs
|
|
5491
5493
|
};
|
|
5492
5494
|
const { payloadWithoutImage, images } = await separateImageFromFields(offlineRevisionPayload);
|
|
@@ -5508,10 +5510,11 @@ class UserFormService extends BaseApiService {
|
|
|
5508
5510
|
} : void 0,
|
|
5509
5511
|
payload: {
|
|
5510
5512
|
...offlineFormPayload,
|
|
5511
|
-
...
|
|
5513
|
+
...componentTypeId && { component_type: componentTypeId },
|
|
5514
|
+
...componentStageId && { component_stage: componentStageId },
|
|
5512
5515
|
initial_revision: payloadWithoutImage
|
|
5513
5516
|
},
|
|
5514
|
-
blockers: [],
|
|
5517
|
+
blockers: [componentTypeId, componentStageId].filter((x) => x !== void 0),
|
|
5515
5518
|
blocks: [offlineFormPayload.offline_id, payloadWithoutImage.offline_id]
|
|
5516
5519
|
});
|
|
5517
5520
|
const attachImagesPromises = this.getAttachImagePromises(images, offlineRevisionPayload.offline_id);
|
|
@@ -5523,7 +5526,7 @@ class UserFormService extends BaseApiService {
|
|
|
5523
5526
|
const settledPromise = Promise.all([formPromise, ...attachImagesPromises]).then(() => formPromise);
|
|
5524
5527
|
return [retForm, retRevision, formPromise, settledPromise];
|
|
5525
5528
|
}
|
|
5526
|
-
async addForOrganization(initialRevision,
|
|
5529
|
+
async addForOrganization(initialRevision, componentTypeId, componentStageId) {
|
|
5527
5530
|
const state = this.client.store.getState();
|
|
5528
5531
|
const activeOrganizationId = state.organizationReducer.activeOrganizationId;
|
|
5529
5532
|
if (!activeOrganizationId) {
|
|
@@ -5535,13 +5538,22 @@ class UserFormService extends BaseApiService {
|
|
|
5535
5538
|
`/forms/in-organization/${activeOrganizationId}/`,
|
|
5536
5539
|
void 0,
|
|
5537
5540
|
activeOrganizationId,
|
|
5538
|
-
|
|
5541
|
+
componentTypeId,
|
|
5542
|
+
componentStageId
|
|
5539
5543
|
);
|
|
5540
5544
|
}
|
|
5541
|
-
async addForCurrentUser(initialRevision,
|
|
5545
|
+
async addForCurrentUser(initialRevision, componentTypeId, componentStageId) {
|
|
5542
5546
|
const state = this.client.store.getState();
|
|
5543
5547
|
const currentUser = state.userReducer.currentUser;
|
|
5544
|
-
return await this.add(
|
|
5548
|
+
return await this.add(
|
|
5549
|
+
state,
|
|
5550
|
+
initialRevision,
|
|
5551
|
+
"/forms/my-forms/",
|
|
5552
|
+
currentUser.id,
|
|
5553
|
+
void 0,
|
|
5554
|
+
componentTypeId,
|
|
5555
|
+
componentStageId
|
|
5556
|
+
);
|
|
5545
5557
|
}
|
|
5546
5558
|
async createRevision(formId2, revision) {
|
|
5547
5559
|
const offlineRevision = offline(revision);
|
|
@@ -10389,6 +10401,10 @@ const FormBrowser = memo(
|
|
|
10389
10401
|
}, [filter, maxResults, ownerFilter]);
|
|
10390
10402
|
const userForms = useAppSelector(selectFilteredUserForms(ownerFilterOptions)) ?? [];
|
|
10391
10403
|
const userFormMapping = useAppSelector(selectUserFormMapping);
|
|
10404
|
+
const attachableUserForms = userForms.filter((form) => !form.component_type && !form.component_stage);
|
|
10405
|
+
const attachableUserFormMapping = Object.values(userFormMapping).filter(
|
|
10406
|
+
(form) => !form.component_type && !form.component_stage
|
|
10407
|
+
);
|
|
10392
10408
|
const handleToggleFavorite = useCallback(
|
|
10393
10409
|
(form) => {
|
|
10394
10410
|
if (form.favorite) {
|
|
@@ -10402,7 +10418,7 @@ const FormBrowser = memo(
|
|
|
10402
10418
|
const options = useMemo(() => {
|
|
10403
10419
|
const state = sdk.store.getState();
|
|
10404
10420
|
const accumulator = {};
|
|
10405
|
-
for (const form of
|
|
10421
|
+
for (const form of attachableUserFormMapping) {
|
|
10406
10422
|
const organization = selectOrganization(form.owner_organization || -1)(state);
|
|
10407
10423
|
if (organization) {
|
|
10408
10424
|
accumulator[`${orgOptionPrefix}${organization.id}`] = organization.name;
|
|
@@ -10413,13 +10429,13 @@ const FormBrowser = memo(
|
|
|
10413
10429
|
}
|
|
10414
10430
|
}
|
|
10415
10431
|
return Object.entries(accumulator).map(([value, label]) => ({ itemContent: label, value }));
|
|
10416
|
-
}, [
|
|
10432
|
+
}, [sdk.store, attachableUserFormMapping]);
|
|
10417
10433
|
const handleChange = useCallback((e) => {
|
|
10418
10434
|
setFilter(e.currentTarget.value);
|
|
10419
10435
|
}, []);
|
|
10420
10436
|
const numberOfForms = useAppSelector(selectNumberOfUserForms) || 0;
|
|
10421
|
-
const numberOfHiddenForms = numberOfForms -
|
|
10422
|
-
const overflowMessage =
|
|
10437
|
+
const numberOfHiddenForms = numberOfForms - attachableUserForms.length;
|
|
10438
|
+
const overflowMessage = attachableUserForms.length == maxResults && numberOfHiddenForms > 0 ? `Only the first ${maxResults} results are shown (${numberOfHiddenForms} hidden)` : numberOfHiddenForms > 0 && `${numberOfHiddenForms} hidden forms`;
|
|
10423
10439
|
return /* @__PURE__ */ jsxs(Flex, { ref, direction: "column", gap: "2", children: [
|
|
10424
10440
|
/* @__PURE__ */ jsxs(Flex, { gap: "2", grow: "1", children: [
|
|
10425
10441
|
/* @__PURE__ */ jsx(Box, { grow: "1", asChild: true, children: /* @__PURE__ */ jsx(TextField$1.Root, { size: "3", children: /* @__PURE__ */ jsx(TextField$1.Input, { placeholder: "Filter", value: filter, onChange: handleChange }) }) }),
|
|
@@ -10434,7 +10450,7 @@ const FormBrowser = memo(
|
|
|
10434
10450
|
}
|
|
10435
10451
|
)
|
|
10436
10452
|
] }),
|
|
10437
|
-
|
|
10453
|
+
attachableUserForms.length > 0 && /* @__PURE__ */ jsx(ButtonList.Root, { children: attachableUserForms.map((form) => /* @__PURE__ */ jsx(
|
|
10438
10454
|
FormBrowserEntry,
|
|
10439
10455
|
{
|
|
10440
10456
|
...entryProps,
|
|
@@ -12064,6 +12080,7 @@ export {
|
|
|
12064
12080
|
selectCompletedStages,
|
|
12065
12081
|
selectComponent,
|
|
12066
12082
|
selectComponentType,
|
|
12083
|
+
selectComponentTypeForm,
|
|
12067
12084
|
selectComponentTypeFromComponent,
|
|
12068
12085
|
selectComponentTypeFromComponents,
|
|
12069
12086
|
selectComponentTypes,
|
|
@@ -12088,7 +12105,6 @@ export {
|
|
|
12088
12105
|
selectFileAttachmentsOfIssue,
|
|
12089
12106
|
selectFilteredUserForms,
|
|
12090
12107
|
selectFormRevision,
|
|
12091
|
-
selectFormsForComponentType,
|
|
12092
12108
|
selectHiddenCategoryCount,
|
|
12093
12109
|
selectHiddenComponentTypeIds,
|
|
12094
12110
|
selectIsFetchingInitialData,
|
|
@@ -12102,7 +12118,7 @@ export {
|
|
|
12102
12118
|
selectLatestFormRevision,
|
|
12103
12119
|
selectLatestRetryTime,
|
|
12104
12120
|
selectLatestRevisionByFormId,
|
|
12105
|
-
|
|
12121
|
+
selectLatestRevisionsForComponentStageForms,
|
|
12106
12122
|
selectLatestRevisionsFromComponentTypeIds,
|
|
12107
12123
|
selectMainWorkspace,
|
|
12108
12124
|
selectMapStyle,
|