@overmap-ai/core 1.0.58-export-overmap-reducer.8 → 1.0.58-export-overmap-reducer.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/forms/provider.d.ts +5 -5
- package/dist/overmap-core.js +146 -113
- package/dist/overmap-core.js.map +1 -1
- package/dist/overmap-core.umd.cjs +146 -113
- package/dist/overmap-core.umd.cjs.map +1 -1
- package/dist/sdk/services/UserFormService.d.ts +7 -11
- package/dist/store/slices/formSlice.d.ts +2 -76
- package/dist/typings/models/forms.d.ts +6 -10
- package/package.json +1 -1
|
@@ -3567,17 +3567,15 @@ var __publicField = (obj, key, value) => {
|
|
|
3567
3567
|
(_state, search) => search
|
|
3568
3568
|
],
|
|
3569
3569
|
(userForms, revisions, search) => {
|
|
3570
|
-
const { searchTerm, maxResults, favorites,
|
|
3570
|
+
const { searchTerm, maxResults, favorites, organization } = search;
|
|
3571
3571
|
const favoriteMatches = [];
|
|
3572
3572
|
const regularMatches = [];
|
|
3573
3573
|
for (const [userFormId, userForm] of Object.entries(userForms)) {
|
|
3574
3574
|
if (favorites !== void 0 && userForm.favorite != favorites)
|
|
3575
3575
|
continue;
|
|
3576
|
-
if (Number.isInteger(
|
|
3576
|
+
if (Number.isInteger(organization) && organization !== userForm.organization) {
|
|
3577
3577
|
continue;
|
|
3578
3578
|
}
|
|
3579
|
-
if (Number.isInteger(owner_user) && owner_user !== userForm.owner_user)
|
|
3580
|
-
continue;
|
|
3581
3579
|
const latestRevision = _selectLatestFormRevision(revisions, userFormId);
|
|
3582
3580
|
if (latestRevision.title.toLowerCase().includes(searchTerm.toLowerCase())) {
|
|
3583
3581
|
if (userForm.favorite) {
|
|
@@ -4362,10 +4360,6 @@ var __publicField = (obj, key, value) => {
|
|
|
4362
4360
|
throw new Error(`Failed to update index_workspace of issue ${issue.offline_id} to main workspace`);
|
|
4363
4361
|
}
|
|
4364
4362
|
}
|
|
4365
|
-
const indexedForms = Object.values(draft.formReducer.forms).filter((form) => form.index_workspace === workspaceId);
|
|
4366
|
-
for (const form of indexedForms) {
|
|
4367
|
-
form.index_workspace = mainWorkspace.offline_id;
|
|
4368
|
-
}
|
|
4369
4363
|
}
|
|
4370
4364
|
const overmapRootReducer = (state, action) => {
|
|
4371
4365
|
if (action.type === "auth/setLoggedIn" && !action.payload) {
|
|
@@ -6747,8 +6741,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6747
6741
|
});
|
|
6748
6742
|
}
|
|
6749
6743
|
}
|
|
6750
|
-
const separateImageFromFields = async (
|
|
6751
|
-
const { fields } = payload;
|
|
6744
|
+
const separateImageFromFields = async (fields) => {
|
|
6752
6745
|
const images = {};
|
|
6753
6746
|
const newFields = [];
|
|
6754
6747
|
for (const section of fields) {
|
|
@@ -6774,11 +6767,7 @@ var __publicField = (obj, key, value) => {
|
|
|
6774
6767
|
}
|
|
6775
6768
|
newFields.push({ ...section, fields: newSectionFields });
|
|
6776
6769
|
}
|
|
6777
|
-
|
|
6778
|
-
...payload,
|
|
6779
|
-
fields: newFields
|
|
6780
|
-
};
|
|
6781
|
-
return { payloadWithoutImage, images };
|
|
6770
|
+
return { fields: newFields, images };
|
|
6782
6771
|
};
|
|
6783
6772
|
class UserFormService extends BaseApiService {
|
|
6784
6773
|
constructor() {
|
|
@@ -6812,93 +6801,90 @@ var __publicField = (obj, key, value) => {
|
|
|
6812
6801
|
});
|
|
6813
6802
|
});
|
|
6814
6803
|
}
|
|
6815
|
-
async add(
|
|
6816
|
-
if (!!ownerUser === !!ownerOrganization) {
|
|
6817
|
-
throw new Error("Exactly one of ownerUser and ownerOrganization must be defined.");
|
|
6818
|
-
}
|
|
6819
|
-
const ownerAttrs = {
|
|
6820
|
-
owner_user: ownerUser,
|
|
6821
|
-
owner_organization: ownerOrganization
|
|
6822
|
-
};
|
|
6823
|
-
const currentUser = state.userReducer.currentUser;
|
|
6824
|
-
const activeWorkspaceId = state.workspaceReducer.activeWorkspaceId;
|
|
6825
|
-
const submittedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
6826
|
-
const offlineFormPayload = offline({ ...ownerAttrs });
|
|
6827
|
-
const offlineRevisionPayload = offline({ ...initialRevision, submitted_at: submittedAt });
|
|
6828
|
-
const retForm = {
|
|
6829
|
-
...offlineFormPayload,
|
|
6830
|
-
index_workspace: activeWorkspaceId,
|
|
6831
|
-
favorite: true,
|
|
6832
|
-
submitted_at: submittedAt,
|
|
6833
|
-
created_by: currentUser.id,
|
|
6834
|
-
...assetTypeId && { asset_type: assetTypeId },
|
|
6835
|
-
...issueTypeId && { issue_type: issueTypeId },
|
|
6836
|
-
...ownerAttrs
|
|
6837
|
-
};
|
|
6838
|
-
const { payloadWithoutImage, images } = await separateImageFromFields(offlineRevisionPayload);
|
|
6839
|
-
const retRevision = {
|
|
6840
|
-
...payloadWithoutImage,
|
|
6841
|
-
created_by: currentUser.id,
|
|
6842
|
-
form: retForm.offline_id,
|
|
6843
|
-
revision: 0,
|
|
6844
|
-
submitted_at: submittedAt
|
|
6845
|
-
};
|
|
6804
|
+
async add(ownerId, form, initialRevision, urlPrefix) {
|
|
6846
6805
|
const { store } = this.client;
|
|
6847
|
-
|
|
6848
|
-
|
|
6806
|
+
const { fields, images } = await separateImageFromFields(initialRevision.fields);
|
|
6807
|
+
const offlineFormRevision = offline({
|
|
6808
|
+
...initialRevision,
|
|
6809
|
+
fields,
|
|
6810
|
+
created_by: form.created_by,
|
|
6811
|
+
form: form.offline_id,
|
|
6812
|
+
submitted_at: form.submitted_at,
|
|
6813
|
+
revision: "Pending"
|
|
6814
|
+
});
|
|
6815
|
+
store.dispatch(addForm(form));
|
|
6816
|
+
store.dispatch(addFormRevision(offlineFormRevision));
|
|
6849
6817
|
const formPromise = this.client.enqueueRequest({
|
|
6850
6818
|
description: "Create form",
|
|
6851
6819
|
method: HttpMethod.POST,
|
|
6852
|
-
url,
|
|
6853
|
-
queryParams: activeWorkspaceId ? {
|
|
6854
|
-
workspace_id: activeWorkspaceId
|
|
6855
|
-
} : void 0,
|
|
6820
|
+
url: urlPrefix,
|
|
6856
6821
|
payload: {
|
|
6857
|
-
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6822
|
+
// Sending exactly what is currently needed for the endpoint
|
|
6823
|
+
offline_id: form.offline_id,
|
|
6824
|
+
initial_revision: {
|
|
6825
|
+
offline_id: offlineFormRevision.offline_id,
|
|
6826
|
+
submitted_at: offlineFormRevision.submitted_at,
|
|
6827
|
+
title: offlineFormRevision.title,
|
|
6828
|
+
description: offlineFormRevision.description,
|
|
6829
|
+
fields: offlineFormRevision.fields
|
|
6830
|
+
}
|
|
6861
6831
|
},
|
|
6862
|
-
blockers:
|
|
6863
|
-
blocks: [
|
|
6832
|
+
blockers: [ownerId],
|
|
6833
|
+
blocks: [form.offline_id, offlineFormRevision.offline_id]
|
|
6864
6834
|
});
|
|
6865
|
-
const attachImagesPromises = this.getAttachImagePromises(images,
|
|
6835
|
+
const attachImagesPromises = this.getAttachImagePromises(images, offlineFormRevision.offline_id);
|
|
6866
6836
|
void formPromise.catch((e) => {
|
|
6867
|
-
store.dispatch(deleteForm(
|
|
6868
|
-
store.dispatch(deleteFormRevision(
|
|
6837
|
+
store.dispatch(deleteForm(form.offline_id));
|
|
6838
|
+
store.dispatch(deleteFormRevision(offlineFormRevision.offline_id));
|
|
6869
6839
|
throw e;
|
|
6870
6840
|
});
|
|
6871
6841
|
const settledPromise = Promise.all([formPromise, ...attachImagesPromises]).then(() => formPromise);
|
|
6872
|
-
return [
|
|
6842
|
+
return [form, offlineFormRevision, formPromise, settledPromise];
|
|
6873
6843
|
}
|
|
6874
|
-
|
|
6844
|
+
addForOrganization(organizationId, initialRevision) {
|
|
6875
6845
|
const state = this.client.store.getState();
|
|
6876
|
-
const
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
|
|
6880
|
-
|
|
6881
|
-
|
|
6846
|
+
const offlineForm = offline({
|
|
6847
|
+
favorite: false,
|
|
6848
|
+
created_by: state.userReducer.currentUser.id,
|
|
6849
|
+
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6850
|
+
organization: organizationId
|
|
6851
|
+
});
|
|
6852
|
+
return this.add(
|
|
6853
|
+
organizationId.toString(),
|
|
6854
|
+
offlineForm,
|
|
6882
6855
|
initialRevision,
|
|
6883
|
-
`/
|
|
6884
|
-
void 0,
|
|
6885
|
-
activeOrganizationId,
|
|
6886
|
-
attachedTo && "assetTypeId" in attachedTo ? attachedTo.assetTypeId : void 0,
|
|
6887
|
-
attachedTo && "issueTypeId" in attachedTo ? attachedTo.issueTypeId : void 0
|
|
6856
|
+
`/organizations/${organizationId}/create-form/`
|
|
6888
6857
|
);
|
|
6889
6858
|
}
|
|
6890
|
-
|
|
6859
|
+
addForProject(projectId, initialRevision) {
|
|
6891
6860
|
const state = this.client.store.getState();
|
|
6892
|
-
const
|
|
6893
|
-
|
|
6894
|
-
state,
|
|
6895
|
-
|
|
6896
|
-
|
|
6897
|
-
|
|
6898
|
-
|
|
6899
|
-
|
|
6900
|
-
|
|
6901
|
-
);
|
|
6861
|
+
const offlineForm = offline({
|
|
6862
|
+
favorite: false,
|
|
6863
|
+
created_by: state.userReducer.currentUser.id,
|
|
6864
|
+
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6865
|
+
project: projectId
|
|
6866
|
+
});
|
|
6867
|
+
return this.add(projectId.toString(), offlineForm, initialRevision, `/projects/${projectId}/create-form/`);
|
|
6868
|
+
}
|
|
6869
|
+
addForIssueType(issueTypeId, initialRevision) {
|
|
6870
|
+
const state = this.client.store.getState();
|
|
6871
|
+
const offlineForm = offline({
|
|
6872
|
+
favorite: false,
|
|
6873
|
+
created_by: state.userReducer.currentUser.id,
|
|
6874
|
+
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6875
|
+
issue_type: issueTypeId
|
|
6876
|
+
});
|
|
6877
|
+
return this.add(issueTypeId, offlineForm, initialRevision, `/issues/types/${issueTypeId}/create-form/`);
|
|
6878
|
+
}
|
|
6879
|
+
addForAssetType(assetTypeId, initialRevision) {
|
|
6880
|
+
const state = this.client.store.getState();
|
|
6881
|
+
const offlineForm = offline({
|
|
6882
|
+
favorite: false,
|
|
6883
|
+
created_by: state.userReducer.currentUser.id,
|
|
6884
|
+
submitted_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
6885
|
+
asset_type: assetTypeId
|
|
6886
|
+
});
|
|
6887
|
+
return this.add(assetTypeId, offlineForm, initialRevision, `/assets/types/${assetTypeId}/create-form/`);
|
|
6902
6888
|
}
|
|
6903
6889
|
async createRevision(formId2, revision) {
|
|
6904
6890
|
const offlineRevision = offline(revision);
|
|
@@ -6909,9 +6895,10 @@ var __publicField = (obj, key, value) => {
|
|
|
6909
6895
|
throw new Error("Cannot create form revision when there is no active project.");
|
|
6910
6896
|
}
|
|
6911
6897
|
const currentUserId = state.userReducer.currentUser.id;
|
|
6912
|
-
const {
|
|
6898
|
+
const { fields, images } = await separateImageFromFields(offlineRevision.fields);
|
|
6913
6899
|
const fullRevision = {
|
|
6914
|
-
...
|
|
6900
|
+
...offlineRevision,
|
|
6901
|
+
fields,
|
|
6915
6902
|
created_by: currentUserId,
|
|
6916
6903
|
revision: "Pending",
|
|
6917
6904
|
form: formId2,
|
|
@@ -6922,9 +6909,14 @@ var __publicField = (obj, key, value) => {
|
|
|
6922
6909
|
description: "Create form revision",
|
|
6923
6910
|
method: HttpMethod.PATCH,
|
|
6924
6911
|
url: `/forms/${formId2}/`,
|
|
6925
|
-
payload: {
|
|
6926
|
-
|
|
6927
|
-
|
|
6912
|
+
payload: {
|
|
6913
|
+
initial_revision: {
|
|
6914
|
+
offline_id: fullRevision.offline_id,
|
|
6915
|
+
submitted_at: fullRevision.submitted_at,
|
|
6916
|
+
title: fullRevision.title,
|
|
6917
|
+
description: fullRevision.description,
|
|
6918
|
+
fields: fullRevision.fields
|
|
6919
|
+
}
|
|
6928
6920
|
},
|
|
6929
6921
|
blockers: [formId2],
|
|
6930
6922
|
blocks: [offlineRevision.offline_id]
|
|
@@ -7009,16 +7001,68 @@ var __publicField = (obj, key, value) => {
|
|
|
7009
7001
|
}
|
|
7010
7002
|
async refreshStore() {
|
|
7011
7003
|
const { store } = this.client;
|
|
7012
|
-
const
|
|
7013
|
-
|
|
7004
|
+
const activeProjectId = store.getState().projectReducer.activeProjectId;
|
|
7005
|
+
if (!activeProjectId) {
|
|
7006
|
+
throw new Error("No active project");
|
|
7007
|
+
}
|
|
7008
|
+
const forms = [];
|
|
7009
|
+
const revisions = [];
|
|
7010
|
+
const attachments = [];
|
|
7011
|
+
const projectFormsResult = await this.client.enqueueRequest({
|
|
7012
|
+
description: "Fetch project forms",
|
|
7014
7013
|
method: HttpMethod.GET,
|
|
7015
|
-
url: `/
|
|
7016
|
-
blockers: [],
|
|
7014
|
+
url: `/projects/${activeProjectId}/forms/`,
|
|
7015
|
+
blockers: [activeProjectId.toString()],
|
|
7017
7016
|
blocks: []
|
|
7018
7017
|
});
|
|
7019
|
-
|
|
7020
|
-
|
|
7021
|
-
|
|
7018
|
+
for (const form of projectFormsResult.forms)
|
|
7019
|
+
forms.push(form);
|
|
7020
|
+
for (const revision of projectFormsResult.revisions)
|
|
7021
|
+
revisions.push(revision);
|
|
7022
|
+
for (const attachment of projectFormsResult.attachments)
|
|
7023
|
+
attachments.push(attachment);
|
|
7024
|
+
const organizationFormsResult = await this.client.enqueueRequest({
|
|
7025
|
+
description: "Fetch organization forms",
|
|
7026
|
+
method: HttpMethod.GET,
|
|
7027
|
+
url: `/projects/${activeProjectId}/organizations/forms/`,
|
|
7028
|
+
blockers: [activeProjectId.toString()],
|
|
7029
|
+
blocks: []
|
|
7030
|
+
});
|
|
7031
|
+
for (const form of organizationFormsResult.forms)
|
|
7032
|
+
forms.push(form);
|
|
7033
|
+
for (const revision of organizationFormsResult.revisions)
|
|
7034
|
+
revisions.push(revision);
|
|
7035
|
+
for (const attachment of organizationFormsResult.attachments)
|
|
7036
|
+
attachments.push(attachment);
|
|
7037
|
+
const assetTypeFormsResult = await this.client.enqueueRequest({
|
|
7038
|
+
description: "Fetch asset type forms",
|
|
7039
|
+
method: HttpMethod.GET,
|
|
7040
|
+
url: `/projects/${activeProjectId}/asset-types/forms/`,
|
|
7041
|
+
blockers: [activeProjectId.toString()],
|
|
7042
|
+
blocks: []
|
|
7043
|
+
});
|
|
7044
|
+
for (const form of assetTypeFormsResult.forms)
|
|
7045
|
+
forms.push(form);
|
|
7046
|
+
for (const revision of assetTypeFormsResult.latest_revisions)
|
|
7047
|
+
revisions.push(revision);
|
|
7048
|
+
for (const attachment of assetTypeFormsResult.attachments)
|
|
7049
|
+
attachments.push(attachment);
|
|
7050
|
+
const issueTypeFormsResult = await this.client.enqueueRequest({
|
|
7051
|
+
description: "Fetch issue type forms",
|
|
7052
|
+
method: HttpMethod.GET,
|
|
7053
|
+
url: `/projects/${activeProjectId}/issue-types/forms/`,
|
|
7054
|
+
blockers: [activeProjectId.toString()],
|
|
7055
|
+
blocks: []
|
|
7056
|
+
});
|
|
7057
|
+
for (const form of issueTypeFormsResult.forms)
|
|
7058
|
+
forms.push(form);
|
|
7059
|
+
for (const revision of issueTypeFormsResult.latest_revisions)
|
|
7060
|
+
revisions.push(revision);
|
|
7061
|
+
for (const attachment of issueTypeFormsResult.attachments)
|
|
7062
|
+
attachments.push(attachment);
|
|
7063
|
+
store.dispatch(setForms(forms));
|
|
7064
|
+
store.dispatch(setFormRevisions(revisions));
|
|
7065
|
+
store.dispatch(setFormRevisionAttachments(attachments));
|
|
7022
7066
|
}
|
|
7023
7067
|
}
|
|
7024
7068
|
const isArrayOfFiles = (value) => {
|
|
@@ -18474,7 +18518,6 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
18474
18518
|
regularIcon
|
|
18475
18519
|
};
|
|
18476
18520
|
const orgOptionPrefix = "organization:";
|
|
18477
|
-
const userOptionPrefix = "user:";
|
|
18478
18521
|
const FormBrowser = React.memo(
|
|
18479
18522
|
React.forwardRef((props, ref) => {
|
|
18480
18523
|
const { maxResults = 20, ...entryProps } = props;
|
|
@@ -18485,9 +18528,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
18485
18528
|
const ret = { maxResults, searchTerm: filter };
|
|
18486
18529
|
if (ownerFilter) {
|
|
18487
18530
|
if (ownerFilter.startsWith(orgOptionPrefix)) {
|
|
18488
|
-
ret.
|
|
18489
|
-
} else if (ownerFilter.startsWith(userOptionPrefix)) {
|
|
18490
|
-
ret.owner_user = parseInt(ownerFilter.slice(userOptionPrefix.length));
|
|
18531
|
+
ret.organization = parseInt(ownerFilter.slice(orgOptionPrefix.length));
|
|
18491
18532
|
}
|
|
18492
18533
|
}
|
|
18493
18534
|
return ret;
|
|
@@ -18512,14 +18553,10 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
18512
18553
|
const state = sdk.store.getState();
|
|
18513
18554
|
const accumulator = {};
|
|
18514
18555
|
for (const form of attachableUserFormMapping) {
|
|
18515
|
-
const organization = selectOrganization(form.
|
|
18556
|
+
const organization = selectOrganization(form.organization || -1)(state);
|
|
18516
18557
|
if (organization) {
|
|
18517
18558
|
accumulator[`${orgOptionPrefix}${organization.id}`] = organization.name;
|
|
18518
18559
|
}
|
|
18519
|
-
const user = selectUser(form.owner_user || -1)(state);
|
|
18520
|
-
if (user) {
|
|
18521
|
-
accumulator[`${userOptionPrefix}${user.id}`] = user.username;
|
|
18522
|
-
}
|
|
18523
18560
|
}
|
|
18524
18561
|
return Object.entries(accumulator).map(([value, label]) => ({ itemContent: label, value }));
|
|
18525
18562
|
}, [sdk.store, attachableUserFormMapping]);
|
|
@@ -18561,11 +18598,7 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
18561
18598
|
const FormBrowserEntry = (props) => {
|
|
18562
18599
|
var _a2;
|
|
18563
18600
|
const { form, onSelectForm, isFavoriteEditable, handleToggleFavorite } = props;
|
|
18564
|
-
const ownerOrganization = (_a2 = reactRedux.useSelector(selectOrganization(form.
|
|
18565
|
-
const ownerUser = reactRedux.useSelector(selectUser(form.owner_user || -1));
|
|
18566
|
-
const currentUserId = reactRedux.useSelector(selectCurrentUser).id;
|
|
18567
|
-
const ownedByCurrentUser = !!ownerUser && ownerUser.id === currentUserId;
|
|
18568
|
-
const owner = ownerOrganization ?? (ownedByCurrentUser ? "You" : ownerUser == null ? void 0 : ownerUser.username) ?? "Unknown";
|
|
18601
|
+
const ownerOrganization = (_a2 = reactRedux.useSelector(selectOrganization(form.organization || -1))) == null ? void 0 : _a2.name;
|
|
18569
18602
|
const handleFavoriteClick = React.useCallback(
|
|
18570
18603
|
(e) => {
|
|
18571
18604
|
e.stopPropagation();
|
|
@@ -18596,10 +18629,10 @@ Defaulting to \`${$89eedd556c436f6a$var$DEFAULT_ORIENTATION}\`.`;
|
|
|
18596
18629
|
/* @__PURE__ */ jsxRuntime.jsx(Text, { children: form.latestRevision.title }),
|
|
18597
18630
|
form.latestRevision.description && /* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiQuestionLine" })
|
|
18598
18631
|
] }),
|
|
18599
|
-
|
|
18632
|
+
ownerOrganization && /* @__PURE__ */ jsxRuntime.jsxs(Flex, { align: "center", gap: "2", children: [
|
|
18600
18633
|
/* @__PURE__ */ jsxRuntime.jsx(blocks.RiIcon, { icon: "RiUserLine" }),
|
|
18601
18634
|
" ",
|
|
18602
|
-
|
|
18635
|
+
ownerOrganization
|
|
18603
18636
|
] })
|
|
18604
18637
|
] })
|
|
18605
18638
|
}
|