@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.
@@ -3309,13 +3309,27 @@ var __publicField = (obj, key, value) => {
3309
3309
  const selectIssueAssociationById = (id) => (state) => {
3310
3310
  return state.issueAssociationReducer.instances[id];
3311
3311
  };
3312
- const selectAssociationsOfIssue = restructureCreateSelectorWithArgs(
3312
+ const selectIssueAssociationsToIssue = restructureCreateSelectorWithArgs(
3313
3313
  toolkit.createSelector(
3314
3314
  [selectIssueAssociationMapping, (_state, issueId) => issueId],
3315
3315
  (associationMapping, issueId) => {
3316
- return Object.values(associationMapping).filter(
3317
- (assoc) => assoc.issue === issueId
3318
- );
3316
+ return Object.values(associationMapping).filter((assoc) => assoc.associated_issue === issueId);
3317
+ }
3318
+ )
3319
+ );
3320
+ const selectIssueAssociationsOfIssue = restructureCreateSelectorWithArgs(
3321
+ toolkit.createSelector(
3322
+ [selectIssueAssociationMapping, (_state, issueId) => issueId],
3323
+ (associationMapping, issueId) => {
3324
+ return Object.values(associationMapping).filter((assoc) => assoc.issue === issueId);
3325
+ }
3326
+ )
3327
+ );
3328
+ const selectIssueAssociationsOfAsset = restructureCreateSelectorWithArgs(
3329
+ toolkit.createSelector(
3330
+ [selectIssueAssociationMapping, (_state, assetId) => assetId],
3331
+ (associationMapping, assetId) => {
3332
+ return Object.values(associationMapping).filter((assoc) => assoc.asset === assetId);
3319
3333
  }
3320
3334
  )
3321
3335
  );
@@ -4184,11 +4198,13 @@ var __publicField = (obj, key, value) => {
4184
4198
  }
4185
4199
  async remove(assetId) {
4186
4200
  const { store } = this.client;
4187
- const assetToBeDeleted = selectAsset(assetId)(store.getState());
4201
+ const state = store.getState();
4202
+ const assetToBeDeleted = selectAsset(assetId)(state);
4188
4203
  if (!assetToBeDeleted)
4189
4204
  throw new Error(`No asset with id ${assetId} found in the store`);
4190
- const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(store.getState());
4191
- const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(assetId)(store.getState());
4205
+ const attachmentsOfAssets = selectAttachmentsOfAsset(assetId)(state);
4206
+ const formSubmissionsOfAssets = selectFormSubmissionsOfAsset(assetId)(state);
4207
+ const issueAssociations = selectIssueAssociationsOfAsset(assetId)(state);
4192
4208
  this.dispatch(deleteAsset(assetId));
4193
4209
  if (attachmentsOfAssets.length > 0) {
4194
4210
  const attachmentsOfAssetIds = attachmentsOfAssets.map(({ offline_id }) => offline_id);
@@ -4198,6 +4214,10 @@ var __publicField = (obj, key, value) => {
4198
4214
  const formSubmissionsOfAssetIds = formSubmissionsOfAssets.map(({ offline_id }) => offline_id);
4199
4215
  this.dispatch(deleteFormSubmissions(formSubmissionsOfAssetIds));
4200
4216
  }
4217
+ if (issueAssociations.length > 0) {
4218
+ const issueAssociationsIds = issueAssociations.map(({ offline_id }) => offline_id);
4219
+ this.dispatch(deleteIssueAssociations(issueAssociationsIds));
4220
+ }
4201
4221
  return this.enqueueRequest({
4202
4222
  description: "Delete asset",
4203
4223
  method: HttpMethod.DELETE,
@@ -4208,6 +4228,7 @@ var __publicField = (obj, key, value) => {
4208
4228
  this.dispatch(addAsset(assetToBeDeleted));
4209
4229
  this.dispatch(addAssetAttachments(attachmentsOfAssets));
4210
4230
  this.dispatch(addFormSubmissions(formSubmissionsOfAssets));
4231
+ this.dispatch(addIssueAssociations(issueAssociations));
4211
4232
  throw err;
4212
4233
  });
4213
4234
  }
@@ -5083,6 +5104,12 @@ var __publicField = (obj, key, value) => {
5083
5104
  const attachmentsOfIssue = selectAttachmentsOfIssue(id)(state);
5084
5105
  const updatesOfIssue = selectIssueUpdatesOfIssue(id)(state);
5085
5106
  const formSubmissionsOfIssue = selectFormSubmissionsOfIssue(id)(state);
5107
+ const issueAssociationsRecord = {};
5108
+ for (const issueAssociation of selectIssueAssociationsToIssue(id)(state))
5109
+ issueAssociationsRecord[issueAssociation.offline_id] = issueAssociation;
5110
+ for (const issueAssociation of selectIssueAssociationsOfIssue(id)(state))
5111
+ issueAssociationsRecord[issueAssociation.offline_id] = issueAssociation;
5112
+ const issueAssociations = Object.values(issueAssociationsRecord);
5086
5113
  this.dispatch(deleteIssue(id));
5087
5114
  this.dispatch(addActiveProjectIssuesCount(-1));
5088
5115
  if (attachmentsOfIssue.length > 0)
@@ -5091,6 +5118,8 @@ var __publicField = (obj, key, value) => {
5091
5118
  this.dispatch(deleteIssueUpdates(updatesOfIssue.map(({ offline_id }) => offline_id)));
5092
5119
  if (formSubmissionsOfIssue.length > 0)
5093
5120
  this.dispatch(deleteFormSubmissions(formSubmissionsOfIssue.map(({ offline_id }) => offline_id)));
5121
+ if (issueAssociations.length > 0)
5122
+ this.dispatch(deleteIssueAssociations(issueAssociations.map(({ offline_id }) => offline_id)));
5094
5123
  try {
5095
5124
  return await this.enqueueRequest({
5096
5125
  description: "Delete issue",
@@ -5105,6 +5134,7 @@ var __publicField = (obj, key, value) => {
5105
5134
  this.dispatch(addIssueUpdates(updatesOfIssue));
5106
5135
  this.dispatch(addActiveProjectIssuesCount(1));
5107
5136
  this.dispatch(addFormSubmissions(formSubmissionsOfIssue));
5137
+ this.dispatch(addIssueAssociations(issueAssociations));
5108
5138
  throw e;
5109
5139
  }
5110
5140
  }
@@ -7278,7 +7308,7 @@ var __publicField = (obj, key, value) => {
7278
7308
  store.dispatch(initializeGeoImages(result));
7279
7309
  }
7280
7310
  }
7281
- class IssueAssociationSlice extends BaseUploadService {
7311
+ class IssueAssociationService extends BaseUploadService {
7282
7312
  add(payload) {
7283
7313
  const { store } = this.client;
7284
7314
  const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
@@ -7371,7 +7401,7 @@ var __publicField = (obj, key, value) => {
7371
7401
  exports2.GREEN = GREEN;
7372
7402
  exports2.GeoImageService = GeoImageService;
7373
7403
  exports2.HttpMethod = HttpMethod;
7374
- exports2.IssueAssociationSlice = IssueAssociationSlice;
7404
+ exports2.IssueAssociationService = IssueAssociationService;
7375
7405
  exports2.IssueAttachmentService = IssueAttachmentService;
7376
7406
  exports2.IssueCommentService = IssueCommentService;
7377
7407
  exports2.IssuePriority = IssuePriority;
@@ -7690,7 +7720,6 @@ var __publicField = (obj, key, value) => {
7690
7720
  exports2.selectAssets = selectAssets;
7691
7721
  exports2.selectAssetsMapping = selectAssetsMapping;
7692
7722
  exports2.selectAssetsOfAssetType = selectAssetsOfAssetType;
7693
- exports2.selectAssociationsOfIssue = selectAssociationsOfIssue;
7694
7723
  exports2.selectAttachedFormSubmissionsOfAsset = selectAttachedFormSubmissionsOfAsset;
7695
7724
  exports2.selectAttachedFormSubmissionsOfIssue = selectAttachedFormSubmissionsOfIssue;
7696
7725
  exports2.selectAttachmentsOfAsset = selectAttachmentsOfAsset;
@@ -7759,6 +7788,9 @@ var __publicField = (obj, key, value) => {
7759
7788
  exports2.selectIssue = selectIssue;
7760
7789
  exports2.selectIssueAssociationById = selectIssueAssociationById;
7761
7790
  exports2.selectIssueAssociationMapping = selectIssueAssociationMapping;
7791
+ exports2.selectIssueAssociationsOfAsset = selectIssueAssociationsOfAsset;
7792
+ exports2.selectIssueAssociationsOfIssue = selectIssueAssociationsOfIssue;
7793
+ exports2.selectIssueAssociationsToIssue = selectIssueAssociationsToIssue;
7762
7794
  exports2.selectIssueAttachment = selectIssueAttachment;
7763
7795
  exports2.selectIssueAttachmentMapping = selectIssueAttachmentMapping;
7764
7796
  exports2.selectIssueAttachments = selectIssueAttachments;