@overmap-ai/core 1.0.65-strip-workspace-access.1 → 1.0.65-strip-workspace-access.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/overmap-core.js +216 -229
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +216 -229
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/services/BaseAttachmentService.d.ts +1 -1
- package/dist/sdk/services/CategoryService.d.ts +3 -7
- package/dist/sdk/services/DocumentService.d.ts +4 -4
- package/dist/sdk/services/FormSubmissionService.d.ts +2 -2
- package/dist/sdk/services/IssueCommentService.d.ts +4 -4
- package/dist/sdk/services/IssueService.d.ts +3 -3
- package/dist/sdk/services/IssueTypeService.d.ts +4 -4
- package/dist/sdk/services/ProjectFileService.d.ts +1 -1
- package/dist/sdk/services/TeamService.d.ts +3 -3
- package/dist/sdk/services/WorkspaceService.d.ts +2 -2
- package/dist/store/slices/documentSlice.d.ts +3 -3
- package/dist/store/slices/formSlice.d.ts +2 -2
- package/dist/store/slices/issueCommentSlice.d.ts +2 -1
- package/dist/store/slices/userSlice.d.ts +13 -33
- package/dist/store/slices/workspaceSlice.d.ts +11 -11
- package/dist/typings/models/documents.d.ts +1 -2
- package/dist/typings/models/forms.d.ts +4 -11
- package/dist/typings/models/issueTypes.d.ts +1 -2
- package/dist/typings/models/issues.d.ts +8 -11
- package/dist/typings/models/projects.d.ts +2 -4
- package/dist/typings/models/teams.d.ts +1 -2
- package/package.json +1 -1
package/dist/overmap-core.js
CHANGED
|
@@ -1633,12 +1633,7 @@ var LicenseStatus = /* @__PURE__ */ ((LicenseStatus2) => {
|
|
|
1633
1633
|
})(LicenseStatus || {});
|
|
1634
1634
|
const initialState$p = {
|
|
1635
1635
|
users: {},
|
|
1636
|
-
currentUser:
|
|
1637
|
-
id: 0,
|
|
1638
|
-
username: "",
|
|
1639
|
-
email: "",
|
|
1640
|
-
profile: { file: null, file_sha1: null, favourite_project_ids: [], tour_step: -1 }
|
|
1641
|
-
}
|
|
1636
|
+
currentUser: null
|
|
1642
1637
|
};
|
|
1643
1638
|
const userSlice = createSlice({
|
|
1644
1639
|
name: "users",
|
|
@@ -1661,6 +1656,8 @@ const userSlice = createSlice({
|
|
|
1661
1656
|
state.currentUser = action.payload;
|
|
1662
1657
|
},
|
|
1663
1658
|
setProfilePicture: (state, action) => {
|
|
1659
|
+
if (!state.currentUser)
|
|
1660
|
+
return;
|
|
1664
1661
|
state.currentUser.profile.file = action.payload.file ?? null;
|
|
1665
1662
|
state.currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
|
|
1666
1663
|
const currentUser = state.users[state.currentUser.id];
|
|
@@ -1670,32 +1667,12 @@ const userSlice = createSlice({
|
|
|
1670
1667
|
currentUser.profile.file = action.payload.file ?? null;
|
|
1671
1668
|
currentUser.profile.file_sha1 = action.payload.file_sha1 ?? null;
|
|
1672
1669
|
},
|
|
1673
|
-
addFavouriteProjectId: (state, action) => {
|
|
1674
|
-
state.currentUser.profile.favourite_project_ids.push(action.payload);
|
|
1675
|
-
},
|
|
1676
|
-
removeFavouriteProjectId: (state, action) => {
|
|
1677
|
-
state.currentUser.profile.favourite_project_ids = state.currentUser.profile.favourite_project_ids.filter(
|
|
1678
|
-
(id) => id !== action.payload
|
|
1679
|
-
);
|
|
1680
|
-
},
|
|
1681
|
-
setTourStep: (state, action) => {
|
|
1682
|
-
state.currentUser.profile.tour_step = action.payload;
|
|
1683
|
-
},
|
|
1684
1670
|
removeUser: (state, action) => {
|
|
1685
1671
|
delete state.users[action.payload];
|
|
1686
1672
|
}
|
|
1687
1673
|
}
|
|
1688
1674
|
});
|
|
1689
|
-
const {
|
|
1690
|
-
setCurrentUser,
|
|
1691
|
-
setProfilePicture,
|
|
1692
|
-
setUsers,
|
|
1693
|
-
addUsers,
|
|
1694
|
-
addFavouriteProjectId,
|
|
1695
|
-
removeFavouriteProjectId,
|
|
1696
|
-
setTourStep,
|
|
1697
|
-
removeUser
|
|
1698
|
-
} = userSlice.actions;
|
|
1675
|
+
const { setCurrentUser, setProfilePicture, setUsers, addUsers, removeUser } = userSlice.actions;
|
|
1699
1676
|
const userReducer = userSlice.reducer;
|
|
1700
1677
|
const selectCurrentUser = (state) => state.userReducer.currentUser;
|
|
1701
1678
|
const selectUsersMapping = (state) => state.userReducer.users;
|
|
@@ -1716,7 +1693,6 @@ const selectUsersByIds = restructureCreateSelectorWithArgs(
|
|
|
1716
1693
|
return fallbackToEmptyArray(users);
|
|
1717
1694
|
})
|
|
1718
1695
|
);
|
|
1719
|
-
const selectFavouriteProjects = (state) => state.userReducer.currentUser.profile.favourite_project_ids;
|
|
1720
1696
|
const organizationAccessAdapter = createModelAdapter(
|
|
1721
1697
|
(organizationAccess) => organizationAccess.offline_id
|
|
1722
1698
|
);
|
|
@@ -1742,7 +1718,7 @@ const selectActiveOrganizationAccess = createSelector(
|
|
|
1742
1718
|
[selectCurrentUser, selectOrganizationAccesses],
|
|
1743
1719
|
(currentUser, organizationAccesses) => {
|
|
1744
1720
|
const activeOrganizationAccess = Object.values(organizationAccesses).find(
|
|
1745
|
-
(organizationAccess) => organizationAccess.user === currentUser.id
|
|
1721
|
+
(organizationAccess) => organizationAccess.user === (currentUser == null ? void 0 : currentUser.id)
|
|
1746
1722
|
);
|
|
1747
1723
|
return activeOrganizationAccess ?? null;
|
|
1748
1724
|
}
|
|
@@ -1819,7 +1795,7 @@ const selectActiveProjectAccess = (state) => {
|
|
|
1819
1795
|
const currentUser = state.userReducer.currentUser;
|
|
1820
1796
|
const activeProjectId = state.projectReducer.activeProjectId;
|
|
1821
1797
|
return Object.values(state.projectAccessReducer.instances).find((projectAccess) => {
|
|
1822
|
-
return projectAccess.user === currentUser.id && projectAccess.project === activeProjectId;
|
|
1798
|
+
return projectAccess.user === (currentUser == null ? void 0 : currentUser.id) && projectAccess.project === activeProjectId;
|
|
1823
1799
|
}) ?? null;
|
|
1824
1800
|
};
|
|
1825
1801
|
const selectProjectAccessForUser = (user) => (state) => {
|
|
@@ -1932,9 +1908,9 @@ const selectSortedProjectUsers = createSelector(
|
|
|
1932
1908
|
[selectCurrentUser, selectProjectUsersAsMapping, selectProjectAccessUserMapping],
|
|
1933
1909
|
(currentUser, userMapping, projectAccessMapping) => {
|
|
1934
1910
|
return Object.values(userMapping).sort((userA, userB) => {
|
|
1935
|
-
if (userA.id === currentUser.id) {
|
|
1911
|
+
if (userA.id === (currentUser == null ? void 0 : currentUser.id)) {
|
|
1936
1912
|
return -1;
|
|
1937
|
-
} else if (userB.id === currentUser.id) {
|
|
1913
|
+
} else if (userB.id === (currentUser == null ? void 0 : currentUser.id)) {
|
|
1938
1914
|
return 1;
|
|
1939
1915
|
}
|
|
1940
1916
|
const projectAccessesA = projectAccessMapping[userA.id];
|
|
@@ -2011,9 +1987,9 @@ const selectSortedOrganizationUsers = createSelector(
|
|
|
2011
1987
|
[selectCurrentUser, selectOrganizationUsersAsMapping, selectOrganizationAccessUserMapping],
|
|
2012
1988
|
(currentUser, userMapping, organizationAccessMapping) => {
|
|
2013
1989
|
return Object.values(userMapping).sort((userA, userB) => {
|
|
2014
|
-
if (userA.id === currentUser.id) {
|
|
1990
|
+
if (userA.id === (currentUser == null ? void 0 : currentUser.id)) {
|
|
2015
1991
|
return -1;
|
|
2016
|
-
} else if (userB.id === currentUser.id) {
|
|
1992
|
+
} else if (userB.id === (currentUser == null ? void 0 : currentUser.id)) {
|
|
2017
1993
|
return 1;
|
|
2018
1994
|
}
|
|
2019
1995
|
const organizationAccessesA = organizationAccessMapping[userA.id];
|
|
@@ -2383,7 +2359,7 @@ const selectFilteredForms = restructureCreateSelectorWithArgs(
|
|
|
2383
2359
|
}
|
|
2384
2360
|
const latestRevision = _selectLatestFormRevision(revisions, formId);
|
|
2385
2361
|
if (latestRevision.title.toLowerCase().includes(searchTerm.toLowerCase())) {
|
|
2386
|
-
regularMatches.push(
|
|
2362
|
+
regularMatches.push(form);
|
|
2387
2363
|
}
|
|
2388
2364
|
}
|
|
2389
2365
|
return [...regularMatches.slice(0, maxResults)];
|
|
@@ -3120,13 +3096,13 @@ const {
|
|
|
3120
3096
|
deleteIssueComments
|
|
3121
3097
|
} = issueCommentSlice.actions;
|
|
3122
3098
|
const selectIssueCommentMapping = (state) => state.issueCommentReducer.instances;
|
|
3099
|
+
const selectIssueCommentById = (id) => (state) => {
|
|
3100
|
+
return state.issueCommentReducer.instances[id];
|
|
3101
|
+
};
|
|
3123
3102
|
const selectCommentsOfIssue = restructureCreateSelectorWithArgs(
|
|
3124
|
-
createSelector(
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
return fallbackToEmptyArray(Object.values(commentMapping).filter((comment) => comment.issue === issueId));
|
|
3128
|
-
}
|
|
3129
|
-
)
|
|
3103
|
+
createSelector([selectIssueCommentMapping, (_state, issueId) => issueId], (commentMapping, issueId) => {
|
|
3104
|
+
return fallbackToEmptyArray(Object.values(commentMapping).filter((comment) => comment.issue === issueId));
|
|
3105
|
+
})
|
|
3130
3106
|
);
|
|
3131
3107
|
const issueCommentReducer = issueCommentSlice.reducer;
|
|
3132
3108
|
const issueUpdateAdapter = createModelAdapter((issueUpdate) => issueUpdate.offline_id);
|
|
@@ -4036,15 +4012,15 @@ class BaseApiService extends BaseService {
|
|
|
4036
4012
|
}
|
|
4037
4013
|
}
|
|
4038
4014
|
class CategoryService extends BaseApiService {
|
|
4039
|
-
add(payload
|
|
4015
|
+
add(payload) {
|
|
4016
|
+
var _a2;
|
|
4040
4017
|
const { store } = this.client;
|
|
4041
|
-
const createdBy = store.getState().userReducer.currentUser.id;
|
|
4018
|
+
const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
4042
4019
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
4043
4020
|
const offlineCategory = offline({
|
|
4044
4021
|
...payload,
|
|
4045
4022
|
created_by: createdBy,
|
|
4046
|
-
submitted_at: submittedAt
|
|
4047
|
-
workspace: workspaceId
|
|
4023
|
+
submitted_at: submittedAt
|
|
4048
4024
|
});
|
|
4049
4025
|
this.dispatch(addCategory(offlineCategory));
|
|
4050
4026
|
const promise = this.enqueueRequest({
|
|
@@ -4052,48 +4028,50 @@ class CategoryService extends BaseApiService {
|
|
|
4052
4028
|
method: HttpMethod.POST,
|
|
4053
4029
|
url: "/categories/",
|
|
4054
4030
|
queryParams: {
|
|
4055
|
-
workspace_id:
|
|
4031
|
+
workspace_id: payload.workspace.toString()
|
|
4056
4032
|
},
|
|
4057
4033
|
payload: offlineCategory,
|
|
4058
|
-
blockers: [
|
|
4034
|
+
blockers: [payload.workspace],
|
|
4059
4035
|
blocks: [offlineCategory.offline_id]
|
|
4060
4036
|
});
|
|
4061
4037
|
return [offlineCategory, promise];
|
|
4062
4038
|
}
|
|
4063
|
-
update(
|
|
4039
|
+
update(payload) {
|
|
4064
4040
|
const state = this.client.store.getState();
|
|
4065
|
-
const existingCategory = selectCategoryById(
|
|
4041
|
+
const existingCategory = selectCategoryById(payload.offline_id)(state);
|
|
4066
4042
|
if (!existingCategory) {
|
|
4067
|
-
throw new Error(`Expected an existing category with offline_id ${
|
|
4043
|
+
throw new Error(`Expected an existing category with offline_id ${payload.offline_id}`);
|
|
4068
4044
|
}
|
|
4069
|
-
const optimisticCategory = { ...existingCategory, ...
|
|
4045
|
+
const optimisticCategory = { ...existingCategory, ...payload };
|
|
4070
4046
|
this.dispatch(updateCategory(optimisticCategory));
|
|
4071
4047
|
const promise = this.enqueueRequest({
|
|
4072
4048
|
description: "Edit Category",
|
|
4073
4049
|
method: HttpMethod.PATCH,
|
|
4074
|
-
url: `/categories/${
|
|
4075
|
-
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
payload: category,
|
|
4079
|
-
blockers: [category.offline_id],
|
|
4080
|
-
blocks: [category.offline_id]
|
|
4050
|
+
url: `/categories/${payload.offline_id}/`,
|
|
4051
|
+
payload,
|
|
4052
|
+
blockers: [payload.offline_id],
|
|
4053
|
+
blocks: [payload.offline_id]
|
|
4081
4054
|
});
|
|
4082
4055
|
return [optimisticCategory, promise];
|
|
4083
4056
|
}
|
|
4084
|
-
remove(
|
|
4085
|
-
this.
|
|
4086
|
-
|
|
4057
|
+
remove(id) {
|
|
4058
|
+
const { store } = this.client;
|
|
4059
|
+
const category = selectCategoryById(id)(store.getState());
|
|
4060
|
+
if (!category) {
|
|
4061
|
+
throw new Error(`No category with id ${id} found in the store`);
|
|
4062
|
+
}
|
|
4063
|
+
this.dispatch(deleteCategory(id));
|
|
4064
|
+
const promise = this.enqueueRequest({
|
|
4087
4065
|
description: "Delete Category",
|
|
4088
4066
|
method: HttpMethod.DELETE,
|
|
4089
4067
|
url: `/categories/${category.offline_id}/`,
|
|
4090
|
-
// TODO: Shouldn't be necessary to specify workspace_id here
|
|
4091
|
-
queryParams: {
|
|
4092
|
-
workspace_id: workspaceId.toString()
|
|
4093
|
-
},
|
|
4094
4068
|
blockers: [category.offline_id],
|
|
4095
4069
|
blocks: []
|
|
4096
4070
|
});
|
|
4071
|
+
promise.catch(() => {
|
|
4072
|
+
this.dispatch(addCategory(category));
|
|
4073
|
+
});
|
|
4074
|
+
return promise;
|
|
4097
4075
|
}
|
|
4098
4076
|
async refreshStore(projectId) {
|
|
4099
4077
|
const result = await this.enqueueRequest({
|
|
@@ -4547,8 +4525,9 @@ const AttachmentModelMeta = {
|
|
|
4547
4525
|
};
|
|
4548
4526
|
class BaseAttachmentService extends BaseUploadService {
|
|
4549
4527
|
async attachFiles(files, modelId, buildOfflineAttachment) {
|
|
4528
|
+
var _a2;
|
|
4550
4529
|
const { store } = this.client;
|
|
4551
|
-
const
|
|
4530
|
+
const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
4552
4531
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
4553
4532
|
const offlineAttachments = [];
|
|
4554
4533
|
const attachmentPayloads = [];
|
|
@@ -4568,7 +4547,7 @@ class BaseAttachmentService extends BaseUploadService {
|
|
|
4568
4547
|
file,
|
|
4569
4548
|
sha1,
|
|
4570
4549
|
submittedAt,
|
|
4571
|
-
createdBy
|
|
4550
|
+
createdBy,
|
|
4572
4551
|
description: "",
|
|
4573
4552
|
modelId
|
|
4574
4553
|
});
|
|
@@ -4772,21 +4751,21 @@ class AssetTypeAttachmentService extends BaseAttachmentService {
|
|
|
4772
4751
|
}
|
|
4773
4752
|
}
|
|
4774
4753
|
class IssueCommentService extends BaseApiService {
|
|
4775
|
-
|
|
4776
|
-
|
|
4754
|
+
add(payload) {
|
|
4755
|
+
var _a2;
|
|
4777
4756
|
const { store } = this.client;
|
|
4778
4757
|
const offlineComment = offline({
|
|
4779
|
-
...
|
|
4780
|
-
author: store.getState().userReducer.currentUser.id,
|
|
4758
|
+
...payload,
|
|
4759
|
+
author: (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id,
|
|
4781
4760
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
4782
4761
|
});
|
|
4783
4762
|
this.dispatch(addIssueComment(offlineComment));
|
|
4784
4763
|
const promise = this.enqueueRequest({
|
|
4785
|
-
description:
|
|
4764
|
+
description: "Add issue comment",
|
|
4786
4765
|
method: HttpMethod.POST,
|
|
4787
|
-
url: `/issues/${
|
|
4766
|
+
url: `/issues/${payload.issue}/comment/`,
|
|
4788
4767
|
payload: offlineComment,
|
|
4789
|
-
blockers: [
|
|
4768
|
+
blockers: [payload.issue],
|
|
4790
4769
|
blocks: [offlineComment.offline_id]
|
|
4791
4770
|
});
|
|
4792
4771
|
promise.catch(() => {
|
|
@@ -4794,37 +4773,41 @@ class IssueCommentService extends BaseApiService {
|
|
|
4794
4773
|
});
|
|
4795
4774
|
return [offlineComment, promise];
|
|
4796
4775
|
}
|
|
4797
|
-
update(
|
|
4776
|
+
update(payload) {
|
|
4798
4777
|
const { store } = this.client;
|
|
4799
|
-
const commentToUpdate = store.getState()
|
|
4778
|
+
const commentToUpdate = selectIssueCommentById(payload.offline_id)(store.getState());
|
|
4800
4779
|
if (!commentToUpdate) {
|
|
4801
|
-
throw new Error(`Comment with offline_id ${
|
|
4780
|
+
throw new Error(`Comment with offline_id ${payload.offline_id} not found in store`);
|
|
4802
4781
|
}
|
|
4803
|
-
|
|
4782
|
+
const updatedComment = {
|
|
4783
|
+
...commentToUpdate,
|
|
4784
|
+
...payload
|
|
4785
|
+
};
|
|
4786
|
+
this.dispatch(setIssueComment(updatedComment));
|
|
4804
4787
|
const promise = this.enqueueRequest({
|
|
4805
|
-
description:
|
|
4788
|
+
description: "Edit issue comment",
|
|
4806
4789
|
method: HttpMethod.PATCH,
|
|
4807
|
-
url: `/issues/comments/${
|
|
4808
|
-
payload
|
|
4809
|
-
blockers: [
|
|
4810
|
-
blocks: [
|
|
4790
|
+
url: `/issues/comments/${payload.offline_id}/`,
|
|
4791
|
+
payload,
|
|
4792
|
+
blockers: [payload.offline_id],
|
|
4793
|
+
blocks: [payload.offline_id]
|
|
4811
4794
|
});
|
|
4812
4795
|
promise.catch(() => {
|
|
4813
4796
|
this.dispatch(setIssueComment(commentToUpdate));
|
|
4814
4797
|
});
|
|
4815
|
-
return [
|
|
4798
|
+
return [updatedComment, promise];
|
|
4816
4799
|
}
|
|
4817
|
-
remove(
|
|
4818
|
-
const commentToRemove = this.client.store.getState().issueCommentReducer.instances[
|
|
4800
|
+
remove(id) {
|
|
4801
|
+
const commentToRemove = this.client.store.getState().issueCommentReducer.instances[id];
|
|
4819
4802
|
if (!commentToRemove) {
|
|
4820
|
-
throw new Error(`Comment with offline_id ${
|
|
4803
|
+
throw new Error(`Comment with offline_id ${id} not found in store`);
|
|
4821
4804
|
}
|
|
4822
|
-
this.dispatch(deleteIssueComment(
|
|
4805
|
+
this.dispatch(deleteIssueComment(id));
|
|
4823
4806
|
const promise = this.enqueueRequest({
|
|
4824
4807
|
description: "Delete comment",
|
|
4825
4808
|
method: HttpMethod.DELETE,
|
|
4826
|
-
url: `/issues/comments/${
|
|
4827
|
-
blockers: [
|
|
4809
|
+
url: `/issues/comments/${id}/`,
|
|
4810
|
+
blockers: [id],
|
|
4828
4811
|
blocks: []
|
|
4829
4812
|
});
|
|
4830
4813
|
promise.catch(() => {
|
|
@@ -4897,67 +4880,60 @@ class IssueAttachmentService extends BaseAttachmentService {
|
|
|
4897
4880
|
}
|
|
4898
4881
|
class IssueService extends BaseApiService {
|
|
4899
4882
|
// Basic CRUD functions
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
add(issue, workspaceId, issueType = null) {
|
|
4883
|
+
add(payload) {
|
|
4884
|
+
var _a2;
|
|
4903
4885
|
const { store } = this.client;
|
|
4904
|
-
const dateWithoutMilliseconds = /* @__PURE__ */ new Date();
|
|
4905
4886
|
const state = store.getState();
|
|
4906
|
-
const
|
|
4907
|
-
|
|
4908
|
-
|
|
4909
|
-
|
|
4910
|
-
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
created_by: currentUserId,
|
|
4916
|
-
status: issue.status ?? DEFAULT_ISSUE_STATUS,
|
|
4917
|
-
priority: issue.priority ?? DEFAULT_ISSUE_PRIORITY
|
|
4918
|
-
});
|
|
4919
|
-
this.dispatch(addIssue(issuePayload));
|
|
4920
|
-
this.dispatch(addToRecentIssues(issuePayload.offline_id));
|
|
4887
|
+
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
4888
|
+
const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
4889
|
+
const offlineIssue = offline({
|
|
4890
|
+
...payload,
|
|
4891
|
+
submitted_at: submittedAt,
|
|
4892
|
+
created_by: createdBy
|
|
4893
|
+
});
|
|
4894
|
+
this.dispatch(addIssue(offlineIssue));
|
|
4895
|
+
this.dispatch(addToRecentIssues(offlineIssue.offline_id));
|
|
4921
4896
|
this.dispatch(addActiveProjectIssuesCount(1));
|
|
4922
4897
|
const promise = this.enqueueRequest({
|
|
4923
4898
|
description: "Create issue",
|
|
4924
4899
|
method: HttpMethod.POST,
|
|
4925
4900
|
url: "/issues/",
|
|
4926
4901
|
queryParams: {
|
|
4927
|
-
workspace_id:
|
|
4928
|
-
...
|
|
4902
|
+
workspace_id: payload.index_workspace,
|
|
4903
|
+
...payload.issue_type ? { issue_type: payload.issue_type } : {}
|
|
4929
4904
|
},
|
|
4930
|
-
payload:
|
|
4931
|
-
blockers: ["add-issue", ...
|
|
4932
|
-
blocks: [
|
|
4905
|
+
payload: offlineIssue,
|
|
4906
|
+
blockers: ["add-issue", ...offlineIssue.index_workspace ? [offlineIssue.index_workspace] : []],
|
|
4907
|
+
blocks: [offlineIssue.offline_id]
|
|
4933
4908
|
});
|
|
4934
4909
|
void promise.then((result) => {
|
|
4935
4910
|
this.dispatch(updateIssue(result));
|
|
4936
4911
|
}).catch((error) => {
|
|
4937
|
-
var
|
|
4912
|
+
var _a3;
|
|
4938
4913
|
console.error(error);
|
|
4939
4914
|
if (error instanceof APIError) {
|
|
4940
|
-
(
|
|
4915
|
+
(_a3 = unsafeShowToast) == null ? void 0 : _a3({
|
|
4941
4916
|
title: "Could not create issue",
|
|
4942
4917
|
description: error.message,
|
|
4943
4918
|
accentColor: "red"
|
|
4944
4919
|
});
|
|
4945
4920
|
}
|
|
4946
|
-
this.dispatch(deleteIssue(
|
|
4921
|
+
this.dispatch(deleteIssue(offlineIssue.offline_id));
|
|
4947
4922
|
this.dispatch(addActiveProjectIssuesCount(-1));
|
|
4948
4923
|
throw error;
|
|
4949
4924
|
});
|
|
4950
|
-
return [
|
|
4925
|
+
return [offlineIssue, promise];
|
|
4951
4926
|
}
|
|
4952
|
-
update(
|
|
4927
|
+
update(payload) {
|
|
4928
|
+
var _a2;
|
|
4953
4929
|
const state = this.client.store.getState();
|
|
4954
|
-
const issueToBeUpdated = selectIssueById(
|
|
4930
|
+
const issueToBeUpdated = selectIssueById(payload.offline_id)(state);
|
|
4955
4931
|
if (!issueToBeUpdated) {
|
|
4956
4932
|
throw new Error(
|
|
4957
|
-
`Attempting to update an issue with offline_id ${
|
|
4933
|
+
`Attempting to update an issue with offline_id ${payload.offline_id} that doesn't exist in the store`
|
|
4958
4934
|
);
|
|
4959
4935
|
}
|
|
4960
|
-
const updatedIssue = { ...issueToBeUpdated, ...
|
|
4936
|
+
const updatedIssue = { ...issueToBeUpdated, ...payload };
|
|
4961
4937
|
this.dispatch(updateIssue(updatedIssue));
|
|
4962
4938
|
const changes = {};
|
|
4963
4939
|
for (const issueUpdateChange of [
|
|
@@ -4969,11 +4945,11 @@ class IssueService extends BaseApiService {
|
|
|
4969
4945
|
IssueUpdateChange.ASSIGNED_TO,
|
|
4970
4946
|
IssueUpdateChange.DUE_DATE
|
|
4971
4947
|
]) {
|
|
4972
|
-
if (issueUpdateChange in
|
|
4948
|
+
if (issueUpdateChange in payload && payload[issueUpdateChange] !== issueToBeUpdated[issueUpdateChange]) {
|
|
4973
4949
|
switch (issueUpdateChange) {
|
|
4974
4950
|
case "category": {
|
|
4975
4951
|
let categoryOrNull = null;
|
|
4976
|
-
const categoryIdOrNull =
|
|
4952
|
+
const categoryIdOrNull = payload[issueUpdateChange];
|
|
4977
4953
|
if (categoryIdOrNull) {
|
|
4978
4954
|
categoryOrNull = state.categoryReducer.instances[categoryIdOrNull] ?? null;
|
|
4979
4955
|
if (!categoryOrNull)
|
|
@@ -4990,7 +4966,7 @@ class IssueService extends BaseApiService {
|
|
|
4990
4966
|
}
|
|
4991
4967
|
case "assigned_to": {
|
|
4992
4968
|
let userOrNull = null;
|
|
4993
|
-
const userIdOrNull =
|
|
4969
|
+
const userIdOrNull = payload[issueUpdateChange];
|
|
4994
4970
|
if (userIdOrNull) {
|
|
4995
4971
|
userOrNull = state.userReducer.users[userIdOrNull] ?? null;
|
|
4996
4972
|
if (!userOrNull)
|
|
@@ -5005,24 +4981,24 @@ class IssueService extends BaseApiService {
|
|
|
5005
4981
|
break;
|
|
5006
4982
|
}
|
|
5007
4983
|
case "description":
|
|
5008
|
-
changes[issueUpdateChange] =
|
|
4984
|
+
changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
|
|
5009
4985
|
break;
|
|
5010
4986
|
case "title":
|
|
5011
|
-
changes[issueUpdateChange] =
|
|
4987
|
+
changes[issueUpdateChange] = payload[issueUpdateChange] ?? null;
|
|
5012
4988
|
break;
|
|
5013
4989
|
case "priority":
|
|
5014
|
-
changes[issueUpdateChange] =
|
|
4990
|
+
changes[issueUpdateChange] = payload[issueUpdateChange];
|
|
5015
4991
|
break;
|
|
5016
4992
|
case "status":
|
|
5017
|
-
changes[issueUpdateChange] =
|
|
4993
|
+
changes[issueUpdateChange] = payload[issueUpdateChange];
|
|
5018
4994
|
break;
|
|
5019
4995
|
case "due_date":
|
|
5020
|
-
changes[issueUpdateChange] =
|
|
4996
|
+
changes[issueUpdateChange] = payload[issueUpdateChange] ? payload[issueUpdateChange] : null;
|
|
5021
4997
|
}
|
|
5022
4998
|
}
|
|
5023
4999
|
}
|
|
5024
5000
|
const offlineIssueUpdate = offline({
|
|
5025
|
-
created_by: state.userReducer.currentUser.id,
|
|
5001
|
+
created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
|
|
5026
5002
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5027
5003
|
issue: issueToBeUpdated.offline_id,
|
|
5028
5004
|
changes
|
|
@@ -5031,10 +5007,10 @@ class IssueService extends BaseApiService {
|
|
|
5031
5007
|
const promise = this.enqueueRequest({
|
|
5032
5008
|
description: "Edit issue",
|
|
5033
5009
|
method: HttpMethod.PATCH,
|
|
5034
|
-
url: `/issues/${
|
|
5035
|
-
payload
|
|
5036
|
-
blockers: [
|
|
5037
|
-
blocks: [
|
|
5010
|
+
url: `/issues/${payload.offline_id}/`,
|
|
5011
|
+
payload,
|
|
5012
|
+
blockers: [payload.offline_id],
|
|
5013
|
+
blocks: [payload.offline_id]
|
|
5038
5014
|
});
|
|
5039
5015
|
promise.catch(() => {
|
|
5040
5016
|
this.dispatch(updateIssue(issueToBeUpdated));
|
|
@@ -5086,7 +5062,6 @@ class IssueService extends BaseApiService {
|
|
|
5086
5062
|
throw e;
|
|
5087
5063
|
}
|
|
5088
5064
|
}
|
|
5089
|
-
// Special functions
|
|
5090
5065
|
async refreshStore(projectId) {
|
|
5091
5066
|
const result = await this.enqueueRequest({
|
|
5092
5067
|
description: "Get issues",
|
|
@@ -5094,33 +5069,24 @@ class IssueService extends BaseApiService {
|
|
|
5094
5069
|
url: `/projects/${projectId}/issues/`,
|
|
5095
5070
|
blockers: [],
|
|
5096
5071
|
blocks: []
|
|
5097
|
-
}).then((result2) => {
|
|
5098
|
-
const filteredResult = result2.filter(onlyUniqueOfflineIds);
|
|
5099
|
-
if (result2.length !== filteredResult.length) {
|
|
5100
|
-
console.error(
|
|
5101
|
-
`Received duplicate issues from the API (new length ${filteredResult.length});
|
|
5102
|
-
filtered in browser.`
|
|
5103
|
-
);
|
|
5104
|
-
}
|
|
5105
|
-
return filteredResult;
|
|
5106
5072
|
});
|
|
5107
5073
|
this.dispatch(initializeIssues(result));
|
|
5108
5074
|
}
|
|
5109
5075
|
}
|
|
5110
5076
|
class IssueTypeService extends BaseApiService {
|
|
5111
|
-
add(payload
|
|
5077
|
+
add(payload) {
|
|
5078
|
+
var _a2;
|
|
5112
5079
|
const { store } = this.client;
|
|
5113
5080
|
const state = store.getState();
|
|
5114
5081
|
const offlineIssueType = offline({
|
|
5115
5082
|
...payload,
|
|
5116
5083
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5117
|
-
created_by: state.userReducer.currentUser.id
|
|
5118
|
-
organization: organizationId
|
|
5084
|
+
created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id
|
|
5119
5085
|
});
|
|
5120
5086
|
this.dispatch(addIssueType(offlineIssueType));
|
|
5121
5087
|
const promise = this.enqueueRequest({
|
|
5122
5088
|
method: HttpMethod.POST,
|
|
5123
|
-
url: `/organizations/${
|
|
5089
|
+
url: `/organizations/${payload.organization}/issue-types/`,
|
|
5124
5090
|
// Sending only whats needed here
|
|
5125
5091
|
payload: {
|
|
5126
5092
|
offline_id: offlineIssueType.offline_id,
|
|
@@ -5166,20 +5132,20 @@ class IssueTypeService extends BaseApiService {
|
|
|
5166
5132
|
});
|
|
5167
5133
|
return [offlineUpdatedIssueType, promise];
|
|
5168
5134
|
}
|
|
5169
|
-
delete(
|
|
5135
|
+
delete(id) {
|
|
5170
5136
|
const { store } = this.client;
|
|
5171
5137
|
const state = store.getState();
|
|
5172
|
-
const issueTypeToDelete = selectIssueTypeById(
|
|
5138
|
+
const issueTypeToDelete = selectIssueTypeById(id)(state);
|
|
5173
5139
|
if (!issueTypeToDelete) {
|
|
5174
|
-
throw new Error(`IssueType with offline_id ${
|
|
5140
|
+
throw new Error(`IssueType with offline_id ${id} does not exist in the store.`);
|
|
5175
5141
|
}
|
|
5176
|
-
const issuesOfIssueType = selectIssuesOfIssueType(
|
|
5177
|
-
this.dispatch(removeIssueType(
|
|
5142
|
+
const issuesOfIssueType = selectIssuesOfIssueType(id)(state);
|
|
5143
|
+
this.dispatch(removeIssueType(id));
|
|
5178
5144
|
this.dispatch(deleteIssues(issuesOfIssueType.map((issue) => issue.offline_id)));
|
|
5179
5145
|
const promise = this.enqueueRequest({
|
|
5180
5146
|
method: HttpMethod.DELETE,
|
|
5181
|
-
url: `/issues/types/${
|
|
5182
|
-
blockers: [
|
|
5147
|
+
url: `/issues/types/${id}/`,
|
|
5148
|
+
blockers: [id],
|
|
5183
5149
|
blocks: []
|
|
5184
5150
|
});
|
|
5185
5151
|
promise.catch(() => {
|
|
@@ -5237,17 +5203,6 @@ class ProjectAccessService extends BaseApiService {
|
|
|
5237
5203
|
}
|
|
5238
5204
|
}
|
|
5239
5205
|
class ProjectFileService extends BaseApiService {
|
|
5240
|
-
async refreshStore(projectId) {
|
|
5241
|
-
const result = await this.enqueueRequest({
|
|
5242
|
-
description: "Get project files",
|
|
5243
|
-
method: HttpMethod.GET,
|
|
5244
|
-
url: `/projects/${projectId}/files/`,
|
|
5245
|
-
blockers: [],
|
|
5246
|
-
blocks: []
|
|
5247
|
-
});
|
|
5248
|
-
this.dispatch(addOrReplaceProjectFiles([]));
|
|
5249
|
-
this.dispatch(addOrReplaceProjectFiles(result));
|
|
5250
|
-
}
|
|
5251
5206
|
async saveExisting(file) {
|
|
5252
5207
|
if (!file.offline_id) {
|
|
5253
5208
|
throw new Error(
|
|
@@ -5335,6 +5290,17 @@ class ProjectFileService extends BaseApiService {
|
|
|
5335
5290
|
blocks: []
|
|
5336
5291
|
});
|
|
5337
5292
|
}
|
|
5293
|
+
async refreshStore(projectId) {
|
|
5294
|
+
const result = await this.enqueueRequest({
|
|
5295
|
+
description: "Get project files",
|
|
5296
|
+
method: HttpMethod.GET,
|
|
5297
|
+
url: `/projects/${projectId}/files/`,
|
|
5298
|
+
blockers: [],
|
|
5299
|
+
blocks: []
|
|
5300
|
+
});
|
|
5301
|
+
this.dispatch(addOrReplaceProjectFiles([]));
|
|
5302
|
+
this.dispatch(addOrReplaceProjectFiles(result));
|
|
5303
|
+
}
|
|
5338
5304
|
}
|
|
5339
5305
|
class ProjectAttachmentService extends BaseAttachmentService {
|
|
5340
5306
|
constructor() {
|
|
@@ -5520,8 +5486,9 @@ const separateImageFromFields = async (fields) => {
|
|
|
5520
5486
|
};
|
|
5521
5487
|
class FormService extends BaseUploadService {
|
|
5522
5488
|
async bulkAddRevisionAttachments(revisionId, files) {
|
|
5489
|
+
var _a2;
|
|
5523
5490
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5524
|
-
const createdBy = this.client.store.getState().userReducer.currentUser.id;
|
|
5491
|
+
const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
5525
5492
|
const filePayloads = {};
|
|
5526
5493
|
const offlineFormRevisionAttachments = [];
|
|
5527
5494
|
const attachmentPayloads = [];
|
|
@@ -5623,10 +5590,11 @@ class FormService extends BaseUploadService {
|
|
|
5623
5590
|
return [form, offlineFormRevision, offlineFormRevisionAttachments, formPromise, attachmentsPromise];
|
|
5624
5591
|
}
|
|
5625
5592
|
addForOrganization(organizationId, initialRevision) {
|
|
5593
|
+
var _a2;
|
|
5626
5594
|
const state = this.client.store.getState();
|
|
5627
5595
|
const offlineForm = offline({
|
|
5628
5596
|
favorite: false,
|
|
5629
|
-
created_by: state.userReducer.currentUser.id,
|
|
5597
|
+
created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
|
|
5630
5598
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5631
5599
|
organization: organizationId
|
|
5632
5600
|
});
|
|
@@ -5638,45 +5606,49 @@ class FormService extends BaseUploadService {
|
|
|
5638
5606
|
);
|
|
5639
5607
|
}
|
|
5640
5608
|
addForProject(projectId, initialRevision) {
|
|
5609
|
+
var _a2;
|
|
5641
5610
|
const state = this.client.store.getState();
|
|
5642
5611
|
const offlineForm = offline({
|
|
5643
5612
|
favorite: false,
|
|
5644
|
-
created_by: state.userReducer.currentUser.id,
|
|
5613
|
+
created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
|
|
5645
5614
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5646
5615
|
project: projectId
|
|
5647
5616
|
});
|
|
5648
5617
|
return this.add(projectId.toString(), offlineForm, initialRevision, `/projects/${projectId}/create-form/`);
|
|
5649
5618
|
}
|
|
5650
5619
|
addForIssueType(issueTypeId, initialRevision) {
|
|
5620
|
+
var _a2;
|
|
5651
5621
|
const state = this.client.store.getState();
|
|
5652
5622
|
const offlineForm = offline({
|
|
5653
5623
|
favorite: false,
|
|
5654
|
-
created_by: state.userReducer.currentUser.id,
|
|
5624
|
+
created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
|
|
5655
5625
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5656
5626
|
issue_type: issueTypeId
|
|
5657
5627
|
});
|
|
5658
5628
|
return this.add(issueTypeId, offlineForm, initialRevision, `/issues/types/${issueTypeId}/create-form/`);
|
|
5659
5629
|
}
|
|
5660
5630
|
addForAssetType(assetTypeId, initialRevision) {
|
|
5631
|
+
var _a2;
|
|
5661
5632
|
const state = this.client.store.getState();
|
|
5662
5633
|
const offlineForm = offline({
|
|
5663
5634
|
favorite: false,
|
|
5664
|
-
created_by: state.userReducer.currentUser.id,
|
|
5635
|
+
created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
|
|
5665
5636
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5666
5637
|
asset_type: assetTypeId
|
|
5667
5638
|
});
|
|
5668
5639
|
return this.add(assetTypeId, offlineForm, initialRevision, `/assets/types/${assetTypeId}/create-form/`);
|
|
5669
5640
|
}
|
|
5670
5641
|
async createRevision(formId, revision) {
|
|
5642
|
+
var _a2;
|
|
5671
5643
|
const offlineRevision = offline(revision);
|
|
5672
5644
|
const { store } = this.client;
|
|
5673
5645
|
const state = store.getState();
|
|
5674
|
-
const
|
|
5646
|
+
const createdBy = (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
5675
5647
|
const { fields, images } = await separateImageFromFields(offlineRevision.fields);
|
|
5676
5648
|
const fullRevision = {
|
|
5677
5649
|
...offlineRevision,
|
|
5678
5650
|
fields,
|
|
5679
|
-
created_by:
|
|
5651
|
+
created_by: createdBy,
|
|
5680
5652
|
revision: "Pending",
|
|
5681
5653
|
form: formId,
|
|
5682
5654
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -5825,8 +5797,9 @@ const separateFilesFromValues = (values) => {
|
|
|
5825
5797
|
};
|
|
5826
5798
|
class FormSubmissionService extends BaseUploadService {
|
|
5827
5799
|
async bulkAddSubmissionAttachments(submissionId, files) {
|
|
5800
|
+
var _a2;
|
|
5828
5801
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5829
|
-
const createdBy = this.client.store.getState().userReducer.currentUser.id;
|
|
5802
|
+
const createdBy = (_a2 = this.client.store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
5830
5803
|
const filePayloads = {};
|
|
5831
5804
|
const offlineFormSubmissionAttachments = [];
|
|
5832
5805
|
const attachmentPayloads = [];
|
|
@@ -5908,13 +5881,14 @@ class FormSubmissionService extends BaseUploadService {
|
|
|
5908
5881
|
}
|
|
5909
5882
|
// Outer promise is for hashing and caching files for submission attachments
|
|
5910
5883
|
async add(payload) {
|
|
5884
|
+
var _a2;
|
|
5911
5885
|
const { store } = this.client;
|
|
5912
5886
|
const state = store.getState();
|
|
5913
5887
|
const { values, files } = separateFilesFromValues(payload.values);
|
|
5914
5888
|
const offlineSubmission = offline({
|
|
5915
5889
|
...payload,
|
|
5916
5890
|
values,
|
|
5917
|
-
created_by: state.userReducer.currentUser.id,
|
|
5891
|
+
created_by: (_a2 = state.userReducer.currentUser) == null ? void 0 : _a2.id,
|
|
5918
5892
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
5919
5893
|
});
|
|
5920
5894
|
const promise = this.enqueueRequest({
|
|
@@ -6170,8 +6144,9 @@ class FormSubmissionService extends BaseUploadService {
|
|
|
6170
6144
|
}
|
|
6171
6145
|
class WorkspaceService extends BaseApiService {
|
|
6172
6146
|
add(payload) {
|
|
6147
|
+
var _a2;
|
|
6173
6148
|
const { store } = this.client;
|
|
6174
|
-
const createdBy = store.getState().userReducer.currentUser.id;
|
|
6149
|
+
const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
6175
6150
|
const offlineWorkspace = offline({
|
|
6176
6151
|
...payload,
|
|
6177
6152
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -6193,8 +6168,14 @@ class WorkspaceService extends BaseApiService {
|
|
|
6193
6168
|
});
|
|
6194
6169
|
return [offlineWorkspace, promise];
|
|
6195
6170
|
}
|
|
6196
|
-
update(
|
|
6197
|
-
this.
|
|
6171
|
+
update(payload) {
|
|
6172
|
+
const { store } = this.client;
|
|
6173
|
+
const workspace = selectWorkspaceById(payload.offline_id)(store.getState());
|
|
6174
|
+
if (!workspace) {
|
|
6175
|
+
throw new Error(`Expected an existing workspace with offline_id ${payload.offline_id}`);
|
|
6176
|
+
}
|
|
6177
|
+
const updatedWorkspace = { ...workspace, ...payload };
|
|
6178
|
+
this.dispatch(updateWorkspace(updatedWorkspace));
|
|
6198
6179
|
const promise = this.enqueueRequest({
|
|
6199
6180
|
description: "Update Workspace",
|
|
6200
6181
|
method: HttpMethod.PATCH,
|
|
@@ -6203,10 +6184,17 @@ class WorkspaceService extends BaseApiService {
|
|
|
6203
6184
|
blockers: [workspace.offline_id],
|
|
6204
6185
|
blocks: [workspace.offline_id]
|
|
6205
6186
|
});
|
|
6187
|
+
promise.then((result) => {
|
|
6188
|
+
this.dispatch(updateWorkspace(result));
|
|
6189
|
+
}).catch(() => {
|
|
6190
|
+
this.dispatch(updateWorkspace(workspace));
|
|
6191
|
+
});
|
|
6206
6192
|
return [workspace, promise];
|
|
6207
6193
|
}
|
|
6208
6194
|
delete(workspaceId) {
|
|
6209
6195
|
const { store } = this.client;
|
|
6196
|
+
const originalWorkspace = selectWorkspaceById(workspaceId)(store.getState());
|
|
6197
|
+
this.dispatch(deleteWorkspace(workspaceId));
|
|
6210
6198
|
const promise = this.enqueueRequest({
|
|
6211
6199
|
description: "Delete Workspace",
|
|
6212
6200
|
method: HttpMethod.DELETE,
|
|
@@ -6214,8 +6202,6 @@ class WorkspaceService extends BaseApiService {
|
|
|
6214
6202
|
blockers: [workspaceId],
|
|
6215
6203
|
blocks: []
|
|
6216
6204
|
});
|
|
6217
|
-
const originalWorkspace = store.getState().workspaceReducer.instances[workspaceId];
|
|
6218
|
-
this.dispatch(deleteWorkspace(workspaceId));
|
|
6219
6205
|
void promise.then(() => {
|
|
6220
6206
|
}).catch((reason) => {
|
|
6221
6207
|
if (originalWorkspace) {
|
|
@@ -6717,12 +6703,13 @@ class LicenseService extends BaseApiService {
|
|
|
6717
6703
|
}
|
|
6718
6704
|
class DocumentService extends BaseApiService {
|
|
6719
6705
|
add(payload) {
|
|
6706
|
+
var _a2;
|
|
6720
6707
|
const { store } = this.client;
|
|
6721
|
-
const
|
|
6708
|
+
const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
6722
6709
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
6723
6710
|
const offlineDocument = offline({
|
|
6724
6711
|
...payload,
|
|
6725
|
-
created_by:
|
|
6712
|
+
created_by: createdBy,
|
|
6726
6713
|
submitted_at: submittedAt
|
|
6727
6714
|
});
|
|
6728
6715
|
this.dispatch(addDocuments([offlineDocument]));
|
|
@@ -6751,7 +6738,11 @@ class DocumentService extends BaseApiService {
|
|
|
6751
6738
|
`attempting to update a document with offline_id ${document2.offline_id} that does not exist in store.documents`
|
|
6752
6739
|
);
|
|
6753
6740
|
}
|
|
6754
|
-
|
|
6741
|
+
const updatedDocument = {
|
|
6742
|
+
...documentToBeUpdated,
|
|
6743
|
+
...document2
|
|
6744
|
+
};
|
|
6745
|
+
this.dispatch(updateDocuments([updatedDocument]));
|
|
6755
6746
|
const promise = this.enqueueRequest({
|
|
6756
6747
|
description: "Update Document",
|
|
6757
6748
|
method: HttpMethod.PATCH,
|
|
@@ -6763,8 +6754,7 @@ class DocumentService extends BaseApiService {
|
|
|
6763
6754
|
promise.catch(() => {
|
|
6764
6755
|
updateDocuments([documentToBeUpdated]);
|
|
6765
6756
|
});
|
|
6766
|
-
|
|
6767
|
-
return [fullDocument, promise];
|
|
6757
|
+
return [updatedDocument, promise];
|
|
6768
6758
|
}
|
|
6769
6759
|
move(documentId, targetDocumentId, position) {
|
|
6770
6760
|
const { store } = this.client;
|
|
@@ -6811,22 +6801,22 @@ class DocumentService extends BaseApiService {
|
|
|
6811
6801
|
});
|
|
6812
6802
|
return promise;
|
|
6813
6803
|
}
|
|
6814
|
-
delete(
|
|
6804
|
+
delete(id) {
|
|
6815
6805
|
const { store } = this.client;
|
|
6816
6806
|
const documentsMapping = selectDocumentsMapping(store.getState());
|
|
6817
|
-
const documentToBeDeleted =
|
|
6807
|
+
const documentToBeDeleted = selectDocumentById(id)(store.getState());
|
|
6818
6808
|
if (!documentToBeDeleted) {
|
|
6819
6809
|
throw new Error(
|
|
6820
|
-
`attempting to delete a document with offline_id ${
|
|
6810
|
+
`attempting to delete a document with offline_id ${id} that does not exist in store.documents`
|
|
6821
6811
|
);
|
|
6822
6812
|
}
|
|
6823
6813
|
const parentDocument = documentToBeDeleted.parent_document ? documentsMapping[documentToBeDeleted.parent_document] : void 0;
|
|
6824
|
-
this.dispatch(removeDocuments([
|
|
6814
|
+
this.dispatch(removeDocuments([id]));
|
|
6825
6815
|
const promise = this.enqueueRequest({
|
|
6826
6816
|
description: "Delete Document",
|
|
6827
6817
|
method: HttpMethod.DELETE,
|
|
6828
|
-
url: `/documents/${
|
|
6829
|
-
blockers: [
|
|
6818
|
+
url: `/documents/${id}/`,
|
|
6819
|
+
blockers: [id],
|
|
6830
6820
|
blocks: []
|
|
6831
6821
|
});
|
|
6832
6822
|
promise.then((documentsToUpdate) => {
|
|
@@ -6884,8 +6874,9 @@ class DocumentAttachmentService extends BaseAttachmentService {
|
|
|
6884
6874
|
}
|
|
6885
6875
|
// NOTE: overriding the method from BaseAttachmentService since document attachments get vectorized
|
|
6886
6876
|
async attachFilesToDocument(files, documentId) {
|
|
6877
|
+
var _a2;
|
|
6887
6878
|
const { store } = this.client;
|
|
6888
|
-
const
|
|
6879
|
+
const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
6889
6880
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
6890
6881
|
const offlineAttachments = [];
|
|
6891
6882
|
const attachmentPayloads = [];
|
|
@@ -6907,7 +6898,7 @@ class DocumentAttachmentService extends BaseAttachmentService {
|
|
|
6907
6898
|
file,
|
|
6908
6899
|
sha1,
|
|
6909
6900
|
submittedAt,
|
|
6910
|
-
createdBy
|
|
6901
|
+
createdBy,
|
|
6911
6902
|
description: "",
|
|
6912
6903
|
modelId: documentId
|
|
6913
6904
|
});
|
|
@@ -7070,10 +7061,9 @@ class AgentService extends BaseApiService {
|
|
|
7070
7061
|
}
|
|
7071
7062
|
}
|
|
7072
7063
|
class TeamService extends BaseApiService {
|
|
7073
|
-
add(
|
|
7064
|
+
add(payload) {
|
|
7074
7065
|
const offlineTeam = offline({
|
|
7075
|
-
...
|
|
7076
|
-
organization: organizationId,
|
|
7066
|
+
...payload,
|
|
7077
7067
|
submitted_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
7078
7068
|
// TODO: uncomment once supported
|
|
7079
7069
|
// created_by: state.userReducer.currentUser.id,
|
|
@@ -7082,7 +7072,7 @@ class TeamService extends BaseApiService {
|
|
|
7082
7072
|
const promise = this.enqueueRequest({
|
|
7083
7073
|
description: "Create team",
|
|
7084
7074
|
method: HttpMethod.POST,
|
|
7085
|
-
url: `/organizations/${
|
|
7075
|
+
url: `/organizations/${payload.organization}/teams/`,
|
|
7086
7076
|
payload: offlineTeam,
|
|
7087
7077
|
// No blocks since users and organizations are not offline
|
|
7088
7078
|
blockers: [],
|
|
@@ -7095,25 +7085,24 @@ class TeamService extends BaseApiService {
|
|
|
7095
7085
|
});
|
|
7096
7086
|
return [offlineTeam, promise];
|
|
7097
7087
|
}
|
|
7098
|
-
|
|
7099
|
-
update(team) {
|
|
7088
|
+
update(payload) {
|
|
7100
7089
|
const { store } = this.client;
|
|
7101
|
-
const teamToBeUpdated = selectTeamById(
|
|
7090
|
+
const teamToBeUpdated = selectTeamById(payload.offline_id)(store.getState());
|
|
7102
7091
|
if (!teamToBeUpdated) {
|
|
7103
|
-
throw new Error(`Expected team with offline_id ${
|
|
7092
|
+
throw new Error(`Expected team with offline_id ${payload.offline_id} to exist`);
|
|
7104
7093
|
}
|
|
7105
7094
|
const offlineUpdatedTeam = {
|
|
7106
7095
|
...teamToBeUpdated,
|
|
7107
|
-
...
|
|
7096
|
+
...payload
|
|
7108
7097
|
};
|
|
7109
7098
|
this.dispatch(updateTeam(offlineUpdatedTeam));
|
|
7110
7099
|
const promise = this.enqueueRequest({
|
|
7111
7100
|
description: "Update team",
|
|
7112
7101
|
method: HttpMethod.PATCH,
|
|
7113
|
-
url: `/organizations/teams/${
|
|
7102
|
+
url: `/organizations/teams/${payload.offline_id}/`,
|
|
7114
7103
|
payload: offlineUpdatedTeam,
|
|
7115
|
-
blockers: [
|
|
7116
|
-
blocks: [
|
|
7104
|
+
blockers: [payload.offline_id],
|
|
7105
|
+
blocks: [payload.offline_id]
|
|
7117
7106
|
});
|
|
7118
7107
|
promise.then((updatedTeam) => {
|
|
7119
7108
|
this.dispatch(setTeam(updatedTeam));
|
|
@@ -7225,10 +7214,11 @@ class UserService extends BaseApiService {
|
|
|
7225
7214
|
}
|
|
7226
7215
|
class GeoImageService extends BaseUploadService {
|
|
7227
7216
|
async add(payload) {
|
|
7217
|
+
var _a2;
|
|
7228
7218
|
const { store } = this.client;
|
|
7229
7219
|
const { file, ...payloadWithoutFile } = payload;
|
|
7230
7220
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7231
|
-
const
|
|
7221
|
+
const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
7232
7222
|
const projectId = payloadWithoutFile.project;
|
|
7233
7223
|
const sha1 = await hashFile(file);
|
|
7234
7224
|
const filePayload = {
|
|
@@ -7243,9 +7233,9 @@ class GeoImageService extends BaseUploadService {
|
|
|
7243
7233
|
file_sha1: sha1,
|
|
7244
7234
|
file: URL.createObjectURL(file),
|
|
7245
7235
|
submitted_at: submittedAt,
|
|
7246
|
-
created_by:
|
|
7236
|
+
created_by: createdBy
|
|
7247
7237
|
});
|
|
7248
|
-
|
|
7238
|
+
this.dispatch(addGeoImage(offlineMapImage));
|
|
7249
7239
|
const promise = this.enqueueRequest({
|
|
7250
7240
|
description: "Add geo image",
|
|
7251
7241
|
method: HttpMethod.POST,
|
|
@@ -7269,16 +7259,17 @@ class GeoImageService extends BaseUploadService {
|
|
|
7269
7259
|
});
|
|
7270
7260
|
promise.then((result) => {
|
|
7271
7261
|
this.processPresignedUrls(result.presigned_urls);
|
|
7272
|
-
|
|
7262
|
+
this.dispatch(setGeoImage(result.geo_image));
|
|
7273
7263
|
}).catch(() => {
|
|
7274
|
-
|
|
7264
|
+
this.dispatch(deleteGeoImage(offlineMapImage.offline_id));
|
|
7275
7265
|
});
|
|
7276
7266
|
return [offlineMapImage, promise.then((result) => result.geo_image)];
|
|
7277
7267
|
}
|
|
7278
7268
|
async bulkAdd(payloads, projectId) {
|
|
7269
|
+
var _a2;
|
|
7279
7270
|
const { store } = this.client;
|
|
7280
7271
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7281
|
-
const
|
|
7272
|
+
const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
7282
7273
|
const offlineGeoImages = [];
|
|
7283
7274
|
const offlineIds = [];
|
|
7284
7275
|
const geoImagePayloads = [];
|
|
@@ -7301,7 +7292,7 @@ class GeoImageService extends BaseUploadService {
|
|
|
7301
7292
|
file_sha1: sha1,
|
|
7302
7293
|
file: URL.createObjectURL(file),
|
|
7303
7294
|
submitted_at: submittedAt,
|
|
7304
|
-
created_by:
|
|
7295
|
+
created_by: createdBy,
|
|
7305
7296
|
project: projectId
|
|
7306
7297
|
});
|
|
7307
7298
|
offlineGeoImages.push(offlineMapImage);
|
|
@@ -7318,7 +7309,7 @@ class GeoImageService extends BaseUploadService {
|
|
|
7318
7309
|
original_date: offlineMapImage.original_date
|
|
7319
7310
|
});
|
|
7320
7311
|
}
|
|
7321
|
-
|
|
7312
|
+
this.dispatch(addGeoImages(offlineGeoImages));
|
|
7322
7313
|
const promise = this.enqueueRequest({
|
|
7323
7314
|
description: "Bulk add geo images",
|
|
7324
7315
|
method: HttpMethod.POST,
|
|
@@ -7334,9 +7325,9 @@ class GeoImageService extends BaseUploadService {
|
|
|
7334
7325
|
});
|
|
7335
7326
|
promise.then((result) => {
|
|
7336
7327
|
this.processPresignedUrls(result.presigned_urls);
|
|
7337
|
-
|
|
7328
|
+
this.dispatch(setGeoImages(result.geo_images));
|
|
7338
7329
|
}).catch(() => {
|
|
7339
|
-
|
|
7330
|
+
this.dispatch(deleteGeoImages(offlineIds));
|
|
7340
7331
|
});
|
|
7341
7332
|
return [offlineGeoImages, promise.then((result) => result.geo_images)];
|
|
7342
7333
|
}
|
|
@@ -7348,7 +7339,7 @@ class GeoImageService extends BaseUploadService {
|
|
|
7348
7339
|
throw new Error(`Map image with offline_id ${payload.offline_id} does not exist in the store`);
|
|
7349
7340
|
}
|
|
7350
7341
|
const updatedGeoImage = { ...geoImageToUpdate, ...payload };
|
|
7351
|
-
|
|
7342
|
+
this.dispatch(updateGeoImage(updatedGeoImage));
|
|
7352
7343
|
const promise = this.enqueueRequest({
|
|
7353
7344
|
description: "Update geo image",
|
|
7354
7345
|
method: HttpMethod.PATCH,
|
|
@@ -7358,9 +7349,9 @@ class GeoImageService extends BaseUploadService {
|
|
|
7358
7349
|
blockers: [payload.offline_id]
|
|
7359
7350
|
});
|
|
7360
7351
|
promise.then((result) => {
|
|
7361
|
-
|
|
7352
|
+
this.dispatch(setGeoImage(result));
|
|
7362
7353
|
}).catch(() => {
|
|
7363
|
-
|
|
7354
|
+
this.dispatch(setGeoImage(geoImageToUpdate));
|
|
7364
7355
|
});
|
|
7365
7356
|
return [updatedGeoImage, promise];
|
|
7366
7357
|
}
|
|
@@ -7371,7 +7362,7 @@ class GeoImageService extends BaseUploadService {
|
|
|
7371
7362
|
if (!geoImageToDelete) {
|
|
7372
7363
|
throw new Error(`Map image with offline_id ${geoImageId} does not exist in the store`);
|
|
7373
7364
|
}
|
|
7374
|
-
|
|
7365
|
+
this.dispatch(deleteGeoImage(geoImageId));
|
|
7375
7366
|
const promise = this.enqueueRequest({
|
|
7376
7367
|
description: "Delete geo image",
|
|
7377
7368
|
method: HttpMethod.DELETE,
|
|
@@ -7380,12 +7371,11 @@ class GeoImageService extends BaseUploadService {
|
|
|
7380
7371
|
blockers: [geoImageId]
|
|
7381
7372
|
});
|
|
7382
7373
|
promise.catch(() => {
|
|
7383
|
-
|
|
7374
|
+
this.dispatch(setGeoImage(geoImageToDelete));
|
|
7384
7375
|
});
|
|
7385
7376
|
return promise;
|
|
7386
7377
|
}
|
|
7387
7378
|
async refreshStore(projectId) {
|
|
7388
|
-
const { store } = this.client;
|
|
7389
7379
|
const result = await this.enqueueRequest({
|
|
7390
7380
|
description: "Get geo images",
|
|
7391
7381
|
method: HttpMethod.GET,
|
|
@@ -7393,14 +7383,15 @@ class GeoImageService extends BaseUploadService {
|
|
|
7393
7383
|
blocks: [projectId.toString()],
|
|
7394
7384
|
blockers: []
|
|
7395
7385
|
});
|
|
7396
|
-
|
|
7386
|
+
this.dispatch(initializeGeoImages(result));
|
|
7397
7387
|
}
|
|
7398
7388
|
}
|
|
7399
7389
|
class IssueAssociationService extends BaseUploadService {
|
|
7400
7390
|
add(payload) {
|
|
7391
|
+
var _a2;
|
|
7401
7392
|
const { store } = this.client;
|
|
7402
7393
|
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
7403
|
-
const createdBy = store.getState().userReducer.currentUser.id;
|
|
7394
|
+
const createdBy = (_a2 = store.getState().userReducer.currentUser) == null ? void 0 : _a2.id;
|
|
7404
7395
|
const offlineIssueAssociation = offline({
|
|
7405
7396
|
...payload,
|
|
7406
7397
|
submitted_at: submittedAt,
|
|
@@ -7414,7 +7405,6 @@ class IssueAssociationService extends BaseUploadService {
|
|
|
7414
7405
|
payload: {
|
|
7415
7406
|
offline_id: offlineIssueAssociation.offline_id,
|
|
7416
7407
|
submitted_at: submittedAt,
|
|
7417
|
-
created_by: createdBy,
|
|
7418
7408
|
...payload
|
|
7419
7409
|
},
|
|
7420
7410
|
blockers: [
|
|
@@ -7539,7 +7529,6 @@ export {
|
|
|
7539
7529
|
addDocumentAttachments,
|
|
7540
7530
|
addDocuments,
|
|
7541
7531
|
addEmailDomain,
|
|
7542
|
-
addFavouriteProjectId,
|
|
7543
7532
|
addForm,
|
|
7544
7533
|
addFormRevision,
|
|
7545
7534
|
addFormRevisionAttachment,
|
|
@@ -7769,7 +7758,6 @@ export {
|
|
|
7769
7758
|
rehydratedReducer,
|
|
7770
7759
|
rehydratedSlice,
|
|
7771
7760
|
removeDocuments,
|
|
7772
|
-
removeFavouriteProjectId,
|
|
7773
7761
|
removeIssueType,
|
|
7774
7762
|
removeProjectFile,
|
|
7775
7763
|
removeProjectFilesOfProject,
|
|
@@ -7848,7 +7836,6 @@ export {
|
|
|
7848
7836
|
selectEmailDomains,
|
|
7849
7837
|
selectEmailDomainsAsMapping,
|
|
7850
7838
|
selectEmailDomainsOfOrganization,
|
|
7851
|
-
selectFavouriteProjects,
|
|
7852
7839
|
selectFilteredForms,
|
|
7853
7840
|
selectFormById,
|
|
7854
7841
|
selectFormMapping,
|
|
@@ -7889,6 +7876,7 @@ export {
|
|
|
7889
7876
|
selectIssueAttachmentMapping,
|
|
7890
7877
|
selectIssueAttachments,
|
|
7891
7878
|
selectIssueById,
|
|
7879
|
+
selectIssueCommentById,
|
|
7892
7880
|
selectIssueCommentMapping,
|
|
7893
7881
|
selectIssueCountOfCategory,
|
|
7894
7882
|
selectIssueMapping,
|
|
@@ -8005,7 +7993,6 @@ export {
|
|
|
8005
7993
|
setStageCompletions,
|
|
8006
7994
|
setTeam,
|
|
8007
7995
|
setTokens,
|
|
8008
|
-
setTourStep,
|
|
8009
7996
|
setUploadUrl,
|
|
8010
7997
|
setUsers,
|
|
8011
7998
|
setWorkspaces,
|