@overmap-ai/core 1.0.71-mapbox.6 → 1.0.71-mapbox.8
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/overmap-core.js +1913 -1079
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +1913 -1079
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/services/AssetAttachmentService.d.ts +29 -7
- package/dist/sdk/services/AssetService.d.ts +1 -1
- package/dist/sdk/services/AssetStageService.d.ts +1 -3
- package/dist/sdk/services/AssetTypeAttachmentService.d.ts +29 -8
- package/dist/sdk/services/AssetTypeFieldValuesAttachmentService.d.ts +13 -0
- package/dist/sdk/services/AssetTypeFieldValuesService.d.ts +21 -0
- package/dist/sdk/services/AssetTypeFieldsAttachmentService.d.ts +13 -0
- package/dist/sdk/services/AssetTypeFieldsService.d.ts +9 -0
- package/dist/sdk/services/AssetTypeService.d.ts +1 -1
- package/dist/sdk/services/BaseAttachmentService.d.ts +17 -19
- package/dist/sdk/services/BaseUploadService.d.ts +2 -1
- package/dist/sdk/services/DocumentAttachmentService.d.ts +27 -7
- package/dist/sdk/services/FormRevisionAttachmentService.d.ts +13 -0
- package/dist/sdk/services/FormRevisionService.d.ts +9 -0
- package/dist/sdk/services/FormService.d.ts +11 -14
- package/dist/sdk/services/FormSubmissionAttachmentService.d.ts +14 -0
- package/dist/sdk/services/FormSubmissionService.d.ts +8 -28
- package/dist/sdk/services/IssueAssociationService.d.ts +2 -2
- package/dist/sdk/services/IssueAttachmentService.d.ts +28 -7
- package/dist/sdk/services/IssueService.d.ts +0 -3
- package/dist/sdk/services/IssueTypeFieldValuesAttachmentService.d.ts +14 -0
- package/dist/sdk/services/IssueTypeFieldValuesService.d.ts +11 -0
- package/dist/sdk/services/IssueTypeFieldsAttachmentService.d.ts +13 -0
- package/dist/sdk/services/IssueTypeFieldsService.d.ts +9 -0
- package/dist/sdk/services/ProjectAttachmentService.d.ts +28 -7
- package/dist/sdk/services/index.d.ts +11 -0
- package/dist/store/slices/assetStageSlice.d.ts +0 -1
- package/dist/store/slices/assetTypeFieldValuesAttachmentSlice.d.ts +64 -0
- package/dist/store/slices/assetTypeFieldValuesSlice.d.ts +64 -0
- package/dist/store/slices/assetTypeFieldsAttachmentSlice.d.ts +63 -0
- package/dist/store/slices/assetTypeFieldsSlice.d.ts +64 -0
- package/dist/store/slices/formRevisionSlice.d.ts +1 -2
- package/dist/store/slices/formSlice.d.ts +1 -5
- package/dist/store/slices/formSubmissionSlice.d.ts +0 -6
- package/dist/store/slices/index.d.ts +8 -0
- package/dist/store/slices/issueTypeFieldValuesAttachmentSlice.d.ts +64 -0
- package/dist/store/slices/issueTypeFieldValuesSlice.d.ts +63 -0
- package/dist/store/slices/issueTypeFieldsAttachmentSlice.d.ts +63 -0
- package/dist/store/slices/issueTypeFieldsSlice.d.ts +65 -0
- package/dist/store/store.d.ts +9 -1
- package/dist/typings/files.d.ts +8 -4
- package/dist/typings/models/assets.d.ts +17 -2
- package/dist/typings/models/attachments.d.ts +1 -6
- package/dist/typings/models/fields.d.ts +17 -0
- package/dist/typings/models/forms.d.ts +12 -29
- package/dist/typings/models/index.d.ts +1 -0
- package/dist/typings/models/issues.d.ts +15 -0
- package/dist/typings/models/store.d.ts +9 -1
- package/dist/utils/file.d.ts +2 -2
- package/package.json +1 -1
package/dist/overmap-core.js
CHANGED
|
@@ -662,15 +662,15 @@ const wrapMigration = (migrator) => (state) => {
|
|
|
662
662
|
};
|
|
663
663
|
const migrations = [initialVersioning, signOut, signOut, createOutboxState];
|
|
664
664
|
const manifest = Object.fromEntries(migrations.map((migration2, i) => [i, wrapMigration(migration2)]));
|
|
665
|
-
const initialState$
|
|
665
|
+
const initialState$J = {
|
|
666
666
|
accessToken: "",
|
|
667
667
|
refreshToken: "",
|
|
668
668
|
isLoggedIn: false
|
|
669
669
|
};
|
|
670
670
|
const authSlice = createSlice({
|
|
671
671
|
name: "auth",
|
|
672
|
-
initialState: initialState$
|
|
673
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
672
|
+
initialState: initialState$J,
|
|
673
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$J)),
|
|
674
674
|
reducers: {
|
|
675
675
|
setTokens: (state, action) => {
|
|
676
676
|
state.accessToken = action.payload.accessToken;
|
|
@@ -758,11 +758,11 @@ function createModelAdapter(computeModelId) {
|
|
|
758
758
|
};
|
|
759
759
|
}
|
|
760
760
|
const categoryAdapter = createModelAdapter((category) => category.offline_id);
|
|
761
|
-
const initialState$
|
|
761
|
+
const initialState$I = categoryAdapter.getInitialState({});
|
|
762
762
|
const categorySlice = createSlice({
|
|
763
763
|
name: "categories",
|
|
764
|
-
initialState: initialState$
|
|
765
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
764
|
+
initialState: initialState$I,
|
|
765
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$I)),
|
|
766
766
|
reducers: {
|
|
767
767
|
initializeCategories: categoryAdapter.initialize,
|
|
768
768
|
addCategory: categoryAdapter.addOne,
|
|
@@ -800,11 +800,11 @@ const selectIssueCountOfCategory = (categoryId) => (state) => {
|
|
|
800
800
|
};
|
|
801
801
|
const categoryReducer = categorySlice.reducer;
|
|
802
802
|
const assetAdapter = createModelAdapter((asset) => asset.offline_id);
|
|
803
|
-
const initialState$
|
|
803
|
+
const initialState$H = assetAdapter.getInitialState({});
|
|
804
804
|
const assetSlice = createSlice({
|
|
805
805
|
name: "assets",
|
|
806
|
-
initialState: initialState$
|
|
807
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
806
|
+
initialState: initialState$H,
|
|
807
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$H)),
|
|
808
808
|
reducers: {
|
|
809
809
|
initializeAssets: assetAdapter.initialize,
|
|
810
810
|
addAsset: assetAdapter.addOne,
|
|
@@ -855,11 +855,11 @@ const selectNumberOfAssetsOfAssetType = (assetTypeId) => (state) => {
|
|
|
855
855
|
};
|
|
856
856
|
const assetReducer = assetSlice.reducer;
|
|
857
857
|
const assetAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
|
|
858
|
-
const initialState$
|
|
858
|
+
const initialState$G = assetAttachmentAdapter.getInitialState({});
|
|
859
859
|
const assetAttachmentSlice = createSlice({
|
|
860
860
|
name: "assetAttachments",
|
|
861
|
-
initialState: initialState$
|
|
862
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
861
|
+
initialState: initialState$G,
|
|
862
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$G)),
|
|
863
863
|
reducers: {
|
|
864
864
|
initializeAssetAttachments: assetAttachmentAdapter.initialize,
|
|
865
865
|
addAssetAttachment: assetAttachmentAdapter.addOne,
|
|
@@ -920,11 +920,11 @@ const assetAttachmentReducer = assetAttachmentSlice.reducer;
|
|
|
920
920
|
const assetStageCompletionAdapter = createModelAdapter(
|
|
921
921
|
(stageCompletion) => stageCompletion.offline_id
|
|
922
922
|
);
|
|
923
|
-
const initialState$
|
|
923
|
+
const initialState$F = assetStageCompletionAdapter.getInitialState({});
|
|
924
924
|
const assetStageCompletionSlice = createSlice({
|
|
925
925
|
name: "assetStageCompletions",
|
|
926
|
-
initialState: initialState$
|
|
927
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
926
|
+
initialState: initialState$F,
|
|
927
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$F)),
|
|
928
928
|
reducers: {
|
|
929
929
|
initializeAssetStageCompletions: assetStageCompletionAdapter.initialize,
|
|
930
930
|
addAssetStageCompletion: assetStageCompletionAdapter.addOne,
|
|
@@ -977,11 +977,11 @@ const selectAssetStageCompletionsByIds = restructureCreateSelectorWithArgs(
|
|
|
977
977
|
);
|
|
978
978
|
const assetStageCompletionReducer = assetStageCompletionSlice.reducer;
|
|
979
979
|
const assetStageAdapter = createModelAdapter((assetStage) => assetStage.offline_id);
|
|
980
|
-
const initialState$
|
|
980
|
+
const initialState$E = assetStageAdapter.getInitialState({});
|
|
981
981
|
const assetStageSlice = createSlice({
|
|
982
982
|
name: "assetStages",
|
|
983
|
-
initialState: initialState$
|
|
984
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
983
|
+
initialState: initialState$E,
|
|
984
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$E)),
|
|
985
985
|
reducers: {
|
|
986
986
|
initializeAssetStages: assetStageAdapter.initialize,
|
|
987
987
|
setAssetStage: assetStageAdapter.setOne,
|
|
@@ -1045,27 +1045,12 @@ const selectAssetStagesByIds = restructureCreateSelectorWithArgs(
|
|
|
1045
1045
|
return fallbackToEmptyArray(assetStages);
|
|
1046
1046
|
})
|
|
1047
1047
|
);
|
|
1048
|
-
const selectStageFormIdsFromStageIds = restructureCreateSelectorWithArgs(
|
|
1049
|
-
createSelector([selectStageMapping, (_state, stageIds) => stageIds], (stageMapping, stageIds) => {
|
|
1050
|
-
const ret = {};
|
|
1051
|
-
for (const stageId of stageIds) {
|
|
1052
|
-
const stage = stageMapping[stageId];
|
|
1053
|
-
if (!stage) {
|
|
1054
|
-
throw new Error("No stage exists with the id " + stageId);
|
|
1055
|
-
}
|
|
1056
|
-
if (stage.form) {
|
|
1057
|
-
ret[stageId] = stage.form;
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
return ret;
|
|
1061
|
-
})
|
|
1062
|
-
);
|
|
1063
1048
|
const assetTypeAdapter = createModelAdapter((assetType) => assetType.offline_id);
|
|
1064
|
-
const initialState$
|
|
1049
|
+
const initialState$D = assetTypeAdapter.getInitialState({});
|
|
1065
1050
|
const assetTypeSlice = createSlice({
|
|
1066
1051
|
name: "assetTypes",
|
|
1067
|
-
initialState: initialState$
|
|
1068
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1052
|
+
initialState: initialState$D,
|
|
1053
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$D)),
|
|
1069
1054
|
reducers: {
|
|
1070
1055
|
initializeAssetTypes: assetTypeAdapter.initialize,
|
|
1071
1056
|
setAssetType: assetTypeAdapter.setOne,
|
|
@@ -1118,11 +1103,11 @@ const assetTypeReducer = assetTypeSlice.reducer;
|
|
|
1118
1103
|
const assetTypeAttachmentAdapter = createModelAdapter(
|
|
1119
1104
|
(attachment) => attachment.offline_id
|
|
1120
1105
|
);
|
|
1121
|
-
const initialState$
|
|
1106
|
+
const initialState$C = assetTypeAttachmentAdapter.getInitialState({});
|
|
1122
1107
|
const assetTypeAttachmentSlice = createSlice({
|
|
1123
1108
|
name: "assetTypeAttachments",
|
|
1124
|
-
initialState: initialState$
|
|
1125
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1109
|
+
initialState: initialState$C,
|
|
1110
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$C)),
|
|
1126
1111
|
reducers: {
|
|
1127
1112
|
initializeAssetTypeAttachments: assetTypeAttachmentAdapter.initialize,
|
|
1128
1113
|
addAssetTypeAttachment: assetTypeAttachmentAdapter.addOne,
|
|
@@ -1181,12 +1166,12 @@ const selectAttachmentsOfAssetTypeByType = restructureCreateSelectorWithArgs(
|
|
|
1181
1166
|
);
|
|
1182
1167
|
const assetTypeAttachmentReducer = assetTypeAttachmentSlice.reducer;
|
|
1183
1168
|
const issueAdapter = createModelAdapter((issue) => issue.offline_id);
|
|
1184
|
-
const initialState$
|
|
1169
|
+
const initialState$B = issueAdapter.getInitialState({});
|
|
1185
1170
|
const issueSlice = createSlice({
|
|
1186
1171
|
name: "issues",
|
|
1187
|
-
initialState: initialState$
|
|
1172
|
+
initialState: initialState$B,
|
|
1188
1173
|
extraReducers: (builder) => builder.addCase("RESET", (state) => {
|
|
1189
|
-
Object.assign(state, initialState$
|
|
1174
|
+
Object.assign(state, initialState$B);
|
|
1190
1175
|
}),
|
|
1191
1176
|
reducers: {
|
|
1192
1177
|
initializeIssues: issueAdapter.initialize,
|
|
@@ -1218,12 +1203,12 @@ const selectIssuesByIds = restructureCreateSelectorWithArgs(
|
|
|
1218
1203
|
);
|
|
1219
1204
|
const issueReducer = issueSlice.reducer;
|
|
1220
1205
|
const issueTypeAdapter = createModelAdapter((issueType) => issueType.offline_id);
|
|
1221
|
-
const initialState$
|
|
1206
|
+
const initialState$A = issueTypeAdapter.getInitialState({});
|
|
1222
1207
|
const issueTypeSlice = createSlice({
|
|
1223
1208
|
name: "issueTypes",
|
|
1224
|
-
initialState: initialState$
|
|
1209
|
+
initialState: initialState$A,
|
|
1225
1210
|
extraReducers: (builder) => builder.addCase("RESET", (state) => {
|
|
1226
|
-
Object.assign(state, initialState$
|
|
1211
|
+
Object.assign(state, initialState$A);
|
|
1227
1212
|
}),
|
|
1228
1213
|
reducers: {
|
|
1229
1214
|
initializeIssueTypes: issueTypeAdapter.initialize,
|
|
@@ -1280,15 +1265,15 @@ const selectIssuesOfIssueTypeCount = (issueTypeId) => (state) => {
|
|
|
1280
1265
|
return selectIssuesOfIssueType(issueTypeId)(state).length;
|
|
1281
1266
|
};
|
|
1282
1267
|
const issueTypeReducer = issueTypeSlice.reducer;
|
|
1283
|
-
const initialState$
|
|
1268
|
+
const initialState$z = {
|
|
1284
1269
|
s3Urls: {}
|
|
1285
1270
|
};
|
|
1286
1271
|
const msPerHour = 1e3 * 60 * 60;
|
|
1287
1272
|
const msPerWeek = msPerHour * 24 * 7;
|
|
1288
1273
|
const fileSlice = createSlice({
|
|
1289
1274
|
name: "file",
|
|
1290
|
-
initialState: initialState$
|
|
1291
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1275
|
+
initialState: initialState$z,
|
|
1276
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$z)),
|
|
1292
1277
|
reducers: {
|
|
1293
1278
|
setUploadUrl: (state, action) => {
|
|
1294
1279
|
const { url, fields, sha1 } = action.payload;
|
|
@@ -1314,14 +1299,14 @@ const selectUploadUrl = (sha1) => (state) => {
|
|
|
1314
1299
|
return url;
|
|
1315
1300
|
};
|
|
1316
1301
|
const fileReducer = fileSlice.reducer;
|
|
1317
|
-
const initialState$
|
|
1302
|
+
const initialState$y = {
|
|
1318
1303
|
users: {},
|
|
1319
1304
|
currentUser: null
|
|
1320
1305
|
};
|
|
1321
1306
|
const userSlice = createSlice({
|
|
1322
1307
|
name: "users",
|
|
1323
|
-
initialState: initialState$
|
|
1324
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1308
|
+
initialState: initialState$y,
|
|
1309
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$y)),
|
|
1325
1310
|
reducers: {
|
|
1326
1311
|
setUsers: (state, action) => {
|
|
1327
1312
|
const usersMapping = {};
|
|
@@ -1378,11 +1363,11 @@ const selectUsersByIds = restructureCreateSelectorWithArgs(
|
|
|
1378
1363
|
const organizationAccessAdapter = createModelAdapter(
|
|
1379
1364
|
(organizationAccess) => organizationAccess.offline_id
|
|
1380
1365
|
);
|
|
1381
|
-
const initialState$
|
|
1366
|
+
const initialState$x = organizationAccessAdapter.getInitialState({});
|
|
1382
1367
|
const organizationAccessSlice = createSlice({
|
|
1383
1368
|
name: "organizationAccess",
|
|
1384
|
-
initialState: initialState$
|
|
1385
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1369
|
+
initialState: initialState$x,
|
|
1370
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$x)),
|
|
1386
1371
|
reducers: {
|
|
1387
1372
|
initializeOrganizationAccesses: organizationAccessAdapter.initialize,
|
|
1388
1373
|
updateOrganizationAccess: organizationAccessAdapter.updateOne,
|
|
@@ -1419,11 +1404,11 @@ const selectOrganizationAccessUserMapping = (state) => {
|
|
|
1419
1404
|
};
|
|
1420
1405
|
const organizationAccessReducer = organizationAccessSlice.reducer;
|
|
1421
1406
|
const licenseAdapter = createModelAdapter((license) => license.offline_id);
|
|
1422
|
-
const initialState$
|
|
1407
|
+
const initialState$w = licenseAdapter.getInitialState({});
|
|
1423
1408
|
const licenseSlice = createSlice({
|
|
1424
1409
|
name: "license",
|
|
1425
|
-
initialState: initialState$
|
|
1426
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1410
|
+
initialState: initialState$w,
|
|
1411
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$w)),
|
|
1427
1412
|
reducers: {
|
|
1428
1413
|
initializeLicences: licenseAdapter.initialize,
|
|
1429
1414
|
addLicenses: licenseAdapter.addMany,
|
|
@@ -1450,11 +1435,11 @@ const selectLicensesForProjectsMapping = createSelector(
|
|
|
1450
1435
|
);
|
|
1451
1436
|
const licenseReducer = licenseSlice.reducer;
|
|
1452
1437
|
const projectAccessAdapter = createModelAdapter((projectAccess) => projectAccess.offline_id);
|
|
1453
|
-
const initialState$
|
|
1438
|
+
const initialState$v = projectAccessAdapter.getInitialState({});
|
|
1454
1439
|
const projectAccessSlice = createSlice({
|
|
1455
1440
|
name: "projectAccess",
|
|
1456
|
-
initialState: initialState$
|
|
1457
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1441
|
+
initialState: initialState$v,
|
|
1442
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$v)),
|
|
1458
1443
|
reducers: {
|
|
1459
1444
|
initializeProjectAccesses: projectAccessAdapter.initialize,
|
|
1460
1445
|
updateProjectAccess: projectAccessAdapter.updateOne,
|
|
@@ -1488,13 +1473,13 @@ const selectProjectAccessUserMapping = (state) => {
|
|
|
1488
1473
|
return fallbackToEmptyObject(projectAccesses);
|
|
1489
1474
|
};
|
|
1490
1475
|
const projectAccessReducer = projectAccessSlice.reducer;
|
|
1491
|
-
const initialState$
|
|
1476
|
+
const initialState$u = {
|
|
1492
1477
|
projects: {}
|
|
1493
1478
|
};
|
|
1494
1479
|
const projectSlice = createSlice({
|
|
1495
1480
|
name: "projects",
|
|
1496
|
-
initialState: initialState$
|
|
1497
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1481
|
+
initialState: initialState$u,
|
|
1482
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$u)),
|
|
1498
1483
|
reducers: {
|
|
1499
1484
|
setProjects: (state, action) => {
|
|
1500
1485
|
const projectsMap = {};
|
|
@@ -1555,13 +1540,13 @@ const selectSortedProjectUsers = createSelector(
|
|
|
1555
1540
|
);
|
|
1556
1541
|
}
|
|
1557
1542
|
);
|
|
1558
|
-
const initialState$
|
|
1543
|
+
const initialState$t = {
|
|
1559
1544
|
organizations: {}
|
|
1560
1545
|
};
|
|
1561
1546
|
const organizationSlice = createSlice({
|
|
1562
1547
|
name: "organizations",
|
|
1563
|
-
initialState: initialState$
|
|
1564
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1548
|
+
initialState: initialState$t,
|
|
1549
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$t)),
|
|
1565
1550
|
reducers: {
|
|
1566
1551
|
setOrganizations: (state, action) => {
|
|
1567
1552
|
for (const org of action.payload) {
|
|
@@ -1656,14 +1641,14 @@ const createOfflineAction = (request2, baseUrl, serviceName) => {
|
|
|
1656
1641
|
}
|
|
1657
1642
|
};
|
|
1658
1643
|
};
|
|
1659
|
-
const initialState$
|
|
1644
|
+
const initialState$s = {
|
|
1660
1645
|
deletedRequests: [],
|
|
1661
1646
|
latestRetryTime: 0
|
|
1662
1647
|
};
|
|
1663
1648
|
const outboxSlice = createSlice({
|
|
1664
1649
|
name: "outbox",
|
|
1665
|
-
initialState: initialState$
|
|
1666
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1650
|
+
initialState: initialState$s,
|
|
1651
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$s)),
|
|
1667
1652
|
reducers: {
|
|
1668
1653
|
// enqueueActions is a reducer that does nothing but enqueue API request to the Redux Offline outbox
|
|
1669
1654
|
// Whenever an issue is being created, a reducer addIssue() is responsible for adding it to the offline store
|
|
@@ -1695,14 +1680,14 @@ const selectLatestRetryTime = (state) => state.outboxReducer.latestRetryTime;
|
|
|
1695
1680
|
const { enqueueRequest, markForDeletion, markAsDeleted, _setLatestRetryTime } = outboxSlice.actions;
|
|
1696
1681
|
const outboxReducer = outboxSlice.reducer;
|
|
1697
1682
|
const projectFileModelAdapter = createModelAdapter((projectFile) => projectFile.offline_id);
|
|
1698
|
-
const initialState$
|
|
1683
|
+
const initialState$r = projectFileModelAdapter.getInitialState({
|
|
1699
1684
|
activeProjectFileId: null,
|
|
1700
1685
|
isImportingProjectFile: false
|
|
1701
1686
|
});
|
|
1702
1687
|
const projectFileSlice = createSlice({
|
|
1703
1688
|
name: "projectFiles",
|
|
1704
|
-
initialState: initialState$
|
|
1705
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1689
|
+
initialState: initialState$r,
|
|
1690
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$r)),
|
|
1706
1691
|
reducers: {
|
|
1707
1692
|
initializeProjectFiles: projectFileModelAdapter.initialize,
|
|
1708
1693
|
setProjectFile: projectFileModelAdapter.setOne,
|
|
@@ -1767,11 +1752,11 @@ const selectActiveProjectFileId = (state) => state.projectFileReducer.activeProj
|
|
|
1767
1752
|
const selectIsImportingProjectFile = (state) => state.projectFileReducer.isImportingProjectFile;
|
|
1768
1753
|
const projectFileReducer = projectFileSlice.reducer;
|
|
1769
1754
|
const projectAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
|
|
1770
|
-
const initialState$
|
|
1755
|
+
const initialState$q = projectAttachmentAdapter.getInitialState({});
|
|
1771
1756
|
const projectAttachmentSlice = createSlice({
|
|
1772
1757
|
name: "projectAttachments",
|
|
1773
|
-
initialState: initialState$
|
|
1774
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1758
|
+
initialState: initialState$q,
|
|
1759
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$q)),
|
|
1775
1760
|
reducers: {
|
|
1776
1761
|
initializeProjectAttachments: projectAttachmentAdapter.initialize,
|
|
1777
1762
|
addProjectAttachment: projectAttachmentAdapter.addOne,
|
|
@@ -1826,12 +1811,12 @@ const selectAttachmentsOfProjectByType = restructureCreateSelectorWithArgs(
|
|
|
1826
1811
|
)
|
|
1827
1812
|
);
|
|
1828
1813
|
const projectAttachmentReducer = projectAttachmentSlice.reducer;
|
|
1829
|
-
const initialState$
|
|
1814
|
+
const initialState$p = {
|
|
1830
1815
|
isRehydrated: false
|
|
1831
1816
|
};
|
|
1832
1817
|
const rehydratedSlice = createSlice({
|
|
1833
1818
|
name: "rehydrated",
|
|
1834
|
-
initialState: initialState$
|
|
1819
|
+
initialState: initialState$p,
|
|
1835
1820
|
// The `reducers` field lets us define reducers and generate associated actions
|
|
1836
1821
|
reducers: {
|
|
1837
1822
|
setRehydrated: (state, action) => {
|
|
@@ -1856,11 +1841,11 @@ const formRevisionSortFn = (formRevisionA, formRevisionB) => {
|
|
|
1856
1841
|
}
|
|
1857
1842
|
};
|
|
1858
1843
|
const formRevisionAdapter = createModelAdapter((revision) => revision.offline_id);
|
|
1859
|
-
const initialState$
|
|
1844
|
+
const initialState$o = formRevisionAdapter.getInitialState({});
|
|
1860
1845
|
const formRevisionsSlice = createSlice({
|
|
1861
1846
|
name: "formRevisions",
|
|
1862
|
-
initialState: initialState$
|
|
1863
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1847
|
+
initialState: initialState$o,
|
|
1848
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$o)),
|
|
1864
1849
|
reducers: {
|
|
1865
1850
|
initializeFormRevisions: formRevisionAdapter.initialize,
|
|
1866
1851
|
setFormRevision: formRevisionAdapter.setOne,
|
|
@@ -1918,24 +1903,13 @@ const selectFormRevisionsOfForm = restructureCreateSelectorWithArgs(
|
|
|
1918
1903
|
}
|
|
1919
1904
|
)
|
|
1920
1905
|
);
|
|
1921
|
-
const selectLatestFormRevisionByForm = createSelector([selectFormRevisionMapping], (revisions) => {
|
|
1922
|
-
const latestRevisions = {};
|
|
1923
|
-
for (const revision of Object.values(revisions)) {
|
|
1924
|
-
const formId = revision.form;
|
|
1925
|
-
const currentLatestRevision = latestRevisions[formId];
|
|
1926
|
-
if (!currentLatestRevision || currentLatestRevision.revision < revision.revision) {
|
|
1927
|
-
latestRevisions[formId] = revision;
|
|
1928
|
-
}
|
|
1929
|
-
}
|
|
1930
|
-
return latestRevisions;
|
|
1931
|
-
});
|
|
1932
1906
|
const formRevisionReducer = formRevisionsSlice.reducer;
|
|
1933
1907
|
const formAdapter = createModelAdapter((form) => form.offline_id);
|
|
1934
|
-
const initialState$
|
|
1908
|
+
const initialState$n = formAdapter.getInitialState({});
|
|
1935
1909
|
const formSlice = createSlice({
|
|
1936
1910
|
name: "forms",
|
|
1937
|
-
initialState: initialState$
|
|
1938
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1911
|
+
initialState: initialState$n,
|
|
1912
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$n)),
|
|
1939
1913
|
reducers: {
|
|
1940
1914
|
initializeForms: formAdapter.initialize,
|
|
1941
1915
|
setForm: formAdapter.setOne,
|
|
@@ -1953,6 +1927,9 @@ const selectFormMapping = (state) => {
|
|
|
1953
1927
|
const selectForms = createSelector([selectFormMapping], (formsMapping) => {
|
|
1954
1928
|
return Object.values(formsMapping);
|
|
1955
1929
|
});
|
|
1930
|
+
const selectFormById = (formId) => (state) => {
|
|
1931
|
+
return state.formReducer.instances[formId];
|
|
1932
|
+
};
|
|
1956
1933
|
const selectFilteredForms = restructureCreateSelectorWithArgs(
|
|
1957
1934
|
createSelector(
|
|
1958
1935
|
[
|
|
@@ -1978,37 +1955,12 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
|
|
|
1978
1955
|
{ memoizeOptions: { resultEqualityCheck: shallowEqual } }
|
|
1979
1956
|
)
|
|
1980
1957
|
);
|
|
1981
|
-
const selectFormById = (formId) => (state) => {
|
|
1982
|
-
return state.formReducer.instances[formId];
|
|
1983
|
-
};
|
|
1984
|
-
const selectFormOfAssetType = restructureCreateSelectorWithArgs(
|
|
1985
|
-
createSelector(
|
|
1986
|
-
[selectFormMapping, (_state, assetTypeId) => assetTypeId],
|
|
1987
|
-
(formsMapping, assetTypeId) => {
|
|
1988
|
-
return Object.values(formsMapping).find((form) => form.asset_type === assetTypeId);
|
|
1989
|
-
}
|
|
1990
|
-
)
|
|
1991
|
-
);
|
|
1992
|
-
const selectFormOfIssueType = restructureCreateSelectorWithArgs(
|
|
1993
|
-
createSelector(
|
|
1994
|
-
[selectFormMapping, (_state, issueTypeId) => issueTypeId],
|
|
1995
|
-
(formsMapping, issueTypeId) => {
|
|
1996
|
-
return Object.values(formsMapping).find((form) => form.issue_type === issueTypeId);
|
|
1997
|
-
}
|
|
1998
|
-
)
|
|
1999
|
-
);
|
|
2000
|
-
const selectFormsCount = createSelector([selectFormMapping], (formsMapping) => {
|
|
2001
|
-
return Object.keys(formsMapping).length;
|
|
2002
|
-
});
|
|
2003
|
-
const selectGeneralFormCount = createSelector([selectFormMapping], (formsMapping) => {
|
|
2004
|
-
return Object.values(formsMapping).filter((form) => !form.asset_type).length;
|
|
2005
|
-
});
|
|
2006
1958
|
const submissionAdapter = createModelAdapter((submission) => submission.offline_id);
|
|
2007
|
-
const initialState$
|
|
1959
|
+
const initialState$m = submissionAdapter.getInitialState({});
|
|
2008
1960
|
const formSubmissionSlice = createSlice({
|
|
2009
1961
|
name: "formSubmissions",
|
|
2010
|
-
initialState: initialState$
|
|
2011
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
1962
|
+
initialState: initialState$m,
|
|
1963
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$m)),
|
|
2012
1964
|
reducers: {
|
|
2013
1965
|
initializeFormSubmissions: submissionAdapter.initialize,
|
|
2014
1966
|
setFormSubmission: submissionAdapter.setOne,
|
|
@@ -2063,43 +2015,6 @@ const selectFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
|
|
|
2063
2015
|
}
|
|
2064
2016
|
)
|
|
2065
2017
|
);
|
|
2066
|
-
const selectFormSubmissionsByFormRevisions = createSelector([selectFormRevisionMapping, selectFormSubmissions], (revisions, submissions) => {
|
|
2067
|
-
var _a2;
|
|
2068
|
-
const submissionMapping = {};
|
|
2069
|
-
for (const revisionId in revisions) {
|
|
2070
|
-
submissionMapping[revisionId] = [];
|
|
2071
|
-
}
|
|
2072
|
-
for (const submission of submissions) {
|
|
2073
|
-
(_a2 = submissionMapping[submission.form_revision]) == null ? void 0 : _a2.push(submission);
|
|
2074
|
-
}
|
|
2075
|
-
return submissionMapping;
|
|
2076
|
-
});
|
|
2077
|
-
const selectSortedFormSubmissionsOfForm = restructureCreateSelectorWithArgs(
|
|
2078
|
-
createSelector(
|
|
2079
|
-
[
|
|
2080
|
-
selectFormRevisionMapping,
|
|
2081
|
-
selectFormSubmissionsByFormRevisions,
|
|
2082
|
-
(_state, formId) => formId
|
|
2083
|
-
],
|
|
2084
|
-
(revisionsMapping, submissionsByRevision, formId) => {
|
|
2085
|
-
const submissionsByFormRevisions = {};
|
|
2086
|
-
for (const revisionId in revisionsMapping) {
|
|
2087
|
-
const revision = revisionsMapping[revisionId];
|
|
2088
|
-
const submissionsOfRevision = submissionsByRevision[revisionId];
|
|
2089
|
-
if (revision && submissionsOfRevision && revision.form === formId) {
|
|
2090
|
-
submissionsByFormRevisions[revisionId] = submissionsOfRevision.sort(
|
|
2091
|
-
(a, b) => a.submitted_at < b.submitted_at ? -1 : 1
|
|
2092
|
-
);
|
|
2093
|
-
}
|
|
2094
|
-
}
|
|
2095
|
-
return Object.entries(submissionsByFormRevisions).sort((a, b) => {
|
|
2096
|
-
const aRevision = revisionsMapping[a[0]];
|
|
2097
|
-
const bRevision = revisionsMapping[b[0]];
|
|
2098
|
-
return formRevisionSortFn(aRevision, bRevision);
|
|
2099
|
-
}).map(([_revisionId, submissions]) => submissions).flat();
|
|
2100
|
-
}
|
|
2101
|
-
)
|
|
2102
|
-
);
|
|
2103
2018
|
const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
|
|
2104
2019
|
createSelector(
|
|
2105
2020
|
[selectFormSubmissions, (_state, issueId) => issueId],
|
|
@@ -2110,53 +2025,6 @@ const selectFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
|
|
|
2110
2025
|
}
|
|
2111
2026
|
)
|
|
2112
2027
|
);
|
|
2113
|
-
const selectAttachedFormSubmissionsOfIssue = restructureCreateSelectorWithArgs(
|
|
2114
|
-
createSelector(
|
|
2115
|
-
[
|
|
2116
|
-
(state) => state.issueReducer.instances,
|
|
2117
|
-
(state) => state.formReducer.instances,
|
|
2118
|
-
(state) => state.formRevisionReducer.instances,
|
|
2119
|
-
(state) => state.formSubmissionReducer.instances,
|
|
2120
|
-
(_state, issueId) => issueId
|
|
2121
|
-
],
|
|
2122
|
-
(issues, forms, formRevisions, submissions, issueId) => {
|
|
2123
|
-
const issue = issues[issueId];
|
|
2124
|
-
if (!issue) return [];
|
|
2125
|
-
if (!issue.issue_type) {
|
|
2126
|
-
return Object.values(submissions).filter((submission) => submission.issue === issueId);
|
|
2127
|
-
}
|
|
2128
|
-
const issueTypeForms = new Set(
|
|
2129
|
-
Object.keys(forms).filter((formId) => forms[formId].issue_type === issue.issue_type)
|
|
2130
|
-
);
|
|
2131
|
-
const issueTypeFormRevisions = new Set(
|
|
2132
|
-
Object.keys(formRevisions).filter(
|
|
2133
|
-
(formRevisionId) => issueTypeForms.has(formRevisions[formRevisionId].form)
|
|
2134
|
-
)
|
|
2135
|
-
);
|
|
2136
|
-
return Object.values(submissions).filter(
|
|
2137
|
-
(submission) => submission.issue === issueId && !issueTypeFormRevisions.has(submission.form_revision)
|
|
2138
|
-
);
|
|
2139
|
-
}
|
|
2140
|
-
)
|
|
2141
|
-
);
|
|
2142
|
-
const selectFormSubmissionsByIssues = restructureCreateSelectorWithArgs(
|
|
2143
|
-
createSelector(
|
|
2144
|
-
[selectFormSubmissions, (_state, issueIds) => issueIds],
|
|
2145
|
-
(submissions, issueIds) => {
|
|
2146
|
-
var _a2;
|
|
2147
|
-
const issueSubmissions = {};
|
|
2148
|
-
for (const issueId of issueIds) {
|
|
2149
|
-
issueSubmissions[issueId] = [];
|
|
2150
|
-
}
|
|
2151
|
-
for (const submission of submissions) {
|
|
2152
|
-
if (submission.issue && issueIds.includes(submission.issue)) {
|
|
2153
|
-
(_a2 = issueSubmissions[submission.issue]) == null ? void 0 : _a2.push(submission);
|
|
2154
|
-
}
|
|
2155
|
-
}
|
|
2156
|
-
return issueSubmissions;
|
|
2157
|
-
}
|
|
2158
|
-
)
|
|
2159
|
-
);
|
|
2160
2028
|
const selectFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
|
|
2161
2029
|
createSelector(
|
|
2162
2030
|
[selectFormSubmissions, (_state, assetId) => assetId],
|
|
@@ -2167,61 +2035,15 @@ const selectFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
|
|
|
2167
2035
|
}
|
|
2168
2036
|
)
|
|
2169
2037
|
);
|
|
2170
|
-
const selectAttachedFormSubmissionsOfAsset = restructureCreateSelectorWithArgs(
|
|
2171
|
-
createSelector(
|
|
2172
|
-
[
|
|
2173
|
-
(state) => state.assetReducer.instances,
|
|
2174
|
-
(state) => state.formReducer.instances,
|
|
2175
|
-
(state) => state.formRevisionReducer.instances,
|
|
2176
|
-
(state) => state.formSubmissionReducer.instances,
|
|
2177
|
-
(_state, assetId) => assetId
|
|
2178
|
-
],
|
|
2179
|
-
(assets, forms, formRevisions, submissions, assetId) => {
|
|
2180
|
-
const asset = assets[assetId];
|
|
2181
|
-
if (!asset) return [];
|
|
2182
|
-
if (!asset.asset_type) {
|
|
2183
|
-
return Object.values(submissions).filter((submission) => submission.asset === assetId);
|
|
2184
|
-
}
|
|
2185
|
-
const issueTypeForms = new Set(
|
|
2186
|
-
Object.keys(forms).filter((formId) => forms[formId].asset_type === asset.asset_type)
|
|
2187
|
-
);
|
|
2188
|
-
const issueTypeFormRevisions = new Set(
|
|
2189
|
-
Object.keys(formRevisions).filter(
|
|
2190
|
-
(formRevisionId) => issueTypeForms.has(formRevisions[formRevisionId].form)
|
|
2191
|
-
)
|
|
2192
|
-
);
|
|
2193
|
-
return Object.values(submissions).filter(
|
|
2194
|
-
(submission) => submission.asset === assetId && !issueTypeFormRevisions.has(submission.form_revision)
|
|
2195
|
-
);
|
|
2196
|
-
}
|
|
2197
|
-
)
|
|
2198
|
-
);
|
|
2199
|
-
const selectFormSubmissionsByAssets = createSelector(
|
|
2200
|
-
[selectFormSubmissionsMapping, selectAssetsMapping],
|
|
2201
|
-
(submissions, assets) => {
|
|
2202
|
-
var _a2;
|
|
2203
|
-
const assetSubmissionMapping = {};
|
|
2204
|
-
for (const assetId in assets) {
|
|
2205
|
-
assetSubmissionMapping[assetId] = [];
|
|
2206
|
-
}
|
|
2207
|
-
for (const submissionId in submissions) {
|
|
2208
|
-
const submission = submissions[submissionId];
|
|
2209
|
-
if (submission.asset) {
|
|
2210
|
-
(_a2 = assetSubmissionMapping[submission.asset]) == null ? void 0 : _a2.push(submission);
|
|
2211
|
-
}
|
|
2212
|
-
}
|
|
2213
|
-
return assetSubmissionMapping;
|
|
2214
|
-
}
|
|
2215
|
-
);
|
|
2216
2038
|
const formSubmissionReducer = formSubmissionSlice.reducer;
|
|
2217
2039
|
const formSubmissionAttachmentAdapter = createModelAdapter(
|
|
2218
2040
|
(attachment) => attachment.offline_id
|
|
2219
2041
|
);
|
|
2220
|
-
const initialState$
|
|
2042
|
+
const initialState$l = formSubmissionAttachmentAdapter.getInitialState({});
|
|
2221
2043
|
const formSubmissionAttachmentSlice = createSlice({
|
|
2222
2044
|
name: "formSubmissionAttachments",
|
|
2223
|
-
initialState: initialState$
|
|
2224
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2045
|
+
initialState: initialState$l,
|
|
2046
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$l)),
|
|
2225
2047
|
reducers: {
|
|
2226
2048
|
initializeFormSubmissionAttachments: formSubmissionAttachmentAdapter.initialize,
|
|
2227
2049
|
addFormSubmissionAttachment: formSubmissionAttachmentAdapter.addOne,
|
|
@@ -2264,7 +2086,9 @@ const selectAttachmentsOfFormSubmission = restructureCreateSelectorWithArgs(
|
|
|
2264
2086
|
[selectFormSubmissionAttachmentsMapping, (_state, submissionId) => submissionId],
|
|
2265
2087
|
(attachmentsMapping, submissionId) => {
|
|
2266
2088
|
return fallbackToEmptyArray(
|
|
2267
|
-
Object.values(attachmentsMapping).filter(
|
|
2089
|
+
Object.values(attachmentsMapping).filter(
|
|
2090
|
+
(attachment) => attachment.form_submission === submissionId
|
|
2091
|
+
)
|
|
2268
2092
|
);
|
|
2269
2093
|
}
|
|
2270
2094
|
)
|
|
@@ -2273,11 +2097,11 @@ const formSubmissionAttachmentReducer = formSubmissionAttachmentSlice.reducer;
|
|
|
2273
2097
|
const formRevisionAttachmentAdapter = createModelAdapter(
|
|
2274
2098
|
(attachment) => attachment.offline_id
|
|
2275
2099
|
);
|
|
2276
|
-
const initialState$
|
|
2100
|
+
const initialState$k = formRevisionAttachmentAdapter.getInitialState({});
|
|
2277
2101
|
const formRevisionAttachmentSlice = createSlice({
|
|
2278
2102
|
name: "formRevisionAttachments",
|
|
2279
|
-
initialState: initialState$
|
|
2280
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2103
|
+
initialState: initialState$k,
|
|
2104
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$k)),
|
|
2281
2105
|
reducers: {
|
|
2282
2106
|
initializeFormRevisionAttachments: formRevisionAttachmentAdapter.initialize,
|
|
2283
2107
|
addFormRevisionAttachment: formRevisionAttachmentAdapter.addOne,
|
|
@@ -2309,17 +2133,17 @@ const selectAttachmentsOfFormRevision = restructureCreateSelectorWithArgs(
|
|
|
2309
2133
|
[selectFormRevisionAttachmentsMapping, (_state, revisionId) => revisionId],
|
|
2310
2134
|
(attachments, revisionId) => {
|
|
2311
2135
|
return fallbackToEmptyArray(
|
|
2312
|
-
Object.values(attachments).filter((attachment) => attachment.
|
|
2136
|
+
Object.values(attachments).filter((attachment) => attachment.form_revision === revisionId)
|
|
2313
2137
|
);
|
|
2314
2138
|
}
|
|
2315
2139
|
)
|
|
2316
2140
|
);
|
|
2317
2141
|
const formRevisionAttachmentReducer = formRevisionAttachmentSlice.reducer;
|
|
2318
2142
|
const workspaceAdapter = createModelAdapter((workspace) => workspace.offline_id);
|
|
2319
|
-
const initialState$
|
|
2143
|
+
const initialState$j = workspaceAdapter.getInitialState({});
|
|
2320
2144
|
const workspaceSlice = createSlice({
|
|
2321
2145
|
name: "workspace",
|
|
2322
|
-
initialState: initialState$
|
|
2146
|
+
initialState: initialState$j,
|
|
2323
2147
|
reducers: {
|
|
2324
2148
|
initializeWorkspaces: workspaceAdapter.initialize,
|
|
2325
2149
|
setWorkspaces: workspaceAdapter.setMany,
|
|
@@ -2350,10 +2174,10 @@ const selectPermittedWorkspaceIds = createSelector(
|
|
|
2350
2174
|
);
|
|
2351
2175
|
const workspaceReducer = workspaceSlice.reducer;
|
|
2352
2176
|
const emailDomainAdapter = createModelAdapter((emailDomain) => emailDomain.offline_id);
|
|
2353
|
-
const initialState$
|
|
2177
|
+
const initialState$i = emailDomainAdapter.getInitialState({});
|
|
2354
2178
|
const emailDomainsSlice = createSlice({
|
|
2355
2179
|
name: "emailDomains",
|
|
2356
|
-
initialState: initialState$
|
|
2180
|
+
initialState: initialState$i,
|
|
2357
2181
|
reducers: {
|
|
2358
2182
|
initializeEmailDomains: emailDomainAdapter.initialize,
|
|
2359
2183
|
addEmailDomain: emailDomainAdapter.addOne,
|
|
@@ -2374,14 +2198,14 @@ const selectEmailDomainsOfOrganization = restructureCreateSelectorWithArgs(
|
|
|
2374
2198
|
)
|
|
2375
2199
|
);
|
|
2376
2200
|
const emailDomainsReducer = emailDomainsSlice.reducer;
|
|
2377
|
-
const initialState$
|
|
2201
|
+
const initialState$h = {
|
|
2378
2202
|
documents: {}
|
|
2379
2203
|
};
|
|
2380
2204
|
const documentSlice = createSlice({
|
|
2381
2205
|
name: "documents",
|
|
2382
|
-
initialState: initialState$
|
|
2206
|
+
initialState: initialState$h,
|
|
2383
2207
|
extraReducers: (builder) => builder.addCase("RESET", (state) => {
|
|
2384
|
-
Object.assign(state, initialState$
|
|
2208
|
+
Object.assign(state, initialState$h);
|
|
2385
2209
|
}),
|
|
2386
2210
|
reducers: {
|
|
2387
2211
|
setDocuments: (state, action) => {
|
|
@@ -2569,11 +2393,11 @@ const selectRootDocuments = createSelector(
|
|
|
2569
2393
|
);
|
|
2570
2394
|
const documentsReducer = documentSlice.reducer;
|
|
2571
2395
|
const documentAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
|
|
2572
|
-
const initialState$
|
|
2396
|
+
const initialState$g = documentAttachmentAdapter.getInitialState({});
|
|
2573
2397
|
const documentAttachmentSlice = createSlice({
|
|
2574
2398
|
name: "documentAttachments",
|
|
2575
|
-
initialState: initialState$
|
|
2576
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2399
|
+
initialState: initialState$g,
|
|
2400
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$g)),
|
|
2577
2401
|
reducers: {
|
|
2578
2402
|
initializeDocumentAttachments: documentAttachmentAdapter.initialize,
|
|
2579
2403
|
addDocumentAttachment: documentAttachmentAdapter.addOne,
|
|
@@ -2632,11 +2456,11 @@ const selectAttachmentsOfDocumentByType = restructureCreateSelectorWithArgs(
|
|
|
2632
2456
|
);
|
|
2633
2457
|
const documentAttachmentReducer = documentAttachmentSlice.reducer;
|
|
2634
2458
|
const teamAdapter = createModelAdapter((team) => team.offline_id);
|
|
2635
|
-
const initialState$
|
|
2459
|
+
const initialState$f = teamAdapter.getInitialState({});
|
|
2636
2460
|
const teamSlice = createSlice({
|
|
2637
2461
|
name: "teams",
|
|
2638
|
-
initialState: initialState$
|
|
2639
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2462
|
+
initialState: initialState$f,
|
|
2463
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$f)),
|
|
2640
2464
|
reducers: {
|
|
2641
2465
|
setTeam: teamAdapter.setOne,
|
|
2642
2466
|
initializeTeams: teamAdapter.initialize,
|
|
@@ -2687,11 +2511,11 @@ const teamReducer = teamSlice.reducer;
|
|
|
2687
2511
|
const agentUserConversationAdapter = createModelAdapter(
|
|
2688
2512
|
(conversation) => conversation.offline_id
|
|
2689
2513
|
);
|
|
2690
|
-
const initialState$
|
|
2514
|
+
const initialState$e = agentUserConversationAdapter.getInitialState({});
|
|
2691
2515
|
const agentsSlice = createSlice({
|
|
2692
2516
|
name: "agents",
|
|
2693
|
-
initialState: initialState$
|
|
2694
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2517
|
+
initialState: initialState$e,
|
|
2518
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$e)),
|
|
2695
2519
|
reducers: {
|
|
2696
2520
|
initializeConversations: agentUserConversationAdapter.initialize,
|
|
2697
2521
|
addConversation: agentUserConversationAdapter.addOne,
|
|
@@ -2713,11 +2537,11 @@ const selectConversation = restructureCreateSelectorWithArgs(
|
|
|
2713
2537
|
);
|
|
2714
2538
|
const agentsReducer = agentsSlice.reducer;
|
|
2715
2539
|
const issueCommentAdapter = createModelAdapter((comment) => comment.offline_id);
|
|
2716
|
-
const initialState$
|
|
2540
|
+
const initialState$d = issueCommentAdapter.getInitialState({});
|
|
2717
2541
|
const issueCommentSlice = createSlice({
|
|
2718
2542
|
name: "issueComments",
|
|
2719
|
-
initialState: initialState$
|
|
2720
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2543
|
+
initialState: initialState$d,
|
|
2544
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$d)),
|
|
2721
2545
|
reducers: {
|
|
2722
2546
|
addIssueComment: issueCommentAdapter.addOne,
|
|
2723
2547
|
addIssueComments: issueCommentAdapter.addMany,
|
|
@@ -2746,11 +2570,11 @@ const selectCommentsOfIssue = restructureCreateSelectorWithArgs(
|
|
|
2746
2570
|
);
|
|
2747
2571
|
const issueCommentReducer = issueCommentSlice.reducer;
|
|
2748
2572
|
const issueUpdateAdapter = createModelAdapter((issueUpdate) => issueUpdate.offline_id);
|
|
2749
|
-
const initialState$
|
|
2573
|
+
const initialState$c = issueUpdateAdapter.getInitialState({});
|
|
2750
2574
|
const issueUpdateSlice = createSlice({
|
|
2751
2575
|
name: "issueUpdates",
|
|
2752
|
-
initialState: initialState$
|
|
2753
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2576
|
+
initialState: initialState$c,
|
|
2577
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$c)),
|
|
2754
2578
|
reducers: {
|
|
2755
2579
|
initializeIssueUpdates: issueUpdateAdapter.setMany,
|
|
2756
2580
|
setIssueUpdate: issueUpdateAdapter.setOne,
|
|
@@ -2779,11 +2603,11 @@ const selectIssueUpdatesOfIssue = restructureCreateSelectorWithArgs(
|
|
|
2779
2603
|
);
|
|
2780
2604
|
const issueUpdateReducer = issueUpdateSlice.reducer;
|
|
2781
2605
|
const issueAttachmentAdapter = createModelAdapter((attachment) => attachment.offline_id);
|
|
2782
|
-
const initialState$
|
|
2606
|
+
const initialState$b = issueAttachmentAdapter.getInitialState({});
|
|
2783
2607
|
const issueAttachmentSlice = createSlice({
|
|
2784
2608
|
name: "issueAttachments",
|
|
2785
|
-
initialState: initialState$
|
|
2786
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$
|
|
2609
|
+
initialState: initialState$b,
|
|
2610
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$b)),
|
|
2787
2611
|
reducers: {
|
|
2788
2612
|
initializeIssueAttachments: issueAttachmentAdapter.initialize,
|
|
2789
2613
|
addIssueAttachment: issueAttachmentAdapter.addOne,
|
|
@@ -2841,23 +2665,23 @@ const selectAttachmentsOfIssueByType = restructureCreateSelectorWithArgs(
|
|
|
2841
2665
|
)
|
|
2842
2666
|
);
|
|
2843
2667
|
const issueAttachmentReducer = issueAttachmentSlice.reducer;
|
|
2844
|
-
const initialState$
|
|
2668
|
+
const initialState$a = {
|
|
2845
2669
|
version: 0
|
|
2846
2670
|
};
|
|
2847
2671
|
const versioningSlice = createSlice({
|
|
2848
2672
|
name: "versioning",
|
|
2849
|
-
initialState: initialState$
|
|
2673
|
+
initialState: initialState$a,
|
|
2850
2674
|
reducers: {}
|
|
2851
2675
|
});
|
|
2852
2676
|
const versioningReducer = versioningSlice.reducer;
|
|
2853
2677
|
const geoImageAdapter = createModelAdapter((model) => model.offline_id);
|
|
2854
|
-
const initialState$
|
|
2678
|
+
const initialState$9 = geoImageAdapter.getInitialState({});
|
|
2855
2679
|
const geoImageSlice = createSlice({
|
|
2856
2680
|
name: "geoImages",
|
|
2857
|
-
initialState: initialState$
|
|
2681
|
+
initialState: initialState$9,
|
|
2858
2682
|
extraReducers: (builder) => {
|
|
2859
2683
|
builder.addCase("RESET", (state) => {
|
|
2860
|
-
Object.assign(state, initialState$
|
|
2684
|
+
Object.assign(state, initialState$9);
|
|
2861
2685
|
});
|
|
2862
2686
|
},
|
|
2863
2687
|
reducers: {
|
|
@@ -2897,11 +2721,11 @@ const selectGeoImagesOfProject = restructureCreateSelectorWithArgs(
|
|
|
2897
2721
|
);
|
|
2898
2722
|
const geoImageReducer = geoImageSlice.reducer;
|
|
2899
2723
|
const issueAssociationAdapter = createModelAdapter((assoc) => assoc.offline_id);
|
|
2900
|
-
const initialState = issueAssociationAdapter.getInitialState({});
|
|
2724
|
+
const initialState$8 = issueAssociationAdapter.getInitialState({});
|
|
2901
2725
|
const issueAssociationSlice = createSlice({
|
|
2902
2726
|
name: "issueAssociations",
|
|
2903
|
-
initialState,
|
|
2904
|
-
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState)),
|
|
2727
|
+
initialState: initialState$8,
|
|
2728
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$8)),
|
|
2905
2729
|
reducers: {
|
|
2906
2730
|
initializeIssueAssociations: issueAssociationAdapter.initialize,
|
|
2907
2731
|
addIssueAssociation: issueAssociationAdapter.addOne,
|
|
@@ -2959,37 +2783,459 @@ const selectIssueAssociationsOfAsset = restructureCreateSelectorWithArgs(
|
|
|
2959
2783
|
)
|
|
2960
2784
|
);
|
|
2961
2785
|
const issueAssociationReducer = issueAssociationSlice.reducer;
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
}
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
CLASS_NAME_TO_SERVICE[this.constructor.name] = this;
|
|
2981
|
-
this.client = sdk;
|
|
2786
|
+
const issueTypeFieldValuesAdapter = createModelAdapter(
|
|
2787
|
+
(fieldValues) => fieldValues.offline_id
|
|
2788
|
+
);
|
|
2789
|
+
const initialState$7 = issueTypeFieldValuesAdapter.getInitialState({});
|
|
2790
|
+
const issueTypeFieldValuesSlice = createSlice({
|
|
2791
|
+
name: "issueTypeFieldValues",
|
|
2792
|
+
initialState: initialState$7,
|
|
2793
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$7)),
|
|
2794
|
+
reducers: {
|
|
2795
|
+
initializeIssueTypeFieldValues: issueTypeFieldValuesAdapter.initialize,
|
|
2796
|
+
addIssueTypeFieldValues: issueTypeFieldValuesAdapter.addOne,
|
|
2797
|
+
addIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.addMany,
|
|
2798
|
+
setIssueTypeFieldValues: issueTypeFieldValuesAdapter.setOne,
|
|
2799
|
+
setIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.setMany,
|
|
2800
|
+
updateIssueTypeFieldValues: issueTypeFieldValuesAdapter.updateOne,
|
|
2801
|
+
updateIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.updateMany,
|
|
2802
|
+
deleteIssueTypeFieldValues: issueTypeFieldValuesAdapter.deleteOne,
|
|
2803
|
+
deleteIssueTypeFieldValuesMany: issueTypeFieldValuesAdapter.deleteMany
|
|
2982
2804
|
}
|
|
2983
|
-
|
|
2984
|
-
|
|
2805
|
+
});
|
|
2806
|
+
const {
|
|
2807
|
+
initializeIssueTypeFieldValues,
|
|
2808
|
+
addIssueTypeFieldValues,
|
|
2809
|
+
addIssueTypeFieldValuesMany,
|
|
2810
|
+
setIssueTypeFieldValues,
|
|
2811
|
+
setIssueTypeFieldValuesMany,
|
|
2812
|
+
updateIssueTypeFieldValues,
|
|
2813
|
+
updateIssueTypeFieldValuesMany,
|
|
2814
|
+
deleteIssueTypeFieldValues,
|
|
2815
|
+
deleteIssueTypeFieldValuesMany
|
|
2816
|
+
} = issueTypeFieldValuesSlice.actions;
|
|
2817
|
+
const selectIssueTypeFieldValuesMapping = (state) => state.issueTypeFieldValuesReducer.instances;
|
|
2818
|
+
const selectIssueTypeFieldValues = createSelector([selectIssueTypeFieldValuesMapping], (fieldValuesMapping) => {
|
|
2819
|
+
return Object.values(fieldValuesMapping);
|
|
2820
|
+
});
|
|
2821
|
+
const selectIssueTypeFieldValuesOfIssue = restructureCreateSelectorWithArgs(
|
|
2822
|
+
createSelector([selectIssueTypeFieldValues, (_state, issueId) => issueId], (fieldValues, issueId) => {
|
|
2823
|
+
return fallbackToEmptyArray(fieldValues.filter((fieldValue) => fieldValue.issue === issueId));
|
|
2824
|
+
})
|
|
2825
|
+
);
|
|
2826
|
+
const selectIssueTypeFieldValuesById = (fieldValuesId) => (state) => {
|
|
2827
|
+
return state.issueTypeFieldValuesReducer.instances[fieldValuesId];
|
|
2828
|
+
};
|
|
2829
|
+
const issueTypeFieldValuesReducer = issueTypeFieldValuesSlice.reducer;
|
|
2830
|
+
const issueTypeFieldsAdapter = createModelAdapter((fields) => fields.offline_id);
|
|
2831
|
+
const initialState$6 = issueTypeFieldsAdapter.getInitialState({});
|
|
2832
|
+
const issueTypeFieldsSlice = createSlice({
|
|
2833
|
+
name: "issueTypeFields",
|
|
2834
|
+
initialState: initialState$6,
|
|
2835
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$6)),
|
|
2836
|
+
reducers: {
|
|
2837
|
+
initializeIssueTypeFields: issueTypeFieldsAdapter.initialize,
|
|
2838
|
+
addIssueTypeFields: issueTypeFieldsAdapter.addOne,
|
|
2839
|
+
addIssueTypeFieldsMany: issueTypeFieldsAdapter.addMany,
|
|
2840
|
+
setIssueTypeFields: issueTypeFieldsAdapter.setOne,
|
|
2841
|
+
setIssueTypeFieldsMany: issueTypeFieldsAdapter.setMany,
|
|
2842
|
+
updateIssueTypeFields: issueTypeFieldsAdapter.updateOne,
|
|
2843
|
+
updateIssueTypeFieldsMany: issueTypeFieldsAdapter.updateMany,
|
|
2844
|
+
deleteIssueTypeFields: issueTypeFieldsAdapter.deleteOne,
|
|
2845
|
+
deleteIssueTypeFieldsMany: issueTypeFieldsAdapter.deleteMany
|
|
2985
2846
|
}
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2847
|
+
});
|
|
2848
|
+
const {
|
|
2849
|
+
initializeIssueTypeFields,
|
|
2850
|
+
addIssueTypeFields,
|
|
2851
|
+
addIssueTypeFieldsMany,
|
|
2852
|
+
setIssueTypeFields,
|
|
2853
|
+
setIssueTypeFieldsMany,
|
|
2854
|
+
updateIssueTypeFields,
|
|
2855
|
+
updateIssueTypeFieldsMany,
|
|
2856
|
+
deleteIssueTypeFields,
|
|
2857
|
+
deleteIssueTypeFieldsMany
|
|
2858
|
+
} = issueTypeFieldsSlice.actions;
|
|
2859
|
+
const selectIssueTypeFieldsMapping = (state) => state.issueTypeFieldsReducer.instances;
|
|
2860
|
+
const selectIssueTypeFields = createSelector([selectIssueTypeFieldsMapping], (fieldsMapping) => {
|
|
2861
|
+
return Object.values(fieldsMapping);
|
|
2862
|
+
});
|
|
2863
|
+
const selectIssueTypeFieldsOfIssueType = restructureCreateSelectorWithArgs(
|
|
2864
|
+
createSelector([selectIssueTypeFields, (_state, issueTypeId) => issueTypeId], (fields, issueTypeId) => {
|
|
2865
|
+
return fallbackToEmptyArray(fields.filter((field) => field.issue_type === issueTypeId));
|
|
2866
|
+
})
|
|
2867
|
+
);
|
|
2868
|
+
const selectLatestIssueTypeFieldsOfIssueType = restructureCreateSelectorWithArgs(
|
|
2869
|
+
createSelector([selectIssueTypeFields, (_state, id) => id], (fields, id) => {
|
|
2870
|
+
return fields.filter((field) => field.issue_type === id).sort((a, b) => a.submitted_at > b.submitted_at ? -1 : 1)[0];
|
|
2871
|
+
})
|
|
2872
|
+
);
|
|
2873
|
+
const selectIssueTypeValuesOfIssueType = restructureCreateSelectorWithArgs(
|
|
2874
|
+
createSelector(
|
|
2875
|
+
[selectIssueTypeFields, selectIssueTypeFieldValues, (_state, id) => id],
|
|
2876
|
+
(fields, fieldValues, id) => {
|
|
2877
|
+
const fieldsIds = new Set(
|
|
2878
|
+
fields.filter((field) => field.issue_type === id).map((field) => field.offline_id)
|
|
2879
|
+
);
|
|
2880
|
+
return fallbackToEmptyArray(fieldValues.filter((values) => fieldsIds.has(values.fields_revision)));
|
|
2881
|
+
}
|
|
2882
|
+
)
|
|
2883
|
+
);
|
|
2884
|
+
const selectIssueTypeFieldsById = (fieldsId) => (state) => {
|
|
2885
|
+
return state.issueTypeFieldsReducer.instances[fieldsId];
|
|
2886
|
+
};
|
|
2887
|
+
const issueTypeFieldsReducer = issueTypeFieldsSlice.reducer;
|
|
2888
|
+
const issueTypeFieldsAttachmentAdapter = createModelAdapter(
|
|
2889
|
+
(attachment) => attachment.offline_id
|
|
2890
|
+
);
|
|
2891
|
+
const initialState$5 = issueTypeFieldsAttachmentAdapter.getInitialState({});
|
|
2892
|
+
const issueTypeFieldsAttachmentSlice = createSlice({
|
|
2893
|
+
name: "issueTypeFieldsAttachments",
|
|
2894
|
+
initialState: initialState$5,
|
|
2895
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$5)),
|
|
2896
|
+
reducers: {
|
|
2897
|
+
initializeIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.initialize,
|
|
2898
|
+
addIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.addOne,
|
|
2899
|
+
addIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.addMany,
|
|
2900
|
+
setIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.setOne,
|
|
2901
|
+
setIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.setMany,
|
|
2902
|
+
updateIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.updateOne,
|
|
2903
|
+
updateIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.updateMany,
|
|
2904
|
+
deleteIssueTypeFieldsAttachment: issueTypeFieldsAttachmentAdapter.deleteOne,
|
|
2905
|
+
deleteIssueTypeFieldsAttachments: issueTypeFieldsAttachmentAdapter.deleteMany
|
|
2989
2906
|
}
|
|
2990
|
-
}
|
|
2991
|
-
const
|
|
2992
|
-
|
|
2907
|
+
});
|
|
2908
|
+
const {
|
|
2909
|
+
initializeIssueTypeFieldsAttachments,
|
|
2910
|
+
addIssueTypeFieldsAttachment,
|
|
2911
|
+
addIssueTypeFieldsAttachments,
|
|
2912
|
+
setIssueTypeFieldsAttachment,
|
|
2913
|
+
setIssueTypeFieldsAttachments,
|
|
2914
|
+
updateIssueTypeFieldsAttachment,
|
|
2915
|
+
updateIssueTypeFieldsAttachments,
|
|
2916
|
+
deleteIssueTypeFieldsAttachment,
|
|
2917
|
+
deleteIssueTypeFieldsAttachments
|
|
2918
|
+
} = issueTypeFieldsAttachmentSlice.actions;
|
|
2919
|
+
const selectIssueTypeFieldsAttachmentsMapping = (state) => state.issueTypeFieldsAttachmentReducer.instances;
|
|
2920
|
+
const selectIssueTypeFieldsAttachments = createSelector(
|
|
2921
|
+
[selectIssueTypeFieldsAttachmentsMapping],
|
|
2922
|
+
(attachmentsMapping) => {
|
|
2923
|
+
return Object.values(attachmentsMapping);
|
|
2924
|
+
}
|
|
2925
|
+
);
|
|
2926
|
+
const selectAttachmentsOfIssueTypeFields = restructureCreateSelectorWithArgs(
|
|
2927
|
+
createSelector(
|
|
2928
|
+
[selectIssueTypeFieldsAttachments, (_state, fieldsRevision) => fieldsRevision],
|
|
2929
|
+
(attachments, fieldsRevision) => {
|
|
2930
|
+
return fallbackToEmptyArray(
|
|
2931
|
+
attachments.filter((attachment) => attachment.fields_revision === fieldsRevision)
|
|
2932
|
+
);
|
|
2933
|
+
}
|
|
2934
|
+
)
|
|
2935
|
+
);
|
|
2936
|
+
const selectIssueTypeFieldsAttachmentById = (attachmentId) => (state) => {
|
|
2937
|
+
return state.issueTypeFieldsAttachmentReducer.instances[attachmentId];
|
|
2938
|
+
};
|
|
2939
|
+
const issueTypeFieldsAttachmentReducer = issueTypeFieldsAttachmentSlice.reducer;
|
|
2940
|
+
const issueTypeFieldValuesAttachmentAdapter = createModelAdapter(
|
|
2941
|
+
(attachment) => attachment.offline_id
|
|
2942
|
+
);
|
|
2943
|
+
const initialState$4 = issueTypeFieldValuesAttachmentAdapter.getInitialState({});
|
|
2944
|
+
const issueTypeFieldValuesAttachmentSlice = createSlice({
|
|
2945
|
+
name: "issueTypeFieldValuesAttachments",
|
|
2946
|
+
initialState: initialState$4,
|
|
2947
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$4)),
|
|
2948
|
+
reducers: {
|
|
2949
|
+
initializeIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.initialize,
|
|
2950
|
+
addIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.addOne,
|
|
2951
|
+
addIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.addMany,
|
|
2952
|
+
setIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.setOne,
|
|
2953
|
+
setIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.setMany,
|
|
2954
|
+
updateIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.updateOne,
|
|
2955
|
+
updateIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.updateMany,
|
|
2956
|
+
deleteIssueTypeFieldValuesAttachment: issueTypeFieldValuesAttachmentAdapter.deleteOne,
|
|
2957
|
+
deleteIssueTypeFieldValuesAttachments: issueTypeFieldValuesAttachmentAdapter.deleteMany
|
|
2958
|
+
}
|
|
2959
|
+
});
|
|
2960
|
+
const {
|
|
2961
|
+
initializeIssueTypeFieldValuesAttachments,
|
|
2962
|
+
addIssueTypeFieldValuesAttachment,
|
|
2963
|
+
addIssueTypeFieldValuesAttachments,
|
|
2964
|
+
setIssueTypeFieldValuesAttachment,
|
|
2965
|
+
setIssueTypeFieldValuesAttachments,
|
|
2966
|
+
updateIssueTypeFieldValuesAttachment,
|
|
2967
|
+
updateIssueTypeFieldValuesAttachments,
|
|
2968
|
+
deleteIssueTypeFieldValuesAttachment,
|
|
2969
|
+
deleteIssueTypeFieldValuesAttachments
|
|
2970
|
+
} = issueTypeFieldValuesAttachmentSlice.actions;
|
|
2971
|
+
const selectIssueTypeFieldValuesAttachmentsMapping = (state) => state.issueTypeFieldValuesAttachmentReducer.instances;
|
|
2972
|
+
const selectIssueTypeFieldValuesAttachments = createSelector(
|
|
2973
|
+
[selectIssueTypeFieldValuesAttachmentsMapping],
|
|
2974
|
+
(attachmentsMapping) => {
|
|
2975
|
+
return Object.values(attachmentsMapping);
|
|
2976
|
+
}
|
|
2977
|
+
);
|
|
2978
|
+
const selectIssueTypeFieldValuesAttachmentById = (attachmentId) => (state) => {
|
|
2979
|
+
return state.issueTypeFieldValuesAttachmentReducer.instances[attachmentId];
|
|
2980
|
+
};
|
|
2981
|
+
const selectIssueTypeFieldValuesAttachmentsByIds = restructureCreateSelectorWithArgs(
|
|
2982
|
+
createSelector(
|
|
2983
|
+
[selectIssueTypeFieldValuesAttachmentsMapping, (_, attachmentIds) => attachmentIds],
|
|
2984
|
+
(mapping, attachmentIds) => {
|
|
2985
|
+
const attachmentIdsSet = new Set(attachmentIds);
|
|
2986
|
+
return fallbackToEmptyArray(
|
|
2987
|
+
Object.values(mapping).filter((attachment) => attachmentIdsSet.has(attachment.offline_id))
|
|
2988
|
+
);
|
|
2989
|
+
}
|
|
2990
|
+
)
|
|
2991
|
+
);
|
|
2992
|
+
const selectAttachmentsOfIssueTypeFieldValues = restructureCreateSelectorWithArgs(
|
|
2993
|
+
createSelector(
|
|
2994
|
+
[selectIssueTypeFieldValuesAttachments, (_state, fieldValuesId) => fieldValuesId],
|
|
2995
|
+
(attachments, fieldValuesId) => {
|
|
2996
|
+
return fallbackToEmptyArray(attachments.filter((attachment) => attachment.field_values === fieldValuesId));
|
|
2997
|
+
}
|
|
2998
|
+
)
|
|
2999
|
+
);
|
|
3000
|
+
const issueTypeFieldValuesAttachmentReducer = issueTypeFieldValuesAttachmentSlice.reducer;
|
|
3001
|
+
const assetTypeFieldsAdapter = createModelAdapter((fields) => fields.offline_id);
|
|
3002
|
+
const initialState$3 = assetTypeFieldsAdapter.getInitialState({});
|
|
3003
|
+
const assetTypeFieldsSlice = createSlice({
|
|
3004
|
+
name: "assetTypeFields",
|
|
3005
|
+
initialState: initialState$3,
|
|
3006
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$3)),
|
|
3007
|
+
reducers: {
|
|
3008
|
+
initializeAssetTypeFields: assetTypeFieldsAdapter.initialize,
|
|
3009
|
+
addAssetTypeFields: assetTypeFieldsAdapter.addOne,
|
|
3010
|
+
addAssetTypeFieldsMany: assetTypeFieldsAdapter.addMany,
|
|
3011
|
+
setAssetTypeFields: assetTypeFieldsAdapter.setOne,
|
|
3012
|
+
setAssetTypeFieldsMany: assetTypeFieldsAdapter.setMany,
|
|
3013
|
+
updateAssetTypeFields: assetTypeFieldsAdapter.updateOne,
|
|
3014
|
+
updateAssetTypeFieldsMany: assetTypeFieldsAdapter.updateMany,
|
|
3015
|
+
deleteAssetTypeFields: assetTypeFieldsAdapter.deleteOne,
|
|
3016
|
+
deleteAssetTypeFieldsMany: assetTypeFieldsAdapter.deleteMany
|
|
3017
|
+
}
|
|
3018
|
+
});
|
|
3019
|
+
const {
|
|
3020
|
+
initializeAssetTypeFields,
|
|
3021
|
+
addAssetTypeFields,
|
|
3022
|
+
addAssetTypeFieldsMany,
|
|
3023
|
+
setAssetTypeFields,
|
|
3024
|
+
setAssetTypeFieldsMany,
|
|
3025
|
+
updateAssetTypeFields,
|
|
3026
|
+
updateAssetTypeFieldsMany,
|
|
3027
|
+
deleteAssetTypeFields,
|
|
3028
|
+
deleteAssetTypeFieldsMany
|
|
3029
|
+
} = assetTypeFieldsSlice.actions;
|
|
3030
|
+
const selectAssetTypeFieldsMapping = (state) => state.assetTypeFieldsReducer.instances;
|
|
3031
|
+
const selectAssetTypeFields = createSelector([selectAssetTypeFieldsMapping], (fieldsMapping) => {
|
|
3032
|
+
return Object.values(fieldsMapping);
|
|
3033
|
+
});
|
|
3034
|
+
const selectAssetTypeFieldsOfAssetType = restructureCreateSelectorWithArgs(
|
|
3035
|
+
createSelector([selectAssetTypeFields, (_state, assetTypeId) => assetTypeId], (fields, assetTypeId) => {
|
|
3036
|
+
return fallbackToEmptyArray(fields.filter((field) => field.asset_type === assetTypeId));
|
|
3037
|
+
})
|
|
3038
|
+
);
|
|
3039
|
+
const selectLatestAssetTypeFieldsOfAssetType = restructureCreateSelectorWithArgs(
|
|
3040
|
+
createSelector([selectAssetTypeFields, (_state, id) => id], (fields, id) => {
|
|
3041
|
+
return fields.filter((field) => field.asset_type === id).sort((a, b) => a.submitted_at > b.submitted_at ? -1 : 1)[0];
|
|
3042
|
+
})
|
|
3043
|
+
);
|
|
3044
|
+
const selectAssetTypeFieldsById = (fieldsId) => (state) => {
|
|
3045
|
+
return state.assetTypeFieldsReducer.instances[fieldsId];
|
|
3046
|
+
};
|
|
3047
|
+
const assetTypeFieldsReducer = assetTypeFieldsSlice.reducer;
|
|
3048
|
+
const assetTypeFieldValuesAdapter = createModelAdapter(
|
|
3049
|
+
(fieldValues) => fieldValues.offline_id
|
|
3050
|
+
);
|
|
3051
|
+
const initialState$2 = assetTypeFieldValuesAdapter.getInitialState({});
|
|
3052
|
+
const assetTypeFieldValuesSlice = createSlice({
|
|
3053
|
+
name: "assetTypeFieldValues",
|
|
3054
|
+
initialState: initialState$2,
|
|
3055
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$2)),
|
|
3056
|
+
reducers: {
|
|
3057
|
+
initializeAssetTypeFieldValues: assetTypeFieldValuesAdapter.initialize,
|
|
3058
|
+
addAssetTypeFieldValues: assetTypeFieldValuesAdapter.addOne,
|
|
3059
|
+
addAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.addMany,
|
|
3060
|
+
setAssetTypeFieldValues: assetTypeFieldValuesAdapter.setOne,
|
|
3061
|
+
setAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.setMany,
|
|
3062
|
+
updateAssetTypeFieldValues: assetTypeFieldValuesAdapter.updateOne,
|
|
3063
|
+
updateAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.updateMany,
|
|
3064
|
+
deleteAssetTypeFieldValues: assetTypeFieldValuesAdapter.deleteOne,
|
|
3065
|
+
deleteAssetTypeFieldValuesMany: assetTypeFieldValuesAdapter.deleteMany
|
|
3066
|
+
}
|
|
3067
|
+
});
|
|
3068
|
+
const {
|
|
3069
|
+
initializeAssetTypeFieldValues,
|
|
3070
|
+
addAssetTypeFieldValues,
|
|
3071
|
+
addAssetTypeFieldValuesMany,
|
|
3072
|
+
setAssetTypeFieldValues,
|
|
3073
|
+
setAssetTypeFieldValuesMany,
|
|
3074
|
+
updateAssetTypeFieldValues,
|
|
3075
|
+
updateAssetTypeFieldValuesMany,
|
|
3076
|
+
deleteAssetTypeFieldValues,
|
|
3077
|
+
deleteAssetTypeFieldValuesMany
|
|
3078
|
+
} = assetTypeFieldValuesSlice.actions;
|
|
3079
|
+
const selectAssetTypeFieldValuesMapping = (state) => state.assetTypeFieldValuesReducer.instances;
|
|
3080
|
+
const selectAssetTypeFieldValues = createSelector([selectAssetTypeFieldValuesMapping], (fieldValuesMapping) => {
|
|
3081
|
+
return Object.values(fieldValuesMapping);
|
|
3082
|
+
});
|
|
3083
|
+
const selectAssetTypeFieldValuesOfAsset = restructureCreateSelectorWithArgs(
|
|
3084
|
+
createSelector([selectAssetTypeFieldValues, (_state, assetId) => assetId], (fieldValues, assetId) => {
|
|
3085
|
+
return fallbackToEmptyArray(fieldValues.filter((fieldValue) => fieldValue.asset === assetId));
|
|
3086
|
+
})
|
|
3087
|
+
);
|
|
3088
|
+
const selectAssetTypeValuesOfAssetType = restructureCreateSelectorWithArgs(
|
|
3089
|
+
createSelector(
|
|
3090
|
+
[selectAssetTypeFields, selectAssetTypeFieldValues, (_state, id) => id],
|
|
3091
|
+
(fields, fieldValues, id) => {
|
|
3092
|
+
const fieldsIds = new Set(
|
|
3093
|
+
fields.filter((field) => field.asset_type === id).map((field) => field.offline_id)
|
|
3094
|
+
);
|
|
3095
|
+
return fallbackToEmptyArray(fieldValues.filter((values) => fieldsIds.has(values.fields_revision)));
|
|
3096
|
+
}
|
|
3097
|
+
)
|
|
3098
|
+
);
|
|
3099
|
+
const selectAssetTypeFieldValuesById = (fieldValuesId) => (state) => {
|
|
3100
|
+
return state.assetTypeFieldValuesReducer.instances[fieldValuesId];
|
|
3101
|
+
};
|
|
3102
|
+
const assetTypeFieldValuesReducer = assetTypeFieldValuesSlice.reducer;
|
|
3103
|
+
const assetTypeFieldsAttachmentAdapter = createModelAdapter(
|
|
3104
|
+
(attachment) => attachment.offline_id
|
|
3105
|
+
);
|
|
3106
|
+
const initialState$1 = assetTypeFieldsAttachmentAdapter.getInitialState({});
|
|
3107
|
+
const assetTypeFieldsAttachmentSlice = createSlice({
|
|
3108
|
+
name: "assetTypeFieldsAttachments",
|
|
3109
|
+
initialState: initialState$1,
|
|
3110
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState$1)),
|
|
3111
|
+
reducers: {
|
|
3112
|
+
initializeAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.initialize,
|
|
3113
|
+
addAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.addOne,
|
|
3114
|
+
addAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.addMany,
|
|
3115
|
+
setAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.setOne,
|
|
3116
|
+
setAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.setMany,
|
|
3117
|
+
updateAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.updateOne,
|
|
3118
|
+
updateAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.updateMany,
|
|
3119
|
+
deleteAssetTypeFieldsAttachment: assetTypeFieldsAttachmentAdapter.deleteOne,
|
|
3120
|
+
deleteAssetTypeFieldsAttachments: assetTypeFieldsAttachmentAdapter.deleteMany
|
|
3121
|
+
}
|
|
3122
|
+
});
|
|
3123
|
+
const {
|
|
3124
|
+
initializeAssetTypeFieldsAttachments,
|
|
3125
|
+
addAssetTypeFieldsAttachment,
|
|
3126
|
+
addAssetTypeFieldsAttachments,
|
|
3127
|
+
setAssetTypeFieldsAttachment,
|
|
3128
|
+
setAssetTypeFieldsAttachments,
|
|
3129
|
+
updateAssetTypeFieldsAttachment,
|
|
3130
|
+
updateAssetTypeFieldsAttachments,
|
|
3131
|
+
deleteAssetTypeFieldsAttachment,
|
|
3132
|
+
deleteAssetTypeFieldsAttachments
|
|
3133
|
+
} = assetTypeFieldsAttachmentSlice.actions;
|
|
3134
|
+
const selectAssetTypeFieldsAttachmentsMapping = (state) => state.assetTypeFieldsAttachmentReducer.instances;
|
|
3135
|
+
const selectAssetTypeFieldsAttachments = createSelector(
|
|
3136
|
+
[selectAssetTypeFieldsAttachmentsMapping],
|
|
3137
|
+
(attachmentsMapping) => {
|
|
3138
|
+
return Object.values(attachmentsMapping);
|
|
3139
|
+
}
|
|
3140
|
+
);
|
|
3141
|
+
const selectAttachmentsOfAssetTypeFields = restructureCreateSelectorWithArgs(
|
|
3142
|
+
createSelector([selectAssetTypeFieldsAttachments, (_state, id) => id], (attachments, id) => {
|
|
3143
|
+
return fallbackToEmptyArray(attachments.filter((attachment) => attachment.fields_revision === id));
|
|
3144
|
+
})
|
|
3145
|
+
);
|
|
3146
|
+
const selectAssetTypeFieldsAttachmentById = (attachmentId) => (state) => {
|
|
3147
|
+
return state.assetTypeFieldsAttachmentReducer.instances[attachmentId];
|
|
3148
|
+
};
|
|
3149
|
+
const assetTypeFieldsAttachmentReducer = assetTypeFieldsAttachmentSlice.reducer;
|
|
3150
|
+
const assetTypeFieldValuesAttachmentAdapter = createModelAdapter(
|
|
3151
|
+
(attachment) => attachment.offline_id
|
|
3152
|
+
);
|
|
3153
|
+
const initialState = assetTypeFieldValuesAttachmentAdapter.getInitialState({});
|
|
3154
|
+
const assetTypeFieldValuesAttachmentSlice = createSlice({
|
|
3155
|
+
name: "assetTypeFieldValuesAttachments",
|
|
3156
|
+
initialState,
|
|
3157
|
+
extraReducers: (builder) => builder.addCase("RESET", (state) => Object.assign(state, initialState)),
|
|
3158
|
+
reducers: {
|
|
3159
|
+
initializeAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.initialize,
|
|
3160
|
+
addAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.addOne,
|
|
3161
|
+
addAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.addMany,
|
|
3162
|
+
setAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.setOne,
|
|
3163
|
+
setAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.setMany,
|
|
3164
|
+
updateAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.updateOne,
|
|
3165
|
+
updateAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.updateMany,
|
|
3166
|
+
deleteAssetTypeFieldValuesAttachment: assetTypeFieldValuesAttachmentAdapter.deleteOne,
|
|
3167
|
+
deleteAssetTypeFieldValuesAttachments: assetTypeFieldValuesAttachmentAdapter.deleteMany
|
|
3168
|
+
}
|
|
3169
|
+
});
|
|
3170
|
+
const {
|
|
3171
|
+
initializeAssetTypeFieldValuesAttachments,
|
|
3172
|
+
addAssetTypeFieldValuesAttachment,
|
|
3173
|
+
addAssetTypeFieldValuesAttachments,
|
|
3174
|
+
setAssetTypeFieldValuesAttachment,
|
|
3175
|
+
setAssetTypeFieldValuesAttachments,
|
|
3176
|
+
updateAssetTypeFieldValuesAttachment,
|
|
3177
|
+
updateAssetTypeFieldValuesAttachments,
|
|
3178
|
+
deleteAssetTypeFieldValuesAttachment,
|
|
3179
|
+
deleteAssetTypeFieldValuesAttachments
|
|
3180
|
+
} = assetTypeFieldValuesAttachmentSlice.actions;
|
|
3181
|
+
const selectAssetTypeFieldValuesAttachmentsMapping = (state) => state.assetTypeFieldValuesAttachmentReducer.instances;
|
|
3182
|
+
const selectAssetTypeFieldValuesAttachments = createSelector(
|
|
3183
|
+
[selectAssetTypeFieldValuesAttachmentsMapping],
|
|
3184
|
+
(attachmentsMapping) => {
|
|
3185
|
+
return Object.values(attachmentsMapping);
|
|
3186
|
+
}
|
|
3187
|
+
);
|
|
3188
|
+
const selectAssetTypeFieldValuesAttachmentById = (attachmentId) => (state) => {
|
|
3189
|
+
return state.assetTypeFieldValuesAttachmentReducer.instances[attachmentId];
|
|
3190
|
+
};
|
|
3191
|
+
const selectAssetTypeFieldValuesAttachmentsByIds = restructureCreateSelectorWithArgs(
|
|
3192
|
+
createSelector(
|
|
3193
|
+
[selectAssetTypeFieldValuesAttachmentsMapping, (_, attachmentIds) => attachmentIds],
|
|
3194
|
+
(mapping, attachmentIds) => {
|
|
3195
|
+
const attachmentIdsSet = new Set(attachmentIds);
|
|
3196
|
+
return fallbackToEmptyArray(
|
|
3197
|
+
Object.values(mapping).filter((attachment) => attachmentIdsSet.has(attachment.offline_id))
|
|
3198
|
+
);
|
|
3199
|
+
}
|
|
3200
|
+
)
|
|
3201
|
+
);
|
|
3202
|
+
const selectAttachmentsOfAssetTypeFieldValues = restructureCreateSelectorWithArgs(
|
|
3203
|
+
createSelector([selectAssetTypeFieldValuesAttachments, (_state, id) => id], (attachments, id) => {
|
|
3204
|
+
return fallbackToEmptyArray(attachments.filter((attachment) => attachment.field_values === id));
|
|
3205
|
+
})
|
|
3206
|
+
);
|
|
3207
|
+
const assetTypeFieldValuesAttachmentReducer = assetTypeFieldValuesAttachmentSlice.reducer;
|
|
3208
|
+
let clientStore;
|
|
3209
|
+
function setClientStore(store) {
|
|
3210
|
+
clientStore = store;
|
|
3211
|
+
}
|
|
3212
|
+
function getClientStore() {
|
|
3213
|
+
return clientStore;
|
|
3214
|
+
}
|
|
3215
|
+
let clientSDK;
|
|
3216
|
+
function setClientSDK(sdkCtor) {
|
|
3217
|
+
clientSDK = sdkCtor;
|
|
3218
|
+
}
|
|
3219
|
+
function getClientSDK() {
|
|
3220
|
+
return clientSDK;
|
|
3221
|
+
}
|
|
3222
|
+
const CLASS_NAME_TO_SERVICE = {};
|
|
3223
|
+
class BaseService {
|
|
3224
|
+
constructor(sdk) {
|
|
3225
|
+
__publicField(this, "client");
|
|
3226
|
+
CLASS_NAME_TO_SERVICE[this.constructor.name] = this;
|
|
3227
|
+
this.client = sdk;
|
|
3228
|
+
}
|
|
3229
|
+
async enqueueRequest(requestDetails) {
|
|
3230
|
+
return this.client.enqueueRequest(requestDetails, this.host, this.constructor.name);
|
|
3231
|
+
}
|
|
3232
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3233
|
+
dispatch(action) {
|
|
3234
|
+
this.client.store.dispatch(action);
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
const VERSION_REDUCER_KEY = "versioning";
|
|
3238
|
+
const overmapReducers = {
|
|
2993
3239
|
// TODO: attachmentReducer,
|
|
2994
3240
|
[VERSION_REDUCER_KEY]: versioningReducer,
|
|
2995
3241
|
fileReducer,
|
|
@@ -3028,7 +3274,15 @@ const overmapReducers = {
|
|
|
3028
3274
|
issueCommentReducer,
|
|
3029
3275
|
issueUpdateReducer,
|
|
3030
3276
|
geoImageReducer,
|
|
3031
|
-
issueAssociationReducer
|
|
3277
|
+
issueAssociationReducer,
|
|
3278
|
+
issueTypeFieldsReducer,
|
|
3279
|
+
issueTypeFieldValuesReducer,
|
|
3280
|
+
issueTypeFieldsAttachmentReducer,
|
|
3281
|
+
issueTypeFieldValuesAttachmentReducer,
|
|
3282
|
+
assetTypeFieldsReducer,
|
|
3283
|
+
assetTypeFieldValuesReducer,
|
|
3284
|
+
assetTypeFieldsAttachmentReducer,
|
|
3285
|
+
assetTypeFieldValuesAttachmentReducer
|
|
3032
3286
|
};
|
|
3033
3287
|
const overmapReducer = combineReducers(overmapReducers);
|
|
3034
3288
|
const resetStore = "RESET";
|
|
@@ -3629,9 +3883,6 @@ class CategoryService extends BaseApiService {
|
|
|
3629
3883
|
description: "Create Category",
|
|
3630
3884
|
method: HttpMethod.POST,
|
|
3631
3885
|
url: "/categories/",
|
|
3632
|
-
queryParams: {
|
|
3633
|
-
workspace_id: payload.workspace.toString()
|
|
3634
|
-
},
|
|
3635
3886
|
payload: offlineCategory,
|
|
3636
3887
|
blockers: [payload.workspace],
|
|
3637
3888
|
blocks: [offlineCategory.offline_id]
|
|
@@ -3714,15 +3965,7 @@ class AssetService extends BaseApiService {
|
|
|
3714
3965
|
description: "Create asset",
|
|
3715
3966
|
method: HttpMethod.POST,
|
|
3716
3967
|
url: "/assets/",
|
|
3717
|
-
payload:
|
|
3718
|
-
offline_id: offlineAsset.offline_id,
|
|
3719
|
-
submitted_at: offlineAsset.submitted_at,
|
|
3720
|
-
geo_marker: offlineAsset.geo_marker,
|
|
3721
|
-
canvas_marker: offlineAsset.canvas_marker,
|
|
3722
|
-
label: offlineAsset.label,
|
|
3723
|
-
description: offlineAsset.description,
|
|
3724
|
-
asset_type: offlineAsset.asset_type
|
|
3725
|
-
},
|
|
3968
|
+
payload: offlineAsset,
|
|
3726
3969
|
blockers: [offlineAsset.asset_type],
|
|
3727
3970
|
blocks: [offlineAsset.offline_id]
|
|
3728
3971
|
});
|
|
@@ -3797,7 +4040,7 @@ class AssetService extends BaseApiService {
|
|
|
3797
4040
|
throw e;
|
|
3798
4041
|
});
|
|
3799
4042
|
}
|
|
3800
|
-
bulkAdd(payloads, assetTypeId, batchSize) {
|
|
4043
|
+
bulkAdd(payloads, assetTypeId, projectId, batchSize) {
|
|
3801
4044
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3802
4045
|
const transactionId = v4();
|
|
3803
4046
|
const assetBatches = chunkArray(payloads, batchSize).map((assetBatch) => {
|
|
@@ -3808,6 +4051,7 @@ class AssetService extends BaseApiService {
|
|
|
3808
4051
|
transaction_id: transactionId,
|
|
3809
4052
|
submitted_at: submittedAt,
|
|
3810
4053
|
asset_type: assetTypeId,
|
|
4054
|
+
project: projectId,
|
|
3811
4055
|
assets: assetPayloads
|
|
3812
4056
|
}
|
|
3813
4057
|
};
|
|
@@ -3842,7 +4086,10 @@ class AssetService extends BaseApiService {
|
|
|
3842
4086
|
const result = await this.enqueueRequest({
|
|
3843
4087
|
description: "Get assets",
|
|
3844
4088
|
method: HttpMethod.GET,
|
|
3845
|
-
url:
|
|
4089
|
+
url: "/assets/",
|
|
4090
|
+
queryParams: {
|
|
4091
|
+
project: projectId.toString()
|
|
4092
|
+
},
|
|
3846
4093
|
blockers: [],
|
|
3847
4094
|
blocks: []
|
|
3848
4095
|
});
|
|
@@ -3863,7 +4110,7 @@ class AssetStageCompletionService extends BaseApiService {
|
|
|
3863
4110
|
const promise = this.enqueueRequest({
|
|
3864
4111
|
description: "Add asset stage completion",
|
|
3865
4112
|
method: HttpMethod.POST,
|
|
3866
|
-
url: "/
|
|
4113
|
+
url: "/asset-stage-completions/",
|
|
3867
4114
|
payload: {
|
|
3868
4115
|
offline_id: offlineStageCompletion.offline_id,
|
|
3869
4116
|
submitted_at: submittedAt,
|
|
@@ -3890,7 +4137,7 @@ class AssetStageCompletionService extends BaseApiService {
|
|
|
3890
4137
|
const promise = this.enqueueRequest({
|
|
3891
4138
|
description: "Delete asset stage completion",
|
|
3892
4139
|
method: HttpMethod.DELETE,
|
|
3893
|
-
url: `/
|
|
4140
|
+
url: `/asset-stage-completions/${id}/`,
|
|
3894
4141
|
blockers: [id],
|
|
3895
4142
|
blocks: []
|
|
3896
4143
|
});
|
|
@@ -3916,7 +4163,7 @@ class AssetStageCompletionService extends BaseApiService {
|
|
|
3916
4163
|
const promise = this.enqueueRequest({
|
|
3917
4164
|
description: "Bulk create asset stage completions",
|
|
3918
4165
|
method: HttpMethod.POST,
|
|
3919
|
-
url: "/
|
|
4166
|
+
url: "/asset-stage-completions/bulk/",
|
|
3920
4167
|
payload: {
|
|
3921
4168
|
submitted_at: submittedAt,
|
|
3922
4169
|
completions: payload
|
|
@@ -3938,7 +4185,7 @@ class AssetStageCompletionService extends BaseApiService {
|
|
|
3938
4185
|
const promise = this.enqueueRequest({
|
|
3939
4186
|
description: "Deleting asset stage completions",
|
|
3940
4187
|
method: HttpMethod.DELETE,
|
|
3941
|
-
url: "/
|
|
4188
|
+
url: "/asset-stage-completions/bulk/",
|
|
3942
4189
|
payload: {
|
|
3943
4190
|
completion_ids: ids
|
|
3944
4191
|
},
|
|
@@ -3954,7 +4201,10 @@ class AssetStageCompletionService extends BaseApiService {
|
|
|
3954
4201
|
const result = await this.enqueueRequest({
|
|
3955
4202
|
description: "Get asset stage completions",
|
|
3956
4203
|
method: HttpMethod.GET,
|
|
3957
|
-
url:
|
|
4204
|
+
url: "/asset-stage-completions/",
|
|
4205
|
+
queryParams: {
|
|
4206
|
+
project: projectId.toString()
|
|
4207
|
+
},
|
|
3958
4208
|
blockers: [],
|
|
3959
4209
|
blocks: []
|
|
3960
4210
|
});
|
|
@@ -3975,7 +4225,7 @@ class AssetStageService extends BaseApiService {
|
|
|
3975
4225
|
const promise = this.enqueueRequest({
|
|
3976
4226
|
description: "Add asset stages",
|
|
3977
4227
|
method: HttpMethod.POST,
|
|
3978
|
-
url: "/
|
|
4228
|
+
url: "/asset-stages/bulk/",
|
|
3979
4229
|
payload: {
|
|
3980
4230
|
submitted_at: submittedAt,
|
|
3981
4231
|
asset_type: assetTypeId,
|
|
@@ -3999,7 +4249,7 @@ class AssetStageService extends BaseApiService {
|
|
|
3999
4249
|
return this.enqueueRequest({
|
|
4000
4250
|
description: "Edit asset stages",
|
|
4001
4251
|
method: HttpMethod.PATCH,
|
|
4002
|
-
url: `/
|
|
4252
|
+
url: `/asset-types/${assetTypeId}/bulk-update-stages/`,
|
|
4003
4253
|
payload: {
|
|
4004
4254
|
stages: stagesToUpdate
|
|
4005
4255
|
},
|
|
@@ -4017,7 +4267,7 @@ class AssetStageService extends BaseApiService {
|
|
|
4017
4267
|
const promise = this.enqueueRequest({
|
|
4018
4268
|
description: "Delete asset stages",
|
|
4019
4269
|
method: HttpMethod.DELETE,
|
|
4020
|
-
url: "/
|
|
4270
|
+
url: "/asset-stages/bulk/",
|
|
4021
4271
|
payload: {
|
|
4022
4272
|
stage_ids: idsToDelete
|
|
4023
4273
|
},
|
|
@@ -4041,7 +4291,7 @@ class AssetStageService extends BaseApiService {
|
|
|
4041
4291
|
const promise = this.enqueueRequest({
|
|
4042
4292
|
description: "Update asset stage",
|
|
4043
4293
|
method: HttpMethod.PATCH,
|
|
4044
|
-
url: `/
|
|
4294
|
+
url: `/asset-stages/${assetStage.offline_id}/`,
|
|
4045
4295
|
payload: {
|
|
4046
4296
|
name: payload.name,
|
|
4047
4297
|
description: payload.description,
|
|
@@ -4058,52 +4308,14 @@ class AssetStageService extends BaseApiService {
|
|
|
4058
4308
|
});
|
|
4059
4309
|
return [updatedAssetStage, promise];
|
|
4060
4310
|
}
|
|
4061
|
-
async
|
|
4062
|
-
const { store } = this.client;
|
|
4063
|
-
const stage = store.getState().assetStageReducer.instances[stageId];
|
|
4064
|
-
if (!stage) {
|
|
4065
|
-
throw new Error(`No asset stage with id ${stageId} found in the store`);
|
|
4066
|
-
}
|
|
4067
|
-
this.dispatch(updateAssetStage({ ...stage, form: formId }));
|
|
4068
|
-
try {
|
|
4069
|
-
await this.enqueueRequest({
|
|
4070
|
-
description: "Link asset stage to form",
|
|
4071
|
-
method: HttpMethod.POST,
|
|
4072
|
-
url: `/assets/stages/${stageId}/associate-with-form/`,
|
|
4073
|
-
payload: { form: formId },
|
|
4074
|
-
blockers: [stageId, formId],
|
|
4075
|
-
blocks: [stageId]
|
|
4076
|
-
});
|
|
4077
|
-
} catch (e) {
|
|
4078
|
-
this.dispatch(setAssetStage(stage));
|
|
4079
|
-
throw e;
|
|
4080
|
-
}
|
|
4081
|
-
}
|
|
4082
|
-
async unlinkForm(stageId, formId) {
|
|
4083
|
-
const { store } = this.client;
|
|
4084
|
-
const stage = store.getState().assetStageReducer.instances[stageId];
|
|
4085
|
-
if (!stage) {
|
|
4086
|
-
throw new Error(`No asset stage with id ${stageId} found in the store`);
|
|
4087
|
-
}
|
|
4088
|
-
this.dispatch(updateAssetStage({ ...stage, form: void 0 }));
|
|
4089
|
-
try {
|
|
4090
|
-
await this.enqueueRequest({
|
|
4091
|
-
description: "Unlink asset stage from form",
|
|
4092
|
-
method: HttpMethod.DELETE,
|
|
4093
|
-
url: `/assets/stages/${stageId}/associate-with-form/`,
|
|
4094
|
-
blockers: [stageId, formId],
|
|
4095
|
-
blocks: [stageId]
|
|
4096
|
-
});
|
|
4097
|
-
} catch (e) {
|
|
4098
|
-
this.dispatch(setAssetStage(stage));
|
|
4099
|
-
throw e;
|
|
4100
|
-
}
|
|
4101
|
-
}
|
|
4102
|
-
async refreshStore(projectId) {
|
|
4311
|
+
async refreshStore(organizationId) {
|
|
4103
4312
|
const result = await this.enqueueRequest({
|
|
4104
4313
|
description: "Get asset stages",
|
|
4105
4314
|
method: HttpMethod.GET,
|
|
4106
|
-
url:
|
|
4315
|
+
url: "/asset-stages/",
|
|
4316
|
+
queryParams: {
|
|
4317
|
+
organization: organizationId.toString()
|
|
4318
|
+
},
|
|
4107
4319
|
blockers: [],
|
|
4108
4320
|
blocks: []
|
|
4109
4321
|
});
|
|
@@ -4120,7 +4332,12 @@ class BaseUploadService extends BaseApiService {
|
|
|
4120
4332
|
projectAttachmentReducer: projectAttachmentReducer2,
|
|
4121
4333
|
formRevisionAttachmentReducer: formRevisionAttachmentReducer2,
|
|
4122
4334
|
formSubmissionAttachmentReducer: formSubmissionAttachmentReducer2,
|
|
4123
|
-
geoImageReducer: geoImageReducer2
|
|
4335
|
+
geoImageReducer: geoImageReducer2,
|
|
4336
|
+
// fields
|
|
4337
|
+
assetTypeFieldsAttachmentReducer: assetTypeFieldsAttachmentReducer2,
|
|
4338
|
+
assetTypeFieldValuesAttachmentReducer: assetTypeFieldValuesAttachmentReducer2,
|
|
4339
|
+
issueTypeFieldsAttachmentReducer: issueTypeFieldsAttachmentReducer2,
|
|
4340
|
+
issueTypeFieldValuesAttachmentReducer: issueTypeFieldValuesAttachmentReducer2
|
|
4124
4341
|
} = this.client.store.getState();
|
|
4125
4342
|
const objectsWithSha1 = [].concat(
|
|
4126
4343
|
Object.values(issueAttachmentReducer2.instances),
|
|
@@ -4130,7 +4347,11 @@ class BaseUploadService extends BaseApiService {
|
|
|
4130
4347
|
Object.values(projectAttachmentReducer2.instances),
|
|
4131
4348
|
Object.values(formRevisionAttachmentReducer2.instances),
|
|
4132
4349
|
Object.values(formSubmissionAttachmentReducer2.instances),
|
|
4133
|
-
Object.values(geoImageReducer2.instances)
|
|
4350
|
+
Object.values(geoImageReducer2.instances),
|
|
4351
|
+
Object.values(assetTypeFieldsAttachmentReducer2.instances),
|
|
4352
|
+
Object.values(assetTypeFieldValuesAttachmentReducer2.instances),
|
|
4353
|
+
Object.values(issueTypeFieldsAttachmentReducer2.instances),
|
|
4354
|
+
Object.values(issueTypeFieldValuesAttachmentReducer2.instances)
|
|
4134
4355
|
);
|
|
4135
4356
|
return objectsWithSha1.filter((object) => object.file_sha1 === sha1).length;
|
|
4136
4357
|
}
|
|
@@ -4152,41 +4373,20 @@ class BaseUploadService extends BaseApiService {
|
|
|
4152
4373
|
}
|
|
4153
4374
|
return promisesBySha1;
|
|
4154
4375
|
}
|
|
4155
|
-
|
|
4156
|
-
const
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
attachUrlPrefix: "/assets",
|
|
4166
|
-
deleteUrlPrefix: "/assets",
|
|
4167
|
-
fetchUrlPostfix: "/asset-attachments"
|
|
4168
|
-
},
|
|
4169
|
-
[AttachmentModel.AssetType]: {
|
|
4170
|
-
name: "asset type",
|
|
4171
|
-
attachUrlPrefix: "/assets/types",
|
|
4172
|
-
deleteUrlPrefix: "/assets/types",
|
|
4173
|
-
fetchUrlPostfix: "/asset-type-attachments"
|
|
4174
|
-
},
|
|
4175
|
-
[AttachmentModel.Project]: {
|
|
4176
|
-
name: "project",
|
|
4177
|
-
attachUrlPrefix: "/projects",
|
|
4178
|
-
deleteUrlPrefix: "/projects",
|
|
4179
|
-
fetchUrlPostfix: "/attachments"
|
|
4180
|
-
},
|
|
4181
|
-
[AttachmentModel.Document]: {
|
|
4182
|
-
name: "document",
|
|
4183
|
-
attachUrlPrefix: "/documents",
|
|
4184
|
-
deleteUrlPrefix: "/documents",
|
|
4185
|
-
fetchUrlPostfix: "/document-attachments"
|
|
4376
|
+
async getFilePayload(file) {
|
|
4377
|
+
const sha1 = await hashFile(file);
|
|
4378
|
+
const filePayload = {
|
|
4379
|
+
sha1,
|
|
4380
|
+
file_type: file.type,
|
|
4381
|
+
extension: file.name.split(".").pop(),
|
|
4382
|
+
size: file.size
|
|
4383
|
+
};
|
|
4384
|
+
await this.client.files.addCache(file, sha1);
|
|
4385
|
+
return filePayload;
|
|
4186
4386
|
}
|
|
4187
|
-
}
|
|
4387
|
+
}
|
|
4188
4388
|
class BaseAttachmentService extends BaseUploadService {
|
|
4189
|
-
async
|
|
4389
|
+
async _bulkAdd(payloads) {
|
|
4190
4390
|
var _a2;
|
|
4191
4391
|
const { store } = this.client;
|
|
4192
4392
|
const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
@@ -4194,39 +4394,35 @@ class BaseAttachmentService extends BaseUploadService {
|
|
|
4194
4394
|
const offlineAttachments = [];
|
|
4195
4395
|
const attachmentPayloads = [];
|
|
4196
4396
|
const filePayloads = {};
|
|
4197
|
-
for (const
|
|
4198
|
-
const
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
file_type: file.type,
|
|
4203
|
-
extension: file.name.split(".").pop(),
|
|
4204
|
-
size: file.size
|
|
4205
|
-
};
|
|
4206
|
-
await this.client.files.addCache(file, sha1);
|
|
4207
|
-
}
|
|
4208
|
-
const offlineAttachment = buildOfflineAttachment({
|
|
4397
|
+
for (const payload of payloads) {
|
|
4398
|
+
const { modelId, file } = payload;
|
|
4399
|
+
const filePayload = await this.getFilePayload(file);
|
|
4400
|
+
if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
|
|
4401
|
+
const offlineAttachment = this.buildOfflineAttachment({
|
|
4209
4402
|
file,
|
|
4210
|
-
sha1,
|
|
4211
|
-
submittedAt,
|
|
4212
|
-
createdBy,
|
|
4403
|
+
file_sha1: filePayload.sha1,
|
|
4404
|
+
submitted_at: submittedAt,
|
|
4405
|
+
created_by: createdBy,
|
|
4213
4406
|
description: "",
|
|
4214
4407
|
modelId
|
|
4215
4408
|
});
|
|
4216
4409
|
offlineAttachments.push(offlineAttachment);
|
|
4217
|
-
attachmentPayloads.push(
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4221
|
-
|
|
4222
|
-
|
|
4410
|
+
attachmentPayloads.push(
|
|
4411
|
+
this.buildAttachmentPayload({
|
|
4412
|
+
offline_id: offlineAttachment.offline_id,
|
|
4413
|
+
file_name: offlineAttachment.file_name,
|
|
4414
|
+
file_sha1: offlineAttachment.file_sha1,
|
|
4415
|
+
file_extension: filePayload.extension,
|
|
4416
|
+
description: offlineAttachment.description,
|
|
4417
|
+
modelId
|
|
4418
|
+
})
|
|
4419
|
+
);
|
|
4223
4420
|
}
|
|
4224
4421
|
this.dispatch(this.addAttachments(offlineAttachments));
|
|
4225
|
-
const meta = AttachmentModelMeta[this.attachmentModel];
|
|
4226
4422
|
const promise = this.enqueueRequest({
|
|
4227
|
-
description: `
|
|
4423
|
+
description: `Add ${this.name}`,
|
|
4228
4424
|
method: HttpMethod.POST,
|
|
4229
|
-
url: `${
|
|
4425
|
+
url: `${this.url}/bulk/`,
|
|
4230
4426
|
payload: {
|
|
4231
4427
|
submitted_at: submittedAt,
|
|
4232
4428
|
attachments: attachmentPayloads,
|
|
@@ -4243,7 +4439,7 @@ class BaseAttachmentService extends BaseUploadService {
|
|
|
4243
4439
|
});
|
|
4244
4440
|
return [offlineAttachments, promise.then(({ attachments }) => attachments)];
|
|
4245
4441
|
}
|
|
4246
|
-
async
|
|
4442
|
+
async _delete(attachmendId) {
|
|
4247
4443
|
const { store } = this.client;
|
|
4248
4444
|
const attachment = this.selectAttachment(attachmendId)(store.getState());
|
|
4249
4445
|
if (!attachment) {
|
|
@@ -4252,11 +4448,10 @@ class BaseAttachmentService extends BaseUploadService {
|
|
|
4252
4448
|
);
|
|
4253
4449
|
}
|
|
4254
4450
|
this.dispatch(this.removeAttachment(attachment.offline_id));
|
|
4255
|
-
const meta = AttachmentModelMeta[this.attachmentModel];
|
|
4256
4451
|
const promise = this.enqueueRequest({
|
|
4257
|
-
description:
|
|
4452
|
+
description: `Delete ${this.name}`,
|
|
4258
4453
|
method: HttpMethod.DELETE,
|
|
4259
|
-
url: `${
|
|
4454
|
+
url: `${this.url}/${attachmendId}/`,
|
|
4260
4455
|
blockers: [attachmendId],
|
|
4261
4456
|
blocks: []
|
|
4262
4457
|
});
|
|
@@ -4269,24 +4464,12 @@ class BaseAttachmentService extends BaseUploadService {
|
|
|
4269
4464
|
});
|
|
4270
4465
|
return promise;
|
|
4271
4466
|
}
|
|
4272
|
-
// Note that currently the fetching of attachments for all models dependds on the active projectId. This may change in the future. And
|
|
4273
|
-
// so for some attachment model services, this method will have to be overridden.
|
|
4274
|
-
async refreshStore(projectId, _organizationId) {
|
|
4275
|
-
const meta = AttachmentModelMeta[this.attachmentModel];
|
|
4276
|
-
const result = await this.enqueueRequest({
|
|
4277
|
-
description: `Get ${meta.name} attachments`,
|
|
4278
|
-
method: HttpMethod.GET,
|
|
4279
|
-
url: `/projects/${projectId}${meta.fetchUrlPostfix}/`,
|
|
4280
|
-
blocks: [],
|
|
4281
|
-
blockers: []
|
|
4282
|
-
});
|
|
4283
|
-
this.dispatch(this.initializeAttachments(result));
|
|
4284
|
-
}
|
|
4285
4467
|
}
|
|
4286
4468
|
class AssetAttachmentService extends BaseAttachmentService {
|
|
4287
4469
|
constructor() {
|
|
4288
4470
|
super(...arguments);
|
|
4289
|
-
__publicField(this, "
|
|
4471
|
+
__publicField(this, "name", "Asset Attachment");
|
|
4472
|
+
__publicField(this, "url", "/asset-attachments");
|
|
4290
4473
|
__publicField(this, "initializeAttachments", initializeAssetAttachments);
|
|
4291
4474
|
__publicField(this, "addAttachments", addAssetAttachments);
|
|
4292
4475
|
__publicField(this, "updateAttachments", updateAssetAttachments);
|
|
@@ -4298,20 +4481,39 @@ class AssetAttachmentService extends BaseAttachmentService {
|
|
|
4298
4481
|
buildOfflineAttachment(data) {
|
|
4299
4482
|
return offline({
|
|
4300
4483
|
file: URL.createObjectURL(data.file),
|
|
4301
|
-
file_sha1: data.
|
|
4302
|
-
created_by: data.
|
|
4484
|
+
file_sha1: data.file_sha1,
|
|
4485
|
+
created_by: data.created_by,
|
|
4303
4486
|
file_name: data.file.name,
|
|
4304
4487
|
file_type: data.file.type,
|
|
4305
|
-
submitted_at: data.
|
|
4488
|
+
submitted_at: data.submitted_at,
|
|
4306
4489
|
description: data.description,
|
|
4307
4490
|
asset: data.modelId
|
|
4308
4491
|
});
|
|
4309
4492
|
}
|
|
4310
|
-
|
|
4311
|
-
return
|
|
4493
|
+
buildAttachmentPayload(data) {
|
|
4494
|
+
return {
|
|
4495
|
+
...data,
|
|
4496
|
+
asset: data.modelId
|
|
4497
|
+
};
|
|
4498
|
+
}
|
|
4499
|
+
async bulkAdd(payloads) {
|
|
4500
|
+
return this._bulkAdd(payloads.map((p) => ({ modelId: p.assetId, file: p.file })));
|
|
4501
|
+
}
|
|
4502
|
+
async delete(id) {
|
|
4503
|
+
return this._delete(id);
|
|
4312
4504
|
}
|
|
4313
|
-
async
|
|
4314
|
-
|
|
4505
|
+
async refreshStore(projectId) {
|
|
4506
|
+
const result = await this.enqueueRequest({
|
|
4507
|
+
description: "Get asset attachments",
|
|
4508
|
+
method: HttpMethod.GET,
|
|
4509
|
+
url: `${this.url}/`,
|
|
4510
|
+
queryParams: {
|
|
4511
|
+
project: projectId.toString()
|
|
4512
|
+
},
|
|
4513
|
+
blocks: [],
|
|
4514
|
+
blockers: []
|
|
4515
|
+
});
|
|
4516
|
+
this.dispatch(initializeAssetAttachments(result));
|
|
4315
4517
|
}
|
|
4316
4518
|
}
|
|
4317
4519
|
class AssetTypeService extends BaseApiService {
|
|
@@ -4328,8 +4530,8 @@ class AssetTypeService extends BaseApiService {
|
|
|
4328
4530
|
const promise = this.enqueueRequest({
|
|
4329
4531
|
description: "Create asset type",
|
|
4330
4532
|
method: HttpMethod.POST,
|
|
4331
|
-
url:
|
|
4332
|
-
payload:
|
|
4533
|
+
url: "/asset-types/",
|
|
4534
|
+
payload: offlineAssetType,
|
|
4333
4535
|
blockers: [],
|
|
4334
4536
|
blocks: [offlineAssetType.offline_id]
|
|
4335
4537
|
});
|
|
@@ -4354,7 +4556,7 @@ class AssetTypeService extends BaseApiService {
|
|
|
4354
4556
|
const promise = this.enqueueRequest({
|
|
4355
4557
|
description: "Update asset type",
|
|
4356
4558
|
method: HttpMethod.PATCH,
|
|
4357
|
-
url: `/
|
|
4559
|
+
url: `/asset-types/${payload.offline_id}/`,
|
|
4358
4560
|
payload: {
|
|
4359
4561
|
icon: payload.icon,
|
|
4360
4562
|
color: payload.color,
|
|
@@ -4388,7 +4590,7 @@ class AssetTypeService extends BaseApiService {
|
|
|
4388
4590
|
return this.enqueueRequest({
|
|
4389
4591
|
description: "Delete asset type",
|
|
4390
4592
|
method: HttpMethod.DELETE,
|
|
4391
|
-
url: `/
|
|
4593
|
+
url: `/asset-types/${assetTypeId}/`,
|
|
4392
4594
|
blockers: [assetTypeId],
|
|
4393
4595
|
blocks: []
|
|
4394
4596
|
}).catch((e) => {
|
|
@@ -4399,11 +4601,14 @@ class AssetTypeService extends BaseApiService {
|
|
|
4399
4601
|
throw e;
|
|
4400
4602
|
});
|
|
4401
4603
|
}
|
|
4402
|
-
async refreshStore(
|
|
4604
|
+
async refreshStore(organizationId) {
|
|
4403
4605
|
const result = await this.enqueueRequest({
|
|
4404
4606
|
description: "Get asset types",
|
|
4405
4607
|
method: HttpMethod.GET,
|
|
4406
|
-
url:
|
|
4608
|
+
url: "/asset-types/",
|
|
4609
|
+
queryParams: {
|
|
4610
|
+
organization: organizationId.toString()
|
|
4611
|
+
},
|
|
4407
4612
|
blockers: [],
|
|
4408
4613
|
blocks: []
|
|
4409
4614
|
});
|
|
@@ -4413,8 +4618,8 @@ class AssetTypeService extends BaseApiService {
|
|
|
4413
4618
|
class AssetTypeAttachmentService extends BaseAttachmentService {
|
|
4414
4619
|
constructor() {
|
|
4415
4620
|
super(...arguments);
|
|
4416
|
-
__publicField(this, "
|
|
4417
|
-
__publicField(this, "
|
|
4621
|
+
__publicField(this, "name", "Asset Type Attachment");
|
|
4622
|
+
__publicField(this, "url", "/asset-type-attachments");
|
|
4418
4623
|
__publicField(this, "addAttachments", addAssetTypeAttachments);
|
|
4419
4624
|
__publicField(this, "updateAttachments", updateAssetTypeAttachments);
|
|
4420
4625
|
__publicField(this, "removeAttachments", deleteAssetTypeAttachments);
|
|
@@ -4425,20 +4630,39 @@ class AssetTypeAttachmentService extends BaseAttachmentService {
|
|
|
4425
4630
|
buildOfflineAttachment(data) {
|
|
4426
4631
|
return offline({
|
|
4427
4632
|
file: URL.createObjectURL(data.file),
|
|
4428
|
-
file_sha1: data.
|
|
4429
|
-
created_by: data.
|
|
4633
|
+
file_sha1: data.file_sha1,
|
|
4634
|
+
created_by: data.created_by,
|
|
4430
4635
|
file_name: data.file.name,
|
|
4431
4636
|
file_type: data.file.type,
|
|
4432
|
-
submitted_at: data.
|
|
4637
|
+
submitted_at: data.submitted_at,
|
|
4433
4638
|
description: data.description,
|
|
4434
4639
|
asset_type: data.modelId
|
|
4435
4640
|
});
|
|
4436
4641
|
}
|
|
4437
|
-
|
|
4438
|
-
return
|
|
4642
|
+
buildAttachmentPayload(data) {
|
|
4643
|
+
return {
|
|
4644
|
+
...data,
|
|
4645
|
+
asset_type: data.modelId
|
|
4646
|
+
};
|
|
4647
|
+
}
|
|
4648
|
+
async bulkAdd(payloads) {
|
|
4649
|
+
return this._bulkAdd(payloads.map((p) => ({ modelId: p.assetTypeId, file: p.file })));
|
|
4650
|
+
}
|
|
4651
|
+
async delete(attachmentId) {
|
|
4652
|
+
return this._delete(attachmentId);
|
|
4439
4653
|
}
|
|
4440
|
-
async
|
|
4441
|
-
|
|
4654
|
+
async refreshStore(organizationId) {
|
|
4655
|
+
const result = await this.enqueueRequest({
|
|
4656
|
+
description: "Get asset type attachments",
|
|
4657
|
+
method: HttpMethod.GET,
|
|
4658
|
+
url: `${this.url}/`,
|
|
4659
|
+
queryParams: {
|
|
4660
|
+
organization: organizationId.toString()
|
|
4661
|
+
},
|
|
4662
|
+
blocks: [],
|
|
4663
|
+
blockers: []
|
|
4664
|
+
});
|
|
4665
|
+
this.dispatch(initializeAssetTypeAttachments(result));
|
|
4442
4666
|
}
|
|
4443
4667
|
}
|
|
4444
4668
|
class IssueCommentService extends BaseApiService {
|
|
@@ -4454,7 +4678,7 @@ class IssueCommentService extends BaseApiService {
|
|
|
4454
4678
|
const promise = this.enqueueRequest({
|
|
4455
4679
|
description: "Add issue comment",
|
|
4456
4680
|
method: HttpMethod.POST,
|
|
4457
|
-
url:
|
|
4681
|
+
url: "/issue-comments/",
|
|
4458
4682
|
payload: offlineComment,
|
|
4459
4683
|
blockers: [payload.issue],
|
|
4460
4684
|
blocks: [offlineComment.offline_id]
|
|
@@ -4478,7 +4702,7 @@ class IssueCommentService extends BaseApiService {
|
|
|
4478
4702
|
const promise = this.enqueueRequest({
|
|
4479
4703
|
description: "Edit issue comment",
|
|
4480
4704
|
method: HttpMethod.PATCH,
|
|
4481
|
-
url: `/
|
|
4705
|
+
url: `/issue-comments/${payload.offline_id}/`,
|
|
4482
4706
|
payload,
|
|
4483
4707
|
blockers: [payload.offline_id],
|
|
4484
4708
|
blocks: [payload.offline_id]
|
|
@@ -4497,7 +4721,7 @@ class IssueCommentService extends BaseApiService {
|
|
|
4497
4721
|
const promise = this.enqueueRequest({
|
|
4498
4722
|
description: "Delete comment",
|
|
4499
4723
|
method: HttpMethod.DELETE,
|
|
4500
|
-
url: `/
|
|
4724
|
+
url: `/issue-comments/${id}/`,
|
|
4501
4725
|
blockers: [id],
|
|
4502
4726
|
blocks: []
|
|
4503
4727
|
});
|
|
@@ -4510,7 +4734,10 @@ class IssueCommentService extends BaseApiService {
|
|
|
4510
4734
|
const result = await this.enqueueRequest({
|
|
4511
4735
|
description: "Get comments",
|
|
4512
4736
|
method: HttpMethod.GET,
|
|
4513
|
-
url:
|
|
4737
|
+
url: "/issue-comments/",
|
|
4738
|
+
queryParams: {
|
|
4739
|
+
project: projectId.toString()
|
|
4740
|
+
},
|
|
4514
4741
|
blockers: [],
|
|
4515
4742
|
blocks: []
|
|
4516
4743
|
});
|
|
@@ -4522,27 +4749,21 @@ class IssueUpdateService extends BaseApiService {
|
|
|
4522
4749
|
const result = await this.enqueueRequest({
|
|
4523
4750
|
description: "Get issue updates",
|
|
4524
4751
|
method: HttpMethod.GET,
|
|
4525
|
-
url:
|
|
4752
|
+
url: "/issue-updates/",
|
|
4753
|
+
queryParams: {
|
|
4754
|
+
project: projectId.toString()
|
|
4755
|
+
},
|
|
4526
4756
|
blockers: [],
|
|
4527
4757
|
blocks: []
|
|
4528
4758
|
});
|
|
4529
|
-
|
|
4530
|
-
filteredResult = filteredResult.map((comment) => {
|
|
4531
|
-
return { ...comment };
|
|
4532
|
-
});
|
|
4533
|
-
if (result.length !== filteredResult.length) {
|
|
4534
|
-
console.error(
|
|
4535
|
-
`Received duplicate comments from the API (new length ${filteredResult.length}); filtered in browser.`
|
|
4536
|
-
);
|
|
4537
|
-
}
|
|
4538
|
-
this.dispatch(initializeIssueUpdates(filteredResult));
|
|
4759
|
+
this.dispatch(initializeIssueUpdates(result));
|
|
4539
4760
|
}
|
|
4540
4761
|
}
|
|
4541
4762
|
class IssueAttachmentService extends BaseAttachmentService {
|
|
4542
4763
|
constructor() {
|
|
4543
4764
|
super(...arguments);
|
|
4544
|
-
__publicField(this, "
|
|
4545
|
-
__publicField(this, "
|
|
4765
|
+
__publicField(this, "name", "Issue Attachment");
|
|
4766
|
+
__publicField(this, "url", "/issue-attachments");
|
|
4546
4767
|
__publicField(this, "addAttachments", addIssueAttachments);
|
|
4547
4768
|
__publicField(this, "updateAttachments", updateIssueAttachments);
|
|
4548
4769
|
__publicField(this, "removeAttachments", deleteIssueAttachments);
|
|
@@ -4553,24 +4774,42 @@ class IssueAttachmentService extends BaseAttachmentService {
|
|
|
4553
4774
|
buildOfflineAttachment(data) {
|
|
4554
4775
|
return offline({
|
|
4555
4776
|
file: URL.createObjectURL(data.file),
|
|
4556
|
-
file_sha1: data.
|
|
4557
|
-
created_by: data.
|
|
4777
|
+
file_sha1: data.file_sha1,
|
|
4778
|
+
created_by: data.created_by,
|
|
4558
4779
|
file_name: data.file.name,
|
|
4559
4780
|
file_type: data.file.type,
|
|
4560
|
-
submitted_at: data.
|
|
4781
|
+
submitted_at: data.submitted_at,
|
|
4561
4782
|
description: data.description,
|
|
4562
4783
|
issue: data.modelId
|
|
4563
4784
|
});
|
|
4564
4785
|
}
|
|
4565
|
-
|
|
4566
|
-
return
|
|
4786
|
+
buildAttachmentPayload(data) {
|
|
4787
|
+
return {
|
|
4788
|
+
...data,
|
|
4789
|
+
issue: data.modelId
|
|
4790
|
+
};
|
|
4791
|
+
}
|
|
4792
|
+
async bulkAdd(payloads) {
|
|
4793
|
+
return this._bulkAdd(payloads.map((p) => ({ modelId: p.issueId, file: p.file })));
|
|
4794
|
+
}
|
|
4795
|
+
async delete(id) {
|
|
4796
|
+
return this._delete(id);
|
|
4567
4797
|
}
|
|
4568
|
-
async
|
|
4569
|
-
|
|
4798
|
+
async refreshStore(projectId) {
|
|
4799
|
+
const result = await this.enqueueRequest({
|
|
4800
|
+
description: "Get issue attachments",
|
|
4801
|
+
method: HttpMethod.GET,
|
|
4802
|
+
url: `${this.url}/`,
|
|
4803
|
+
queryParams: {
|
|
4804
|
+
project: projectId.toString()
|
|
4805
|
+
},
|
|
4806
|
+
blocks: [],
|
|
4807
|
+
blockers: []
|
|
4808
|
+
});
|
|
4809
|
+
this.dispatch(initializeIssueAttachments(result));
|
|
4570
4810
|
}
|
|
4571
4811
|
}
|
|
4572
4812
|
class IssueService extends BaseApiService {
|
|
4573
|
-
// Basic CRUD functions
|
|
4574
4813
|
add(payload) {
|
|
4575
4814
|
var _a2;
|
|
4576
4815
|
const { store } = this.client;
|
|
@@ -4587,10 +4826,6 @@ class IssueService extends BaseApiService {
|
|
|
4587
4826
|
description: "Create issue",
|
|
4588
4827
|
method: HttpMethod.POST,
|
|
4589
4828
|
url: "/issues/",
|
|
4590
|
-
queryParams: {
|
|
4591
|
-
workspace_id: payload.index_workspace,
|
|
4592
|
-
...payload.issue_type ? { issue_type: payload.issue_type } : {}
|
|
4593
|
-
},
|
|
4594
4829
|
payload: offlineIssue,
|
|
4595
4830
|
blockers: ["add-issue", ...offlineIssue.index_workspace ? [offlineIssue.index_workspace] : []],
|
|
4596
4831
|
blocks: [offlineIssue.offline_id]
|
|
@@ -4740,7 +4975,10 @@ class IssueService extends BaseApiService {
|
|
|
4740
4975
|
const result = await this.enqueueRequest({
|
|
4741
4976
|
description: "Get issues",
|
|
4742
4977
|
method: HttpMethod.GET,
|
|
4743
|
-
url:
|
|
4978
|
+
url: "/issues/",
|
|
4979
|
+
queryParams: {
|
|
4980
|
+
project: projectId.toString()
|
|
4981
|
+
},
|
|
4744
4982
|
blockers: [],
|
|
4745
4983
|
blocks: []
|
|
4746
4984
|
});
|
|
@@ -4760,16 +4998,8 @@ class IssueTypeService extends BaseApiService {
|
|
|
4760
4998
|
this.dispatch(addIssueType(offlineIssueType));
|
|
4761
4999
|
const promise = this.enqueueRequest({
|
|
4762
5000
|
method: HttpMethod.POST,
|
|
4763
|
-
url:
|
|
4764
|
-
|
|
4765
|
-
payload: {
|
|
4766
|
-
offline_id: offlineIssueType.offline_id,
|
|
4767
|
-
submitted_at: offlineIssueType.submitted_at,
|
|
4768
|
-
icon: offlineIssueType.icon,
|
|
4769
|
-
color: offlineIssueType.color,
|
|
4770
|
-
name: offlineIssueType.name,
|
|
4771
|
-
description: offlineIssueType.description
|
|
4772
|
-
},
|
|
5001
|
+
url: "/issue-types/",
|
|
5002
|
+
payload: offlineIssueType,
|
|
4773
5003
|
blockers: [],
|
|
4774
5004
|
blocks: [offlineIssueType.offline_id]
|
|
4775
5005
|
});
|
|
@@ -4794,7 +5024,7 @@ class IssueTypeService extends BaseApiService {
|
|
|
4794
5024
|
this.dispatch(updateIssueType(offlineUpdatedIssueType));
|
|
4795
5025
|
const promise = this.enqueueRequest({
|
|
4796
5026
|
method: HttpMethod.PATCH,
|
|
4797
|
-
url: `/
|
|
5027
|
+
url: `/issue-types/${payload.offline_id}/`,
|
|
4798
5028
|
payload,
|
|
4799
5029
|
blockers: [payload.offline_id],
|
|
4800
5030
|
blocks: [payload.offline_id]
|
|
@@ -4818,7 +5048,7 @@ class IssueTypeService extends BaseApiService {
|
|
|
4818
5048
|
this.dispatch(deleteIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
|
|
4819
5049
|
const promise = this.enqueueRequest({
|
|
4820
5050
|
method: HttpMethod.DELETE,
|
|
4821
|
-
url: `/
|
|
5051
|
+
url: `/issue-types/${id}/`,
|
|
4822
5052
|
blockers: [id],
|
|
4823
5053
|
blocks: []
|
|
4824
5054
|
});
|
|
@@ -4831,7 +5061,10 @@ class IssueTypeService extends BaseApiService {
|
|
|
4831
5061
|
async refreshStore(organizationId) {
|
|
4832
5062
|
const result = await this.enqueueRequest({
|
|
4833
5063
|
method: HttpMethod.GET,
|
|
4834
|
-
url:
|
|
5064
|
+
url: "/issue-types/",
|
|
5065
|
+
queryParams: {
|
|
5066
|
+
organization: organizationId.toString()
|
|
5067
|
+
},
|
|
4835
5068
|
blockers: [],
|
|
4836
5069
|
blocks: []
|
|
4837
5070
|
});
|
|
@@ -4970,8 +5203,8 @@ class ProjectFileService extends BaseApiService {
|
|
|
4970
5203
|
class ProjectAttachmentService extends BaseAttachmentService {
|
|
4971
5204
|
constructor() {
|
|
4972
5205
|
super(...arguments);
|
|
4973
|
-
__publicField(this, "
|
|
4974
|
-
__publicField(this, "
|
|
5206
|
+
__publicField(this, "name", "Project Attachment");
|
|
5207
|
+
__publicField(this, "url", "/project-attachments");
|
|
4975
5208
|
__publicField(this, "addAttachments", addProjectAttachments);
|
|
4976
5209
|
__publicField(this, "updateAttachments", updateProjectAttachments);
|
|
4977
5210
|
__publicField(this, "removeAttachments", deleteProjectAttachments);
|
|
@@ -4982,20 +5215,39 @@ class ProjectAttachmentService extends BaseAttachmentService {
|
|
|
4982
5215
|
buildOfflineAttachment(data) {
|
|
4983
5216
|
return offline({
|
|
4984
5217
|
file: URL.createObjectURL(data.file),
|
|
4985
|
-
file_sha1: data.
|
|
4986
|
-
created_by: data.
|
|
5218
|
+
file_sha1: data.file_sha1,
|
|
5219
|
+
created_by: data.created_by,
|
|
4987
5220
|
file_name: data.file.name,
|
|
4988
5221
|
file_type: data.file.type,
|
|
4989
|
-
submitted_at: data.
|
|
5222
|
+
submitted_at: data.submitted_at,
|
|
4990
5223
|
description: data.description,
|
|
4991
5224
|
project: data.modelId
|
|
4992
5225
|
});
|
|
4993
5226
|
}
|
|
4994
|
-
|
|
4995
|
-
return
|
|
5227
|
+
buildAttachmentPayload(data) {
|
|
5228
|
+
return {
|
|
5229
|
+
...data,
|
|
5230
|
+
project: data.modelId
|
|
5231
|
+
};
|
|
4996
5232
|
}
|
|
4997
|
-
async
|
|
4998
|
-
return this.
|
|
5233
|
+
async bulkAdd(payloads) {
|
|
5234
|
+
return this._bulkAdd(payloads.map((p) => ({ modelId: p.projectId, file: p.file })));
|
|
5235
|
+
}
|
|
5236
|
+
async delete(attachmentId) {
|
|
5237
|
+
return this._delete(attachmentId);
|
|
5238
|
+
}
|
|
5239
|
+
async refreshStore(projectId) {
|
|
5240
|
+
const result = await this.enqueueRequest({
|
|
5241
|
+
description: "Get project attachments",
|
|
5242
|
+
method: HttpMethod.GET,
|
|
5243
|
+
url: `${this.url}/`,
|
|
5244
|
+
queryParams: {
|
|
5245
|
+
project: projectId.toString()
|
|
5246
|
+
},
|
|
5247
|
+
blockers: [],
|
|
5248
|
+
blocks: []
|
|
5249
|
+
});
|
|
5250
|
+
this.dispatch(initializeProjectAttachments(result));
|
|
4999
5251
|
}
|
|
5000
5252
|
}
|
|
5001
5253
|
class ProjectService extends BaseApiService {
|
|
@@ -5138,88 +5390,31 @@ const separateImageFromFields = async (fields) => {
|
|
|
5138
5390
|
return { fields: newFields, images };
|
|
5139
5391
|
};
|
|
5140
5392
|
class FormService extends BaseUploadService {
|
|
5141
|
-
|
|
5393
|
+
add(payload, initialRevision) {
|
|
5142
5394
|
var _a2;
|
|
5395
|
+
const { store } = this.client;
|
|
5143
5396
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5144
|
-
const createdBy = (_a2 =
|
|
5145
|
-
const
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
const sha1 = await hashFile(file);
|
|
5150
|
-
if (!(sha1 in filePayloads)) {
|
|
5151
|
-
filePayloads[sha1] = {
|
|
5152
|
-
sha1,
|
|
5153
|
-
file_type: file.type,
|
|
5154
|
-
extension: file.name.split(".").pop(),
|
|
5155
|
-
size: file.size
|
|
5156
|
-
};
|
|
5157
|
-
await this.client.files.addCache(file, sha1);
|
|
5158
|
-
}
|
|
5159
|
-
const offlineFormRevisionAttachment = offline({
|
|
5160
|
-
file: URL.createObjectURL(file),
|
|
5161
|
-
file_type: file.type,
|
|
5162
|
-
file_name: file.name,
|
|
5163
|
-
file_sha1: sha1,
|
|
5164
|
-
created_by: createdBy,
|
|
5165
|
-
revision: revisionId,
|
|
5166
|
-
submitted_at: submittedAt,
|
|
5167
|
-
field_identifier: fieldIdentifier
|
|
5168
|
-
});
|
|
5169
|
-
offlineFormRevisionAttachments.push(offlineFormRevisionAttachment);
|
|
5170
|
-
const attachmentPayload = {
|
|
5171
|
-
offline_id: offlineFormRevisionAttachment.offline_id,
|
|
5172
|
-
name: file.name,
|
|
5173
|
-
field_identifier: fieldIdentifier,
|
|
5174
|
-
sha1
|
|
5175
|
-
};
|
|
5176
|
-
attachmentPayloads.push(attachmentPayload);
|
|
5177
|
-
}
|
|
5178
|
-
this.dispatch(addFormRevisionAttachments(offlineFormRevisionAttachments));
|
|
5179
|
-
const promise = this.enqueueRequest({
|
|
5180
|
-
description: "Attach files to form revision",
|
|
5181
|
-
method: HttpMethod.POST,
|
|
5182
|
-
url: `/forms/revisions/${revisionId}/attachments/bulk/`,
|
|
5183
|
-
payload: {
|
|
5184
|
-
submitted_at: submittedAt,
|
|
5185
|
-
attachments: attachmentPayloads,
|
|
5186
|
-
files: Object.values(filePayloads)
|
|
5187
|
-
},
|
|
5188
|
-
blockers: [revisionId],
|
|
5189
|
-
blocks: offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
|
|
5190
|
-
});
|
|
5191
|
-
promise.then((result) => {
|
|
5192
|
-
this.processPresignedUrls(result.presigned_urls);
|
|
5193
|
-
this.dispatch(updateFormRevisionAttachments(result.attachments));
|
|
5194
|
-
}).catch(() => {
|
|
5195
|
-
this.dispatch(
|
|
5196
|
-
deleteFormRevisionAttachments(
|
|
5197
|
-
offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
|
|
5198
|
-
)
|
|
5199
|
-
);
|
|
5397
|
+
const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
5398
|
+
const offlineForm = offline({
|
|
5399
|
+
...payload,
|
|
5400
|
+
submitted_at: submittedAt,
|
|
5401
|
+
created_by: createdBy
|
|
5200
5402
|
});
|
|
5201
|
-
return [offlineFormRevisionAttachments, promise.then(({ attachments }) => attachments)];
|
|
5202
|
-
}
|
|
5203
|
-
async add(ownerId, form, initialRevision, urlPrefix) {
|
|
5204
|
-
const { fields, images } = await separateImageFromFields(initialRevision.fields);
|
|
5205
5403
|
const offlineFormRevision = offline({
|
|
5206
5404
|
...initialRevision,
|
|
5207
|
-
|
|
5208
|
-
|
|
5209
|
-
|
|
5210
|
-
|
|
5211
|
-
revision: "Pending"
|
|
5405
|
+
form: offlineForm.offline_id,
|
|
5406
|
+
revision: "Pending",
|
|
5407
|
+
submitted_at: submittedAt,
|
|
5408
|
+
created_by: createdBy
|
|
5212
5409
|
});
|
|
5213
|
-
this.dispatch(addForm(
|
|
5410
|
+
this.dispatch(addForm(offlineForm));
|
|
5214
5411
|
this.dispatch(addFormRevision(offlineFormRevision));
|
|
5215
5412
|
const formPromise = this.enqueueRequest({
|
|
5216
5413
|
description: "Create form",
|
|
5217
5414
|
method: HttpMethod.POST,
|
|
5218
|
-
url:
|
|
5415
|
+
url: "/forms/",
|
|
5219
5416
|
payload: {
|
|
5220
|
-
|
|
5221
|
-
offline_id: form.offline_id,
|
|
5222
|
-
submitted_at: form.submitted_at,
|
|
5417
|
+
...offlineForm,
|
|
5223
5418
|
initial_revision: {
|
|
5224
5419
|
offline_id: offlineFormRevision.offline_id,
|
|
5225
5420
|
submitted_at: offlineFormRevision.submitted_at,
|
|
@@ -5228,111 +5423,15 @@ class FormService extends BaseUploadService {
|
|
|
5228
5423
|
fields: offlineFormRevision.fields
|
|
5229
5424
|
}
|
|
5230
5425
|
},
|
|
5231
|
-
blockers: [
|
|
5232
|
-
blocks: [
|
|
5426
|
+
blockers: [],
|
|
5427
|
+
blocks: [offlineForm.offline_id, offlineFormRevision.offline_id]
|
|
5233
5428
|
});
|
|
5234
|
-
const [offlineFormRevisionAttachments, attachmentsPromise] = await this.bulkAddRevisionAttachments(
|
|
5235
|
-
offlineFormRevision.offline_id,
|
|
5236
|
-
images
|
|
5237
|
-
);
|
|
5238
5429
|
void formPromise.catch((e) => {
|
|
5239
|
-
this.dispatch(deleteForm(
|
|
5430
|
+
this.dispatch(deleteForm(offlineForm.offline_id));
|
|
5240
5431
|
this.dispatch(deleteFormRevision(offlineFormRevision.offline_id));
|
|
5241
5432
|
throw e;
|
|
5242
5433
|
});
|
|
5243
|
-
return [
|
|
5244
|
-
}
|
|
5245
|
-
addForOrganization(organizationId, initialRevision) {
|
|
5246
|
-
var _a2;
|
|
5247
|
-
const state = this.client.store.getState();
|
|
5248
|
-
const offlineForm = offline({
|
|
5249
|
-
favorite: false,
|
|
5250
|
-
created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
|
|
5251
|
-
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5252
|
-
organization: organizationId
|
|
5253
|
-
});
|
|
5254
|
-
return this.add(
|
|
5255
|
-
organizationId.toString(),
|
|
5256
|
-
offlineForm,
|
|
5257
|
-
initialRevision,
|
|
5258
|
-
`/organizations/${organizationId}/create-form/`
|
|
5259
|
-
);
|
|
5260
|
-
}
|
|
5261
|
-
addForProject(projectId, initialRevision) {
|
|
5262
|
-
var _a2;
|
|
5263
|
-
const state = this.client.store.getState();
|
|
5264
|
-
const offlineForm = offline({
|
|
5265
|
-
favorite: false,
|
|
5266
|
-
created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
|
|
5267
|
-
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5268
|
-
project: projectId
|
|
5269
|
-
});
|
|
5270
|
-
return this.add(projectId.toString(), offlineForm, initialRevision, `/projects/${projectId}/create-form/`);
|
|
5271
|
-
}
|
|
5272
|
-
addForIssueType(issueTypeId, initialRevision) {
|
|
5273
|
-
var _a2;
|
|
5274
|
-
const state = this.client.store.getState();
|
|
5275
|
-
const offlineForm = offline({
|
|
5276
|
-
favorite: false,
|
|
5277
|
-
created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
|
|
5278
|
-
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5279
|
-
issue_type: issueTypeId
|
|
5280
|
-
});
|
|
5281
|
-
return this.add(issueTypeId, offlineForm, initialRevision, `/issues/types/${issueTypeId}/create-form/`);
|
|
5282
|
-
}
|
|
5283
|
-
addForAssetType(assetTypeId, initialRevision) {
|
|
5284
|
-
var _a2;
|
|
5285
|
-
const state = this.client.store.getState();
|
|
5286
|
-
const offlineForm = offline({
|
|
5287
|
-
favorite: false,
|
|
5288
|
-
created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
|
|
5289
|
-
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5290
|
-
asset_type: assetTypeId
|
|
5291
|
-
});
|
|
5292
|
-
return this.add(assetTypeId, offlineForm, initialRevision, `/assets/types/${assetTypeId}/create-form/`);
|
|
5293
|
-
}
|
|
5294
|
-
async createRevision(formId, revision) {
|
|
5295
|
-
var _a2;
|
|
5296
|
-
const offlineRevision = offline(revision);
|
|
5297
|
-
const { store } = this.client;
|
|
5298
|
-
const state = store.getState();
|
|
5299
|
-
const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
5300
|
-
const { fields, images } = await separateImageFromFields(offlineRevision.fields);
|
|
5301
|
-
const fullRevision = {
|
|
5302
|
-
...offlineRevision,
|
|
5303
|
-
fields,
|
|
5304
|
-
created_by: createdBy,
|
|
5305
|
-
revision: "Pending",
|
|
5306
|
-
form: formId,
|
|
5307
|
-
submitted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5308
|
-
};
|
|
5309
|
-
this.dispatch(addFormRevision(fullRevision));
|
|
5310
|
-
const promise = this.enqueueRequest({
|
|
5311
|
-
description: "Create form revision",
|
|
5312
|
-
method: HttpMethod.PATCH,
|
|
5313
|
-
url: `/forms/${formId}/`,
|
|
5314
|
-
payload: {
|
|
5315
|
-
initial_revision: {
|
|
5316
|
-
offline_id: fullRevision.offline_id,
|
|
5317
|
-
submitted_at: fullRevision.submitted_at,
|
|
5318
|
-
title: fullRevision.title,
|
|
5319
|
-
description: fullRevision.description,
|
|
5320
|
-
fields: fullRevision.fields
|
|
5321
|
-
}
|
|
5322
|
-
},
|
|
5323
|
-
blockers: [formId],
|
|
5324
|
-
blocks: [offlineRevision.offline_id]
|
|
5325
|
-
});
|
|
5326
|
-
const [offlineFormRevisionAttachments, attachmentsPromise] = await this.bulkAddRevisionAttachments(
|
|
5327
|
-
fullRevision.offline_id,
|
|
5328
|
-
images
|
|
5329
|
-
);
|
|
5330
|
-
void promise.then((result) => {
|
|
5331
|
-
this.dispatch(setFormRevision(result));
|
|
5332
|
-
}).catch(() => {
|
|
5333
|
-
this.dispatch(deleteFormRevision(fullRevision.offline_id));
|
|
5334
|
-
});
|
|
5335
|
-
return [fullRevision, offlineFormRevisionAttachments, promise, attachmentsPromise];
|
|
5434
|
+
return [offlineForm, offlineFormRevision, formPromise];
|
|
5336
5435
|
}
|
|
5337
5436
|
async delete(id) {
|
|
5338
5437
|
const { store } = this.client;
|
|
@@ -5369,53 +5468,18 @@ class FormService extends BaseUploadService {
|
|
|
5369
5468
|
throw e;
|
|
5370
5469
|
}
|
|
5371
5470
|
}
|
|
5372
|
-
async refreshStore(
|
|
5373
|
-
const forms =
|
|
5374
|
-
const revisions = [];
|
|
5375
|
-
const attachments = [];
|
|
5376
|
-
const projectFormsResult = await this.enqueueRequest({
|
|
5377
|
-
description: "Fetch project forms",
|
|
5378
|
-
method: HttpMethod.GET,
|
|
5379
|
-
url: `/projects/${projectId}/forms/`,
|
|
5380
|
-
blockers: [projectId.toString()],
|
|
5381
|
-
blocks: []
|
|
5382
|
-
});
|
|
5383
|
-
for (const form of projectFormsResult.forms) forms.push(form);
|
|
5384
|
-
for (const revision of projectFormsResult.revisions) revisions.push(revision);
|
|
5385
|
-
for (const attachment of projectFormsResult.attachments) attachments.push(attachment);
|
|
5386
|
-
const organizationFormsResult = await this.enqueueRequest({
|
|
5471
|
+
async refreshStore(organizationId) {
|
|
5472
|
+
const forms = await this.enqueueRequest({
|
|
5387
5473
|
description: "Fetch organization forms",
|
|
5388
5474
|
method: HttpMethod.GET,
|
|
5389
|
-
url:
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
for (const revision of organizationFormsResult.revisions) revisions.push(revision);
|
|
5395
|
-
for (const attachment of organizationFormsResult.attachments) attachments.push(attachment);
|
|
5396
|
-
const assetTypeFormsResult = await this.enqueueRequest({
|
|
5397
|
-
description: "Fetch asset type forms",
|
|
5398
|
-
method: HttpMethod.GET,
|
|
5399
|
-
url: `/projects/${projectId}/asset-types/forms/`,
|
|
5400
|
-
blockers: [projectId.toString()],
|
|
5401
|
-
blocks: []
|
|
5402
|
-
});
|
|
5403
|
-
for (const form of assetTypeFormsResult.forms) forms.push(form);
|
|
5404
|
-
for (const revision of assetTypeFormsResult.revisions) revisions.push(revision);
|
|
5405
|
-
for (const attachment of assetTypeFormsResult.attachments) attachments.push(attachment);
|
|
5406
|
-
const issueTypeFormsResult = await this.enqueueRequest({
|
|
5407
|
-
description: "Fetch issue type forms",
|
|
5408
|
-
method: HttpMethod.GET,
|
|
5409
|
-
url: `/projects/${projectId}/issue-types/forms/`,
|
|
5410
|
-
blockers: [projectId.toString()],
|
|
5475
|
+
url: "/forms/",
|
|
5476
|
+
queryParams: {
|
|
5477
|
+
organization: organizationId.toString()
|
|
5478
|
+
},
|
|
5479
|
+
blockers: [organizationId.toString()],
|
|
5411
5480
|
blocks: []
|
|
5412
5481
|
});
|
|
5413
|
-
for (const form of issueTypeFormsResult.forms) forms.push(form);
|
|
5414
|
-
for (const revision of issueTypeFormsResult.revisions) revisions.push(revision);
|
|
5415
|
-
for (const attachment of issueTypeFormsResult.attachments) attachments.push(attachment);
|
|
5416
5482
|
this.dispatch(initializeForms(forms));
|
|
5417
|
-
this.dispatch(initializeFormRevisions(revisions));
|
|
5418
|
-
this.dispatch(initializeFormRevisionAttachments(attachments));
|
|
5419
5483
|
}
|
|
5420
5484
|
}
|
|
5421
5485
|
const isArrayOfFiles = (value) => {
|
|
@@ -5437,95 +5501,11 @@ const separateFilesFromValues = (values) => {
|
|
|
5437
5501
|
return { values: newValues, files };
|
|
5438
5502
|
};
|
|
5439
5503
|
class FormSubmissionService extends BaseUploadService {
|
|
5440
|
-
|
|
5441
|
-
var _a2;
|
|
5442
|
-
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5443
|
-
const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
5444
|
-
const filePayloads = {};
|
|
5445
|
-
const offlineFormSubmissionAttachments = [];
|
|
5446
|
-
const attachmentPayloads = [];
|
|
5447
|
-
for (const [fieldIdentifier, filesArray] of Object.entries(files)) {
|
|
5448
|
-
for (const file of filesArray) {
|
|
5449
|
-
const sha1 = await hashFile(file);
|
|
5450
|
-
if (!(sha1 in filePayloads)) {
|
|
5451
|
-
filePayloads[sha1] = {
|
|
5452
|
-
sha1,
|
|
5453
|
-
file_type: file.type,
|
|
5454
|
-
extension: file.name.split(".").pop(),
|
|
5455
|
-
size: file.size
|
|
5456
|
-
};
|
|
5457
|
-
await this.client.files.addCache(file, sha1);
|
|
5458
|
-
}
|
|
5459
|
-
const offlineFormSubmissionAttachment = offline({
|
|
5460
|
-
file: URL.createObjectURL(file),
|
|
5461
|
-
file_type: file.type,
|
|
5462
|
-
file_name: file.name,
|
|
5463
|
-
file_sha1: sha1,
|
|
5464
|
-
created_by: createdBy,
|
|
5465
|
-
submission: submissionId,
|
|
5466
|
-
submitted_at: submittedAt,
|
|
5467
|
-
field_identifier: fieldIdentifier
|
|
5468
|
-
});
|
|
5469
|
-
offlineFormSubmissionAttachments.push(offlineFormSubmissionAttachment);
|
|
5470
|
-
const attachmentPayload = {
|
|
5471
|
-
offline_id: offlineFormSubmissionAttachment.offline_id,
|
|
5472
|
-
name: file.name,
|
|
5473
|
-
sha1,
|
|
5474
|
-
field_identifier: fieldIdentifier
|
|
5475
|
-
};
|
|
5476
|
-
attachmentPayloads.push(attachmentPayload);
|
|
5477
|
-
}
|
|
5478
|
-
}
|
|
5479
|
-
this.dispatch(addFormSubmissionAttachments(offlineFormSubmissionAttachments));
|
|
5480
|
-
const promise = this.enqueueRequest({
|
|
5481
|
-
description: "Attach files to form submission",
|
|
5482
|
-
method: HttpMethod.POST,
|
|
5483
|
-
url: `/forms/submissions/${submissionId}/attachments/bulk/`,
|
|
5484
|
-
payload: {
|
|
5485
|
-
submitted_at: submittedAt,
|
|
5486
|
-
attachments: attachmentPayloads,
|
|
5487
|
-
files: Object.values(filePayloads)
|
|
5488
|
-
},
|
|
5489
|
-
blockers: [submissionId],
|
|
5490
|
-
blocks: offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
|
|
5491
|
-
});
|
|
5492
|
-
promise.then((result) => {
|
|
5493
|
-
this.processPresignedUrls(result.presigned_urls);
|
|
5494
|
-
this.dispatch(updateFormSubmissionAttachments(result.attachments));
|
|
5495
|
-
}).catch(() => {
|
|
5496
|
-
this.dispatch(
|
|
5497
|
-
deleteFormSubmissionAttachments(
|
|
5498
|
-
offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
|
|
5499
|
-
)
|
|
5500
|
-
);
|
|
5501
|
-
});
|
|
5502
|
-
return [offlineFormSubmissionAttachments, promise.then(({ attachments }) => attachments)];
|
|
5503
|
-
}
|
|
5504
|
-
async bulkDeleteSubmissionAttachments(submissionId, attachmentsIds) {
|
|
5505
|
-
const { store } = this.client;
|
|
5506
|
-
const state = store.getState();
|
|
5507
|
-
const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(attachmentsIds)(state);
|
|
5508
|
-
this.dispatch(deleteFormSubmissionAttachments(attachmentsIds));
|
|
5509
|
-
try {
|
|
5510
|
-
await this.enqueueRequest({
|
|
5511
|
-
description: "Delete form submission attachments",
|
|
5512
|
-
method: HttpMethod.DELETE,
|
|
5513
|
-
url: `/forms/submissions/${submissionId}/attachments/bulk/`,
|
|
5514
|
-
payload: { attachments: attachmentsIds },
|
|
5515
|
-
blockers: [submissionId, ...attachmentsIds],
|
|
5516
|
-
blocks: []
|
|
5517
|
-
});
|
|
5518
|
-
} catch (e) {
|
|
5519
|
-
this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
|
|
5520
|
-
throw e;
|
|
5521
|
-
}
|
|
5522
|
-
}
|
|
5523
|
-
// Outer promise is for hashing and caching files for submission attachments
|
|
5524
|
-
async add(payload) {
|
|
5504
|
+
add(payload) {
|
|
5525
5505
|
var _a2;
|
|
5526
5506
|
const { store } = this.client;
|
|
5527
5507
|
const state = store.getState();
|
|
5528
|
-
const { values
|
|
5508
|
+
const { values } = separateFilesFromValues(payload.values);
|
|
5529
5509
|
const offlineSubmission = offline({
|
|
5530
5510
|
...payload,
|
|
5531
5511
|
values,
|
|
@@ -5533,132 +5513,35 @@ class FormSubmissionService extends BaseUploadService {
|
|
|
5533
5513
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5534
5514
|
});
|
|
5535
5515
|
const promise = this.enqueueRequest({
|
|
5536
|
-
description: "
|
|
5516
|
+
description: "Add form submission",
|
|
5537
5517
|
method: HttpMethod.POST,
|
|
5538
|
-
url:
|
|
5518
|
+
url: "/form-submissions/",
|
|
5539
5519
|
payload: offlineSubmission,
|
|
5540
|
-
blockers: [
|
|
5541
|
-
|
|
5542
|
-
|
|
5520
|
+
blockers: [
|
|
5521
|
+
"add-form-entry",
|
|
5522
|
+
payload.form_revision,
|
|
5523
|
+
...payload.issue ? [payload.issue] : [],
|
|
5524
|
+
...payload.asset ? [payload.asset] : []
|
|
5525
|
+
],
|
|
5543
5526
|
blocks: [offlineSubmission.offline_id]
|
|
5544
5527
|
});
|
|
5545
5528
|
this.dispatch(addFormSubmission(offlineSubmission));
|
|
5546
|
-
const [offlineFormSubmissionAttachments, attachmentsPromise] = await this.bulkAddSubmissionAttachments(
|
|
5547
|
-
offlineSubmission.offline_id,
|
|
5548
|
-
files
|
|
5549
|
-
);
|
|
5550
5529
|
promise.then((result) => {
|
|
5551
5530
|
this.dispatch(setFormSubmission(result));
|
|
5552
5531
|
return result;
|
|
5553
5532
|
}).catch(() => {
|
|
5554
5533
|
this.dispatch(deleteFormSubmission(offlineSubmission.offline_id));
|
|
5555
5534
|
});
|
|
5556
|
-
return [offlineSubmission,
|
|
5557
|
-
}
|
|
5558
|
-
// Note currently the bulkAdd method is specific to form submissions for assets
|
|
5559
|
-
// TODO: adapt the support bulk adding to any model type
|
|
5560
|
-
async bulkAdd(args, batchSize) {
|
|
5561
|
-
const { formRevision, commonFieldValues, fieldValuesByAsset } = args;
|
|
5562
|
-
const { values: fileSeperatedCommonFieldValues, files: commonFiles } = separateFilesFromValues(commonFieldValues);
|
|
5563
|
-
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5564
|
-
const transactionId = v4();
|
|
5565
|
-
const assetIdBatches = chunkArray(Object.keys(fieldValuesByAsset), batchSize);
|
|
5566
|
-
const bulkAddBatches = await Promise.all(
|
|
5567
|
-
assetIdBatches.map(async (assetIdBatch) => {
|
|
5568
|
-
const batchId = v4();
|
|
5569
|
-
const submissionPayloads = [];
|
|
5570
|
-
const attachmentPayloads = [];
|
|
5571
|
-
const files = { ...commonFiles };
|
|
5572
|
-
for (const assetId of assetIdBatch) {
|
|
5573
|
-
const { values: fileSeperatedSubmissionSpecificValues, files: submissionSpecificFiles } = separateFilesFromValues(fieldValuesByAsset[assetId] ?? {});
|
|
5574
|
-
Object.assign(files, submissionSpecificFiles);
|
|
5575
|
-
const submissionPayload = offline({
|
|
5576
|
-
asset_id: assetId,
|
|
5577
|
-
form_data: fileSeperatedSubmissionSpecificValues
|
|
5578
|
-
});
|
|
5579
|
-
submissionPayloads.push(submissionPayload);
|
|
5580
|
-
for (const [fieldIdentifier, fileArray] of Object.entries(files)) {
|
|
5581
|
-
for (const file of fileArray) {
|
|
5582
|
-
const sha1 = await hashFile(file);
|
|
5583
|
-
await this.client.files.addCache(file, sha1);
|
|
5584
|
-
const attachmentPayload = offline({
|
|
5585
|
-
submission_id: submissionPayload.offline_id,
|
|
5586
|
-
sha1,
|
|
5587
|
-
name: file.name,
|
|
5588
|
-
field_identifier: fieldIdentifier
|
|
5589
|
-
});
|
|
5590
|
-
attachmentPayloads.push(attachmentPayload);
|
|
5591
|
-
}
|
|
5592
|
-
}
|
|
5593
|
-
}
|
|
5594
|
-
const filePaylods = [];
|
|
5595
|
-
for (const file of Object.values(files).flat()) {
|
|
5596
|
-
const sha1 = await hashFile(file);
|
|
5597
|
-
const filePayload = {
|
|
5598
|
-
sha1,
|
|
5599
|
-
extension: file.name.split(".").pop() || "",
|
|
5600
|
-
file_type: file.type,
|
|
5601
|
-
size: file.size
|
|
5602
|
-
};
|
|
5603
|
-
filePaylods.push(filePayload);
|
|
5604
|
-
}
|
|
5605
|
-
return {
|
|
5606
|
-
batchId,
|
|
5607
|
-
payload: {
|
|
5608
|
-
transaction_id: transactionId,
|
|
5609
|
-
form_data: fileSeperatedCommonFieldValues,
|
|
5610
|
-
submitted_at: submittedAt,
|
|
5611
|
-
submissions: submissionPayloads,
|
|
5612
|
-
attachments: attachmentPayloads,
|
|
5613
|
-
files: filePaylods
|
|
5614
|
-
}
|
|
5615
|
-
};
|
|
5616
|
-
})
|
|
5617
|
-
);
|
|
5618
|
-
const batchPromises = [];
|
|
5619
|
-
let prevBatchId = null;
|
|
5620
|
-
for (const batch of bulkAddBatches) {
|
|
5621
|
-
const { payload, batchId } = batch;
|
|
5622
|
-
const batchAssetIds = payload.submissions.map((x) => x.asset_id);
|
|
5623
|
-
const batchSubmissionOfflineIds = payload.submissions.map((x) => x.offline_id);
|
|
5624
|
-
const batchAttachmentsOfflineIds = payload.attachments.map((x) => x.offline_id);
|
|
5625
|
-
const blockers = batchAssetIds;
|
|
5626
|
-
if (prevBatchId) blockers.push(prevBatchId);
|
|
5627
|
-
const blocks = [...batchSubmissionOfflineIds, ...batchAttachmentsOfflineIds, batchId];
|
|
5628
|
-
const promise = this.enqueueRequest({
|
|
5629
|
-
description: "Bulk add form submissions",
|
|
5630
|
-
method: HttpMethod.POST,
|
|
5631
|
-
url: `/forms/revisions/${formRevision}/bulk-respond/`,
|
|
5632
|
-
payload,
|
|
5633
|
-
blockers,
|
|
5634
|
-
blocks
|
|
5635
|
-
});
|
|
5636
|
-
void promise.then(({ presigned_urls }) => {
|
|
5637
|
-
this.processPresignedUrls(presigned_urls);
|
|
5638
|
-
});
|
|
5639
|
-
prevBatchId = batchId;
|
|
5640
|
-
batchPromises.push(promise);
|
|
5641
|
-
}
|
|
5642
|
-
void Promise.all(batchPromises).then((results) => {
|
|
5643
|
-
const createdSubmissions = [];
|
|
5644
|
-
const createdAttachments = [];
|
|
5645
|
-
for (const result of results) {
|
|
5646
|
-
for (const createdSubmission of result.submissions) createdSubmissions.push(createdSubmission);
|
|
5647
|
-
for (const createdAttachment of result.attachments) createdAttachments.push(createdAttachment);
|
|
5648
|
-
}
|
|
5649
|
-
this.dispatch(addFormSubmissions(createdSubmissions));
|
|
5650
|
-
this.dispatch(addFormSubmissionAttachments(createdAttachments));
|
|
5651
|
-
});
|
|
5652
|
-
return batchPromises;
|
|
5535
|
+
return [offlineSubmission, promise];
|
|
5653
5536
|
}
|
|
5654
|
-
|
|
5537
|
+
update(payload) {
|
|
5655
5538
|
const { store } = this.client;
|
|
5656
5539
|
const state = store.getState();
|
|
5657
5540
|
const submissionToBeUpdated = selectFormSubmissionById(payload.offline_id)(state);
|
|
5658
5541
|
if (!submissionToBeUpdated) {
|
|
5659
5542
|
throw new Error(`Expected submission with offline_id ${payload.offline_id} to exist`);
|
|
5660
5543
|
}
|
|
5661
|
-
const { values
|
|
5544
|
+
const { values } = separateFilesFromValues(payload.values ?? {});
|
|
5662
5545
|
const updatedSubmission = {
|
|
5663
5546
|
...submissionToBeUpdated,
|
|
5664
5547
|
...payload,
|
|
@@ -5672,39 +5555,18 @@ class FormSubmissionService extends BaseUploadService {
|
|
|
5672
5555
|
const promise = this.enqueueRequest({
|
|
5673
5556
|
description: "Delete user form submissions",
|
|
5674
5557
|
method: HttpMethod.PATCH,
|
|
5675
|
-
url: `/
|
|
5558
|
+
url: `/form-submissions/${updatedSubmission.offline_id}/`,
|
|
5676
5559
|
// TODO: send just payload when FormSubmissionDeserializer is updated to handle partial updates
|
|
5677
5560
|
payload: updatedSubmission,
|
|
5678
5561
|
blockers: [updatedSubmission.offline_id],
|
|
5679
5562
|
blocks: [updatedSubmission.offline_id]
|
|
5680
5563
|
});
|
|
5681
|
-
const formSubmissionAttachments = selectAttachmentsOfFormSubmission(payload.offline_id)(state);
|
|
5682
|
-
const formSubmissionAttachmentIdsToBeDeleted = [];
|
|
5683
|
-
for (const attachment of formSubmissionAttachments) {
|
|
5684
|
-
if (attachment.field_identifier in files) {
|
|
5685
|
-
formSubmissionAttachmentIdsToBeDeleted.push(attachment.offline_id);
|
|
5686
|
-
}
|
|
5687
|
-
}
|
|
5688
|
-
const [offlineFormSubmissionAttachments, attachmentsPromise] = await this.bulkAddSubmissionAttachments(
|
|
5689
|
-
payload.offline_id,
|
|
5690
|
-
files
|
|
5691
|
-
);
|
|
5692
|
-
const deleteAttachmentsPromise = this.bulkDeleteSubmissionAttachments(
|
|
5693
|
-
payload.offline_id,
|
|
5694
|
-
formSubmissionAttachmentIdsToBeDeleted
|
|
5695
|
-
);
|
|
5696
5564
|
promise.then((result) => {
|
|
5697
5565
|
this.dispatch(setFormSubmission(result));
|
|
5698
5566
|
}).catch(() => {
|
|
5699
5567
|
this.dispatch(setFormSubmission(submissionToBeUpdated));
|
|
5700
5568
|
});
|
|
5701
|
-
return [
|
|
5702
|
-
updatedSubmission,
|
|
5703
|
-
offlineFormSubmissionAttachments,
|
|
5704
|
-
promise,
|
|
5705
|
-
attachmentsPromise,
|
|
5706
|
-
deleteAttachmentsPromise
|
|
5707
|
-
];
|
|
5569
|
+
return [updatedSubmission, promise];
|
|
5708
5570
|
}
|
|
5709
5571
|
async delete(id) {
|
|
5710
5572
|
const { store } = this.client;
|
|
@@ -5720,7 +5582,7 @@ class FormSubmissionService extends BaseUploadService {
|
|
|
5720
5582
|
return await this.enqueueRequest({
|
|
5721
5583
|
description: "Delete user form submissions",
|
|
5722
5584
|
method: HttpMethod.DELETE,
|
|
5723
|
-
url: `/
|
|
5585
|
+
url: `/form-submissions/${id}/`,
|
|
5724
5586
|
blockers: [id],
|
|
5725
5587
|
blocks: []
|
|
5726
5588
|
});
|
|
@@ -5731,50 +5593,17 @@ class FormSubmissionService extends BaseUploadService {
|
|
|
5731
5593
|
}
|
|
5732
5594
|
}
|
|
5733
5595
|
async refreshStore(projectId) {
|
|
5734
|
-
const
|
|
5735
|
-
|
|
5736
|
-
description: "Fetch model submissions",
|
|
5737
|
-
method: HttpMethod.GET,
|
|
5738
|
-
url: `/forms/in-project/${projectId}/submissions/model/latest/`,
|
|
5739
|
-
blockers: [],
|
|
5740
|
-
blocks: []
|
|
5741
|
-
});
|
|
5742
|
-
for (const modelSubmission of modelSubmissions) {
|
|
5743
|
-
formSubmissions[modelSubmission.offline_id] = modelSubmission;
|
|
5744
|
-
}
|
|
5745
|
-
const standaloneSubmissions = await this.enqueueRequest({
|
|
5746
|
-
description: "Fetch standalone submissions",
|
|
5747
|
-
method: HttpMethod.GET,
|
|
5748
|
-
url: `/forms/in-project/${projectId}/submissions/standalone/`,
|
|
5749
|
-
blockers: [],
|
|
5750
|
-
blocks: []
|
|
5751
|
-
});
|
|
5752
|
-
for (const standaloneSubmission of standaloneSubmissions) {
|
|
5753
|
-
formSubmissions[standaloneSubmission.offline_id] = standaloneSubmission;
|
|
5754
|
-
}
|
|
5755
|
-
this.dispatch(initializeFormSubmissions(Object.values(formSubmissions)));
|
|
5756
|
-
const attachments = {};
|
|
5757
|
-
const modelAttachments = await this.enqueueRequest({
|
|
5758
|
-
description: "Fetch model submission attachments",
|
|
5759
|
-
method: HttpMethod.GET,
|
|
5760
|
-
url: `/forms/in-project/${projectId}/attachments/model/latest/`,
|
|
5761
|
-
blockers: [],
|
|
5762
|
-
blocks: []
|
|
5763
|
-
});
|
|
5764
|
-
for (const modelAttachment of modelAttachments) {
|
|
5765
|
-
attachments[modelAttachment.offline_id] = modelAttachment;
|
|
5766
|
-
}
|
|
5767
|
-
const standaloneAttachments = await this.enqueueRequest({
|
|
5768
|
-
description: "Fetch standalone submission attachments",
|
|
5596
|
+
const result = await this.enqueueRequest({
|
|
5597
|
+
description: "Fetch form submissions",
|
|
5769
5598
|
method: HttpMethod.GET,
|
|
5770
|
-
url:
|
|
5599
|
+
url: "/form-submissions/",
|
|
5600
|
+
queryParams: {
|
|
5601
|
+
project: projectId.toString()
|
|
5602
|
+
},
|
|
5771
5603
|
blockers: [],
|
|
5772
5604
|
blocks: []
|
|
5773
5605
|
});
|
|
5774
|
-
|
|
5775
|
-
attachments[standaloneAttachent.offline_id] = standaloneAttachent;
|
|
5776
|
-
}
|
|
5777
|
-
this.dispatch(initializeFormSubmissionAttachments(Object.values(attachments)));
|
|
5606
|
+
this.dispatch(initializeFormSubmissions(result));
|
|
5778
5607
|
}
|
|
5779
5608
|
}
|
|
5780
5609
|
class WorkspaceService extends BaseApiService {
|
|
@@ -6474,8 +6303,8 @@ class DocumentService extends BaseApiService {
|
|
|
6474
6303
|
class DocumentAttachmentService extends BaseAttachmentService {
|
|
6475
6304
|
constructor() {
|
|
6476
6305
|
super(...arguments);
|
|
6477
|
-
__publicField(this, "
|
|
6478
|
-
__publicField(this, "
|
|
6306
|
+
__publicField(this, "name", "Document Attachment");
|
|
6307
|
+
__publicField(this, "url", "/document-attachments");
|
|
6479
6308
|
__publicField(this, "addAttachments", addDocumentAttachments);
|
|
6480
6309
|
__publicField(this, "updateAttachments", updateDocumentAttachments);
|
|
6481
6310
|
__publicField(this, "removeAttachments", deleteDocumentAttachments);
|
|
@@ -6486,18 +6315,24 @@ class DocumentAttachmentService extends BaseAttachmentService {
|
|
|
6486
6315
|
buildOfflineAttachment(data) {
|
|
6487
6316
|
return offline({
|
|
6488
6317
|
file: URL.createObjectURL(data.file),
|
|
6489
|
-
file_sha1: data.
|
|
6490
|
-
created_by: data.
|
|
6318
|
+
file_sha1: data.file_sha1,
|
|
6319
|
+
created_by: data.created_by,
|
|
6491
6320
|
file_name: data.file.name,
|
|
6492
6321
|
file_type: data.file.type,
|
|
6493
|
-
submitted_at: data.
|
|
6322
|
+
submitted_at: data.submitted_at,
|
|
6494
6323
|
description: data.description,
|
|
6495
6324
|
document: data.modelId
|
|
6496
6325
|
});
|
|
6497
6326
|
}
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6327
|
+
buildAttachmentPayload(data) {
|
|
6328
|
+
return {
|
|
6329
|
+
...data,
|
|
6330
|
+
document: data.modelId
|
|
6331
|
+
};
|
|
6332
|
+
}
|
|
6333
|
+
// NOTE: overriding the method from BaseAttachmentService since document attachments get vectorized
|
|
6334
|
+
async bulkAdd(payloads) {
|
|
6335
|
+
var _a2;
|
|
6501
6336
|
const { store } = this.client;
|
|
6502
6337
|
const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
6503
6338
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -6505,40 +6340,37 @@ class DocumentAttachmentService extends BaseAttachmentService {
|
|
|
6505
6340
|
const attachmentPayloads = [];
|
|
6506
6341
|
const filePayloads = {};
|
|
6507
6342
|
const sha1ToAttachmentIds = {};
|
|
6508
|
-
for (const
|
|
6509
|
-
const
|
|
6510
|
-
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
extension: file.name.split(".").pop(),
|
|
6515
|
-
size: file.size
|
|
6516
|
-
};
|
|
6517
|
-
sha1ToAttachmentIds[sha1] = [];
|
|
6518
|
-
await this.client.files.addCache(file, sha1);
|
|
6343
|
+
for (const payload of payloads) {
|
|
6344
|
+
const { documentId, file } = payload;
|
|
6345
|
+
const filePayload = await this.getFilePayload(file);
|
|
6346
|
+
if (!(filePayload.sha1 in filePayloads)) {
|
|
6347
|
+
filePayloads[filePayload.sha1] = filePayload;
|
|
6348
|
+
sha1ToAttachmentIds[filePayload.sha1] = [];
|
|
6519
6349
|
}
|
|
6520
6350
|
const offlineAttachment = this.buildOfflineAttachment({
|
|
6521
6351
|
file,
|
|
6522
|
-
sha1,
|
|
6523
|
-
submittedAt,
|
|
6524
|
-
createdBy,
|
|
6352
|
+
file_sha1: filePayload.sha1,
|
|
6353
|
+
submitted_at: submittedAt,
|
|
6354
|
+
created_by: createdBy,
|
|
6525
6355
|
description: "",
|
|
6526
6356
|
modelId: documentId
|
|
6527
6357
|
});
|
|
6528
6358
|
offlineAttachments.push(offlineAttachment);
|
|
6529
6359
|
attachmentPayloads.push({
|
|
6530
6360
|
offline_id: offlineAttachment.offline_id,
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6361
|
+
file_name: offlineAttachment.file_name,
|
|
6362
|
+
file_sha1: offlineAttachment.file_sha1,
|
|
6363
|
+
file_extension: filePayload.extension,
|
|
6364
|
+
description: offlineAttachment.description,
|
|
6365
|
+
document: documentId
|
|
6534
6366
|
});
|
|
6535
|
-
sha1ToAttachmentIds[sha1].push(offlineAttachment.offline_id);
|
|
6367
|
+
sha1ToAttachmentIds[filePayload.sha1].push(offlineAttachment.offline_id);
|
|
6536
6368
|
}
|
|
6537
6369
|
this.dispatch(this.addAttachments(offlineAttachments));
|
|
6538
6370
|
const promise = this.enqueueRequest({
|
|
6539
6371
|
description: "Attach files to document",
|
|
6540
6372
|
method: HttpMethod.POST,
|
|
6541
|
-
url:
|
|
6373
|
+
url: "/document-attachments/bulk/",
|
|
6542
6374
|
payload: {
|
|
6543
6375
|
submitted_at: submittedAt,
|
|
6544
6376
|
attachments: attachmentPayloads,
|
|
@@ -6563,14 +6395,14 @@ class DocumentAttachmentService extends BaseAttachmentService {
|
|
|
6563
6395
|
});
|
|
6564
6396
|
return [offlineAttachments, promise.then(({ attachments }) => attachments)];
|
|
6565
6397
|
}
|
|
6566
|
-
async
|
|
6567
|
-
return this.
|
|
6398
|
+
async delete(id) {
|
|
6399
|
+
return this._delete(id);
|
|
6568
6400
|
}
|
|
6569
6401
|
makeReadable(attachmnentId) {
|
|
6570
6402
|
void this.enqueueRequest({
|
|
6571
6403
|
description: "Add attachment to AI assistant",
|
|
6572
6404
|
method: HttpMethod.PATCH,
|
|
6573
|
-
url: `/
|
|
6405
|
+
url: `/document-attachments/${attachmnentId}/`,
|
|
6574
6406
|
payload: {
|
|
6575
6407
|
readable_to_assistant: true
|
|
6576
6408
|
},
|
|
@@ -6587,7 +6419,7 @@ class DocumentAttachmentService extends BaseAttachmentService {
|
|
|
6587
6419
|
blocks: [],
|
|
6588
6420
|
blockers: []
|
|
6589
6421
|
});
|
|
6590
|
-
this.dispatch(
|
|
6422
|
+
this.dispatch(initializeDocumentAttachments(projectDocumentAttachments));
|
|
6591
6423
|
const organizationDocumentAttachments = await this.enqueueRequest({
|
|
6592
6424
|
description: "Get document attachments",
|
|
6593
6425
|
method: HttpMethod.GET,
|
|
@@ -6823,17 +6655,11 @@ class GeoImageService extends BaseUploadService {
|
|
|
6823
6655
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
6824
6656
|
const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
6825
6657
|
const projectId = payloadWithoutFile.project;
|
|
6826
|
-
const
|
|
6827
|
-
const filePayload = {
|
|
6828
|
-
sha1,
|
|
6829
|
-
file_type: file.type,
|
|
6830
|
-
extension: file.name.split(".").pop(),
|
|
6831
|
-
size: file.size
|
|
6832
|
-
};
|
|
6658
|
+
const filePayload = await this.getFilePayload(file);
|
|
6833
6659
|
const offlineMapImage = offline({
|
|
6834
6660
|
...payloadWithoutFile,
|
|
6835
6661
|
file_name: file.name,
|
|
6836
|
-
file_sha1: sha1,
|
|
6662
|
+
file_sha1: filePayload.sha1,
|
|
6837
6663
|
file: URL.createObjectURL(file),
|
|
6838
6664
|
submitted_at: submittedAt,
|
|
6839
6665
|
created_by: createdBy
|
|
@@ -6876,23 +6702,15 @@ class GeoImageService extends BaseUploadService {
|
|
|
6876
6702
|
const offlineGeoImages = [];
|
|
6877
6703
|
const offlineIds = [];
|
|
6878
6704
|
const geoImagePayloads = [];
|
|
6879
|
-
const
|
|
6705
|
+
const filePayloads = {};
|
|
6880
6706
|
for (const payloadAndFile of payloads) {
|
|
6881
6707
|
const { file, ...payload } = payloadAndFile;
|
|
6882
|
-
const
|
|
6883
|
-
if (!(sha1 in
|
|
6884
|
-
filePayloadRecord[sha1] = {
|
|
6885
|
-
sha1,
|
|
6886
|
-
file_type: file.type,
|
|
6887
|
-
extension: file.name.split(".").pop(),
|
|
6888
|
-
size: file.size
|
|
6889
|
-
};
|
|
6890
|
-
await this.client.files.addCache(file, sha1);
|
|
6891
|
-
}
|
|
6708
|
+
const filePayload = await this.getFilePayload(file);
|
|
6709
|
+
if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
|
|
6892
6710
|
const offlineMapImage = offline({
|
|
6893
6711
|
...payload,
|
|
6894
6712
|
file_name: file.name,
|
|
6895
|
-
file_sha1: sha1,
|
|
6713
|
+
file_sha1: filePayload.sha1,
|
|
6896
6714
|
file: URL.createObjectURL(file),
|
|
6897
6715
|
submitted_at: submittedAt,
|
|
6898
6716
|
created_by: createdBy,
|
|
@@ -6921,7 +6739,7 @@ class GeoImageService extends BaseUploadService {
|
|
|
6921
6739
|
submitted_at: submittedAt,
|
|
6922
6740
|
project: projectId,
|
|
6923
6741
|
geo_images: geoImagePayloads,
|
|
6924
|
-
files: Object.values(
|
|
6742
|
+
files: Object.values(filePayloads)
|
|
6925
6743
|
},
|
|
6926
6744
|
blocks: [projectId.toString()],
|
|
6927
6745
|
blockers: offlineIds
|
|
@@ -6989,7 +6807,7 @@ class GeoImageService extends BaseUploadService {
|
|
|
6989
6807
|
this.dispatch(initializeGeoImages(result));
|
|
6990
6808
|
}
|
|
6991
6809
|
}
|
|
6992
|
-
class IssueAssociationService extends
|
|
6810
|
+
class IssueAssociationService extends BaseApiService {
|
|
6993
6811
|
add(payload) {
|
|
6994
6812
|
var _a2;
|
|
6995
6813
|
const { store } = this.client;
|
|
@@ -7004,7 +6822,7 @@ class IssueAssociationService extends BaseUploadService {
|
|
|
7004
6822
|
const promise = this.enqueueRequest({
|
|
7005
6823
|
description: "Add issue association",
|
|
7006
6824
|
method: HttpMethod.POST,
|
|
7007
|
-
url: "/
|
|
6825
|
+
url: "/issue-associations/",
|
|
7008
6826
|
payload: {
|
|
7009
6827
|
offline_id: offlineIssueAssociation.offline_id,
|
|
7010
6828
|
submitted_at: submittedAt,
|
|
@@ -7034,7 +6852,7 @@ class IssueAssociationService extends BaseUploadService {
|
|
|
7034
6852
|
const promise = this.enqueueRequest({
|
|
7035
6853
|
description: "Delete issue association",
|
|
7036
6854
|
method: HttpMethod.DELETE,
|
|
7037
|
-
url: `/
|
|
6855
|
+
url: `/issue-associations/${id}/`,
|
|
7038
6856
|
blockers: [id],
|
|
7039
6857
|
blocks: []
|
|
7040
6858
|
});
|
|
@@ -7047,14 +6865,903 @@ class IssueAssociationService extends BaseUploadService {
|
|
|
7047
6865
|
const issueAssociations = await this.enqueueRequest({
|
|
7048
6866
|
description: "Fetch issue associations",
|
|
7049
6867
|
method: HttpMethod.GET,
|
|
7050
|
-
url: "/
|
|
7051
|
-
queryParams: {
|
|
6868
|
+
url: "/issue-associations/",
|
|
6869
|
+
queryParams: { project: projectId.toString() },
|
|
7052
6870
|
blockers: [],
|
|
7053
6871
|
blocks: []
|
|
7054
6872
|
});
|
|
7055
6873
|
this.dispatch(initializeIssueAssociations(issueAssociations));
|
|
7056
6874
|
}
|
|
7057
6875
|
}
|
|
6876
|
+
class FormRevisionAttachmentService extends BaseUploadService {
|
|
6877
|
+
async bulkAdd(payloads) {
|
|
6878
|
+
var _a2;
|
|
6879
|
+
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
6880
|
+
const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
6881
|
+
const filePayloads = {};
|
|
6882
|
+
const offlineFormRevisionAttachments = [];
|
|
6883
|
+
const attachmentPayloads = [];
|
|
6884
|
+
for (const payload of payloads) {
|
|
6885
|
+
const { revisionId, fieldIdentifier, file } = payload;
|
|
6886
|
+
const filePayload = await this.getFilePayload(file);
|
|
6887
|
+
if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
|
|
6888
|
+
const offlineFormRevisionAttachment = offline({
|
|
6889
|
+
file: URL.createObjectURL(file),
|
|
6890
|
+
file_type: file.type,
|
|
6891
|
+
file_name: file.name,
|
|
6892
|
+
file_sha1: filePayload.sha1,
|
|
6893
|
+
created_by: createdBy,
|
|
6894
|
+
form_revision: revisionId,
|
|
6895
|
+
submitted_at: submittedAt,
|
|
6896
|
+
field_identifier: fieldIdentifier
|
|
6897
|
+
});
|
|
6898
|
+
offlineFormRevisionAttachments.push(offlineFormRevisionAttachment);
|
|
6899
|
+
const attachmentPayload = {
|
|
6900
|
+
offline_id: offlineFormRevisionAttachment.offline_id,
|
|
6901
|
+
file_name: file.name,
|
|
6902
|
+
field_identifier: fieldIdentifier,
|
|
6903
|
+
file_extension: filePayload.extension,
|
|
6904
|
+
file_sha1: filePayload.sha1,
|
|
6905
|
+
form_revision: revisionId
|
|
6906
|
+
};
|
|
6907
|
+
attachmentPayloads.push(attachmentPayload);
|
|
6908
|
+
}
|
|
6909
|
+
this.dispatch(addFormRevisionAttachments(offlineFormRevisionAttachments));
|
|
6910
|
+
const promise = this.enqueueRequest({
|
|
6911
|
+
description: "Attach files to form revision",
|
|
6912
|
+
method: HttpMethod.POST,
|
|
6913
|
+
url: "/form-revision-attachments/bulk/",
|
|
6914
|
+
payload: {
|
|
6915
|
+
submitted_at: submittedAt,
|
|
6916
|
+
attachments: attachmentPayloads,
|
|
6917
|
+
files: Object.values(filePayloads)
|
|
6918
|
+
},
|
|
6919
|
+
blockers: offlineFormRevisionAttachments.map((attachment) => attachment.form_revision),
|
|
6920
|
+
blocks: offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
|
|
6921
|
+
});
|
|
6922
|
+
promise.then((result) => {
|
|
6923
|
+
this.processPresignedUrls(result.presigned_urls);
|
|
6924
|
+
this.dispatch(updateFormRevisionAttachments(result.attachments));
|
|
6925
|
+
}).catch(() => {
|
|
6926
|
+
this.dispatch(
|
|
6927
|
+
deleteFormRevisionAttachments(
|
|
6928
|
+
offlineFormRevisionAttachments.map((attachment) => attachment.offline_id)
|
|
6929
|
+
)
|
|
6930
|
+
);
|
|
6931
|
+
});
|
|
6932
|
+
return [offlineFormRevisionAttachments, promise.then(({ attachments }) => attachments)];
|
|
6933
|
+
}
|
|
6934
|
+
async refreshStore(organizationId) {
|
|
6935
|
+
const formRevisions = await this.enqueueRequest({
|
|
6936
|
+
description: "Fetch organization form revision attachments",
|
|
6937
|
+
method: HttpMethod.GET,
|
|
6938
|
+
url: "/form-revision-attachments/",
|
|
6939
|
+
queryParams: {
|
|
6940
|
+
organization: organizationId.toString()
|
|
6941
|
+
},
|
|
6942
|
+
blockers: [organizationId.toString()],
|
|
6943
|
+
blocks: []
|
|
6944
|
+
});
|
|
6945
|
+
this.dispatch(initializeFormRevisionAttachments(formRevisions));
|
|
6946
|
+
}
|
|
6947
|
+
}
|
|
6948
|
+
class FormSubmissionAttachmentService extends BaseUploadService {
|
|
6949
|
+
async bulkAdd(payloads) {
|
|
6950
|
+
var _a2;
|
|
6951
|
+
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
6952
|
+
const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
6953
|
+
const filePayloads = {};
|
|
6954
|
+
const offlineFormSubmissionAttachments = [];
|
|
6955
|
+
const attachmentPayloads = [];
|
|
6956
|
+
for (const payload of payloads) {
|
|
6957
|
+
const { submissionId, fieldIdentifier, file } = payload;
|
|
6958
|
+
const filePayload = await this.getFilePayload(file);
|
|
6959
|
+
if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
|
|
6960
|
+
const offlineFormSubmissionAttachment = offline({
|
|
6961
|
+
file: URL.createObjectURL(file),
|
|
6962
|
+
file_type: file.type,
|
|
6963
|
+
file_name: file.name,
|
|
6964
|
+
file_sha1: filePayload.sha1,
|
|
6965
|
+
created_by: createdBy,
|
|
6966
|
+
form_submission: submissionId,
|
|
6967
|
+
submitted_at: submittedAt,
|
|
6968
|
+
field_identifier: fieldIdentifier
|
|
6969
|
+
});
|
|
6970
|
+
offlineFormSubmissionAttachments.push(offlineFormSubmissionAttachment);
|
|
6971
|
+
const attachmentPayload = {
|
|
6972
|
+
offline_id: offlineFormSubmissionAttachment.offline_id,
|
|
6973
|
+
file_name: file.name,
|
|
6974
|
+
file_sha1: filePayload.sha1,
|
|
6975
|
+
file_extension: filePayload.extension,
|
|
6976
|
+
field_identifier: fieldIdentifier,
|
|
6977
|
+
form_submission: submissionId
|
|
6978
|
+
};
|
|
6979
|
+
attachmentPayloads.push(attachmentPayload);
|
|
6980
|
+
}
|
|
6981
|
+
this.dispatch(addFormSubmissionAttachments(offlineFormSubmissionAttachments));
|
|
6982
|
+
const promise = this.enqueueRequest({
|
|
6983
|
+
description: "Attach files to form submission",
|
|
6984
|
+
method: HttpMethod.POST,
|
|
6985
|
+
url: "/form-submission-attachments/bulk/",
|
|
6986
|
+
payload: {
|
|
6987
|
+
submitted_at: submittedAt,
|
|
6988
|
+
attachments: attachmentPayloads,
|
|
6989
|
+
files: Object.values(filePayloads)
|
|
6990
|
+
},
|
|
6991
|
+
blockers: offlineFormSubmissionAttachments.map((attachment) => attachment.form_submission),
|
|
6992
|
+
blocks: offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
|
|
6993
|
+
});
|
|
6994
|
+
promise.then((result) => {
|
|
6995
|
+
this.processPresignedUrls(result.presigned_urls);
|
|
6996
|
+
this.dispatch(updateFormSubmissionAttachments(result.attachments));
|
|
6997
|
+
}).catch((error) => {
|
|
6998
|
+
this.dispatch(
|
|
6999
|
+
deleteFormSubmissionAttachments(
|
|
7000
|
+
offlineFormSubmissionAttachments.map((attachment) => attachment.offline_id)
|
|
7001
|
+
)
|
|
7002
|
+
);
|
|
7003
|
+
throw error;
|
|
7004
|
+
});
|
|
7005
|
+
return [offlineFormSubmissionAttachments, promise.then(({ attachments }) => attachments)];
|
|
7006
|
+
}
|
|
7007
|
+
async bulkDelete(attachmentsIds) {
|
|
7008
|
+
const { store } = this.client;
|
|
7009
|
+
const state = store.getState();
|
|
7010
|
+
const formSubmissionAttachments = selectFormSubmissionAttachemntsByIds(attachmentsIds)(state);
|
|
7011
|
+
this.dispatch(deleteFormSubmissionAttachments(attachmentsIds));
|
|
7012
|
+
try {
|
|
7013
|
+
await this.enqueueRequest({
|
|
7014
|
+
description: "Delete form submission attachments",
|
|
7015
|
+
method: HttpMethod.DELETE,
|
|
7016
|
+
url: "/form-submission-attachments/bulk/",
|
|
7017
|
+
payload: { attachment_ids: attachmentsIds },
|
|
7018
|
+
blockers: attachmentsIds,
|
|
7019
|
+
blocks: []
|
|
7020
|
+
});
|
|
7021
|
+
} catch (e) {
|
|
7022
|
+
this.dispatch(addFormSubmissionAttachments(formSubmissionAttachments));
|
|
7023
|
+
throw e;
|
|
7024
|
+
}
|
|
7025
|
+
}
|
|
7026
|
+
async refreshStore(projectId) {
|
|
7027
|
+
const result = await this.enqueueRequest({
|
|
7028
|
+
description: "Get form submission attachments",
|
|
7029
|
+
method: HttpMethod.GET,
|
|
7030
|
+
url: "/form-submission-attachments/",
|
|
7031
|
+
queryParams: {
|
|
7032
|
+
project: projectId.toString()
|
|
7033
|
+
},
|
|
7034
|
+
blockers: [],
|
|
7035
|
+
blocks: []
|
|
7036
|
+
});
|
|
7037
|
+
this.dispatch(initializeFormSubmissionAttachments(result));
|
|
7038
|
+
}
|
|
7039
|
+
}
|
|
7040
|
+
class FormRevisionService extends BaseUploadService {
|
|
7041
|
+
add(payload) {
|
|
7042
|
+
var _a2;
|
|
7043
|
+
const { store } = this.client;
|
|
7044
|
+
const state = store.getState();
|
|
7045
|
+
const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
7046
|
+
const offlineFormRevision = offline({
|
|
7047
|
+
...payload,
|
|
7048
|
+
created_by: createdBy,
|
|
7049
|
+
revision: "Pending",
|
|
7050
|
+
submitted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
7051
|
+
});
|
|
7052
|
+
this.dispatch(addFormRevision(offlineFormRevision));
|
|
7053
|
+
const promise = this.enqueueRequest({
|
|
7054
|
+
description: "Create form revision",
|
|
7055
|
+
method: HttpMethod.POST,
|
|
7056
|
+
url: "/form-revisions/",
|
|
7057
|
+
payload: offlineFormRevision,
|
|
7058
|
+
blockers: [payload.form],
|
|
7059
|
+
blocks: [offlineFormRevision.offline_id]
|
|
7060
|
+
});
|
|
7061
|
+
void promise.then((result) => {
|
|
7062
|
+
this.dispatch(setFormRevision(result));
|
|
7063
|
+
}).catch(() => {
|
|
7064
|
+
this.dispatch(deleteFormRevision(offlineFormRevision.offline_id));
|
|
7065
|
+
});
|
|
7066
|
+
return [offlineFormRevision, promise];
|
|
7067
|
+
}
|
|
7068
|
+
async refreshStore(organizationId) {
|
|
7069
|
+
const formRevisions = await this.enqueueRequest({
|
|
7070
|
+
description: "Get organization form revisions",
|
|
7071
|
+
method: HttpMethod.GET,
|
|
7072
|
+
url: "/form-revisions/",
|
|
7073
|
+
queryParams: {
|
|
7074
|
+
organization: organizationId.toString()
|
|
7075
|
+
},
|
|
7076
|
+
blockers: [organizationId.toString()],
|
|
7077
|
+
blocks: []
|
|
7078
|
+
});
|
|
7079
|
+
this.dispatch(initializeFormRevisions(formRevisions));
|
|
7080
|
+
}
|
|
7081
|
+
}
|
|
7082
|
+
class AssetTypeFieldsAttachmentService extends BaseUploadService {
|
|
7083
|
+
async bulkAdd(payloads) {
|
|
7084
|
+
var _a2;
|
|
7085
|
+
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7086
|
+
const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
7087
|
+
const filePayloads = {};
|
|
7088
|
+
const offlineAssetTypeFieldsAttachments = [];
|
|
7089
|
+
const attachmentPayloads = [];
|
|
7090
|
+
for (const payload of payloads) {
|
|
7091
|
+
const { fieldsRevisionId, fieldIdentifier, file } = payload;
|
|
7092
|
+
const filePayload = await this.getFilePayload(file);
|
|
7093
|
+
if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
|
|
7094
|
+
const offlineAssetTypeFieldsAttachment = offline({
|
|
7095
|
+
file: URL.createObjectURL(file),
|
|
7096
|
+
file_type: file.type,
|
|
7097
|
+
file_name: file.name,
|
|
7098
|
+
file_sha1: filePayload.sha1,
|
|
7099
|
+
created_by: createdBy,
|
|
7100
|
+
fields_revision: fieldsRevisionId,
|
|
7101
|
+
submitted_at: submittedAt,
|
|
7102
|
+
field_identifier: fieldIdentifier
|
|
7103
|
+
});
|
|
7104
|
+
offlineAssetTypeFieldsAttachments.push(offlineAssetTypeFieldsAttachment);
|
|
7105
|
+
const attachmentPayload = {
|
|
7106
|
+
offline_id: offlineAssetTypeFieldsAttachment.offline_id,
|
|
7107
|
+
file_name: file.name,
|
|
7108
|
+
field_identifier: fieldIdentifier,
|
|
7109
|
+
file_extension: filePayload.extension,
|
|
7110
|
+
file_sha1: filePayload.sha1,
|
|
7111
|
+
fields_revision: fieldsRevisionId
|
|
7112
|
+
};
|
|
7113
|
+
attachmentPayloads.push(attachmentPayload);
|
|
7114
|
+
}
|
|
7115
|
+
this.dispatch(addAssetTypeFieldsAttachments(offlineAssetTypeFieldsAttachments));
|
|
7116
|
+
const promise = this.enqueueRequest({
|
|
7117
|
+
description: "Add asset type fields attachments",
|
|
7118
|
+
method: HttpMethod.POST,
|
|
7119
|
+
url: "/asset-type-fields-attachments/bulk/",
|
|
7120
|
+
payload: {
|
|
7121
|
+
submitted_at: submittedAt,
|
|
7122
|
+
attachments: attachmentPayloads,
|
|
7123
|
+
files: Object.values(filePayloads)
|
|
7124
|
+
},
|
|
7125
|
+
blockers: offlineAssetTypeFieldsAttachments.map((attachment) => attachment.fields_revision),
|
|
7126
|
+
blocks: offlineAssetTypeFieldsAttachments.map((attachment) => attachment.offline_id)
|
|
7127
|
+
});
|
|
7128
|
+
promise.then((result) => {
|
|
7129
|
+
this.processPresignedUrls(result.presigned_urls);
|
|
7130
|
+
this.dispatch(updateAssetTypeFieldsAttachments(result.attachments));
|
|
7131
|
+
}).catch(() => {
|
|
7132
|
+
this.dispatch(
|
|
7133
|
+
deleteAssetTypeFieldsAttachments(
|
|
7134
|
+
offlineAssetTypeFieldsAttachments.map((attachment) => attachment.offline_id)
|
|
7135
|
+
)
|
|
7136
|
+
);
|
|
7137
|
+
});
|
|
7138
|
+
return [offlineAssetTypeFieldsAttachments, promise.then(({ attachments }) => attachments)];
|
|
7139
|
+
}
|
|
7140
|
+
async refreshStore(organization) {
|
|
7141
|
+
const result = await this.enqueueRequest({
|
|
7142
|
+
description: "Get asset type fields attachments",
|
|
7143
|
+
method: HttpMethod.GET,
|
|
7144
|
+
url: "/asset-type-fields-attachments/",
|
|
7145
|
+
queryParams: {
|
|
7146
|
+
organization: organization.toString()
|
|
7147
|
+
},
|
|
7148
|
+
blockers: [organization.toString()],
|
|
7149
|
+
blocks: []
|
|
7150
|
+
});
|
|
7151
|
+
this.dispatch(initializeAssetTypeFieldsAttachments(result));
|
|
7152
|
+
}
|
|
7153
|
+
}
|
|
7154
|
+
class AssetTypeFieldsService extends BaseApiService {
|
|
7155
|
+
add(payload) {
|
|
7156
|
+
var _a2;
|
|
7157
|
+
const { store } = this.client;
|
|
7158
|
+
const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
7159
|
+
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7160
|
+
const offlineAssetTypeFields = offline({
|
|
7161
|
+
...payload,
|
|
7162
|
+
created_by: createdBy,
|
|
7163
|
+
submitted_at: submittedAt
|
|
7164
|
+
});
|
|
7165
|
+
this.dispatch(addAssetTypeFields(offlineAssetTypeFields));
|
|
7166
|
+
const promise = this.enqueueRequest({
|
|
7167
|
+
description: "Add Asset Type Fields",
|
|
7168
|
+
method: HttpMethod.POST,
|
|
7169
|
+
url: "/asset-type-fields/",
|
|
7170
|
+
payload: offlineAssetTypeFields,
|
|
7171
|
+
blockers: [offlineAssetTypeFields.asset_type],
|
|
7172
|
+
blocks: [offlineAssetTypeFields.offline_id]
|
|
7173
|
+
});
|
|
7174
|
+
promise.then((response) => {
|
|
7175
|
+
this.dispatch(updateAssetTypeFields(response));
|
|
7176
|
+
}).catch((error) => {
|
|
7177
|
+
this.dispatch(deleteAssetTypeFields(offlineAssetTypeFields.offline_id));
|
|
7178
|
+
throw error;
|
|
7179
|
+
});
|
|
7180
|
+
return [offlineAssetTypeFields, promise];
|
|
7181
|
+
}
|
|
7182
|
+
async refreshStore(organizationId) {
|
|
7183
|
+
const result = await this.enqueueRequest({
|
|
7184
|
+
description: "Get Asset Type Fields",
|
|
7185
|
+
method: HttpMethod.GET,
|
|
7186
|
+
url: "/asset-type-fields/",
|
|
7187
|
+
queryParams: {
|
|
7188
|
+
organization: organizationId.toString()
|
|
7189
|
+
},
|
|
7190
|
+
blockers: [],
|
|
7191
|
+
blocks: []
|
|
7192
|
+
});
|
|
7193
|
+
this.dispatch(initializeAssetTypeFields(result));
|
|
7194
|
+
}
|
|
7195
|
+
}
|
|
7196
|
+
class AssetTypeFieldValuesService extends BaseApiService {
|
|
7197
|
+
add(payload) {
|
|
7198
|
+
var _a2;
|
|
7199
|
+
const { store } = this.client;
|
|
7200
|
+
const state = store.getState();
|
|
7201
|
+
const { values } = separateFilesFromValues(payload.values);
|
|
7202
|
+
const offlineAssetTypeFieldValues = offline({
|
|
7203
|
+
...payload,
|
|
7204
|
+
values,
|
|
7205
|
+
created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
|
|
7206
|
+
submitted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
7207
|
+
});
|
|
7208
|
+
const promise = this.enqueueRequest({
|
|
7209
|
+
description: "Add asset type field values",
|
|
7210
|
+
method: HttpMethod.POST,
|
|
7211
|
+
url: "/asset-type-field-values/",
|
|
7212
|
+
payload: offlineAssetTypeFieldValues,
|
|
7213
|
+
blockers: [payload.asset, payload.fields_revision],
|
|
7214
|
+
blocks: [offlineAssetTypeFieldValues.offline_id]
|
|
7215
|
+
});
|
|
7216
|
+
this.dispatch(addAssetTypeFieldValues(offlineAssetTypeFieldValues));
|
|
7217
|
+
promise.then((result) => {
|
|
7218
|
+
this.dispatch(updateAssetTypeFieldValues(result));
|
|
7219
|
+
return result;
|
|
7220
|
+
}).catch(() => {
|
|
7221
|
+
this.dispatch(deleteAssetTypeFieldValues(offlineAssetTypeFieldValues.offline_id));
|
|
7222
|
+
});
|
|
7223
|
+
return [offlineAssetTypeFieldValues, promise];
|
|
7224
|
+
}
|
|
7225
|
+
bulkAdd(payload, batchSize) {
|
|
7226
|
+
var _a2;
|
|
7227
|
+
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7228
|
+
const { values } = separateFilesFromValues(payload.values);
|
|
7229
|
+
const offlineAssetTypeFieldValuesMany = [];
|
|
7230
|
+
const batches = chunkArray(payload.payloads, batchSize ?? payload.payloads.length);
|
|
7231
|
+
const batchPayloads = [];
|
|
7232
|
+
for (const batch of batches) {
|
|
7233
|
+
const assetTypeFieldValuesPayloads = [];
|
|
7234
|
+
for (const payload2 of batch) {
|
|
7235
|
+
const offlineAssetTypeFieldValues = offline({
|
|
7236
|
+
...payload2,
|
|
7237
|
+
values: separateFilesFromValues(payload2.values).values,
|
|
7238
|
+
created_by: (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id,
|
|
7239
|
+
submitted_at: submittedAt
|
|
7240
|
+
});
|
|
7241
|
+
offlineAssetTypeFieldValuesMany.push(offlineAssetTypeFieldValues);
|
|
7242
|
+
assetTypeFieldValuesPayloads.push({
|
|
7243
|
+
offline_id: offlineAssetTypeFieldValues.offline_id,
|
|
7244
|
+
asset: payload2.asset,
|
|
7245
|
+
fields_revision: payload2.fields_revision,
|
|
7246
|
+
published_at: payload2.published_at,
|
|
7247
|
+
values: offlineAssetTypeFieldValues.values
|
|
7248
|
+
});
|
|
7249
|
+
}
|
|
7250
|
+
batchPayloads.push({
|
|
7251
|
+
submitted_at: submittedAt,
|
|
7252
|
+
values,
|
|
7253
|
+
field_values: assetTypeFieldValuesPayloads
|
|
7254
|
+
});
|
|
7255
|
+
}
|
|
7256
|
+
this.dispatch(addAssetTypeFieldValuesMany(offlineAssetTypeFieldValuesMany));
|
|
7257
|
+
const promises = [];
|
|
7258
|
+
for (const payload2 of batchPayloads) {
|
|
7259
|
+
const assetIds = payload2.field_values.map((x) => x.asset);
|
|
7260
|
+
const assetTypeFieldsIds = payload2.field_values.map((x) => x.fields_revision);
|
|
7261
|
+
const assetTypeFieldValuesIds = payload2.field_values.map((x) => x.offline_id);
|
|
7262
|
+
const promise = this.enqueueRequest({
|
|
7263
|
+
description: "Bulk add asset type field values",
|
|
7264
|
+
method: HttpMethod.POST,
|
|
7265
|
+
url: "/asset-type-field-values/bulk/",
|
|
7266
|
+
payload: payload2,
|
|
7267
|
+
blockers: [...assetIds, ...assetTypeFieldsIds],
|
|
7268
|
+
blocks: assetTypeFieldValuesIds
|
|
7269
|
+
});
|
|
7270
|
+
promises.push(promise);
|
|
7271
|
+
}
|
|
7272
|
+
void Promise.all(promises).then((results) => {
|
|
7273
|
+
this.dispatch(updateAssetTypeFieldValuesMany(results.flat()));
|
|
7274
|
+
}).catch(() => {
|
|
7275
|
+
this.dispatch(deleteAssetTypeFieldValuesMany(offlineAssetTypeFieldValuesMany.map((x) => x.offline_id)));
|
|
7276
|
+
});
|
|
7277
|
+
return [offlineAssetTypeFieldValuesMany, promises];
|
|
7278
|
+
}
|
|
7279
|
+
update(payload) {
|
|
7280
|
+
const { store } = this.client;
|
|
7281
|
+
const state = store.getState();
|
|
7282
|
+
const assetTypeFieldValues = selectAssetTypeFieldValuesById(payload.offline_id)(state);
|
|
7283
|
+
if (!assetTypeFieldValues) {
|
|
7284
|
+
throw new Error(`Expected AssetTypeFieldValues with offline_id ${payload.offline_id} to exist`);
|
|
7285
|
+
}
|
|
7286
|
+
const { values } = separateFilesFromValues(payload.values ?? {});
|
|
7287
|
+
const updatedAssetTypeFieldValues = {
|
|
7288
|
+
...assetTypeFieldValues,
|
|
7289
|
+
...payload,
|
|
7290
|
+
values
|
|
7291
|
+
};
|
|
7292
|
+
this.dispatch(updateAssetTypeFieldValues(updatedAssetTypeFieldValues));
|
|
7293
|
+
const promise = this.enqueueRequest({
|
|
7294
|
+
description: "Delete asset type field values",
|
|
7295
|
+
method: HttpMethod.PATCH,
|
|
7296
|
+
url: `/asset-type-field-values/${payload.offline_id}/`,
|
|
7297
|
+
payload: {
|
|
7298
|
+
...payload,
|
|
7299
|
+
values
|
|
7300
|
+
},
|
|
7301
|
+
blockers: [
|
|
7302
|
+
updatedAssetTypeFieldValues.offline_id,
|
|
7303
|
+
updatedAssetTypeFieldValues.fields_revision,
|
|
7304
|
+
updatedAssetTypeFieldValues.asset
|
|
7305
|
+
],
|
|
7306
|
+
blocks: [updatedAssetTypeFieldValues.offline_id]
|
|
7307
|
+
});
|
|
7308
|
+
promise.then((result) => {
|
|
7309
|
+
this.dispatch(updateAssetTypeFieldValues(result));
|
|
7310
|
+
}).catch(() => {
|
|
7311
|
+
this.dispatch(updateAssetTypeFieldValues(assetTypeFieldValues));
|
|
7312
|
+
});
|
|
7313
|
+
return [updatedAssetTypeFieldValues, promise];
|
|
7314
|
+
}
|
|
7315
|
+
async delete(id) {
|
|
7316
|
+
const { store } = this.client;
|
|
7317
|
+
const state = store.getState();
|
|
7318
|
+
const assetTypeFieldValues = selectAssetTypeFieldValuesById(id)(state);
|
|
7319
|
+
if (!assetTypeFieldValues) {
|
|
7320
|
+
throw new Error(`Expected submission with offline_id ${id} to exist`);
|
|
7321
|
+
}
|
|
7322
|
+
const assetTypeFieldValuesAttachments = selectAttachmentsOfAssetTypeFieldValues(id)(state);
|
|
7323
|
+
this.dispatch(deleteAssetTypeFieldValues(id));
|
|
7324
|
+
this.dispatch(deleteAssetTypeFieldValuesAttachments(assetTypeFieldValuesAttachments.map((x) => x.offline_id)));
|
|
7325
|
+
try {
|
|
7326
|
+
await this.enqueueRequest({
|
|
7327
|
+
description: "Delete asset type field values",
|
|
7328
|
+
method: HttpMethod.DELETE,
|
|
7329
|
+
url: `/asset-type-field-values/${id}/`,
|
|
7330
|
+
blockers: [id],
|
|
7331
|
+
blocks: []
|
|
7332
|
+
});
|
|
7333
|
+
} catch (e) {
|
|
7334
|
+
this.dispatch(addAssetTypeFieldValues(assetTypeFieldValues));
|
|
7335
|
+
this.dispatch(addAssetTypeFieldValuesAttachments(assetTypeFieldValuesAttachments));
|
|
7336
|
+
throw e;
|
|
7337
|
+
}
|
|
7338
|
+
}
|
|
7339
|
+
async refreshStore(projectId) {
|
|
7340
|
+
const result = await this.enqueueRequest({
|
|
7341
|
+
description: "Get asset type field values",
|
|
7342
|
+
method: HttpMethod.GET,
|
|
7343
|
+
url: "/asset-type-field-values/",
|
|
7344
|
+
queryParams: {
|
|
7345
|
+
project: projectId.toString()
|
|
7346
|
+
},
|
|
7347
|
+
blockers: [],
|
|
7348
|
+
blocks: []
|
|
7349
|
+
});
|
|
7350
|
+
this.dispatch(initializeAssetTypeFieldValues(result));
|
|
7351
|
+
}
|
|
7352
|
+
}
|
|
7353
|
+
class AssetTypeFieldValuesAttachmentService extends BaseUploadService {
|
|
7354
|
+
async bulkAdd(payloads, batchSize) {
|
|
7355
|
+
var _a2;
|
|
7356
|
+
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7357
|
+
const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
7358
|
+
const batches = chunkArray(payloads, batchSize ?? payloads.length);
|
|
7359
|
+
const offlineAssetTypeFieldValuesAttachments = [];
|
|
7360
|
+
const batchPayloads = [];
|
|
7361
|
+
for (const batch of batches) {
|
|
7362
|
+
const filePayloads = {};
|
|
7363
|
+
const attachmentPayloads = [];
|
|
7364
|
+
for (const payload of batch) {
|
|
7365
|
+
const { fieldValuesId, fieldIdentifier, file } = payload;
|
|
7366
|
+
const filePayload = await this.getFilePayload(file);
|
|
7367
|
+
if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
|
|
7368
|
+
const offlineAssetTypeFieldValuesAttachment = offline({
|
|
7369
|
+
file: URL.createObjectURL(file),
|
|
7370
|
+
file_type: file.type,
|
|
7371
|
+
file_name: file.name,
|
|
7372
|
+
file_sha1: filePayload.sha1,
|
|
7373
|
+
created_by: createdBy,
|
|
7374
|
+
field_values: fieldValuesId,
|
|
7375
|
+
submitted_at: submittedAt,
|
|
7376
|
+
field_identifier: fieldIdentifier
|
|
7377
|
+
});
|
|
7378
|
+
offlineAssetTypeFieldValuesAttachments.push(offlineAssetTypeFieldValuesAttachment);
|
|
7379
|
+
const attachmentPayload = {
|
|
7380
|
+
offline_id: offlineAssetTypeFieldValuesAttachment.offline_id,
|
|
7381
|
+
file_name: file.name,
|
|
7382
|
+
file_sha1: filePayload.sha1,
|
|
7383
|
+
file_extension: filePayload.extension,
|
|
7384
|
+
field_identifier: fieldIdentifier,
|
|
7385
|
+
field_values: fieldValuesId
|
|
7386
|
+
};
|
|
7387
|
+
attachmentPayloads.push(attachmentPayload);
|
|
7388
|
+
}
|
|
7389
|
+
batchPayloads.push({
|
|
7390
|
+
submitted_at: submittedAt,
|
|
7391
|
+
attachments: attachmentPayloads,
|
|
7392
|
+
files: Object.values(filePayloads)
|
|
7393
|
+
});
|
|
7394
|
+
}
|
|
7395
|
+
this.dispatch(addAssetTypeFieldValuesAttachments(offlineAssetTypeFieldValuesAttachments));
|
|
7396
|
+
const promises = batchPayloads.map((payload) => {
|
|
7397
|
+
return this.enqueueRequest({
|
|
7398
|
+
description: "Add asset type field values attachments",
|
|
7399
|
+
method: HttpMethod.POST,
|
|
7400
|
+
url: "/asset-type-field-values-attachments/bulk/",
|
|
7401
|
+
payload,
|
|
7402
|
+
blockers: payload.attachments.map((payload2) => payload2.field_values),
|
|
7403
|
+
blocks: payload.attachments.map((payload2) => payload2.offline_id)
|
|
7404
|
+
});
|
|
7405
|
+
});
|
|
7406
|
+
Promise.all(promises).then((result) => {
|
|
7407
|
+
for (const res of result) this.processPresignedUrls(res.presigned_urls);
|
|
7408
|
+
const attachments = result.flatMap((res) => res.attachments);
|
|
7409
|
+
this.dispatch(updateAssetTypeFieldValuesAttachments(attachments));
|
|
7410
|
+
}).catch((error) => {
|
|
7411
|
+
this.dispatch(
|
|
7412
|
+
deleteAssetTypeFieldValuesAttachments(
|
|
7413
|
+
offlineAssetTypeFieldValuesAttachments.map((attachment) => attachment.offline_id)
|
|
7414
|
+
)
|
|
7415
|
+
);
|
|
7416
|
+
throw error;
|
|
7417
|
+
});
|
|
7418
|
+
return [
|
|
7419
|
+
offlineAssetTypeFieldValuesAttachments,
|
|
7420
|
+
promises.map((promise) => promise.then(({ attachments }) => attachments))
|
|
7421
|
+
];
|
|
7422
|
+
}
|
|
7423
|
+
async bulkDelete(ids) {
|
|
7424
|
+
const { store } = this.client;
|
|
7425
|
+
const state = store.getState();
|
|
7426
|
+
const attachments = selectAssetTypeFieldValuesAttachmentsByIds(ids)(state);
|
|
7427
|
+
this.dispatch(deleteAssetTypeFieldValuesAttachments(ids));
|
|
7428
|
+
try {
|
|
7429
|
+
await this.enqueueRequest({
|
|
7430
|
+
description: "Delete asset type field values attachments",
|
|
7431
|
+
method: HttpMethod.DELETE,
|
|
7432
|
+
url: "/asset-type-field-values-attachments/bulk/",
|
|
7433
|
+
payload: { attachment_ids: ids },
|
|
7434
|
+
blockers: ids,
|
|
7435
|
+
blocks: []
|
|
7436
|
+
});
|
|
7437
|
+
} catch (e) {
|
|
7438
|
+
this.dispatch(addAssetTypeFieldValuesAttachments(attachments));
|
|
7439
|
+
throw e;
|
|
7440
|
+
}
|
|
7441
|
+
}
|
|
7442
|
+
async refreshStore(projectId) {
|
|
7443
|
+
const result = await this.enqueueRequest({
|
|
7444
|
+
description: "Get asset type field values attachments",
|
|
7445
|
+
method: HttpMethod.GET,
|
|
7446
|
+
url: "/asset-type-field-values-attachments/",
|
|
7447
|
+
queryParams: {
|
|
7448
|
+
project: projectId.toString()
|
|
7449
|
+
},
|
|
7450
|
+
blockers: [],
|
|
7451
|
+
blocks: []
|
|
7452
|
+
});
|
|
7453
|
+
this.dispatch(initializeAssetTypeFieldValuesAttachments(result));
|
|
7454
|
+
}
|
|
7455
|
+
}
|
|
7456
|
+
class IssueTypeFieldsAttachmentService extends BaseUploadService {
|
|
7457
|
+
async bulkAdd(payloads) {
|
|
7458
|
+
var _a2;
|
|
7459
|
+
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7460
|
+
const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
7461
|
+
const filePayloads = {};
|
|
7462
|
+
const offlineIssueTypeFieldsAttachments = [];
|
|
7463
|
+
const attachmentPayloads = [];
|
|
7464
|
+
for (const payload of payloads) {
|
|
7465
|
+
const { fieldsRevisionId, fieldIdentifier, file } = payload;
|
|
7466
|
+
const filePayload = await this.getFilePayload(file);
|
|
7467
|
+
if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
|
|
7468
|
+
const offlineIssueTypeFieldsAttachment = offline({
|
|
7469
|
+
file: URL.createObjectURL(file),
|
|
7470
|
+
file_type: file.type,
|
|
7471
|
+
file_name: file.name,
|
|
7472
|
+
file_sha1: filePayload.sha1,
|
|
7473
|
+
created_by: createdBy,
|
|
7474
|
+
fields_revision: fieldsRevisionId,
|
|
7475
|
+
submitted_at: submittedAt,
|
|
7476
|
+
field_identifier: fieldIdentifier
|
|
7477
|
+
});
|
|
7478
|
+
offlineIssueTypeFieldsAttachments.push(offlineIssueTypeFieldsAttachment);
|
|
7479
|
+
const attachmentPayload = {
|
|
7480
|
+
offline_id: offlineIssueTypeFieldsAttachment.offline_id,
|
|
7481
|
+
file_name: file.name,
|
|
7482
|
+
file_extension: filePayload.extension,
|
|
7483
|
+
field_identifier: fieldIdentifier,
|
|
7484
|
+
file_sha1: filePayload.sha1,
|
|
7485
|
+
fields_revision: fieldsRevisionId
|
|
7486
|
+
};
|
|
7487
|
+
attachmentPayloads.push(attachmentPayload);
|
|
7488
|
+
}
|
|
7489
|
+
this.dispatch(addIssueTypeFieldsAttachments(offlineIssueTypeFieldsAttachments));
|
|
7490
|
+
const promise = this.enqueueRequest({
|
|
7491
|
+
description: "Add issue type fields attachments",
|
|
7492
|
+
method: HttpMethod.POST,
|
|
7493
|
+
url: "/issue-type-fields-attachments/bulk/",
|
|
7494
|
+
payload: {
|
|
7495
|
+
submitted_at: submittedAt,
|
|
7496
|
+
attachments: attachmentPayloads,
|
|
7497
|
+
files: Object.values(filePayloads)
|
|
7498
|
+
},
|
|
7499
|
+
blockers: offlineIssueTypeFieldsAttachments.map((attachment) => attachment.fields_revision),
|
|
7500
|
+
blocks: offlineIssueTypeFieldsAttachments.map((attachment) => attachment.offline_id)
|
|
7501
|
+
});
|
|
7502
|
+
promise.then((result) => {
|
|
7503
|
+
this.processPresignedUrls(result.presigned_urls);
|
|
7504
|
+
this.dispatch(updateIssueTypeFieldsAttachments(result.attachments));
|
|
7505
|
+
}).catch(() => {
|
|
7506
|
+
this.dispatch(
|
|
7507
|
+
deleteIssueTypeFieldsAttachments(
|
|
7508
|
+
offlineIssueTypeFieldsAttachments.map((attachment) => attachment.offline_id)
|
|
7509
|
+
)
|
|
7510
|
+
);
|
|
7511
|
+
});
|
|
7512
|
+
return [offlineIssueTypeFieldsAttachments, promise.then(({ attachments }) => attachments)];
|
|
7513
|
+
}
|
|
7514
|
+
async refreshStore(organizationId) {
|
|
7515
|
+
const result = await this.enqueueRequest({
|
|
7516
|
+
description: "get issue type fields attachments",
|
|
7517
|
+
method: HttpMethod.GET,
|
|
7518
|
+
url: "/issue-type-fields-attachments/",
|
|
7519
|
+
queryParams: {
|
|
7520
|
+
organization: organizationId.toString()
|
|
7521
|
+
},
|
|
7522
|
+
blockers: [organizationId.toString()],
|
|
7523
|
+
blocks: []
|
|
7524
|
+
});
|
|
7525
|
+
this.dispatch(initializeIssueTypeFieldsAttachments(result));
|
|
7526
|
+
}
|
|
7527
|
+
}
|
|
7528
|
+
class IssueTypeFieldsService extends BaseApiService {
|
|
7529
|
+
add(payload) {
|
|
7530
|
+
var _a2;
|
|
7531
|
+
const { store } = this.client;
|
|
7532
|
+
const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
7533
|
+
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7534
|
+
const offlineIssueTypeFields = offline({
|
|
7535
|
+
...payload,
|
|
7536
|
+
created_by: createdBy,
|
|
7537
|
+
submitted_at: submittedAt
|
|
7538
|
+
});
|
|
7539
|
+
this.dispatch(addIssueTypeFields(offlineIssueTypeFields));
|
|
7540
|
+
const promise = this.enqueueRequest({
|
|
7541
|
+
description: "Add Issue Type Fields",
|
|
7542
|
+
method: HttpMethod.POST,
|
|
7543
|
+
url: "/issue-type-fields/",
|
|
7544
|
+
payload: offlineIssueTypeFields,
|
|
7545
|
+
blockers: [offlineIssueTypeFields.issue_type],
|
|
7546
|
+
blocks: [offlineIssueTypeFields.offline_id]
|
|
7547
|
+
});
|
|
7548
|
+
promise.then((response) => {
|
|
7549
|
+
this.dispatch(updateIssueTypeFields(response));
|
|
7550
|
+
}).catch((error) => {
|
|
7551
|
+
this.dispatch(deleteIssueTypeFields(offlineIssueTypeFields.offline_id));
|
|
7552
|
+
throw error;
|
|
7553
|
+
});
|
|
7554
|
+
return [offlineIssueTypeFields, promise];
|
|
7555
|
+
}
|
|
7556
|
+
async refreshStore(organizationId) {
|
|
7557
|
+
const result = await this.enqueueRequest({
|
|
7558
|
+
description: "Get Issue Type Fields",
|
|
7559
|
+
method: HttpMethod.GET,
|
|
7560
|
+
url: "/issue-type-fields/",
|
|
7561
|
+
queryParams: {
|
|
7562
|
+
organization: organizationId.toString()
|
|
7563
|
+
},
|
|
7564
|
+
blockers: [],
|
|
7565
|
+
blocks: []
|
|
7566
|
+
});
|
|
7567
|
+
this.dispatch(initializeIssueTypeFields(result));
|
|
7568
|
+
}
|
|
7569
|
+
}
|
|
7570
|
+
class IssueTypeFieldValuesAttachmentService extends BaseUploadService {
|
|
7571
|
+
async bulkAdd(payloads) {
|
|
7572
|
+
var _a2;
|
|
7573
|
+
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7574
|
+
const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
7575
|
+
const filePayloads = {};
|
|
7576
|
+
const offlineIssueTypeFieldValuesAttachments = [];
|
|
7577
|
+
const attachmentPayloads = [];
|
|
7578
|
+
for (const payload of payloads) {
|
|
7579
|
+
const { fieldValuesId, fieldIdentifier, file } = payload;
|
|
7580
|
+
const filePayload = await this.getFilePayload(file);
|
|
7581
|
+
if (!(filePayload.sha1 in filePayloads)) filePayloads[filePayload.sha1] = filePayload;
|
|
7582
|
+
const offlineIssueTypeFieldValuesAttachment = offline({
|
|
7583
|
+
file: URL.createObjectURL(file),
|
|
7584
|
+
file_type: file.type,
|
|
7585
|
+
file_name: file.name,
|
|
7586
|
+
file_sha1: filePayload.sha1,
|
|
7587
|
+
created_by: createdBy,
|
|
7588
|
+
field_values: fieldValuesId,
|
|
7589
|
+
submitted_at: submittedAt,
|
|
7590
|
+
field_identifier: fieldIdentifier
|
|
7591
|
+
});
|
|
7592
|
+
offlineIssueTypeFieldValuesAttachments.push(offlineIssueTypeFieldValuesAttachment);
|
|
7593
|
+
const attachmentPayload = {
|
|
7594
|
+
offline_id: offlineIssueTypeFieldValuesAttachment.offline_id,
|
|
7595
|
+
file_name: file.name,
|
|
7596
|
+
file_sha1: filePayload.sha1,
|
|
7597
|
+
file_extension: filePayload.extension,
|
|
7598
|
+
field_identifier: fieldIdentifier,
|
|
7599
|
+
field_values: fieldValuesId
|
|
7600
|
+
};
|
|
7601
|
+
attachmentPayloads.push(attachmentPayload);
|
|
7602
|
+
}
|
|
7603
|
+
this.dispatch(addIssueTypeFieldValuesAttachments(offlineIssueTypeFieldValuesAttachments));
|
|
7604
|
+
const promise = this.enqueueRequest({
|
|
7605
|
+
description: "Add issue type field values attachments",
|
|
7606
|
+
method: HttpMethod.POST,
|
|
7607
|
+
url: "/issue-type-field-values-attachments/bulk/",
|
|
7608
|
+
payload: {
|
|
7609
|
+
submitted_at: submittedAt,
|
|
7610
|
+
attachments: attachmentPayloads,
|
|
7611
|
+
files: Object.values(filePayloads)
|
|
7612
|
+
},
|
|
7613
|
+
blockers: offlineIssueTypeFieldValuesAttachments.map((attachment) => attachment.field_values),
|
|
7614
|
+
blocks: offlineIssueTypeFieldValuesAttachments.map((attachment) => attachment.offline_id)
|
|
7615
|
+
});
|
|
7616
|
+
promise.then(({ presigned_urls, attachments }) => {
|
|
7617
|
+
this.processPresignedUrls(presigned_urls);
|
|
7618
|
+
this.dispatch(updateIssueTypeFieldValuesAttachments(attachments));
|
|
7619
|
+
}).catch((error) => {
|
|
7620
|
+
this.dispatch(
|
|
7621
|
+
deleteIssueTypeFieldValuesAttachments(
|
|
7622
|
+
offlineIssueTypeFieldValuesAttachments.map((attachment) => attachment.offline_id)
|
|
7623
|
+
)
|
|
7624
|
+
);
|
|
7625
|
+
throw error;
|
|
7626
|
+
});
|
|
7627
|
+
return [offlineIssueTypeFieldValuesAttachments, promise.then(({ attachments }) => attachments)];
|
|
7628
|
+
}
|
|
7629
|
+
async bulkDelete(attachmentsIds) {
|
|
7630
|
+
const { store } = this.client;
|
|
7631
|
+
const state = store.getState();
|
|
7632
|
+
const attachments = selectIssueTypeFieldValuesAttachmentsByIds(attachmentsIds)(state);
|
|
7633
|
+
this.dispatch(deleteIssueTypeFieldValuesAttachments(attachmentsIds));
|
|
7634
|
+
try {
|
|
7635
|
+
await this.enqueueRequest({
|
|
7636
|
+
description: "Delete issue type field values attachments",
|
|
7637
|
+
method: HttpMethod.DELETE,
|
|
7638
|
+
url: "/issue-type-field-values-attachments/bulk/",
|
|
7639
|
+
payload: { attachment_ids: attachmentsIds },
|
|
7640
|
+
blockers: attachmentsIds,
|
|
7641
|
+
blocks: []
|
|
7642
|
+
});
|
|
7643
|
+
} catch (e) {
|
|
7644
|
+
this.dispatch(addIssueTypeFieldValuesAttachments(attachments));
|
|
7645
|
+
throw e;
|
|
7646
|
+
}
|
|
7647
|
+
}
|
|
7648
|
+
async refreshStore(projectId) {
|
|
7649
|
+
const result = await this.enqueueRequest({
|
|
7650
|
+
description: "Get issue type field values attachments",
|
|
7651
|
+
method: HttpMethod.GET,
|
|
7652
|
+
url: "/issue-type-field-values-attachments/",
|
|
7653
|
+
queryParams: {
|
|
7654
|
+
project: projectId.toString()
|
|
7655
|
+
},
|
|
7656
|
+
blockers: [],
|
|
7657
|
+
blocks: []
|
|
7658
|
+
});
|
|
7659
|
+
this.dispatch(initializeIssueTypeFieldValuesAttachments(result));
|
|
7660
|
+
}
|
|
7661
|
+
}
|
|
7662
|
+
class IssueTypeFieldValuesService extends BaseApiService {
|
|
7663
|
+
add(payload) {
|
|
7664
|
+
var _a2;
|
|
7665
|
+
const { store } = this.client;
|
|
7666
|
+
const state = store.getState();
|
|
7667
|
+
const { values } = separateFilesFromValues(payload.values);
|
|
7668
|
+
const offlineIssueTypeFieldValues = offline({
|
|
7669
|
+
...payload,
|
|
7670
|
+
values,
|
|
7671
|
+
created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
|
|
7672
|
+
submitted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
7673
|
+
});
|
|
7674
|
+
const promise = this.enqueueRequest({
|
|
7675
|
+
description: "Add issue type field values",
|
|
7676
|
+
method: HttpMethod.POST,
|
|
7677
|
+
url: "/issue-type-field-values/",
|
|
7678
|
+
payload: offlineIssueTypeFieldValues,
|
|
7679
|
+
blockers: [payload.issue, payload.fields_revision],
|
|
7680
|
+
blocks: [offlineIssueTypeFieldValues.offline_id]
|
|
7681
|
+
});
|
|
7682
|
+
this.dispatch(addIssueTypeFieldValues(offlineIssueTypeFieldValues));
|
|
7683
|
+
promise.then((result) => {
|
|
7684
|
+
this.dispatch(updateIssueTypeFieldValues(result));
|
|
7685
|
+
return result;
|
|
7686
|
+
}).catch(() => {
|
|
7687
|
+
this.dispatch(deleteIssueTypeFieldValues(offlineIssueTypeFieldValues.offline_id));
|
|
7688
|
+
});
|
|
7689
|
+
return [offlineIssueTypeFieldValues, promise];
|
|
7690
|
+
}
|
|
7691
|
+
update(payload) {
|
|
7692
|
+
const { store } = this.client;
|
|
7693
|
+
const state = store.getState();
|
|
7694
|
+
const issueTypeFieldValues = selectIssueTypeFieldValuesById(payload.offline_id)(state);
|
|
7695
|
+
if (!issueTypeFieldValues) {
|
|
7696
|
+
throw new Error(`Expected IssueTypeFieldValues with offline_id ${payload.offline_id} to exist`);
|
|
7697
|
+
}
|
|
7698
|
+
const { values } = separateFilesFromValues(payload.values ?? {});
|
|
7699
|
+
const updatedIssueTypeFieldValues = {
|
|
7700
|
+
...issueTypeFieldValues,
|
|
7701
|
+
...payload,
|
|
7702
|
+
values
|
|
7703
|
+
};
|
|
7704
|
+
this.dispatch(updateIssueTypeFieldValues(updatedIssueTypeFieldValues));
|
|
7705
|
+
const promise = this.enqueueRequest({
|
|
7706
|
+
description: "Update issue type field values",
|
|
7707
|
+
method: HttpMethod.PATCH,
|
|
7708
|
+
url: `/issue-type-field-values/${payload.offline_id}/`,
|
|
7709
|
+
payload: {
|
|
7710
|
+
...payload,
|
|
7711
|
+
values
|
|
7712
|
+
},
|
|
7713
|
+
blockers: [
|
|
7714
|
+
updatedIssueTypeFieldValues.offline_id,
|
|
7715
|
+
updatedIssueTypeFieldValues.fields_revision,
|
|
7716
|
+
updatedIssueTypeFieldValues.issue
|
|
7717
|
+
],
|
|
7718
|
+
blocks: [updatedIssueTypeFieldValues.offline_id]
|
|
7719
|
+
});
|
|
7720
|
+
promise.then((result) => {
|
|
7721
|
+
this.dispatch(updateIssueTypeFieldValues(result));
|
|
7722
|
+
}).catch(() => {
|
|
7723
|
+
this.dispatch(updateIssueTypeFieldValues(issueTypeFieldValues));
|
|
7724
|
+
});
|
|
7725
|
+
return [updatedIssueTypeFieldValues, promise];
|
|
7726
|
+
}
|
|
7727
|
+
async delete(id) {
|
|
7728
|
+
const { store } = this.client;
|
|
7729
|
+
const state = store.getState();
|
|
7730
|
+
const issueTypeFieldValues = selectIssueTypeFieldValuesById(id)(state);
|
|
7731
|
+
if (!issueTypeFieldValues) {
|
|
7732
|
+
throw new Error(`Expected submission with offline_id ${id} to exist`);
|
|
7733
|
+
}
|
|
7734
|
+
const issueTypeFieldValuesAttachments = selectAttachmentsOfIssueTypeFieldValues(id)(state);
|
|
7735
|
+
this.dispatch(deleteIssueTypeFieldValues(id));
|
|
7736
|
+
this.dispatch(deleteIssueTypeFieldValuesAttachments(issueTypeFieldValuesAttachments.map((x) => x.offline_id)));
|
|
7737
|
+
try {
|
|
7738
|
+
await this.enqueueRequest({
|
|
7739
|
+
description: "Delete issue type field values",
|
|
7740
|
+
method: HttpMethod.DELETE,
|
|
7741
|
+
url: `/issue-type-field-values/${id}/`,
|
|
7742
|
+
blockers: [id],
|
|
7743
|
+
blocks: []
|
|
7744
|
+
});
|
|
7745
|
+
} catch (e) {
|
|
7746
|
+
this.dispatch(addIssueTypeFieldValues(issueTypeFieldValues));
|
|
7747
|
+
this.dispatch(addIssueTypeFieldValuesAttachments(issueTypeFieldValuesAttachments));
|
|
7748
|
+
throw e;
|
|
7749
|
+
}
|
|
7750
|
+
}
|
|
7751
|
+
async refreshStore(projectId) {
|
|
7752
|
+
const result = await this.enqueueRequest({
|
|
7753
|
+
description: "Get issue type field values",
|
|
7754
|
+
method: HttpMethod.GET,
|
|
7755
|
+
url: "/issue-type-field-values/",
|
|
7756
|
+
queryParams: {
|
|
7757
|
+
project: projectId.toString()
|
|
7758
|
+
},
|
|
7759
|
+
blockers: [],
|
|
7760
|
+
blocks: []
|
|
7761
|
+
});
|
|
7762
|
+
this.dispatch(initializeIssueTypeFieldValues(result));
|
|
7763
|
+
}
|
|
7764
|
+
}
|
|
7058
7765
|
var VerificationCodeType = /* @__PURE__ */ ((VerificationCodeType2) => {
|
|
7059
7766
|
VerificationCodeType2[VerificationCodeType2["USER_REGISTRATION"] = 0] = "USER_REGISTRATION";
|
|
7060
7767
|
VerificationCodeType2[VerificationCodeType2["APPLICATION_INVITE"] = 2] = "APPLICATION_INVITE";
|
|
@@ -7072,6 +7779,10 @@ export {
|
|
|
7072
7779
|
AssetStageCompletionService,
|
|
7073
7780
|
AssetStageService,
|
|
7074
7781
|
AssetTypeAttachmentService,
|
|
7782
|
+
AssetTypeFieldValuesAttachmentService,
|
|
7783
|
+
AssetTypeFieldValuesService,
|
|
7784
|
+
AssetTypeFieldsAttachmentService,
|
|
7785
|
+
AssetTypeFieldsService,
|
|
7075
7786
|
AssetTypeService,
|
|
7076
7787
|
AttachmentModel,
|
|
7077
7788
|
BaseApiService,
|
|
@@ -7088,7 +7799,10 @@ export {
|
|
|
7088
7799
|
EmailDomainsService,
|
|
7089
7800
|
EmailVerificationService,
|
|
7090
7801
|
FileService,
|
|
7802
|
+
FormRevisionAttachmentService,
|
|
7803
|
+
FormRevisionService,
|
|
7091
7804
|
FormService,
|
|
7805
|
+
FormSubmissionAttachmentService,
|
|
7092
7806
|
FormSubmissionService,
|
|
7093
7807
|
GREEN,
|
|
7094
7808
|
GeoImageService,
|
|
@@ -7099,6 +7813,10 @@ export {
|
|
|
7099
7813
|
IssuePriority,
|
|
7100
7814
|
IssueService,
|
|
7101
7815
|
IssueStatus,
|
|
7816
|
+
IssueTypeFieldValuesAttachmentService,
|
|
7817
|
+
IssueTypeFieldValuesService,
|
|
7818
|
+
IssueTypeFieldsAttachmentService,
|
|
7819
|
+
IssueTypeFieldsService,
|
|
7102
7820
|
IssueTypeService,
|
|
7103
7821
|
IssueUpdateChange,
|
|
7104
7822
|
IssueUpdateService,
|
|
@@ -7137,6 +7855,14 @@ export {
|
|
|
7137
7855
|
addAssetType,
|
|
7138
7856
|
addAssetTypeAttachment,
|
|
7139
7857
|
addAssetTypeAttachments,
|
|
7858
|
+
addAssetTypeFieldValues,
|
|
7859
|
+
addAssetTypeFieldValuesAttachment,
|
|
7860
|
+
addAssetTypeFieldValuesAttachments,
|
|
7861
|
+
addAssetTypeFieldValuesMany,
|
|
7862
|
+
addAssetTypeFields,
|
|
7863
|
+
addAssetTypeFieldsAttachment,
|
|
7864
|
+
addAssetTypeFieldsAttachments,
|
|
7865
|
+
addAssetTypeFieldsMany,
|
|
7140
7866
|
addAssetTypes,
|
|
7141
7867
|
addAssets,
|
|
7142
7868
|
addCategory,
|
|
@@ -7165,6 +7891,14 @@ export {
|
|
|
7165
7891
|
addIssueComment,
|
|
7166
7892
|
addIssueComments,
|
|
7167
7893
|
addIssueType,
|
|
7894
|
+
addIssueTypeFieldValues,
|
|
7895
|
+
addIssueTypeFieldValuesAttachment,
|
|
7896
|
+
addIssueTypeFieldValuesAttachments,
|
|
7897
|
+
addIssueTypeFieldValuesMany,
|
|
7898
|
+
addIssueTypeFields,
|
|
7899
|
+
addIssueTypeFieldsAttachment,
|
|
7900
|
+
addIssueTypeFieldsAttachments,
|
|
7901
|
+
addIssueTypeFieldsMany,
|
|
7168
7902
|
addIssueUpdate,
|
|
7169
7903
|
addIssueUpdates,
|
|
7170
7904
|
addIssues,
|
|
@@ -7189,6 +7923,14 @@ export {
|
|
|
7189
7923
|
assetStageSlice,
|
|
7190
7924
|
assetTypeAttachmentReducer,
|
|
7191
7925
|
assetTypeAttachmentSlice,
|
|
7926
|
+
assetTypeFieldValuesAttachmentReducer,
|
|
7927
|
+
assetTypeFieldValuesAttachmentSlice,
|
|
7928
|
+
assetTypeFieldValuesReducer,
|
|
7929
|
+
assetTypeFieldValuesSlice,
|
|
7930
|
+
assetTypeFieldsAttachmentReducer,
|
|
7931
|
+
assetTypeFieldsAttachmentSlice,
|
|
7932
|
+
assetTypeFieldsReducer,
|
|
7933
|
+
assetTypeFieldsSlice,
|
|
7192
7934
|
assetTypeReducer,
|
|
7193
7935
|
assetTypeSlice,
|
|
7194
7936
|
authReducer,
|
|
@@ -7213,6 +7955,14 @@ export {
|
|
|
7213
7955
|
deleteAssetType,
|
|
7214
7956
|
deleteAssetTypeAttachment,
|
|
7215
7957
|
deleteAssetTypeAttachments,
|
|
7958
|
+
deleteAssetTypeFieldValues,
|
|
7959
|
+
deleteAssetTypeFieldValuesAttachment,
|
|
7960
|
+
deleteAssetTypeFieldValuesAttachments,
|
|
7961
|
+
deleteAssetTypeFieldValuesMany,
|
|
7962
|
+
deleteAssetTypeFields,
|
|
7963
|
+
deleteAssetTypeFieldsAttachment,
|
|
7964
|
+
deleteAssetTypeFieldsAttachments,
|
|
7965
|
+
deleteAssetTypeFieldsMany,
|
|
7216
7966
|
deleteAssetTypes,
|
|
7217
7967
|
deleteAssets,
|
|
7218
7968
|
deleteCategory,
|
|
@@ -7237,6 +7987,14 @@ export {
|
|
|
7237
7987
|
deleteIssueAttachments,
|
|
7238
7988
|
deleteIssueComment,
|
|
7239
7989
|
deleteIssueComments,
|
|
7990
|
+
deleteIssueTypeFieldValues,
|
|
7991
|
+
deleteIssueTypeFieldValuesAttachment,
|
|
7992
|
+
deleteIssueTypeFieldValuesAttachments,
|
|
7993
|
+
deleteIssueTypeFieldValuesMany,
|
|
7994
|
+
deleteIssueTypeFields,
|
|
7995
|
+
deleteIssueTypeFieldsAttachment,
|
|
7996
|
+
deleteIssueTypeFieldsAttachments,
|
|
7997
|
+
deleteIssueTypeFieldsMany,
|
|
7240
7998
|
deleteIssueUpdate,
|
|
7241
7999
|
deleteIssueUpdates,
|
|
7242
8000
|
deleteIssues,
|
|
@@ -7294,6 +8052,10 @@ export {
|
|
|
7294
8052
|
initializeAssetStageCompletions,
|
|
7295
8053
|
initializeAssetStages,
|
|
7296
8054
|
initializeAssetTypeAttachments,
|
|
8055
|
+
initializeAssetTypeFieldValues,
|
|
8056
|
+
initializeAssetTypeFieldValuesAttachments,
|
|
8057
|
+
initializeAssetTypeFields,
|
|
8058
|
+
initializeAssetTypeFieldsAttachments,
|
|
7297
8059
|
initializeAssetTypes,
|
|
7298
8060
|
initializeAssets,
|
|
7299
8061
|
initializeCategories,
|
|
@@ -7308,6 +8070,10 @@ export {
|
|
|
7308
8070
|
initializeGeoImages,
|
|
7309
8071
|
initializeIssueAssociations,
|
|
7310
8072
|
initializeIssueAttachments,
|
|
8073
|
+
initializeIssueTypeFieldValues,
|
|
8074
|
+
initializeIssueTypeFieldValuesAttachments,
|
|
8075
|
+
initializeIssueTypeFields,
|
|
8076
|
+
initializeIssueTypeFieldsAttachments,
|
|
7311
8077
|
initializeIssueTypes,
|
|
7312
8078
|
initializeIssueUpdates,
|
|
7313
8079
|
initializeIssues,
|
|
@@ -7327,6 +8093,14 @@ export {
|
|
|
7327
8093
|
issueCommentSlice,
|
|
7328
8094
|
issueReducer,
|
|
7329
8095
|
issueSlice,
|
|
8096
|
+
issueTypeFieldValuesAttachmentReducer,
|
|
8097
|
+
issueTypeFieldValuesAttachmentSlice,
|
|
8098
|
+
issueTypeFieldValuesReducer,
|
|
8099
|
+
issueTypeFieldValuesSlice,
|
|
8100
|
+
issueTypeFieldsAttachmentReducer,
|
|
8101
|
+
issueTypeFieldsAttachmentSlice,
|
|
8102
|
+
issueTypeFieldsReducer,
|
|
8103
|
+
issueTypeFieldsSlice,
|
|
7330
8104
|
issueTypeReducer,
|
|
7331
8105
|
issueTypeSlice,
|
|
7332
8106
|
issueUpdateReducer,
|
|
@@ -7390,7 +8164,23 @@ export {
|
|
|
7390
8164
|
selectAssetTypeAttachmentMapping,
|
|
7391
8165
|
selectAssetTypeAttachments,
|
|
7392
8166
|
selectAssetTypeById,
|
|
8167
|
+
selectAssetTypeFieldValues,
|
|
8168
|
+
selectAssetTypeFieldValuesAttachmentById,
|
|
8169
|
+
selectAssetTypeFieldValuesAttachments,
|
|
8170
|
+
selectAssetTypeFieldValuesAttachmentsByIds,
|
|
8171
|
+
selectAssetTypeFieldValuesAttachmentsMapping,
|
|
8172
|
+
selectAssetTypeFieldValuesById,
|
|
8173
|
+
selectAssetTypeFieldValuesMapping,
|
|
8174
|
+
selectAssetTypeFieldValuesOfAsset,
|
|
8175
|
+
selectAssetTypeFields,
|
|
8176
|
+
selectAssetTypeFieldsAttachmentById,
|
|
8177
|
+
selectAssetTypeFieldsAttachments,
|
|
8178
|
+
selectAssetTypeFieldsAttachmentsMapping,
|
|
8179
|
+
selectAssetTypeFieldsById,
|
|
8180
|
+
selectAssetTypeFieldsMapping,
|
|
8181
|
+
selectAssetTypeFieldsOfAssetType,
|
|
7393
8182
|
selectAssetTypeStagesMapping,
|
|
8183
|
+
selectAssetTypeValuesOfAssetType,
|
|
7394
8184
|
selectAssetTypes,
|
|
7395
8185
|
selectAssetTypesByIds,
|
|
7396
8186
|
selectAssetTypesMapping,
|
|
@@ -7398,18 +8188,20 @@ export {
|
|
|
7398
8188
|
selectAssetsByIds,
|
|
7399
8189
|
selectAssetsMapping,
|
|
7400
8190
|
selectAssetsOfAssetType,
|
|
7401
|
-
selectAttachedFormSubmissionsOfAsset,
|
|
7402
|
-
selectAttachedFormSubmissionsOfIssue,
|
|
7403
8191
|
selectAttachmentsOfAsset,
|
|
7404
8192
|
selectAttachmentsOfAssetByType,
|
|
7405
8193
|
selectAttachmentsOfAssetType,
|
|
7406
8194
|
selectAttachmentsOfAssetTypeByType,
|
|
8195
|
+
selectAttachmentsOfAssetTypeFieldValues,
|
|
8196
|
+
selectAttachmentsOfAssetTypeFields,
|
|
7407
8197
|
selectAttachmentsOfDocument,
|
|
7408
8198
|
selectAttachmentsOfDocumentByType,
|
|
7409
8199
|
selectAttachmentsOfFormRevision,
|
|
7410
8200
|
selectAttachmentsOfFormSubmission,
|
|
7411
8201
|
selectAttachmentsOfIssue,
|
|
7412
8202
|
selectAttachmentsOfIssueByType,
|
|
8203
|
+
selectAttachmentsOfIssueTypeFieldValues,
|
|
8204
|
+
selectAttachmentsOfIssueTypeFields,
|
|
7413
8205
|
selectAttachmentsOfProject,
|
|
7414
8206
|
selectAttachmentsOfProjectByType,
|
|
7415
8207
|
selectCategories,
|
|
@@ -7435,8 +8227,6 @@ export {
|
|
|
7435
8227
|
selectFilteredForms,
|
|
7436
8228
|
selectFormById,
|
|
7437
8229
|
selectFormMapping,
|
|
7438
|
-
selectFormOfAssetType,
|
|
7439
|
-
selectFormOfIssueType,
|
|
7440
8230
|
selectFormRevisionAttachmentsMapping,
|
|
7441
8231
|
selectFormRevisionById,
|
|
7442
8232
|
selectFormRevisionMapping,
|
|
@@ -7446,16 +8236,11 @@ export {
|
|
|
7446
8236
|
selectFormSubmissionAttachmentsMapping,
|
|
7447
8237
|
selectFormSubmissionById,
|
|
7448
8238
|
selectFormSubmissions,
|
|
7449
|
-
selectFormSubmissionsByAssets,
|
|
7450
|
-
selectFormSubmissionsByFormRevisions,
|
|
7451
|
-
selectFormSubmissionsByIssues,
|
|
7452
8239
|
selectFormSubmissionsMapping,
|
|
7453
8240
|
selectFormSubmissionsOfAsset,
|
|
7454
8241
|
selectFormSubmissionsOfForm,
|
|
7455
8242
|
selectFormSubmissionsOfIssue,
|
|
7456
8243
|
selectForms,
|
|
7457
|
-
selectFormsCount,
|
|
7458
|
-
selectGeneralFormCount,
|
|
7459
8244
|
selectGeoImageById,
|
|
7460
8245
|
selectGeoImageMapping,
|
|
7461
8246
|
selectGeoImages,
|
|
@@ -7477,7 +8262,23 @@ export {
|
|
|
7477
8262
|
selectIssueCountOfCategory,
|
|
7478
8263
|
selectIssueMapping,
|
|
7479
8264
|
selectIssueTypeById,
|
|
8265
|
+
selectIssueTypeFieldValues,
|
|
8266
|
+
selectIssueTypeFieldValuesAttachmentById,
|
|
8267
|
+
selectIssueTypeFieldValuesAttachments,
|
|
8268
|
+
selectIssueTypeFieldValuesAttachmentsByIds,
|
|
8269
|
+
selectIssueTypeFieldValuesAttachmentsMapping,
|
|
8270
|
+
selectIssueTypeFieldValuesById,
|
|
8271
|
+
selectIssueTypeFieldValuesMapping,
|
|
8272
|
+
selectIssueTypeFieldValuesOfIssue,
|
|
8273
|
+
selectIssueTypeFields,
|
|
8274
|
+
selectIssueTypeFieldsAttachmentById,
|
|
8275
|
+
selectIssueTypeFieldsAttachments,
|
|
8276
|
+
selectIssueTypeFieldsAttachmentsMapping,
|
|
8277
|
+
selectIssueTypeFieldsById,
|
|
8278
|
+
selectIssueTypeFieldsMapping,
|
|
8279
|
+
selectIssueTypeFieldsOfIssueType,
|
|
7480
8280
|
selectIssueTypeMapping,
|
|
8281
|
+
selectIssueTypeValuesOfIssueType,
|
|
7481
8282
|
selectIssueTypes,
|
|
7482
8283
|
selectIssueTypesByIds,
|
|
7483
8284
|
selectIssueTypesOfOrganization,
|
|
@@ -7486,8 +8287,9 @@ export {
|
|
|
7486
8287
|
selectIssuesByIds,
|
|
7487
8288
|
selectIssuesOfIssueType,
|
|
7488
8289
|
selectIssuesOfIssueTypeCount,
|
|
7489
|
-
|
|
8290
|
+
selectLatestAssetTypeFieldsOfAssetType,
|
|
7490
8291
|
selectLatestFormRevisionOfForm,
|
|
8292
|
+
selectLatestIssueTypeFieldsOfIssueType,
|
|
7491
8293
|
selectLatestRetryTime,
|
|
7492
8294
|
selectLicense,
|
|
7493
8295
|
selectLicenseForProject,
|
|
@@ -7524,10 +8326,8 @@ export {
|
|
|
7524
8326
|
selectProjectsOfOrganization,
|
|
7525
8327
|
selectRehydrated,
|
|
7526
8328
|
selectRootDocuments,
|
|
7527
|
-
selectSortedFormSubmissionsOfForm,
|
|
7528
8329
|
selectSortedOrganizationUsers,
|
|
7529
8330
|
selectSortedProjectUsers,
|
|
7530
|
-
selectStageFormIdsFromStageIds,
|
|
7531
8331
|
selectStageMapping,
|
|
7532
8332
|
selectStagesOfAssetType,
|
|
7533
8333
|
selectTeamById,
|
|
@@ -7543,6 +8343,8 @@ export {
|
|
|
7543
8343
|
selectWorkspaceById,
|
|
7544
8344
|
selectWorkspaceMapping,
|
|
7545
8345
|
selectWorkspaces,
|
|
8346
|
+
separateFilesFromValues,
|
|
8347
|
+
separateImageFromFields,
|
|
7546
8348
|
setActiveProjectFileId,
|
|
7547
8349
|
setAsset,
|
|
7548
8350
|
setAssetAttachment,
|
|
@@ -7552,6 +8354,14 @@ export {
|
|
|
7552
8354
|
setAssetType,
|
|
7553
8355
|
setAssetTypeAttachment,
|
|
7554
8356
|
setAssetTypeAttachments,
|
|
8357
|
+
setAssetTypeFieldValues,
|
|
8358
|
+
setAssetTypeFieldValuesAttachment,
|
|
8359
|
+
setAssetTypeFieldValuesAttachments,
|
|
8360
|
+
setAssetTypeFieldValuesMany,
|
|
8361
|
+
setAssetTypeFields,
|
|
8362
|
+
setAssetTypeFieldsAttachment,
|
|
8363
|
+
setAssetTypeFieldsAttachments,
|
|
8364
|
+
setAssetTypeFieldsMany,
|
|
7555
8365
|
setAssetTypes,
|
|
7556
8366
|
setAssets,
|
|
7557
8367
|
setConversation,
|
|
@@ -7577,6 +8387,14 @@ export {
|
|
|
7577
8387
|
setIssueComment,
|
|
7578
8388
|
setIssueComments,
|
|
7579
8389
|
setIssueType,
|
|
8390
|
+
setIssueTypeFieldValues,
|
|
8391
|
+
setIssueTypeFieldValuesAttachment,
|
|
8392
|
+
setIssueTypeFieldValuesAttachments,
|
|
8393
|
+
setIssueTypeFieldValuesMany,
|
|
8394
|
+
setIssueTypeFields,
|
|
8395
|
+
setIssueTypeFieldsAttachment,
|
|
8396
|
+
setIssueTypeFieldsAttachments,
|
|
8397
|
+
setIssueTypeFieldsMany,
|
|
7580
8398
|
setIssueUpdate,
|
|
7581
8399
|
setLoggedIn,
|
|
7582
8400
|
setOrganizations,
|
|
@@ -7611,6 +8429,14 @@ export {
|
|
|
7611
8429
|
updateAssetType,
|
|
7612
8430
|
updateAssetTypeAttachment,
|
|
7613
8431
|
updateAssetTypeAttachments,
|
|
8432
|
+
updateAssetTypeFieldValues,
|
|
8433
|
+
updateAssetTypeFieldValuesAttachment,
|
|
8434
|
+
updateAssetTypeFieldValuesAttachments,
|
|
8435
|
+
updateAssetTypeFieldValuesMany,
|
|
8436
|
+
updateAssetTypeFields,
|
|
8437
|
+
updateAssetTypeFieldsAttachment,
|
|
8438
|
+
updateAssetTypeFieldsAttachments,
|
|
8439
|
+
updateAssetTypeFieldsMany,
|
|
7614
8440
|
updateAssetTypes,
|
|
7615
8441
|
updateAssets,
|
|
7616
8442
|
updateCategory,
|
|
@@ -7633,6 +8459,14 @@ export {
|
|
|
7633
8459
|
updateIssueAttachment,
|
|
7634
8460
|
updateIssueAttachments,
|
|
7635
8461
|
updateIssueType,
|
|
8462
|
+
updateIssueTypeFieldValues,
|
|
8463
|
+
updateIssueTypeFieldValuesAttachment,
|
|
8464
|
+
updateIssueTypeFieldValuesAttachments,
|
|
8465
|
+
updateIssueTypeFieldValuesMany,
|
|
8466
|
+
updateIssueTypeFields,
|
|
8467
|
+
updateIssueTypeFieldsAttachment,
|
|
8468
|
+
updateIssueTypeFieldsAttachments,
|
|
8469
|
+
updateIssueTypeFieldsMany,
|
|
7636
8470
|
updateLicense,
|
|
7637
8471
|
updateOrganizationAccess,
|
|
7638
8472
|
updateProject,
|