@overmap-ai/core 1.0.62-store-clear-fixes.1 → 1.0.62-store-clear-fixes.3
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
CHANGED
|
@@ -2583,6 +2583,34 @@ const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
|
|
|
2583
2583
|
}
|
|
2584
2584
|
)
|
|
2585
2585
|
);
|
|
2586
|
+
const selectAttachedFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
|
|
2587
|
+
createSelector(
|
|
2588
|
+
[
|
|
2589
|
+
(state) => state.issueReducer.instances,
|
|
2590
|
+
(state) => state.formReducer.instances,
|
|
2591
|
+
(state) => state.formRevisionReducer.instances,
|
|
2592
|
+
(state) => state.formSubmissionReducer.instances,
|
|
2593
|
+
(_state, issueId) => issueId
|
|
2594
|
+
],
|
|
2595
|
+
(issues, forms, formRevisions, submissions, issueId) => {
|
|
2596
|
+
const issue = issues[issueId];
|
|
2597
|
+
if (!issue || !issue.issue_type) {
|
|
2598
|
+
return [];
|
|
2599
|
+
}
|
|
2600
|
+
const issueTypeForms = new Set(
|
|
2601
|
+
Object.keys(forms).filter((formId) => forms[formId].issue_type === issue.issue_type)
|
|
2602
|
+
);
|
|
2603
|
+
const issueTypeFormRevisions = new Set(
|
|
2604
|
+
Object.keys(formRevisions).filter(
|
|
2605
|
+
(formRevisionId) => issueTypeForms.has(formRevisions[formRevisionId].form)
|
|
2606
|
+
)
|
|
2607
|
+
);
|
|
2608
|
+
return Object.values(submissions).filter(
|
|
2609
|
+
(submission) => !issueTypeFormRevisions.has(submission.form_revision)
|
|
2610
|
+
);
|
|
2611
|
+
}
|
|
2612
|
+
)
|
|
2613
|
+
);
|
|
2586
2614
|
const selectFormSubmissionsByIssues = restructureCreateSelectorWithArgs(
|
|
2587
2615
|
createSelector(
|
|
2588
2616
|
[selectFormSubmissions, (_state, issueIds) => issueIds],
|
|
@@ -2611,6 +2639,34 @@ const selectFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
|
|
|
2611
2639
|
}
|
|
2612
2640
|
)
|
|
2613
2641
|
);
|
|
2642
|
+
const selectAttachedFormSubmissionsOfAssets = restructureCreateSelectorWithArgs(
|
|
2643
|
+
createSelector(
|
|
2644
|
+
[
|
|
2645
|
+
(state) => state.assetReducer.instances,
|
|
2646
|
+
(state) => state.formReducer.instances,
|
|
2647
|
+
(state) => state.formRevisionReducer.instances,
|
|
2648
|
+
(state) => state.formSubmissionReducer.instances,
|
|
2649
|
+
(_state, assetId) => assetId
|
|
2650
|
+
],
|
|
2651
|
+
(assets, forms, formRevisions, submissions, assetId) => {
|
|
2652
|
+
const asset = assets[assetId];
|
|
2653
|
+
if (!asset || !asset.asset_type) {
|
|
2654
|
+
return [];
|
|
2655
|
+
}
|
|
2656
|
+
const issueTypeForms = new Set(
|
|
2657
|
+
Object.keys(forms).filter((formId) => forms[formId].asset_type === asset.asset_type)
|
|
2658
|
+
);
|
|
2659
|
+
const issueTypeFormRevisions = new Set(
|
|
2660
|
+
Object.keys(formRevisions).filter(
|
|
2661
|
+
(formRevisionId) => issueTypeForms.has(formRevisions[formRevisionId].form)
|
|
2662
|
+
)
|
|
2663
|
+
);
|
|
2664
|
+
return Object.values(submissions).filter(
|
|
2665
|
+
(submission) => !issueTypeFormRevisions.has(submission.form_revision)
|
|
2666
|
+
);
|
|
2667
|
+
}
|
|
2668
|
+
)
|
|
2669
|
+
);
|
|
2614
2670
|
const selectFormSubmissionsByAssets = createSelector(
|
|
2615
2671
|
[selectFormSubmissionsMapping, selectAssetsMapping],
|
|
2616
2672
|
(submissions, assets) => {
|
|
@@ -4095,10 +4151,15 @@ class AssetService extends BaseApiService {
|
|
|
4095
4151
|
if (!assetToBeDeleted)
|
|
4096
4152
|
throw new Error(`No asset with id ${assetId} found in the store`);
|
|
4097
4153
|
const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(store.getState());
|
|
4098
|
-
store.
|
|
4154
|
+
const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(assetId)(store.getState());
|
|
4155
|
+
this.dispatch(deleteAsset(assetId));
|
|
4099
4156
|
if (attachmentsOfAssets.length > 0) {
|
|
4100
4157
|
const attachmentsOfAssetIds = attachmentsOfAssets.map(({ offline_id }) => offline_id);
|
|
4101
|
-
|
|
4158
|
+
this.dispatch(deleteAssetAttachments(attachmentsOfAssetIds));
|
|
4159
|
+
}
|
|
4160
|
+
if (formSubmissionsOfAssets.length > 0) {
|
|
4161
|
+
const formSubmissionsOfAssetIds = formSubmissionsOfAssets.map(({ offline_id }) => offline_id);
|
|
4162
|
+
this.dispatch(deleteFormSubmissions(formSubmissionsOfAssetIds));
|
|
4102
4163
|
}
|
|
4103
4164
|
return this.enqueueRequest({
|
|
4104
4165
|
description: "Delete asset",
|
|
@@ -4107,8 +4168,9 @@ class AssetService extends BaseApiService {
|
|
|
4107
4168
|
blockers: [assetId],
|
|
4108
4169
|
blocks: []
|
|
4109
4170
|
}).catch((err) => {
|
|
4110
|
-
|
|
4111
|
-
|
|
4171
|
+
this.dispatch(addAsset(assetToBeDeleted));
|
|
4172
|
+
this.dispatch(addAssetAttachments(attachmentsOfAssets));
|
|
4173
|
+
this.dispatch(addFormSubmissions(formSubmissionsOfAssets));
|
|
4112
4174
|
throw err;
|
|
4113
4175
|
});
|
|
4114
4176
|
}
|
|
@@ -4983,12 +5045,15 @@ class IssueService extends BaseApiService {
|
|
|
4983
5045
|
}
|
|
4984
5046
|
const attachmentsOfIssue = selectAttachmentsOfIssue(id)(state);
|
|
4985
5047
|
const updatesOfIssue = selectIssueUpdatesOfIssue(id)(state);
|
|
5048
|
+
const formSubmissionsOfIssue = selectFormSubmissionsOfIssue(id)(state);
|
|
4986
5049
|
this.dispatch(deleteIssue(id));
|
|
4987
5050
|
this.dispatch(addActiveProjectIssuesCount(-1));
|
|
4988
5051
|
if (attachmentsOfIssue.length > 0)
|
|
4989
5052
|
this.dispatch(deleteIssueAttachments(attachmentsOfIssue.map(({ offline_id }) => offline_id)));
|
|
4990
5053
|
if (updatesOfIssue.length > 0)
|
|
4991
5054
|
this.dispatch(deleteIssueUpdates(updatesOfIssue.map(({ offline_id }) => offline_id)));
|
|
5055
|
+
if (formSubmissionsOfIssue.length > 0)
|
|
5056
|
+
this.dispatch(deleteFormSubmissions(formSubmissionsOfIssue.map(({ offline_id }) => offline_id)));
|
|
4992
5057
|
try {
|
|
4993
5058
|
return await this.enqueueRequest({
|
|
4994
5059
|
description: "Delete issue",
|
|
@@ -5002,6 +5067,7 @@ class IssueService extends BaseApiService {
|
|
|
5002
5067
|
this.dispatch(addIssueAttachments(attachmentsOfIssue));
|
|
5003
5068
|
this.dispatch(addIssueUpdates(updatesOfIssue));
|
|
5004
5069
|
this.dispatch(addActiveProjectIssuesCount(1));
|
|
5070
|
+
this.dispatch(addFormSubmissions(formSubmissionsOfIssue));
|
|
5005
5071
|
throw e;
|
|
5006
5072
|
}
|
|
5007
5073
|
}
|
|
@@ -7483,6 +7549,8 @@ export {
|
|
|
7483
7549
|
selectAssets,
|
|
7484
7550
|
selectAssetsMapping,
|
|
7485
7551
|
selectAssetsOfAssetType,
|
|
7552
|
+
selectAttachedFormSubmissionsOfAssets,
|
|
7553
|
+
selectAttachedFormSubmissionsOfIssue,
|
|
7486
7554
|
selectAttachmentsOfAsset,
|
|
7487
7555
|
selectAttachmentsOfAssetByType,
|
|
7488
7556
|
selectAttachmentsOfAssetType,
|