@overmap-ai/core 1.0.60-forms-refactor-1.0 → 1.0.60-forms-refactor-1.1
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 +38 -40
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +38 -40
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/services/FormService.d.ts +2 -2
- package/dist/store/slices/formRevisionAttachmentSlice.d.ts +1 -1
- package/dist/store/slices/formSlice.d.ts +2 -2
- package/dist/typings/models/forms.d.ts +2 -2
- package/dist/typings/models/issues.d.ts +2 -2
- package/package.json +1 -1
|
@@ -2345,11 +2345,11 @@ var __publicField = (obj, key, value) => {
|
|
|
2345
2345
|
selectFormRevisionMapping,
|
|
2346
2346
|
(_state, assetTypeIds) => assetTypeIds
|
|
2347
2347
|
],
|
|
2348
|
-
(
|
|
2348
|
+
(formsMapping, revisions, assetTypeIds) => {
|
|
2349
2349
|
const assetTypeIdsSet = new Set(assetTypeIds);
|
|
2350
2350
|
const formsOfAssetTypes = {};
|
|
2351
2351
|
const ret = {};
|
|
2352
|
-
for (const form of Object.values(
|
|
2352
|
+
for (const form of Object.values(formsMapping)) {
|
|
2353
2353
|
if (form.asset_type && assetTypeIdsSet.has(form.asset_type)) {
|
|
2354
2354
|
formsOfAssetTypes[form.offline_id] = form;
|
|
2355
2355
|
}
|
|
@@ -2402,22 +2402,22 @@ var __publicField = (obj, key, value) => {
|
|
|
2402
2402
|
(state) => state.formRevisionReducer.instances,
|
|
2403
2403
|
(_state, search) => search
|
|
2404
2404
|
],
|
|
2405
|
-
(
|
|
2405
|
+
(formsMapping, revisions, search) => {
|
|
2406
2406
|
const { searchTerm, maxResults, favorites, organization } = search;
|
|
2407
2407
|
const favoriteMatches = [];
|
|
2408
2408
|
const regularMatches = [];
|
|
2409
|
-
for (const [
|
|
2410
|
-
if (favorites !== void 0 &&
|
|
2409
|
+
for (const [formId, form] of Object.entries(formsMapping)) {
|
|
2410
|
+
if (favorites !== void 0 && form.favorite != favorites)
|
|
2411
2411
|
continue;
|
|
2412
|
-
if (Number.isInteger(organization) && organization !==
|
|
2412
|
+
if (Number.isInteger(organization) && organization !== form.organization) {
|
|
2413
2413
|
continue;
|
|
2414
2414
|
}
|
|
2415
|
-
const latestRevision = _selectLatestFormRevision(revisions,
|
|
2415
|
+
const latestRevision = _selectLatestFormRevision(revisions, formId);
|
|
2416
2416
|
if (latestRevision.title.toLowerCase().includes(searchTerm.toLowerCase())) {
|
|
2417
|
-
if (
|
|
2418
|
-
favoriteMatches.push({ ...
|
|
2417
|
+
if (form.favorite) {
|
|
2418
|
+
favoriteMatches.push({ ...form, latestRevision });
|
|
2419
2419
|
} else {
|
|
2420
|
-
regularMatches.push({ ...
|
|
2420
|
+
regularMatches.push({ ...form, latestRevision });
|
|
2421
2421
|
}
|
|
2422
2422
|
}
|
|
2423
2423
|
if (favoriteMatches.length >= maxResults) {
|
|
@@ -2431,35 +2431,33 @@ var __publicField = (obj, key, value) => {
|
|
|
2431
2431
|
{ memoizeOptions: { equalityCheck: shallowEqual } }
|
|
2432
2432
|
)
|
|
2433
2433
|
);
|
|
2434
|
-
const selectForm =
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
})
|
|
2438
|
-
);
|
|
2434
|
+
const selectForm = (formId) => (state) => {
|
|
2435
|
+
return state.formReducer.instances[formId];
|
|
2436
|
+
};
|
|
2439
2437
|
const selectFormMapping = (state) => {
|
|
2440
2438
|
return state.formReducer.instances;
|
|
2441
2439
|
};
|
|
2442
2440
|
const selectFormOfAssetType = restructureCreateSelectorWithArgs(
|
|
2443
2441
|
toolkit.createSelector(
|
|
2444
2442
|
[selectFormMapping, (_state, assetTypeId) => assetTypeId],
|
|
2445
|
-
(
|
|
2446
|
-
return Object.values(
|
|
2443
|
+
(formsMapping, assetTypeId) => {
|
|
2444
|
+
return Object.values(formsMapping).find((form) => form.asset_type === assetTypeId);
|
|
2447
2445
|
}
|
|
2448
2446
|
)
|
|
2449
2447
|
);
|
|
2450
2448
|
const selectFormOfIssueType = restructureCreateSelectorWithArgs(
|
|
2451
2449
|
toolkit.createSelector(
|
|
2452
2450
|
[selectFormMapping, (_state, issueTypeId) => issueTypeId],
|
|
2453
|
-
(
|
|
2454
|
-
return Object.values(
|
|
2451
|
+
(formsMapping, issueTypeId) => {
|
|
2452
|
+
return Object.values(formsMapping).find((form) => form.issue_type === issueTypeId);
|
|
2455
2453
|
}
|
|
2456
2454
|
)
|
|
2457
2455
|
);
|
|
2458
|
-
const selectFormsCount = toolkit.createSelector([selectFormMapping], (
|
|
2459
|
-
return Object.keys(
|
|
2456
|
+
const selectFormsCount = toolkit.createSelector([selectFormMapping], (formsMapping) => {
|
|
2457
|
+
return Object.keys(formsMapping).length;
|
|
2460
2458
|
});
|
|
2461
|
-
const selectGeneralFormCount = toolkit.createSelector([selectFormMapping], (
|
|
2462
|
-
return Object.values(
|
|
2459
|
+
const selectGeneralFormCount = toolkit.createSelector([selectFormMapping], (formsMapping) => {
|
|
2460
|
+
return Object.values(formsMapping).filter((form) => !form.asset_type).length;
|
|
2463
2461
|
});
|
|
2464
2462
|
const formReducer = formSlice.reducer;
|
|
2465
2463
|
const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
|
|
@@ -2679,12 +2677,12 @@ var __publicField = (obj, key, value) => {
|
|
|
2679
2677
|
deleteFormRevisionAttachment,
|
|
2680
2678
|
deleteFormRevisionAttachments
|
|
2681
2679
|
} = formRevisionAttachmentSlice.actions;
|
|
2682
|
-
const
|
|
2680
|
+
const selectFormRevisionAttachmentsMapping = (state) => {
|
|
2683
2681
|
return state.formRevisionAttachmentReducer.instances;
|
|
2684
2682
|
};
|
|
2685
2683
|
const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
|
|
2686
2684
|
toolkit.createSelector(
|
|
2687
|
-
[
|
|
2685
|
+
[selectFormRevisionAttachmentsMapping, (_state, revisionId) => revisionId],
|
|
2688
2686
|
(attachments, revisionId) => {
|
|
2689
2687
|
return Object.values(attachments).filter((attachment) => attachment.revision === revisionId);
|
|
2690
2688
|
}
|
|
@@ -5619,17 +5617,17 @@ var __publicField = (obj, key, value) => {
|
|
|
5619
5617
|
async delete(formId) {
|
|
5620
5618
|
const { store } = this.client;
|
|
5621
5619
|
const state = store.getState();
|
|
5622
|
-
const
|
|
5623
|
-
if (!
|
|
5624
|
-
throw new Error("Expected
|
|
5620
|
+
const form = selectForm(formId)(state);
|
|
5621
|
+
if (!form) {
|
|
5622
|
+
throw new Error("Expected form to exist");
|
|
5625
5623
|
}
|
|
5626
|
-
const
|
|
5627
|
-
if (
|
|
5628
|
-
this.dispatch(deleteFormSubmissions(
|
|
5624
|
+
const formSubmissions = selectFormSubmissionsOfForm(formId)(state);
|
|
5625
|
+
if (formSubmissions && formSubmissions.length > 0) {
|
|
5626
|
+
this.dispatch(deleteFormSubmissions(formSubmissions.map(({ offline_id }) => offline_id)));
|
|
5629
5627
|
}
|
|
5630
|
-
const
|
|
5631
|
-
if (
|
|
5632
|
-
this.dispatch(deleteFormRevisions(
|
|
5628
|
+
const formRevisions = selectFormRevisionsOfForm(formId)(state);
|
|
5629
|
+
if (formRevisions && formRevisions.length > 0) {
|
|
5630
|
+
this.dispatch(deleteFormRevisions(formRevisions.map(({ offline_id }) => offline_id)));
|
|
5633
5631
|
}
|
|
5634
5632
|
this.dispatch(deleteForm(formId));
|
|
5635
5633
|
try {
|
|
@@ -5641,12 +5639,12 @@ var __publicField = (obj, key, value) => {
|
|
|
5641
5639
|
blocks: []
|
|
5642
5640
|
});
|
|
5643
5641
|
} catch (e) {
|
|
5644
|
-
this.dispatch(addForm(
|
|
5645
|
-
if (
|
|
5646
|
-
this.dispatch(addFormRevisions(
|
|
5642
|
+
this.dispatch(addForm(form));
|
|
5643
|
+
if (formRevisions && formRevisions.length > 0) {
|
|
5644
|
+
this.dispatch(addFormRevisions(formRevisions));
|
|
5647
5645
|
}
|
|
5648
|
-
if (
|
|
5649
|
-
this.dispatch(addFormSubmissions(
|
|
5646
|
+
if (formSubmissions && formSubmissions.length > 0) {
|
|
5647
|
+
this.dispatch(addFormSubmissions(formSubmissions));
|
|
5650
5648
|
}
|
|
5651
5649
|
throw e;
|
|
5652
5650
|
}
|
|
@@ -7490,6 +7488,7 @@ var __publicField = (obj, key, value) => {
|
|
|
7490
7488
|
exports2.selectFormOfAssetType = selectFormOfAssetType;
|
|
7491
7489
|
exports2.selectFormOfIssueType = selectFormOfIssueType;
|
|
7492
7490
|
exports2.selectFormRevision = selectFormRevision;
|
|
7491
|
+
exports2.selectFormRevisionAttachmentsMapping = selectFormRevisionAttachmentsMapping;
|
|
7493
7492
|
exports2.selectFormRevisionMapping = selectFormRevisionMapping;
|
|
7494
7493
|
exports2.selectFormRevisions = selectFormRevisions;
|
|
7495
7494
|
exports2.selectFormRevisionsOfForm = selectFormRevisionsOfForm;
|
|
@@ -7589,7 +7588,6 @@ var __publicField = (obj, key, value) => {
|
|
|
7589
7588
|
exports2.selectTeamsOfUser = selectTeamsOfUser;
|
|
7590
7589
|
exports2.selectUploadUrl = selectUploadUrl;
|
|
7591
7590
|
exports2.selectUser = selectUser;
|
|
7592
|
-
exports2.selectUserFormRevisionAttachmentsMapping = selectUserFormRevisionAttachmentsMapping;
|
|
7593
7591
|
exports2.selectUsersAsMapping = selectUsersAsMapping;
|
|
7594
7592
|
exports2.selectWorkspaceById = selectWorkspaceById;
|
|
7595
7593
|
exports2.selectWorkspaceMapping = selectWorkspaceMapping;
|