@overmap-ai/core 1.0.58-qr-code-field-fix.0 → 1.0.58-sign-up-hotfix.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.
- package/dist/forms/fields/BaseField/BaseField.d.ts +3 -1
- package/dist/forms/fields/MultiStringField/MultiStringField.d.ts +6 -6
- package/dist/forms/fields/typings.d.ts +1 -1
- package/dist/forms/fields/utils.d.ts +3 -0
- package/dist/forms/index.d.ts +1 -0
- package/dist/forms/typings.d.ts +1 -1
- package/dist/overmap-core.js +398 -249
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +398 -249
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/services/AssetService.d.ts +2 -2
- package/dist/sdk/services/UserFormService.d.ts +7 -11
- package/dist/sdk/services/UserFormSubmissionService.d.ts +13 -6
- package/dist/store/slices/assetSlice.d.ts +3 -1
- package/dist/store/slices/formSlice.d.ts +2 -76
- package/dist/typings/models/components.d.ts +1 -0
- package/dist/typings/models/forms.d.ts +6 -10
- package/dist/utils/array.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1728,6 +1728,16 @@ var __publicField = (obj, key, value) => {
|
|
|
1728
1728
|
}
|
|
1729
1729
|
prevAssets = null;
|
|
1730
1730
|
},
|
|
1731
|
+
updateAssets: (state, action) => {
|
|
1732
|
+
for (const asset of action.payload) {
|
|
1733
|
+
if (asset.offline_id in state.assets) {
|
|
1734
|
+
state.assets[asset.offline_id] = asset;
|
|
1735
|
+
} else {
|
|
1736
|
+
throw new Error(`Tried to update asset with ID that doesn't exist: ${asset.offline_id}`);
|
|
1737
|
+
}
|
|
1738
|
+
}
|
|
1739
|
+
prevAssets = null;
|
|
1740
|
+
},
|
|
1731
1741
|
removeAsset: (state, action) => {
|
|
1732
1742
|
if (action.payload in state.assets) {
|
|
1733
1743
|
delete state.assets[action.payload];
|
|
@@ -1736,6 +1746,16 @@ var __publicField = (obj, key, value) => {
|
|
|
1736
1746
|
}
|
|
1737
1747
|
prevAssets = null;
|
|
1738
1748
|
},
|
|
1749
|
+
removeAssets: (state, action) => {
|
|
1750
|
+
for (const assetId of action.payload) {
|
|
1751
|
+
if (assetId in state.assets) {
|
|
1752
|
+
delete state.assets[assetId];
|
|
1753
|
+
} else {
|
|
1754
|
+
throw new Error(`Failed to remove asset because ID doesn't exist: ${assetId}`);
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
prevAssets = null;
|
|
1758
|
+
},
|
|
1739
1759
|
removeAllAssetsOfType: (state, action) => {
|
|
1740
1760
|
var _a2;
|
|
1741
1761
|
for (const componentId in state.assets) {
|
|
@@ -1759,7 +1779,9 @@ var __publicField = (obj, key, value) => {
|
|
|
1759
1779
|
const {
|
|
1760
1780
|
addAsset,
|
|
1761
1781
|
updateAsset,
|
|
1782
|
+
updateAssets,
|
|
1762
1783
|
removeAsset,
|
|
1784
|
+
removeAssets,
|
|
1763
1785
|
addAssetsInBatches,
|
|
1764
1786
|
setAssets,
|
|
1765
1787
|
removeAllAssetsOfType,
|
|
@@ -3800,17 +3822,15 @@ var __publicField = (obj, key, value) => {
|
|
|
3800
3822
|
(_state, search) => search
|
|
3801
3823
|
],
|
|
3802
3824
|
(userForms, revisions, search) => {
|
|
3803
|
-
const { searchTerm, maxResults, favorites,
|
|
3825
|
+
const { searchTerm, maxResults, favorites, organization } = search;
|
|
3804
3826
|
const favoriteMatches = [];
|
|
3805
3827
|
const regularMatches = [];
|
|
3806
3828
|
for (const [userFormId, userForm] of Object.entries(userForms)) {
|
|
3807
3829
|
if (favorites !== void 0 && userForm.favorite != favorites)
|
|
3808
3830
|
continue;
|
|
3809
|
-
if (Number.isInteger(
|
|
3831
|
+
if (Number.isInteger(organization) && organization !== userForm.organization) {
|
|
3810
3832
|
continue;
|
|
3811
3833
|
}
|
|
3812
|
-
if (Number.isInteger(owner_user) && owner_user !== userForm.owner_user)
|
|
3813
|
-
continue;
|
|
3814
3834
|
const latestRevision = _selectLatestFormRevision(revisions, userFormId);
|
|
3815
3835
|
if (latestRevision.title.toLowerCase().includes(searchTerm.toLowerCase())) {
|
|
3816
3836
|
if (userForm.favorite) {
|
|
@@ -4595,10 +4615,6 @@ var __publicField = (obj, key, value) => {
|
|
|
4595
4615
|
throw new Error(`Failed to update index_workspace of issue ${issue.offline_id} to main workspace`);
|
|
4596
4616
|
}
|
|
4597
4617
|
}
|
|
4598
|
-
const indexedForms = Object.values(draft.formReducer.forms).filter((form) => form.index_workspace === workspaceId);
|
|
4599
|
-
for (const form of indexedForms) {
|
|
4600
|
-
form.index_workspace = mainWorkspace.offline_id;
|
|
4601
|
-
}
|
|
4602
4618
|
}
|
|
4603
4619
|
const rootReducer = (state, action) => {
|
|
4604
4620
|
if (action.type === "auth/setLoggedIn" && !action.payload) {
|
|
@@ -5098,12 +5114,8 @@ var __publicField = (obj, key, value) => {
|
|
|
5098
5114
|
const initialDataUuid = uuid.v4();
|
|
5099
5115
|
const timeout = 5;
|
|
5100
5116
|
let timedOut = false;
|
|
5101
|
-
let initialDataRequestFinished = false;
|
|
5102
5117
|
const timeoutPromise = new Promise((_, reject) => {
|
|
5103
5118
|
setTimeout(() => {
|
|
5104
|
-
if (initialDataRequestFinished) {
|
|
5105
|
-
return void 0;
|
|
5106
|
-
}
|
|
5107
5119
|
timedOut = true;
|
|
5108
5120
|
store.dispatch(markForDeletion(uuid$1));
|
|
5109
5121
|
store.dispatch(markForDeletion(initialDataUuid));
|
|
@@ -5115,15 +5127,8 @@ var __publicField = (obj, key, value) => {
|
|
|
5115
5127
|
return void 0;
|
|
5116
5128
|
}
|
|
5117
5129
|
store.dispatch(setTokens(tokens));
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
return void 0;
|
|
5121
|
-
}
|
|
5122
|
-
initialDataRequestFinished = true;
|
|
5123
|
-
store.dispatch(setLoggedIn(true));
|
|
5124
|
-
store.dispatch({ type: "rehydrated/setRehydrated", payload: true });
|
|
5125
|
-
return void 0;
|
|
5126
|
-
});
|
|
5130
|
+
store.dispatch(setLoggedIn(true));
|
|
5131
|
+
store.dispatch({ type: "rehydrated/setRehydrated", payload: true });
|
|
5127
5132
|
});
|
|
5128
5133
|
return Promise.race([timeoutPromise, successPromise]);
|
|
5129
5134
|
}
|
|
@@ -5368,6 +5373,15 @@ var __publicField = (obj, key, value) => {
|
|
|
5368
5373
|
store.dispatch(setCategories(result));
|
|
5369
5374
|
}
|
|
5370
5375
|
}
|
|
5376
|
+
function chunkArray(arr, chunkSize) {
|
|
5377
|
+
const chunks = [];
|
|
5378
|
+
let index2 = 0;
|
|
5379
|
+
const arrLength = arr.length;
|
|
5380
|
+
while (index2 < arrLength) {
|
|
5381
|
+
chunks.push(arr.slice(index2, index2 += chunkSize));
|
|
5382
|
+
}
|
|
5383
|
+
return chunks;
|
|
5384
|
+
}
|
|
5371
5385
|
class AssetService extends BaseApiService {
|
|
5372
5386
|
// Basic CRUD functions
|
|
5373
5387
|
add(asset, workspaceId) {
|
|
@@ -5444,36 +5458,55 @@ var __publicField = (obj, key, value) => {
|
|
|
5444
5458
|
throw err;
|
|
5445
5459
|
});
|
|
5446
5460
|
}
|
|
5447
|
-
|
|
5448
|
-
|
|
5449
|
-
return { ...offline(asset), submitted_at: (/* @__PURE__ */ new Date()).toISOString() };
|
|
5450
|
-
});
|
|
5461
|
+
// TODO: payload does not require asset_type
|
|
5462
|
+
bulkAdd(assetsToCreate, workspaceId, assetTypeId, batchSize) {
|
|
5451
5463
|
const { store } = this.client;
|
|
5452
|
-
|
|
5453
|
-
const
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
|
|
5461
|
-
|
|
5462
|
-
|
|
5463
|
-
|
|
5464
|
-
|
|
5464
|
+
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5465
|
+
const transactionId = uuid.v4();
|
|
5466
|
+
const assetBatches = chunkArray(assetsToCreate, batchSize).map((assetBatch) => {
|
|
5467
|
+
const assetPayloads = assetBatch.map((assetPayload) => {
|
|
5468
|
+
return offline({
|
|
5469
|
+
...assetPayload,
|
|
5470
|
+
submitted_at: submittedAt
|
|
5471
|
+
});
|
|
5472
|
+
});
|
|
5473
|
+
return {
|
|
5474
|
+
batchId: uuid.v4(),
|
|
5475
|
+
payload: {
|
|
5476
|
+
transaction_id: transactionId,
|
|
5477
|
+
assets: assetPayloads
|
|
5478
|
+
}
|
|
5479
|
+
};
|
|
5465
5480
|
});
|
|
5466
|
-
|
|
5467
|
-
|
|
5468
|
-
|
|
5469
|
-
}
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5481
|
+
const batchPromises = [];
|
|
5482
|
+
let prevBatchId = null;
|
|
5483
|
+
for (const assetBatch of assetBatches) {
|
|
5484
|
+
const { batchId, payload } = assetBatch;
|
|
5485
|
+
const batchAssetOfflineIds = payload.assets.map((c) => c.offline_id);
|
|
5486
|
+
const blockers = [assetTypeId];
|
|
5487
|
+
if (prevBatchId)
|
|
5488
|
+
blockers.push(prevBatchId);
|
|
5489
|
+
const blocks2 = batchAssetOfflineIds;
|
|
5490
|
+
blocks2.push(batchId);
|
|
5491
|
+
const promise = this.client.enqueueRequest({
|
|
5492
|
+
description: "Batch create assets",
|
|
5493
|
+
method: HttpMethod.POST,
|
|
5494
|
+
url: `/assets/types/${assetTypeId}/add-assets/`,
|
|
5495
|
+
queryParams: {
|
|
5496
|
+
workspace_id: workspaceId.toString()
|
|
5497
|
+
},
|
|
5498
|
+
payload,
|
|
5499
|
+
blockers,
|
|
5500
|
+
blocks: blocks2
|
|
5501
|
+
});
|
|
5502
|
+
prevBatchId = assetBatch.batchId;
|
|
5503
|
+
batchPromises.push(promise);
|
|
5504
|
+
}
|
|
5505
|
+
void Promise.all(batchPromises).then((result) => {
|
|
5506
|
+
const allCreatedAssets = result.flat();
|
|
5507
|
+
store.dispatch(addAssetsInBatches(allCreatedAssets));
|
|
5475
5508
|
});
|
|
5476
|
-
return
|
|
5509
|
+
return batchPromises;
|
|
5477
5510
|
}
|
|
5478
5511
|
async refreshStore() {
|
|
5479
5512
|
const { store } = this.client;
|
|
@@ -6607,6 +6640,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6607
6640
|
store.dispatch(addOrReplaceProjects(projects));
|
|
6608
6641
|
store.dispatch(addOrReplaceWorkspaces(workspaces));
|
|
6609
6642
|
}
|
|
6643
|
+
console.debug("currentProjectId", currentProjectId);
|
|
6610
6644
|
if (!currentProjectId) {
|
|
6611
6645
|
store.dispatch(setIsFetchingInitialData(false));
|
|
6612
6646
|
} else {
|
|
@@ -6965,8 +6999,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6965
6999
|
});
|
|
6966
7000
|
}
|
|
6967
7001
|
}
|
|
6968
|
-
const separateImageFromFields = async (
|
|
6969
|
-
const { fields } = payload;
|
|
7002
|
+
const separateImageFromFields = async (fields) => {
|
|
6970
7003
|
const images = {};
|
|
6971
7004
|
const newFields = [];
|
|
6972
7005
|
for (const section of fields) {
|
|
@@ -6992,11 +7025,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6992
7025
|
}
|
|
6993
7026
|
newFields.push({ ...section, fields: newSectionFields });
|
|
6994
7027
|
}
|
|
6995
|
-
|
|
6996
|
-
...payload,
|
|
6997
|
-
fields: newFields
|
|
6998
|
-
};
|
|
6999
|
-
return { payloadWithoutImage, images };
|
|
7028
|
+
return { fields: newFields, images };
|
|
7000
7029
|
};
|
|
7001
7030
|
class UserFormService extends BaseApiService {
|
|
7002
7031
|
constructor() {
|
|
@@ -7030,93 +7059,90 @@ var __publicField = (obj, key, value) => {
|
|
|
7030
7059
|
});
|
|
7031
7060
|
});
|
|
7032
7061
|
}
|
|
7033
|
-
async add(
|
|
7034
|
-
if (!!ownerUser === !!ownerOrganization) {
|
|
7035
|
-
throw new Error("Exactly one of ownerUser and ownerOrganization must be defined.");
|
|
7036
|
-
}
|
|
7037
|
-
const ownerAttrs = {
|
|
7038
|
-
owner_user: ownerUser,
|
|
7039
|
-
owner_organization: ownerOrganization
|
|
7040
|
-
};
|
|
7041
|
-
const currentUser = state.userReducer.currentUser;
|
|
7042
|
-
const activeWorkspaceId = state.workspaceReducer.activeWorkspaceId;
|
|
7043
|
-
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7044
|
-
const offlineFormPayload = offline({ ...ownerAttrs });
|
|
7045
|
-
const offlineRevisionPayload = offline({ ...initialRevision, submitted_at: submittedAt });
|
|
7046
|
-
const retForm = {
|
|
7047
|
-
...offlineFormPayload,
|
|
7048
|
-
index_workspace: activeWorkspaceId,
|
|
7049
|
-
favorite: true,
|
|
7050
|
-
submitted_at: submittedAt,
|
|
7051
|
-
created_by: currentUser.id,
|
|
7052
|
-
...assetTypeId && { asset_type: assetTypeId },
|
|
7053
|
-
...issueTypeId && { issue_type: issueTypeId },
|
|
7054
|
-
...ownerAttrs
|
|
7055
|
-
};
|
|
7056
|
-
const { payloadWithoutImage, images } = await separateImageFromFields(offlineRevisionPayload);
|
|
7057
|
-
const retRevision = {
|
|
7058
|
-
...payloadWithoutImage,
|
|
7059
|
-
created_by: currentUser.id,
|
|
7060
|
-
form: retForm.offline_id,
|
|
7061
|
-
revision: 0,
|
|
7062
|
-
submitted_at: submittedAt
|
|
7063
|
-
};
|
|
7062
|
+
async add(ownerId, form, initialRevision, urlPrefix) {
|
|
7064
7063
|
const { store } = this.client;
|
|
7065
|
-
|
|
7066
|
-
|
|
7064
|
+
const { fields, images } = await separateImageFromFields(initialRevision.fields);
|
|
7065
|
+
const offlineFormRevision = offline({
|
|
7066
|
+
...initialRevision,
|
|
7067
|
+
fields,
|
|
7068
|
+
created_by: form.created_by,
|
|
7069
|
+
form: form.offline_id,
|
|
7070
|
+
submitted_at: form.submitted_at,
|
|
7071
|
+
revision: "Pending"
|
|
7072
|
+
});
|
|
7073
|
+
store.dispatch(addForm(form));
|
|
7074
|
+
store.dispatch(addFormRevision(offlineFormRevision));
|
|
7067
7075
|
const formPromise = this.client.enqueueRequest({
|
|
7068
7076
|
description: "Create form",
|
|
7069
7077
|
method: HttpMethod.POST,
|
|
7070
|
-
url,
|
|
7071
|
-
queryParams: activeWorkspaceId ? {
|
|
7072
|
-
workspace_id: activeWorkspaceId
|
|
7073
|
-
} : void 0,
|
|
7078
|
+
url: urlPrefix,
|
|
7074
7079
|
payload: {
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7080
|
+
// Sending exactly what is currently needed for the endpoint
|
|
7081
|
+
offline_id: form.offline_id,
|
|
7082
|
+
initial_revision: {
|
|
7083
|
+
offline_id: offlineFormRevision.offline_id,
|
|
7084
|
+
submitted_at: offlineFormRevision.submitted_at,
|
|
7085
|
+
title: offlineFormRevision.title,
|
|
7086
|
+
description: offlineFormRevision.description,
|
|
7087
|
+
fields: offlineFormRevision.fields
|
|
7088
|
+
}
|
|
7079
7089
|
},
|
|
7080
|
-
blockers:
|
|
7081
|
-
blocks: [
|
|
7090
|
+
blockers: [ownerId],
|
|
7091
|
+
blocks: [form.offline_id, offlineFormRevision.offline_id]
|
|
7082
7092
|
});
|
|
7083
|
-
const attachImagesPromises = this.getAttachImagePromises(images,
|
|
7093
|
+
const attachImagesPromises = this.getAttachImagePromises(images, offlineFormRevision.offline_id);
|
|
7084
7094
|
void formPromise.catch((e) => {
|
|
7085
|
-
store.dispatch(deleteForm(
|
|
7086
|
-
store.dispatch(deleteFormRevision(
|
|
7095
|
+
store.dispatch(deleteForm(form.offline_id));
|
|
7096
|
+
store.dispatch(deleteFormRevision(offlineFormRevision.offline_id));
|
|
7087
7097
|
throw e;
|
|
7088
7098
|
});
|
|
7089
7099
|
const settledPromise = Promise.all([formPromise, ...attachImagesPromises]).then(() => formPromise);
|
|
7090
|
-
return [
|
|
7100
|
+
return [form, offlineFormRevision, formPromise, settledPromise];
|
|
7091
7101
|
}
|
|
7092
|
-
|
|
7102
|
+
addForOrganization(organizationId, initialRevision) {
|
|
7093
7103
|
const state = this.client.store.getState();
|
|
7094
|
-
const
|
|
7095
|
-
|
|
7096
|
-
|
|
7097
|
-
|
|
7098
|
-
|
|
7099
|
-
|
|
7104
|
+
const offlineForm = offline({
|
|
7105
|
+
favorite: false,
|
|
7106
|
+
created_by: state.userReducer.currentUser.id,
|
|
7107
|
+
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7108
|
+
organization: organizationId
|
|
7109
|
+
});
|
|
7110
|
+
return this.add(
|
|
7111
|
+
organizationId.toString(),
|
|
7112
|
+
offlineForm,
|
|
7100
7113
|
initialRevision,
|
|
7101
|
-
`/
|
|
7102
|
-
void 0,
|
|
7103
|
-
activeOrganizationId,
|
|
7104
|
-
attachedTo && "assetTypeId" in attachedTo ? attachedTo.assetTypeId : void 0,
|
|
7105
|
-
attachedTo && "issueTypeId" in attachedTo ? attachedTo.issueTypeId : void 0
|
|
7114
|
+
`/organizations/${organizationId}/create-form/`
|
|
7106
7115
|
);
|
|
7107
7116
|
}
|
|
7108
|
-
|
|
7117
|
+
addForProject(projectId, initialRevision) {
|
|
7109
7118
|
const state = this.client.store.getState();
|
|
7110
|
-
const
|
|
7111
|
-
|
|
7112
|
-
state,
|
|
7113
|
-
|
|
7114
|
-
|
|
7115
|
-
|
|
7116
|
-
|
|
7117
|
-
|
|
7118
|
-
|
|
7119
|
-
);
|
|
7119
|
+
const offlineForm = offline({
|
|
7120
|
+
favorite: false,
|
|
7121
|
+
created_by: state.userReducer.currentUser.id,
|
|
7122
|
+
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7123
|
+
project: projectId
|
|
7124
|
+
});
|
|
7125
|
+
return this.add(projectId.toString(), offlineForm, initialRevision, `/projects/${projectId}/create-form/`);
|
|
7126
|
+
}
|
|
7127
|
+
addForIssueType(issueTypeId, initialRevision) {
|
|
7128
|
+
const state = this.client.store.getState();
|
|
7129
|
+
const offlineForm = offline({
|
|
7130
|
+
favorite: false,
|
|
7131
|
+
created_by: state.userReducer.currentUser.id,
|
|
7132
|
+
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7133
|
+
issue_type: issueTypeId
|
|
7134
|
+
});
|
|
7135
|
+
return this.add(issueTypeId, offlineForm, initialRevision, `/issues/types/${issueTypeId}/create-form/`);
|
|
7136
|
+
}
|
|
7137
|
+
addForAssetType(assetTypeId, initialRevision) {
|
|
7138
|
+
const state = this.client.store.getState();
|
|
7139
|
+
const offlineForm = offline({
|
|
7140
|
+
favorite: false,
|
|
7141
|
+
created_by: state.userReducer.currentUser.id,
|
|
7142
|
+
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
7143
|
+
asset_type: assetTypeId
|
|
7144
|
+
});
|
|
7145
|
+
return this.add(assetTypeId, offlineForm, initialRevision, `/assets/types/${assetTypeId}/create-form/`);
|
|
7120
7146
|
}
|
|
7121
7147
|
async createRevision(formId2, revision) {
|
|
7122
7148
|
const offlineRevision = offline(revision);
|
|
@@ -7127,9 +7153,10 @@ var __publicField = (obj, key, value) => {
|
|
|
7127
7153
|
throw new Error("Cannot create form revision when there is no active project.");
|
|
7128
7154
|
}
|
|
7129
7155
|
const currentUserId = state.userReducer.currentUser.id;
|
|
7130
|
-
const {
|
|
7156
|
+
const { fields, images } = await separateImageFromFields(offlineRevision.fields);
|
|
7131
7157
|
const fullRevision = {
|
|
7132
|
-
...
|
|
7158
|
+
...offlineRevision,
|
|
7159
|
+
fields,
|
|
7133
7160
|
created_by: currentUserId,
|
|
7134
7161
|
revision: "Pending",
|
|
7135
7162
|
form: formId2,
|
|
@@ -7140,9 +7167,14 @@ var __publicField = (obj, key, value) => {
|
|
|
7140
7167
|
description: "Create form revision",
|
|
7141
7168
|
method: HttpMethod.PATCH,
|
|
7142
7169
|
url: `/forms/${formId2}/`,
|
|
7143
|
-
payload: {
|
|
7144
|
-
|
|
7145
|
-
|
|
7170
|
+
payload: {
|
|
7171
|
+
initial_revision: {
|
|
7172
|
+
offline_id: fullRevision.offline_id,
|
|
7173
|
+
submitted_at: fullRevision.submitted_at,
|
|
7174
|
+
title: fullRevision.title,
|
|
7175
|
+
description: fullRevision.description,
|
|
7176
|
+
fields: fullRevision.fields
|
|
7177
|
+
}
|
|
7146
7178
|
},
|
|
7147
7179
|
blockers: [formId2],
|
|
7148
7180
|
blocks: [offlineRevision.offline_id]
|
|
@@ -7227,16 +7259,68 @@ var __publicField = (obj, key, value) => {
|
|
|
7227
7259
|
}
|
|
7228
7260
|
async refreshStore() {
|
|
7229
7261
|
const { store } = this.client;
|
|
7230
|
-
const
|
|
7231
|
-
|
|
7262
|
+
const activeProjectId = store.getState().projectReducer.activeProjectId;
|
|
7263
|
+
if (!activeProjectId) {
|
|
7264
|
+
throw new Error("No active project");
|
|
7265
|
+
}
|
|
7266
|
+
const forms = [];
|
|
7267
|
+
const revisions = [];
|
|
7268
|
+
const attachments = [];
|
|
7269
|
+
const projectFormsResult = await this.client.enqueueRequest({
|
|
7270
|
+
description: "Fetch project forms",
|
|
7232
7271
|
method: HttpMethod.GET,
|
|
7233
|
-
url: `/
|
|
7234
|
-
blockers: [],
|
|
7272
|
+
url: `/projects/${activeProjectId}/forms/`,
|
|
7273
|
+
blockers: [activeProjectId.toString()],
|
|
7274
|
+
blocks: []
|
|
7275
|
+
});
|
|
7276
|
+
for (const form of projectFormsResult.forms)
|
|
7277
|
+
forms.push(form);
|
|
7278
|
+
for (const revision of projectFormsResult.revisions)
|
|
7279
|
+
revisions.push(revision);
|
|
7280
|
+
for (const attachment of projectFormsResult.attachments)
|
|
7281
|
+
attachments.push(attachment);
|
|
7282
|
+
const organizationFormsResult = await this.client.enqueueRequest({
|
|
7283
|
+
description: "Fetch organization forms",
|
|
7284
|
+
method: HttpMethod.GET,
|
|
7285
|
+
url: `/projects/${activeProjectId}/organizations/forms/`,
|
|
7286
|
+
blockers: [activeProjectId.toString()],
|
|
7287
|
+
blocks: []
|
|
7288
|
+
});
|
|
7289
|
+
for (const form of organizationFormsResult.forms)
|
|
7290
|
+
forms.push(form);
|
|
7291
|
+
for (const revision of organizationFormsResult.revisions)
|
|
7292
|
+
revisions.push(revision);
|
|
7293
|
+
for (const attachment of organizationFormsResult.attachments)
|
|
7294
|
+
attachments.push(attachment);
|
|
7295
|
+
const assetTypeFormsResult = await this.client.enqueueRequest({
|
|
7296
|
+
description: "Fetch asset type forms",
|
|
7297
|
+
method: HttpMethod.GET,
|
|
7298
|
+
url: `/projects/${activeProjectId}/asset-types/forms/`,
|
|
7299
|
+
blockers: [activeProjectId.toString()],
|
|
7235
7300
|
blocks: []
|
|
7236
7301
|
});
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
|
|
7302
|
+
for (const form of assetTypeFormsResult.forms)
|
|
7303
|
+
forms.push(form);
|
|
7304
|
+
for (const revision of assetTypeFormsResult.latest_revisions)
|
|
7305
|
+
revisions.push(revision);
|
|
7306
|
+
for (const attachment of assetTypeFormsResult.attachments)
|
|
7307
|
+
attachments.push(attachment);
|
|
7308
|
+
const issueTypeFormsResult = await this.client.enqueueRequest({
|
|
7309
|
+
description: "Fetch issue type forms",
|
|
7310
|
+
method: HttpMethod.GET,
|
|
7311
|
+
url: `/projects/${activeProjectId}/issue-types/forms/`,
|
|
7312
|
+
blockers: [activeProjectId.toString()],
|
|
7313
|
+
blocks: []
|
|
7314
|
+
});
|
|
7315
|
+
for (const form of issueTypeFormsResult.forms)
|
|
7316
|
+
forms.push(form);
|
|
7317
|
+
for (const revision of issueTypeFormsResult.latest_revisions)
|
|
7318
|
+
revisions.push(revision);
|
|
7319
|
+
for (const attachment of issueTypeFormsResult.attachments)
|
|
7320
|
+
attachments.push(attachment);
|
|
7321
|
+
store.dispatch(setForms(forms));
|
|
7322
|
+
store.dispatch(setFormRevisions(revisions));
|
|
7323
|
+
store.dispatch(setFormRevisionAttachments(attachments));
|
|
7240
7324
|
}
|
|
7241
7325
|
}
|
|
7242
7326
|
const isArrayOfFiles = (value) => {
|
|
@@ -7339,100 +7423,120 @@ var __publicField = (obj, key, value) => {
|
|
|
7339
7423
|
}
|
|
7340
7424
|
// Note currently the bulkAdd method is specific to form submissions for assets
|
|
7341
7425
|
// TODO: adapt the support bulk adding to any model type
|
|
7342
|
-
async bulkAdd(args) {
|
|
7343
|
-
const { formRevision, values: argsValues, assetOfflineIds } = args;
|
|
7426
|
+
async bulkAdd(args, batchSize) {
|
|
7344
7427
|
const { store } = this.client;
|
|
7345
|
-
const
|
|
7346
|
-
const
|
|
7347
|
-
const
|
|
7348
|
-
const submissionsPayload = [];
|
|
7349
|
-
const attachmentsPayload = [];
|
|
7350
|
-
const { values, files } = separateFilesFromValues(argsValues);
|
|
7428
|
+
const { formRevision, commonFieldValues, fieldValuesByAsset } = args;
|
|
7429
|
+
const allFilesRecord = {};
|
|
7430
|
+
const { values: fileSeperatedCommonFieldValues, files: commonFiles } = separateFilesFromValues(commonFieldValues);
|
|
7351
7431
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7352
|
-
const
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
const sha1 = await hashFile(file);
|
|
7367
|
-
await this.client.files.addCache(file, sha1);
|
|
7368
|
-
const offlineAttachment = offline({
|
|
7369
|
-
file_name: file.name,
|
|
7370
|
-
file_sha1: sha1,
|
|
7371
|
-
file: URL.createObjectURL(file),
|
|
7372
|
-
submission: submission.offline_id,
|
|
7373
|
-
field_identifier: fieldIdentifier
|
|
7432
|
+
const transactionId = uuid.v4();
|
|
7433
|
+
const assetIdBatches = chunkArray(Object.keys(fieldValuesByAsset), batchSize);
|
|
7434
|
+
const bulkAddBatches = await Promise.all(
|
|
7435
|
+
assetIdBatches.map(async (assetIdBatch) => {
|
|
7436
|
+
const batchId = uuid.v4();
|
|
7437
|
+
const submissionPayloads = [];
|
|
7438
|
+
const attachmentPayloads = [];
|
|
7439
|
+
const files = { ...commonFiles };
|
|
7440
|
+
for (const assetId of assetIdBatch) {
|
|
7441
|
+
const { values: fileSeperatedSubmissionSpecificValues, files: submissionSpecificFiles } = separateFilesFromValues(fieldValuesByAsset[assetId] ?? {});
|
|
7442
|
+
Object.assign(files, submissionSpecificFiles);
|
|
7443
|
+
const submissionPayload = offline({
|
|
7444
|
+
asset_id: assetId,
|
|
7445
|
+
form_data: fileSeperatedSubmissionSpecificValues
|
|
7374
7446
|
});
|
|
7375
|
-
|
|
7376
|
-
|
|
7377
|
-
|
|
7378
|
-
|
|
7447
|
+
submissionPayloads.push(submissionPayload);
|
|
7448
|
+
for (const [fieldIdentifier, fileArray] of Object.entries(files)) {
|
|
7449
|
+
for (const file of fileArray) {
|
|
7450
|
+
const sha1 = await hashFile(file);
|
|
7451
|
+
await this.client.files.addCache(file, sha1);
|
|
7452
|
+
const attachmentPayload = offline({
|
|
7453
|
+
submission_id: submissionPayload.offline_id,
|
|
7454
|
+
sha1,
|
|
7455
|
+
name: file.name,
|
|
7456
|
+
field_identifier: fieldIdentifier
|
|
7457
|
+
});
|
|
7458
|
+
attachmentPayloads.push(attachmentPayload);
|
|
7459
|
+
}
|
|
7460
|
+
}
|
|
7461
|
+
}
|
|
7462
|
+
const filePaylods = [];
|
|
7463
|
+
for (const file of Object.values(files).flat()) {
|
|
7464
|
+
const sha1 = await hashFile(file);
|
|
7465
|
+
const filePayload = {
|
|
7379
7466
|
sha1,
|
|
7380
|
-
|
|
7381
|
-
|
|
7467
|
+
extension: file.name.split(".").pop() || "",
|
|
7468
|
+
file_type: file.type,
|
|
7469
|
+
size: file.size
|
|
7470
|
+
};
|
|
7471
|
+
allFilesRecord[sha1] = filePayload;
|
|
7472
|
+
filePaylods.push(filePayload);
|
|
7473
|
+
}
|
|
7474
|
+
return {
|
|
7475
|
+
batchId,
|
|
7476
|
+
payload: {
|
|
7477
|
+
transaction_id: transactionId,
|
|
7478
|
+
form_data: fileSeperatedCommonFieldValues,
|
|
7479
|
+
submitted_at: submittedAt,
|
|
7480
|
+
submissions: submissionPayloads,
|
|
7481
|
+
attachments: attachmentPayloads,
|
|
7482
|
+
files: filePaylods
|
|
7483
|
+
}
|
|
7484
|
+
};
|
|
7485
|
+
})
|
|
7486
|
+
);
|
|
7487
|
+
const batchPromises = [];
|
|
7488
|
+
let prevBatchId = null;
|
|
7489
|
+
for (const batch of bulkAddBatches) {
|
|
7490
|
+
const { payload, batchId } = batch;
|
|
7491
|
+
const batchAssetIds = payload.submissions.map((x) => x.asset_id);
|
|
7492
|
+
const batchSubmissionOfflineIds = payload.submissions.map((x) => x.offline_id);
|
|
7493
|
+
const batchAttachmentsOfflineIds = payload.attachments.map((x) => x.offline_id);
|
|
7494
|
+
const blockers = batchAssetIds;
|
|
7495
|
+
if (prevBatchId)
|
|
7496
|
+
blockers.push(prevBatchId);
|
|
7497
|
+
const blocks2 = [...batchSubmissionOfflineIds, ...batchAttachmentsOfflineIds, batchId];
|
|
7498
|
+
const promise = this.client.enqueueRequest({
|
|
7499
|
+
description: "Bulk add form submissions",
|
|
7500
|
+
method: HttpMethod.POST,
|
|
7501
|
+
url: `/forms/revisions/${formRevision}/bulk-respond/`,
|
|
7502
|
+
payload,
|
|
7503
|
+
blockers,
|
|
7504
|
+
blocks: blocks2
|
|
7505
|
+
});
|
|
7506
|
+
void promise.then(({ presigned_urls }) => {
|
|
7507
|
+
for (const [sha1, presignedUrl] of Object.entries(presigned_urls)) {
|
|
7508
|
+
const file = allFilesRecord[sha1];
|
|
7509
|
+
if (!file)
|
|
7510
|
+
continue;
|
|
7511
|
+
void this.client.enqueueRequest({
|
|
7512
|
+
url: presignedUrl.url,
|
|
7513
|
+
description: "Upload file",
|
|
7514
|
+
method: HttpMethod.POST,
|
|
7515
|
+
isExternalUrl: true,
|
|
7516
|
+
isAuthNeeded: false,
|
|
7517
|
+
attachmentHash: sha1,
|
|
7518
|
+
blockers: [`s3-${file.sha1}.${file.extension}`],
|
|
7519
|
+
blocks: [sha1],
|
|
7520
|
+
s3url: presignedUrl
|
|
7382
7521
|
});
|
|
7383
7522
|
}
|
|
7384
|
-
}
|
|
7385
|
-
|
|
7386
|
-
|
|
7387
|
-
|
|
7388
|
-
|
|
7389
|
-
|
|
7390
|
-
|
|
7391
|
-
|
|
7392
|
-
|
|
7393
|
-
|
|
7394
|
-
|
|
7395
|
-
|
|
7396
|
-
|
|
7397
|
-
|
|
7398
|
-
|
|
7399
|
-
description: "Bulk add form submissions",
|
|
7400
|
-
method: HttpMethod.POST,
|
|
7401
|
-
url: `/forms/revisions/${formRevision}/bulk-respond/`,
|
|
7402
|
-
payload: {
|
|
7403
|
-
form_data: values,
|
|
7404
|
-
submitted_at: submittedAt,
|
|
7405
|
-
submissions: submissionsPayload,
|
|
7406
|
-
attachments: attachmentsPayload,
|
|
7407
|
-
files: Object.values(filesRecord)
|
|
7408
|
-
},
|
|
7409
|
-
blockers: assetOfflineIds,
|
|
7410
|
-
blocks: submissionOfflineIds
|
|
7411
|
-
});
|
|
7412
|
-
promise.then(({ submissions, attachments, presigned_urls }) => {
|
|
7413
|
-
store.dispatch(updateFormSubmissions(submissions));
|
|
7414
|
-
store.dispatch(updateFormSubmissionAttachments(attachments));
|
|
7415
|
-
for (const [sha1, presigned_url] of Object.entries(presigned_urls)) {
|
|
7416
|
-
const file = filesRecord[sha1];
|
|
7417
|
-
if (!file)
|
|
7418
|
-
continue;
|
|
7419
|
-
void this.client.enqueueRequest({
|
|
7420
|
-
url: presigned_url.url,
|
|
7421
|
-
description: "Upload file",
|
|
7422
|
-
method: HttpMethod.POST,
|
|
7423
|
-
isExternalUrl: true,
|
|
7424
|
-
isAuthNeeded: false,
|
|
7425
|
-
attachmentHash: sha1,
|
|
7426
|
-
blockers: [`s3-${file.sha1}.${file.extension}`],
|
|
7427
|
-
blocks: [sha1],
|
|
7428
|
-
s3url: presigned_url
|
|
7429
|
-
});
|
|
7430
|
-
}
|
|
7431
|
-
}).catch(() => {
|
|
7432
|
-
store.dispatch(deleteFormSubmissions(submissionOfflineIds));
|
|
7433
|
-
store.dispatch(deleteFormSubmissionAttachments(offlineAttachments.map((x) => x.offline_id)));
|
|
7523
|
+
});
|
|
7524
|
+
prevBatchId = batchId;
|
|
7525
|
+
batchPromises.push(promise);
|
|
7526
|
+
}
|
|
7527
|
+
void Promise.all(batchPromises).then((results) => {
|
|
7528
|
+
const createdSubmissions = [];
|
|
7529
|
+
const createdAttachments = [];
|
|
7530
|
+
for (const result of results) {
|
|
7531
|
+
for (const createdSubmission of result.submissions)
|
|
7532
|
+
createdSubmissions.push(createdSubmission);
|
|
7533
|
+
for (const createdAttachment of result.attachments)
|
|
7534
|
+
createdAttachments.push(createdAttachment);
|
|
7535
|
+
}
|
|
7536
|
+
store.dispatch(addFormSubmissions(createdSubmissions));
|
|
7537
|
+
store.dispatch(addFormSubmissionAttachments(createdAttachments));
|
|
7434
7538
|
});
|
|
7435
|
-
return
|
|
7539
|
+
return batchPromises;
|
|
7436
7540
|
}
|
|
7437
7541
|
update(submission) {
|
|
7438
7542
|
const { store } = this.client;
|
|
@@ -8787,6 +8891,12 @@ var __publicField = (obj, key, value) => {
|
|
|
8787
8891
|
getFormValidators() {
|
|
8788
8892
|
return [...this.formValidators];
|
|
8789
8893
|
}
|
|
8894
|
+
encodeValueToJson(value) {
|
|
8895
|
+
return JSON.stringify(value);
|
|
8896
|
+
}
|
|
8897
|
+
decodeJsonToValue(json) {
|
|
8898
|
+
return JSON.parse(json);
|
|
8899
|
+
}
|
|
8790
8900
|
}
|
|
8791
8901
|
__publicField(BaseField, "fieldTypeName");
|
|
8792
8902
|
__publicField(BaseField, "fieldTypeDescription");
|
|
@@ -13040,10 +13150,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13040
13150
|
helpText = showInputOnly ? null : helpText;
|
|
13041
13151
|
label = showInputOnly ? "" : label;
|
|
13042
13152
|
const color = blocks.useSeverityColor(severity);
|
|
13043
|
-
const value = React.useMemo(
|
|
13044
|
-
() => Array.isArray(fieldProps.value) ? fieldProps.value : [],
|
|
13045
|
-
[fieldProps.value]
|
|
13046
|
-
);
|
|
13153
|
+
const value = React.useMemo(() => Array.isArray(fieldProps.value) ? fieldProps.value : [], [fieldProps.value]);
|
|
13047
13154
|
const { onChange, onBlur } = fieldProps;
|
|
13048
13155
|
const droppableId = `${inputId}-droppable`;
|
|
13049
13156
|
const { disabled } = rest;
|
|
@@ -13060,7 +13167,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13060
13167
|
);
|
|
13061
13168
|
const handleChange = React.useCallback(
|
|
13062
13169
|
(e) => {
|
|
13063
|
-
if (value.findIndex((option) => option
|
|
13170
|
+
if (value.findIndex((option) => option === e.target.value.trim()) >= 0) {
|
|
13064
13171
|
setInternalError("All options must be unique");
|
|
13065
13172
|
} else if (!e.target.value) {
|
|
13066
13173
|
setInternalError("Option cannot be empty");
|
|
@@ -13079,7 +13186,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13079
13186
|
return;
|
|
13080
13187
|
}
|
|
13081
13188
|
const trimmedValue = intermediateValue.trim();
|
|
13082
|
-
setValueAndTouched([...value,
|
|
13189
|
+
setValueAndTouched([...value, trimmedValue]);
|
|
13083
13190
|
setIntermediateValue("");
|
|
13084
13191
|
}, [intermediateValue, internalError, setValueAndTouched, value]);
|
|
13085
13192
|
const handleKeyDown = React.useCallback(
|
|
@@ -13149,7 +13256,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13149
13256
|
value.map((option, index2) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
13150
13257
|
dnd.Draggable,
|
|
13151
13258
|
{
|
|
13152
|
-
draggableId: `${option
|
|
13259
|
+
draggableId: `${option}-draggable`,
|
|
13153
13260
|
index: index2,
|
|
13154
13261
|
isDragDisabled: disabled,
|
|
13155
13262
|
children: ({ draggableProps, dragHandleProps, innerRef }) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -13164,7 +13271,10 @@ var __publicField = (obj, key, value) => {
|
|
|
13164
13271
|
mb: "1",
|
|
13165
13272
|
asChild: true,
|
|
13166
13273
|
children: /* @__PURE__ */ jsxRuntime.jsxs(blocks.Badge, { color: "gray", size: "2", children: [
|
|
13167
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", {
|
|
13274
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", {
|
|
13275
|
+
// TODO: remove this, its just a saftey check for old compatibility of what was acceptable as a value for multi string
|
|
13276
|
+
children: typeof option === "object" && "label" in option ? option.label : option
|
|
13277
|
+
}),
|
|
13168
13278
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
13169
13279
|
blocks.IconButton,
|
|
13170
13280
|
{
|
|
@@ -13184,7 +13294,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13184
13294
|
}
|
|
13185
13295
|
)
|
|
13186
13296
|
},
|
|
13187
|
-
option
|
|
13297
|
+
option
|
|
13188
13298
|
)),
|
|
13189
13299
|
droppableProvided.placeholder
|
|
13190
13300
|
] }) })
|
|
@@ -14859,6 +14969,44 @@ var __publicField = (obj, key, value) => {
|
|
|
14859
14969
|
meta: { readonly }
|
|
14860
14970
|
};
|
|
14861
14971
|
}
|
|
14972
|
+
function flattenFields(schema) {
|
|
14973
|
+
const allFields = [];
|
|
14974
|
+
for (const field of schema.fields) {
|
|
14975
|
+
if (field instanceof FieldSection) {
|
|
14976
|
+
for (const subField of field.fields) {
|
|
14977
|
+
allFields.push(subField);
|
|
14978
|
+
}
|
|
14979
|
+
} else {
|
|
14980
|
+
if (!(field instanceof BaseField)) {
|
|
14981
|
+
throw new Error(`Invalid field type: ${field.type}`);
|
|
14982
|
+
}
|
|
14983
|
+
allFields.push(field);
|
|
14984
|
+
}
|
|
14985
|
+
}
|
|
14986
|
+
return allFields;
|
|
14987
|
+
}
|
|
14988
|
+
function decodeFormValues(schema, values) {
|
|
14989
|
+
const allFields = flattenFields(schema);
|
|
14990
|
+
const result = {};
|
|
14991
|
+
for (const field of allFields) {
|
|
14992
|
+
const value = values[field.identifier] ?? null;
|
|
14993
|
+
if (value !== null) {
|
|
14994
|
+
result[field.identifier] = field.decodeJsonToValue(value);
|
|
14995
|
+
} else {
|
|
14996
|
+
result[field.identifier] = value;
|
|
14997
|
+
}
|
|
14998
|
+
}
|
|
14999
|
+
return result;
|
|
15000
|
+
}
|
|
15001
|
+
function encodeFormValues(schema, values) {
|
|
15002
|
+
const allFields = flattenFields(schema);
|
|
15003
|
+
const result = {};
|
|
15004
|
+
for (const field of allFields) {
|
|
15005
|
+
const value = values[field.identifier];
|
|
15006
|
+
result[field.identifier] = field.encodeValueToJson(value);
|
|
15007
|
+
}
|
|
15008
|
+
return result;
|
|
15009
|
+
}
|
|
14862
15010
|
function valueIsFile(v) {
|
|
14863
15011
|
return Array.isArray(v) && v.some((v2) => v2 instanceof File || v2 instanceof Promise);
|
|
14864
15012
|
}
|
|
@@ -15235,7 +15383,6 @@ var __publicField = (obj, key, value) => {
|
|
|
15235
15383
|
regularIcon
|
|
15236
15384
|
};
|
|
15237
15385
|
const orgOptionPrefix = "organization:";
|
|
15238
|
-
const userOptionPrefix = "user:";
|
|
15239
15386
|
const FormBrowser = React.memo(
|
|
15240
15387
|
React.forwardRef((props, ref) => {
|
|
15241
15388
|
const { maxResults = 20, ...entryProps } = props;
|
|
@@ -15246,9 +15393,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15246
15393
|
const ret = { maxResults, searchTerm: filter };
|
|
15247
15394
|
if (ownerFilter) {
|
|
15248
15395
|
if (ownerFilter.startsWith(orgOptionPrefix)) {
|
|
15249
|
-
ret.
|
|
15250
|
-
} else if (ownerFilter.startsWith(userOptionPrefix)) {
|
|
15251
|
-
ret.owner_user = parseInt(ownerFilter.slice(userOptionPrefix.length));
|
|
15396
|
+
ret.organization = parseInt(ownerFilter.slice(orgOptionPrefix.length));
|
|
15252
15397
|
}
|
|
15253
15398
|
}
|
|
15254
15399
|
return ret;
|
|
@@ -15273,14 +15418,10 @@ var __publicField = (obj, key, value) => {
|
|
|
15273
15418
|
const state = sdk.store.getState();
|
|
15274
15419
|
const accumulator = {};
|
|
15275
15420
|
for (const form of attachableUserFormMapping) {
|
|
15276
|
-
const organization = selectOrganization(form.
|
|
15421
|
+
const organization = selectOrganization(form.organization || -1)(state);
|
|
15277
15422
|
if (organization) {
|
|
15278
15423
|
accumulator[`${orgOptionPrefix}${organization.id}`] = organization.name;
|
|
15279
15424
|
}
|
|
15280
|
-
const user = selectUser(form.owner_user || -1)(state);
|
|
15281
|
-
if (user) {
|
|
15282
|
-
accumulator[`${userOptionPrefix}${user.id}`] = user.username;
|
|
15283
|
-
}
|
|
15284
15425
|
}
|
|
15285
15426
|
return Object.entries(accumulator).map(([value, label]) => ({ itemContent: label, value }));
|
|
15286
15427
|
}, [sdk.store, attachableUserFormMapping]);
|
|
@@ -15322,11 +15463,7 @@ var __publicField = (obj, key, value) => {
|
|
|
15322
15463
|
const FormBrowserEntry = (props) => {
|
|
15323
15464
|
var _a2;
|
|
15324
15465
|
const { form, onSelectForm, isFavoriteEditable, handleToggleFavorite } = props;
|
|
15325
|
-
const ownerOrganization = (_a2 = useAppSelector(selectOrganization(form.
|
|
15326
|
-
const ownerUser = useAppSelector(selectUser(form.owner_user || -1));
|
|
15327
|
-
const currentUserId = useAppSelector(selectCurrentUser).id;
|
|
15328
|
-
const ownedByCurrentUser = !!ownerUser && ownerUser.id === currentUserId;
|
|
15329
|
-
const owner = ownerOrganization ?? (ownedByCurrentUser ? "You" : ownerUser == null ? void 0 : ownerUser.username) ?? "Unknown";
|
|
15466
|
+
const ownerOrganization = (_a2 = useAppSelector(selectOrganization(form.organization || -1))) == null ? void 0 : _a2.name;
|
|
15330
15467
|
const handleFavoriteClick = React.useCallback(
|
|
15331
15468
|
(e) => {
|
|
15332
15469
|
e.stopPropagation();
|
|
@@ -15357,10 +15494,10 @@ var __publicField = (obj, key, value) => {
|
|
|
15357
15494
|
/* @__PURE__ */ jsxRuntime.jsx(blocks.Text, { noWrap: true, children: form.latestRevision.title }),
|
|
15358
15495
|
form.latestRevision.description && /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiQuestionLine" })
|
|
15359
15496
|
] }),
|
|
15360
|
-
|
|
15497
|
+
ownerOrganization && /* @__PURE__ */ jsxRuntime.jsxs(blocks.Flex, { align: "center", gap: "2", children: [
|
|
15361
15498
|
/* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiUserLine" }),
|
|
15362
15499
|
" ",
|
|
15363
|
-
|
|
15500
|
+
ownerOrganization
|
|
15364
15501
|
] })
|
|
15365
15502
|
] })
|
|
15366
15503
|
}
|
|
@@ -16640,6 +16777,7 @@ var __publicField = (obj, key, value) => {
|
|
|
16640
16777
|
StringInput,
|
|
16641
16778
|
TextField,
|
|
16642
16779
|
TextInput,
|
|
16780
|
+
decodeFormValues,
|
|
16643
16781
|
deserialize,
|
|
16644
16782
|
deserializeField,
|
|
16645
16783
|
emptyBaseField,
|
|
@@ -16652,11 +16790,15 @@ var __publicField = (obj, key, value) => {
|
|
|
16652
16790
|
emptySelectField,
|
|
16653
16791
|
emptyStringField,
|
|
16654
16792
|
emptyTextField,
|
|
16793
|
+
encodeFormValues,
|
|
16794
|
+
flattenFields,
|
|
16655
16795
|
formRevisionToSchema,
|
|
16796
|
+
initialFormValues,
|
|
16656
16797
|
isConditionMet,
|
|
16657
16798
|
useFieldInput,
|
|
16658
16799
|
useFieldInputs,
|
|
16659
16800
|
useFormikInput,
|
|
16801
|
+
validateForm,
|
|
16660
16802
|
valueIsFile
|
|
16661
16803
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
16662
16804
|
exports2.APIError = APIError;
|
|
@@ -16847,6 +16989,7 @@ var __publicField = (obj, key, value) => {
|
|
|
16847
16989
|
exports2.coordinatesToUrlText = coordinatesToUrlText;
|
|
16848
16990
|
exports2.createOfflineAction = createOfflineAction;
|
|
16849
16991
|
exports2.createPointMarker = createPointMarker;
|
|
16992
|
+
exports2.decodeFormValues = decodeFormValues;
|
|
16850
16993
|
exports2.defaultBadgeColor = defaultBadgeColor;
|
|
16851
16994
|
exports2.defaultStore = defaultStore;
|
|
16852
16995
|
exports2.deleteAssetType = deleteAssetType;
|
|
@@ -16882,6 +17025,7 @@ var __publicField = (obj, key, value) => {
|
|
|
16882
17025
|
exports2.emptySelectField = emptySelectField;
|
|
16883
17026
|
exports2.emptyStringField = emptyStringField;
|
|
16884
17027
|
exports2.emptyTextField = emptyTextField;
|
|
17028
|
+
exports2.encodeFormValues = encodeFormValues;
|
|
16885
17029
|
exports2.enqueue = enqueue;
|
|
16886
17030
|
exports2.enqueueRequest = enqueueRequest;
|
|
16887
17031
|
exports2.errorColor = errorColor;
|
|
@@ -16889,6 +17033,7 @@ var __publicField = (obj, key, value) => {
|
|
|
16889
17033
|
exports2.fileReducer = fileReducer;
|
|
16890
17034
|
exports2.fileSlice = fileSlice;
|
|
16891
17035
|
exports2.fileToBlob = fileToBlob;
|
|
17036
|
+
exports2.flattenFields = flattenFields;
|
|
16892
17037
|
exports2.flipCoordinates = flipCoordinates;
|
|
16893
17038
|
exports2.formReducer = formReducer;
|
|
16894
17039
|
exports2.formRevisionReducer = formRevisionReducer;
|
|
@@ -16912,6 +17057,7 @@ var __publicField = (obj, key, value) => {
|
|
|
16912
17057
|
exports2.hashFile = hashFile;
|
|
16913
17058
|
exports2.hideAllCategories = hideAllCategories;
|
|
16914
17059
|
exports2.hideCategory = hideCategory;
|
|
17060
|
+
exports2.initialFormValues = initialFormValues;
|
|
16915
17061
|
exports2.isConditionMet = isConditionMet;
|
|
16916
17062
|
exports2.isToday = isToday;
|
|
16917
17063
|
exports2.issueReducer = issueReducer;
|
|
@@ -16965,6 +17111,7 @@ var __publicField = (obj, key, value) => {
|
|
|
16965
17111
|
exports2.removeAssetAttachments = removeAssetAttachments;
|
|
16966
17112
|
exports2.removeAssetTypeAttachment = removeAssetTypeAttachment;
|
|
16967
17113
|
exports2.removeAssetTypeAttachments = removeAssetTypeAttachments;
|
|
17114
|
+
exports2.removeAssets = removeAssets;
|
|
16968
17115
|
exports2.removeAttachmentsOfIssue = removeAttachmentsOfIssue;
|
|
16969
17116
|
exports2.removeCategory = removeCategory;
|
|
16970
17117
|
exports2.removeColor = removeColor;
|
|
@@ -17282,6 +17429,7 @@ var __publicField = (obj, key, value) => {
|
|
|
17282
17429
|
exports2.updateAssetAttachments = updateAssetAttachments;
|
|
17283
17430
|
exports2.updateAssetTypeAttachment = updateAssetTypeAttachment;
|
|
17284
17431
|
exports2.updateAssetTypeAttachments = updateAssetTypeAttachments;
|
|
17432
|
+
exports2.updateAssets = updateAssets;
|
|
17285
17433
|
exports2.updateConversation = updateConversation;
|
|
17286
17434
|
exports2.updateDocumentAttachment = updateDocumentAttachment;
|
|
17287
17435
|
exports2.updateDocumentAttachments = updateDocumentAttachments;
|
|
@@ -17312,6 +17460,7 @@ var __publicField = (obj, key, value) => {
|
|
|
17312
17460
|
exports2.useSDK = useSDK;
|
|
17313
17461
|
exports2.userReducer = userReducer;
|
|
17314
17462
|
exports2.userSlice = userSlice;
|
|
17463
|
+
exports2.validateForm = validateForm;
|
|
17315
17464
|
exports2.valueIsFile = valueIsFile;
|
|
17316
17465
|
exports2.warningColor = warningColor;
|
|
17317
17466
|
exports2.workspaceReducer = workspaceReducer;
|