@overmap-ai/core 1.0.38-component-fields.33 → 1.0.38-component-fields.34

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.
@@ -1673,6 +1673,22 @@ var __publicField = (obj, key, value) => {
1673
1673
  action.payload.forEach((id) => {
1674
1674
  delete state.stages[id];
1675
1675
  });
1676
+ },
1677
+ linkStageToForm: (state, action) => {
1678
+ const { stageId, formId: formId2 } = action.payload;
1679
+ const stage = state.stages[stageId];
1680
+ if (!stage) {
1681
+ throw new Error("No stage exists with the id " + stageId);
1682
+ }
1683
+ stage.user_form = formId2;
1684
+ },
1685
+ unlinkStageToForm: (state, action) => {
1686
+ const { stageId } = action.payload;
1687
+ const stage = state.stages[stageId];
1688
+ if (!stage) {
1689
+ throw new Error("No stage exists with the id " + stageId);
1690
+ }
1691
+ delete stage.user_form;
1676
1692
  }
1677
1693
  }
1678
1694
  });
@@ -1717,7 +1733,7 @@ var __publicField = (obj, key, value) => {
1717
1733
  return stageIds.map((offline_id) => stageMapping[offline_id]).filter((stage) => !!stage);
1718
1734
  })
1719
1735
  );
1720
- const { addStages, updateStages, removeStages } = componentStageSlice.actions;
1736
+ const { addStages, updateStages, removeStages, linkStageToForm, unlinkStageToForm } = componentStageSlice.actions;
1721
1737
  const componentStageReducer = componentStageSlice.reducer;
1722
1738
  const initialState$g = {
1723
1739
  componentTypes: {},
@@ -3093,22 +3109,6 @@ var __publicField = (obj, key, value) => {
3093
3109
  }
3094
3110
  form.favorite = false;
3095
3111
  },
3096
- attachFormToComponentStage: (state, action) => {
3097
- const { formId: formId2, componentStageId } = action.payload;
3098
- const form = state.userForms[formId2];
3099
- if (!form) {
3100
- throw new Error("No form exists with the id " + formId2);
3101
- }
3102
- form.component_stage = componentStageId;
3103
- },
3104
- removeFormFromComponentStage: (state, action) => {
3105
- const { formId: formId2 } = action.payload;
3106
- const form = state.userForms[formId2];
3107
- if (!form) {
3108
- throw new Error("No form exists with the id " + formId2);
3109
- }
3110
- form.component_stage = void 0;
3111
- },
3112
3112
  deleteUserForm: (state, action) => {
3113
3113
  delete state.userForms[action.payload];
3114
3114
  }
@@ -3124,8 +3124,6 @@ var __publicField = (obj, key, value) => {
3124
3124
  deleteUserFormSubmissions,
3125
3125
  favoriteForm,
3126
3126
  unfavoriteForm,
3127
- attachFormToComponentStage,
3128
- removeFormFromComponentStage,
3129
3127
  deleteUserForm,
3130
3128
  deleteUserFormRevision,
3131
3129
  deleteUserFormRevisions,
@@ -3281,38 +3279,6 @@ var __publicField = (obj, key, value) => {
3281
3279
  }
3282
3280
  )
3283
3281
  );
3284
- const selectComponentStageFormLatestRevision = restructureCreateSelectorWithArgs(
3285
- toolkit.createSelector(
3286
- [
3287
- selectUserFormMapping,
3288
- selectRevisionMapping,
3289
- (_state, componentStageId) => componentStageId
3290
- ],
3291
- (userForms, revisions, componentStageId) => {
3292
- const form = Object.values(userForms).find((userForm) => userForm.component_stage === componentStageId);
3293
- return form ? _selectLatestFormRevision(revisions, form.offline_id) : void 0;
3294
- }
3295
- )
3296
- );
3297
- const selectLatestRevisionsFromComponentStageIds = restructureCreateSelectorWithArgs(
3298
- toolkit.createSelector(
3299
- [
3300
- selectUserFormMapping,
3301
- selectRevisionMapping,
3302
- (_state, componentStageIds) => componentStageIds
3303
- ],
3304
- (userForms, revisions, componentStageIds) => {
3305
- const componentStageIdsSet = new Set(componentStageIds);
3306
- const ret = {};
3307
- for (const form of Object.values(userForms)) {
3308
- if (form.component_stage && componentStageIdsSet.has(form.component_stage)) {
3309
- ret[form.component_stage] = _selectLatestFormRevision(revisions, form.offline_id);
3310
- }
3311
- }
3312
- return ret;
3313
- }
3314
- )
3315
- );
3316
3282
  const selectLatestRevisionByFormId = toolkit.createSelector([selectRevisionMapping], (revisions) => {
3317
3283
  const latestRevisions = {};
3318
3284
  for (const revision of Object.values(revisions)) {
@@ -4695,6 +4661,39 @@ var __publicField = (obj, key, value) => {
4695
4661
  blocks: [componentStage.offline_id]
4696
4662
  });
4697
4663
  }
4664
+ async linkForm(stageId, formId2) {
4665
+ const { store } = this.client;
4666
+ store.dispatch(linkStageToForm({ stageId, formId: formId2 }));
4667
+ try {
4668
+ await this.enqueueRequest({
4669
+ description: "Link component stage to form",
4670
+ method: HttpMethod.POST,
4671
+ url: `/components/stages/${stageId}/associate-with-form/`,
4672
+ payload: { user_form: formId2 },
4673
+ blockers: [stageId, formId2],
4674
+ blocks: [stageId]
4675
+ });
4676
+ } catch (e) {
4677
+ store.dispatch(unlinkStageToForm({ stageId }));
4678
+ throw e;
4679
+ }
4680
+ }
4681
+ async unlinkForm(stageId, formId2) {
4682
+ const { store } = this.client;
4683
+ store.dispatch(unlinkStageToForm({ stageId }));
4684
+ try {
4685
+ await this.enqueueRequest({
4686
+ description: "Unlink component stage from form",
4687
+ method: HttpMethod.DELETE,
4688
+ url: `/components/stages/${stageId}/associate-with-form/`,
4689
+ blockers: [stageId, formId2],
4690
+ blocks: [stageId]
4691
+ });
4692
+ } catch (e) {
4693
+ store.dispatch(linkStageToForm({ stageId, formId: formId2 }));
4694
+ throw e;
4695
+ }
4696
+ }
4698
4697
  async refreshStore() {
4699
4698
  const { store } = this.client;
4700
4699
  const result = await this.enqueueRequest({
@@ -5480,13 +5479,10 @@ var __publicField = (obj, key, value) => {
5480
5479
  });
5481
5480
  });
5482
5481
  }
5483
- async add(state, initialRevision, url, ownerUser, ownerOrganization, componentTypeId, componentStageId) {
5482
+ async add(state, initialRevision, url, ownerUser, ownerOrganization, componentTypeId) {
5484
5483
  if (!!ownerUser === !!ownerOrganization) {
5485
5484
  throw new Error("Exactly one of ownerUser and ownerOrganization must be defined.");
5486
5485
  }
5487
- if (componentTypeId && componentStageId) {
5488
- throw new Error("At most one of componentTypeId and componentStageId should be defined.");
5489
- }
5490
5486
  const ownerAttrs = {
5491
5487
  owner_user: ownerUser,
5492
5488
  owner_organization: ownerOrganization
@@ -5502,7 +5498,6 @@ var __publicField = (obj, key, value) => {
5502
5498
  submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
5503
5499
  created_by: currentUser.id,
5504
5500
  ...componentTypeId && { component_type: componentTypeId },
5505
- ...componentStageId && { component_stage: componentStageId },
5506
5501
  ...ownerAttrs
5507
5502
  };
5508
5503
  const { payloadWithoutImage, images } = await separateImageFromFields(offlineRevisionPayload);
@@ -5525,10 +5520,9 @@ var __publicField = (obj, key, value) => {
5525
5520
  payload: {
5526
5521
  ...offlineFormPayload,
5527
5522
  ...componentTypeId && { component_type: componentTypeId },
5528
- ...componentStageId && { component_stage: componentStageId },
5529
5523
  initial_revision: payloadWithoutImage
5530
5524
  },
5531
- blockers: [componentTypeId, componentStageId].filter((x) => x !== void 0),
5525
+ blockers: [componentTypeId].filter((x) => x !== void 0),
5532
5526
  blocks: [offlineFormPayload.offline_id, payloadWithoutImage.offline_id]
5533
5527
  });
5534
5528
  const attachImagesPromises = this.getAttachImagePromises(images, offlineRevisionPayload.offline_id);
@@ -5540,7 +5534,7 @@ var __publicField = (obj, key, value) => {
5540
5534
  const settledPromise = Promise.all([formPromise, ...attachImagesPromises]).then(() => formPromise);
5541
5535
  return [retForm, retRevision, formPromise, settledPromise];
5542
5536
  }
5543
- async addForOrganization(initialRevision, componentTypeId, componentStageId) {
5537
+ async addForOrganization(initialRevision, componentTypeId) {
5544
5538
  const state = this.client.store.getState();
5545
5539
  const activeOrganizationId = state.organizationReducer.activeOrganizationId;
5546
5540
  if (!activeOrganizationId) {
@@ -5552,22 +5546,13 @@ var __publicField = (obj, key, value) => {
5552
5546
  `/forms/in-organization/${activeOrganizationId}/`,
5553
5547
  void 0,
5554
5548
  activeOrganizationId,
5555
- componentTypeId,
5556
- componentStageId
5549
+ componentTypeId
5557
5550
  );
5558
5551
  }
5559
- async addForCurrentUser(initialRevision, componentTypeId, componentStageId) {
5552
+ async addForCurrentUser(initialRevision, componentTypeId) {
5560
5553
  const state = this.client.store.getState();
5561
5554
  const currentUser = state.userReducer.currentUser;
5562
- return await this.add(
5563
- state,
5564
- initialRevision,
5565
- "/forms/my-forms/",
5566
- currentUser.id,
5567
- void 0,
5568
- componentTypeId,
5569
- componentStageId
5570
- );
5555
+ return await this.add(state, initialRevision, "/forms/my-forms/", currentUser.id, void 0, componentTypeId);
5571
5556
  }
5572
5557
  async createRevision(formId2, revision) {
5573
5558
  const offlineRevision = offline(revision);
@@ -5640,39 +5625,6 @@ var __publicField = (obj, key, value) => {
5640
5625
  throw e;
5641
5626
  }
5642
5627
  }
5643
- async attachToComponentStage(formId2, componentStageId) {
5644
- const { store } = this.client;
5645
- store.dispatch(attachFormToComponentStage({ formId: formId2, componentStageId }));
5646
- try {
5647
- await this.enqueueRequest({
5648
- description: "Attach form to component stage",
5649
- method: HttpMethod.POST,
5650
- url: `/forms/${formId2}/associate-with-stage/`,
5651
- payload: { component_stage: componentStageId },
5652
- blockers: [formId2, componentStageId],
5653
- blocks: [formId2]
5654
- });
5655
- } catch (e) {
5656
- store.dispatch(removeFormFromComponentStage({ formId: formId2 }));
5657
- throw e;
5658
- }
5659
- }
5660
- async removeFromComponentStage(formId2, componentStageId) {
5661
- const { store } = this.client;
5662
- store.dispatch(removeFormFromComponentStage({ formId: formId2 }));
5663
- try {
5664
- await this.enqueueRequest({
5665
- description: "Remove form from component stage",
5666
- method: HttpMethod.DELETE,
5667
- url: `/forms/${formId2}/associate-with-stage/`,
5668
- blockers: [formId2, componentStageId],
5669
- blocks: [formId2]
5670
- });
5671
- } catch (e) {
5672
- store.dispatch(attachFormToComponentStage({ formId: formId2, componentStageId }));
5673
- throw e;
5674
- }
5675
- }
5676
5628
  async delete(formId2) {
5677
5629
  const { store } = this.client;
5678
5630
  const state = store.getState();
@@ -12014,7 +11966,6 @@ var __publicField = (obj, key, value) => {
12014
11966
  exports2.addUsers = addUsers;
12015
11967
  exports2.addWorkspace = addWorkspace;
12016
11968
  exports2.areArraysEqual = areArraysEqual;
12017
- exports2.attachFormToComponentStage = attachFormToComponentStage;
12018
11969
  exports2.authReducer = authReducer;
12019
11970
  exports2.authSlice = authSlice;
12020
11971
  exports2.blobToBase64 = blobToBase64;
@@ -12093,6 +12044,7 @@ var __publicField = (obj, key, value) => {
12093
12044
  exports2.issueReducer = issueReducer;
12094
12045
  exports2.issueSlice = issueSlice;
12095
12046
  exports2.issueToSearchResult = issueToSearchResult;
12047
+ exports2.linkStageToForm = linkStageToForm;
12096
12048
  exports2.literalToCoordinates = literalToCoordinates;
12097
12049
  exports2.logOnlyOnce = logOnlyOnce;
12098
12050
  exports2.makeClient = makeClient;
@@ -12137,7 +12089,6 @@ var __publicField = (obj, key, value) => {
12137
12089
  exports2.removeComponent = removeComponent;
12138
12090
  exports2.removeEmailDomain = removeEmailDomain;
12139
12091
  exports2.removeFavouriteProjectId = removeFavouriteProjectId;
12140
- exports2.removeFormFromComponentStage = removeFormFromComponentStage;
12141
12092
  exports2.removeIssue = removeIssue;
12142
12093
  exports2.removeIssueComment = removeIssueComment;
12143
12094
  exports2.removeOrganizationAccess = removeOrganizationAccess;
@@ -12182,7 +12133,6 @@ var __publicField = (obj, key, value) => {
12182
12133
  exports2.selectCompletedStageIdsForComponent = selectCompletedStageIdsForComponent;
12183
12134
  exports2.selectCompletedStages = selectCompletedStages;
12184
12135
  exports2.selectComponent = selectComponent;
12185
- exports2.selectComponentStageFormLatestRevision = selectComponentStageFormLatestRevision;
12186
12136
  exports2.selectComponentType = selectComponentType;
12187
12137
  exports2.selectComponentTypeForm = selectComponentTypeForm;
12188
12138
  exports2.selectComponentTypeFromComponent = selectComponentTypeFromComponent;
@@ -12222,7 +12172,6 @@ var __publicField = (obj, key, value) => {
12222
12172
  exports2.selectLatestFormRevision = selectLatestFormRevision;
12223
12173
  exports2.selectLatestRetryTime = selectLatestRetryTime;
12224
12174
  exports2.selectLatestRevisionByFormId = selectLatestRevisionByFormId;
12225
- exports2.selectLatestRevisionsFromComponentStageIds = selectLatestRevisionsFromComponentStageIds;
12226
12175
  exports2.selectLatestRevisionsFromComponentTypeIds = selectLatestRevisionsFromComponentTypeIds;
12227
12176
  exports2.selectMainWorkspace = selectMainWorkspace;
12228
12177
  exports2.selectMapStyle = selectMapStyle;
@@ -12337,6 +12286,7 @@ var __publicField = (obj, key, value) => {
12337
12286
  exports2.unfavoriteForm = unfavoriteForm;
12338
12287
  exports2.unhideAllCategories = unhideAllCategories;
12339
12288
  exports2.unhideCategory = unhideCategory;
12289
+ exports2.unlinkStageToForm = unlinkStageToForm;
12340
12290
  exports2.updateActiveOrganization = updateActiveOrganization;
12341
12291
  exports2.updateAttachment = updateAttachment;
12342
12292
  exports2.updateComponent = updateComponent;