@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.
@@ -2345,11 +2345,11 @@ var __publicField = (obj, key, value) => {
2345
2345
  selectFormRevisionMapping,
2346
2346
  (_state, assetTypeIds) => assetTypeIds
2347
2347
  ],
2348
- (userForms, revisions, assetTypeIds) => {
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(userForms)) {
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
- (userForms, revisions, search) => {
2405
+ (formsMapping, revisions, search) => {
2406
2406
  const { searchTerm, maxResults, favorites, organization } = search;
2407
2407
  const favoriteMatches = [];
2408
2408
  const regularMatches = [];
2409
- for (const [userFormId, userForm] of Object.entries(userForms)) {
2410
- if (favorites !== void 0 && userForm.favorite != favorites)
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 !== userForm.organization) {
2412
+ if (Number.isInteger(organization) && organization !== form.organization) {
2413
2413
  continue;
2414
2414
  }
2415
- const latestRevision = _selectLatestFormRevision(revisions, userFormId);
2415
+ const latestRevision = _selectLatestFormRevision(revisions, formId);
2416
2416
  if (latestRevision.title.toLowerCase().includes(searchTerm.toLowerCase())) {
2417
- if (userForm.favorite) {
2418
- favoriteMatches.push({ ...userForm, latestRevision });
2417
+ if (form.favorite) {
2418
+ favoriteMatches.push({ ...form, latestRevision });
2419
2419
  } else {
2420
- regularMatches.push({ ...userForm, latestRevision });
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 = restructureCreateSelectorWithArgs(
2435
- toolkit.createSelector([selectFormsMapping, (_, formId) => formId], (userForms, formId) => {
2436
- return userForms[formId];
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
- (userForms, assetTypeId) => {
2446
- return Object.values(userForms).find((userForm) => userForm.asset_type === assetTypeId);
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
- (userForms, issueTypeId) => {
2454
- return Object.values(userForms).find((userForm) => userForm.issue_type === issueTypeId);
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], (userForms) => {
2459
- return Object.keys(userForms).length;
2456
+ const selectFormsCount = toolkit.createSelector([selectFormMapping], (formsMapping) => {
2457
+ return Object.keys(formsMapping).length;
2460
2458
  });
2461
- const selectGeneralFormCount = toolkit.createSelector([selectFormMapping], (userForms) => {
2462
- return Object.values(userForms).filter((form) => !form.asset_type).length;
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 selectUserFormRevisionAttachmentsMapping = (state) => {
2680
+ const selectFormRevisionAttachmentsMapping = (state) => {
2683
2681
  return state.formRevisionAttachmentReducer.instances;
2684
2682
  };
2685
2683
  const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
2686
2684
  toolkit.createSelector(
2687
- [selectUserFormRevisionAttachmentsMapping, (_state, revisionId) => revisionId],
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 userForm = selectForm(formId)(state);
5623
- if (!userForm) {
5624
- throw new Error("Expected userForm to exist");
5620
+ const form = selectForm(formId)(state);
5621
+ if (!form) {
5622
+ throw new Error("Expected form to exist");
5625
5623
  }
5626
- const userFormSubmissions = selectFormSubmissionsOfForm(formId)(state);
5627
- if (userFormSubmissions && userFormSubmissions.length > 0) {
5628
- this.dispatch(deleteFormSubmissions(userFormSubmissions.map(({ offline_id }) => offline_id)));
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 userFormRevisions = selectFormRevisionsOfForm(formId)(state);
5631
- if (userFormRevisions && userFormRevisions.length > 0) {
5632
- this.dispatch(deleteFormRevisions(userFormRevisions.map(({ offline_id }) => offline_id)));
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(userForm));
5645
- if (userFormRevisions && userFormRevisions.length > 0) {
5646
- this.dispatch(addFormRevisions(userFormRevisions));
5642
+ this.dispatch(addForm(form));
5643
+ if (formRevisions && formRevisions.length > 0) {
5644
+ this.dispatch(addFormRevisions(formRevisions));
5647
5645
  }
5648
- if (userFormSubmissions && userFormSubmissions.length > 0) {
5649
- this.dispatch(addFormSubmissions(userFormSubmissions));
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;