@overmap-ai/core 1.0.63-issue-association.0 → 1.0.63-issue-association.2

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.
@@ -3321,13 +3321,27 @@ const selectIssueAssociationMapping = (state) => state.issueAssociationReducer.i
3321
3321
  const selectIssueAssociationById = (id) => (state) => {
3322
3322
  return state.issueAssociationReducer.instances[id];
3323
3323
  };
3324
- const selectAssociationsOfIssue = restructureCreateSelectorWithArgs(
3324
+ const selectIssueAssociationsToIssue = restructureCreateSelectorWithArgs(
3325
3325
  createSelector(
3326
3326
  [selectIssueAssociationMapping, (_state, issueId) => issueId],
3327
3327
  (associationMapping, issueId) => {
3328
- return Object.values(associationMapping).filter(
3329
- (assoc) => assoc.issue === issueId
3330
- );
3328
+ return Object.values(associationMapping).filter((assoc) => assoc.associated_issue === issueId);
3329
+ }
3330
+ )
3331
+ );
3332
+ const selectIssueAssociationsOfIssue = restructureCreateSelectorWithArgs(
3333
+ createSelector(
3334
+ [selectIssueAssociationMapping, (_state, issueId) => issueId],
3335
+ (associationMapping, issueId) => {
3336
+ return Object.values(associationMapping).filter((assoc) => assoc.issue === issueId);
3337
+ }
3338
+ )
3339
+ );
3340
+ const selectIssueAssociationsOfAsset = restructureCreateSelectorWithArgs(
3341
+ createSelector(
3342
+ [selectIssueAssociationMapping, (_state, assetId) => assetId],
3343
+ (associationMapping, assetId) => {
3344
+ return Object.values(associationMapping).filter((assoc) => assoc.asset === assetId);
3331
3345
  }
3332
3346
  )
3333
3347
  );
@@ -4196,11 +4210,13 @@ class AssetService extends BaseApiService {
4196
4210
  }
4197
4211
  async remove(assetId) {
4198
4212
  const { store } = this.client;
4199
- const assetToBeDeleted = selectAsset(assetId)(store.getState());
4213
+ const state = store.getState();
4214
+ const assetToBeDeleted = selectAsset(assetId)(state);
4200
4215
  if (!assetToBeDeleted)
4201
4216
  throw new Error(`No asset with id ${assetId} found in the store`);
4202
- const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(store.getState());
4203
- const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(assetId)(store.getState());
4217
+ const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(state);
4218
+ const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(assetId)(state);
4219
+ const issueAssociations = selectIssueAssociationsOfAsset(assetId)(state);
4204
4220
  this.dispatch(deleteAsset(assetId));
4205
4221
  if (attachmentsOfAssets.length > 0) {
4206
4222
  const attachmentsOfAssetIds = attachmentsOfAssets.map(({ offline_id }) => offline_id);
@@ -4210,6 +4226,10 @@ class AssetService extends BaseApiService {
4210
4226
  const formSubmissionsOfAssetIds = formSubmissionsOfAssets.map(({ offline_id }) => offline_id);
4211
4227
  this.dispatch(deleteFormSubmissions(formSubmissionsOfAssetIds));
4212
4228
  }
4229
+ if (issueAssociations.length > 0) {
4230
+ const issueAssociationsIds = issueAssociations.map(({ offline_id }) => offline_id);
4231
+ this.dispatch(deleteIssueAssociations(issueAssociationsIds));
4232
+ }
4213
4233
  return this.enqueueRequest({
4214
4234
  description: "Delete asset",
4215
4235
  method: HttpMethod.DELETE,
@@ -4220,6 +4240,7 @@ class AssetService extends BaseApiService {
4220
4240
  this.dispatch(addAsset(assetToBeDeleted));
4221
4241
  this.dispatch(addAssetAttachments(attachmentsOfAssets));
4222
4242
  this.dispatch(addFormSubmissions(formSubmissionsOfAssets));
4243
+ this.dispatch(addIssueAssociations(issueAssociations));
4223
4244
  throw err;
4224
4245
  });
4225
4246
  }
@@ -5095,6 +5116,12 @@ class IssueService extends BaseApiService {
5095
5116
  const attachmentsOfIssue = selectAttachmentsOfIssue(id)(state);
5096
5117
  const updatesOfIssue = selectIssueUpdatesOfIssue(id)(state);
5097
5118
  const formSubmissionsOfIssue = selectFormSubmissionsOfIssue(id)(state);
5119
+ const issueAssociationsRecord = {};
5120
+ for (const issueAssociation of selectIssueAssociationsToIssue(id)(state))
5121
+ issueAssociationsRecord[issueAssociation.offline_id] = issueAssociation;
5122
+ for (const issueAssociation of selectIssueAssociationsOfIssue(id)(state))
5123
+ issueAssociationsRecord[issueAssociation.offline_id] = issueAssociation;
5124
+ const issueAssociations = Object.values(issueAssociationsRecord);
5098
5125
  this.dispatch(deleteIssue(id));
5099
5126
  this.dispatch(addActiveProjectIssuesCount(-1));
5100
5127
  if (attachmentsOfIssue.length > 0)
@@ -5103,6 +5130,8 @@ class IssueService extends BaseApiService {
5103
5130
  this.dispatch(deleteIssueUpdates(updatesOfIssue.map(({ offline_id }) => offline_id)));
5104
5131
  if (formSubmissionsOfIssue.length > 0)
5105
5132
  this.dispatch(deleteFormSubmissions(formSubmissionsOfIssue.map(({ offline_id }) => offline_id)));
5133
+ if (issueAssociations.length > 0)
5134
+ this.dispatch(deleteIssueAssociations(issueAssociations.map(({ offline_id }) => offline_id)));
5106
5135
  try {
5107
5136
  return await this.enqueueRequest({
5108
5137
  description: "Delete issue",
@@ -5117,6 +5146,7 @@ class IssueService extends BaseApiService {
5117
5146
  this.dispatch(addIssueUpdates(updatesOfIssue));
5118
5147
  this.dispatch(addActiveProjectIssuesCount(1));
5119
5148
  this.dispatch(addFormSubmissions(formSubmissionsOfIssue));
5149
+ this.dispatch(addIssueAssociations(issueAssociations));
5120
5150
  throw e;
5121
5151
  }
5122
5152
  }
@@ -7290,7 +7320,7 @@ class GeoImageService extends BaseUploadService {
7290
7320
  store.dispatch(initializeGeoImages(result));
7291
7321
  }
7292
7322
  }
7293
- class IssueAssociationSlice extends BaseUploadService {
7323
+ class IssueAssociationService extends BaseUploadService {
7294
7324
  add(payload) {
7295
7325
  const { store } = this.client;
7296
7326
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -7384,7 +7414,7 @@ export {
7384
7414
  GREEN,
7385
7415
  GeoImageService,
7386
7416
  HttpMethod,
7387
- IssueAssociationSlice,
7417
+ IssueAssociationService,
7388
7418
  IssueAttachmentService,
7389
7419
  IssueCommentService,
7390
7420
  IssuePriority,
@@ -7703,7 +7733,6 @@ export {
7703
7733
  selectAssets,
7704
7734
  selectAssetsMapping,
7705
7735
  selectAssetsOfAssetType,
7706
- selectAssociationsOfIssue,
7707
7736
  selectAttachedFormSubmissionsOfAsset,
7708
7737
  selectAttachedFormSubmissionsOfIssue,
7709
7738
  selectAttachmentsOfAsset,
@@ -7772,6 +7801,9 @@ export {
7772
7801
  selectIssue,
7773
7802
  selectIssueAssociationById,
7774
7803
  selectIssueAssociationMapping,
7804
+ selectIssueAssociationsOfAsset,
7805
+ selectIssueAssociationsOfIssue,
7806
+ selectIssueAssociationsToIssue,
7775
7807
  selectIssueAttachment,
7776
7808
  selectIssueAttachmentMapping,
7777
7809
  selectIssueAttachments,