@openmrs/esm-form-builder-app 2.0.2-pre.574 → 2.0.2-pre.586
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/README.md +43 -17
- package/dist/127.js +1 -1
- package/dist/127.js.map +1 -1
- package/dist/150.js +1 -1
- package/dist/150.js.map +1 -1
- package/dist/153.js +1 -1
- package/dist/153.js.map +1 -1
- package/dist/164.js +1 -1
- package/dist/256.js +1 -1
- package/dist/319.js +1 -1
- package/dist/447.js +1 -1
- package/dist/447.js.map +1 -1
- package/dist/515.js +2 -0
- package/dist/{773.js.LICENSE.txt → 515.js.LICENSE.txt} +9 -0
- package/dist/515.js.map +1 -0
- package/dist/527.js +1 -0
- package/dist/527.js.map +1 -0
- package/dist/574.js +1 -1
- package/dist/757.js +1 -1
- package/dist/788.js +1 -1
- package/dist/800.js +1 -1
- package/dist/800.js.map +1 -1
- package/dist/807.js +1 -1
- package/dist/833.js +1 -1
- package/dist/878.js +2 -0
- package/dist/{208.js.LICENSE.txt → 878.js.LICENSE.txt} +2 -1
- package/dist/878.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-form-builder-app.js +1 -1
- package/dist/openmrs-esm-form-builder-app.js.buildmanifest.json +154 -175
- package/dist/openmrs-esm-form-builder-app.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +35 -32
- package/src/components/action-buttons/action-buttons.component.tsx +65 -101
- package/src/components/dashboard/dashboard.component.tsx +98 -174
- package/src/components/dashboard/dashboard.test.tsx +51 -81
- package/src/components/empty-state/empty-data-illustration.component.tsx +4 -16
- package/src/components/empty-state/empty-state.component.tsx +11 -15
- package/src/components/error-state/error-state.component.tsx +11 -13
- package/src/components/form-editor/form-editor.component.tsx +97 -128
- package/src/components/form-renderer/form-renderer.component.tsx +30 -41
- package/src/components/interactive-builder/add-question-modal.component.tsx +129 -167
- package/src/components/interactive-builder/delete-page-modal.component.tsx +24 -37
- package/src/components/interactive-builder/delete-question-modal.component.tsx +25 -47
- package/src/components/interactive-builder/delete-section-modal.component.tsx +24 -37
- package/src/components/interactive-builder/draggable-question.component.tsx +21 -34
- package/src/components/interactive-builder/droppable-container.component.tsx +5 -5
- package/src/components/interactive-builder/edit-question-modal.component.tsx +191 -233
- package/src/components/interactive-builder/editable-value.component.tsx +12 -17
- package/src/components/interactive-builder/interactive-builder.component.tsx +134 -184
- package/src/components/interactive-builder/new-form-modal.component.tsx +35 -49
- package/src/components/interactive-builder/page-modal.component.tsx +29 -45
- package/src/components/interactive-builder/question-modal.scss +7 -0
- package/src/components/interactive-builder/section-modal.component.tsx +29 -40
- package/src/components/interactive-builder/value-editor.component.tsx +11 -16
- package/src/components/modals/save-form-modal.component.tsx +112 -165
- package/src/components/pagination/index.ts +2 -2
- package/src/components/pagination/pagination.component.tsx +8 -13
- package/src/components/pagination/usePaginationInfo.ts +4 -9
- package/src/components/schema-editor/schema-editor.component.tsx +11 -17
- package/src/config-schema.ts +28 -30
- package/src/declarations.d.ts +4 -3
- package/src/form-builder-admin-card-link.component.tsx +7 -11
- package/src/forms.resource.ts +66 -87
- package/src/hooks/useClobdata.ts +10 -12
- package/src/hooks/useConceptLookup.ts +5 -8
- package/src/hooks/useConceptName.ts +6 -9
- package/src/hooks/useEncounterTypes.ts +8 -8
- package/src/hooks/useForm.ts +7 -7
- package/src/hooks/useForms.ts +5 -8
- package/src/index.ts +11 -23
- package/src/root.component.tsx +4 -4
- package/src/setup-tests.ts +1 -9
- package/src/test-helpers.tsx +8 -15
- package/src/types.ts +16 -8
- package/dist/208.js +0 -2
- package/dist/208.js.map +0 -1
- package/dist/536.js +0 -1
- package/dist/536.js.map +0 -1
- package/dist/62.js +0 -1
- package/dist/62.js.map +0 -1
- package/dist/773.js +0 -2
- package/dist/773.js.map +0 -1
- package/src/constants.ts +0 -3
package/package.json
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openmrs/esm-form-builder-app",
|
|
3
|
-
"version": "2.0.2-pre.
|
|
3
|
+
"version": "2.0.2-pre.586",
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
5
|
"description": "OpenMRS ESM Form Builder App",
|
|
6
6
|
"browser": "dist/openmrs-esm-form-builder-app.js",
|
|
7
7
|
"main": "src/index.ts",
|
|
8
8
|
"source": true,
|
|
9
|
+
"lint-staged": {
|
|
10
|
+
"*.{js,jsx,ts,tsx}": "eslint --cache --fix"
|
|
11
|
+
},
|
|
9
12
|
"scripts": {
|
|
10
13
|
"start": "openmrs develop",
|
|
11
14
|
"serve": "webpack serve --mode=development",
|
|
12
15
|
"build": "webpack --mode production",
|
|
13
16
|
"analyze": "webpack --mode=production --env.analyze=true",
|
|
14
|
-
"lint": "TIMING=1 eslint src --ext js,jsx,ts,tsx",
|
|
17
|
+
"lint": "TIMING=1 eslint src --ext js,jsx,ts,tsx --max-warnings=0",
|
|
15
18
|
"prettier": "prettier --write \"src/**/*.{ts,tsx}\"",
|
|
16
19
|
"typescript": "tsc",
|
|
17
20
|
"test": "jest --config jest.config.js",
|
|
@@ -32,7 +35,6 @@
|
|
|
32
35
|
"keywords": [
|
|
33
36
|
"openmrs",
|
|
34
37
|
"microfrontends",
|
|
35
|
-
"formbuilder",
|
|
36
38
|
"form builder"
|
|
37
39
|
],
|
|
38
40
|
"repository": {
|
|
@@ -47,13 +49,13 @@
|
|
|
47
49
|
"url": "https://github.com/openmrs/openmrs-esm-form-builder/issues"
|
|
48
50
|
},
|
|
49
51
|
"dependencies": {
|
|
50
|
-
"@carbon/react": "^1.
|
|
52
|
+
"@carbon/react": "^1.38.0",
|
|
51
53
|
"@openmrs/openmrs-form-engine-lib": "next",
|
|
52
|
-
"dotenv": "^16.1
|
|
54
|
+
"dotenv": "^16.3.1",
|
|
53
55
|
"file-loader": "^6.2.0",
|
|
54
56
|
"lodash-es": "^4.17.21",
|
|
55
57
|
"react-ace": "^10.1.0",
|
|
56
|
-
"sass": "^1.
|
|
58
|
+
"sass": "^1.67.0"
|
|
57
59
|
},
|
|
58
60
|
"peerDependencies": {
|
|
59
61
|
"@openmrs/esm-framework": "*",
|
|
@@ -69,44 +71,45 @@
|
|
|
69
71
|
"@dnd-kit/utilities": "^3.2.1",
|
|
70
72
|
"@openmrs/esm-framework": "next",
|
|
71
73
|
"@openmrs/esm-styleguide": "next",
|
|
72
|
-
"@playwright/test": "^1.
|
|
74
|
+
"@playwright/test": "^1.38.0",
|
|
73
75
|
"@swc/cli": "^0.1.62",
|
|
74
|
-
"@swc/core": "^1.3.
|
|
75
|
-
"@swc/jest": "^0.2.
|
|
76
|
-
"@testing-library/dom": "^
|
|
77
|
-
"@testing-library/jest-dom": "^
|
|
78
|
-
"@testing-library/react": "^
|
|
79
|
-
"@testing-library/user-event": "^14.
|
|
80
|
-
"@types/jest": "^29.5.
|
|
81
|
-
"@types/react": "^18.2.
|
|
82
|
-
"@types/react-dom": "^18.2.
|
|
76
|
+
"@swc/core": "^1.3.85",
|
|
77
|
+
"@swc/jest": "^0.2.29",
|
|
78
|
+
"@testing-library/dom": "^9.3.1",
|
|
79
|
+
"@testing-library/jest-dom": "^6.1.3",
|
|
80
|
+
"@testing-library/react": "^14.0.0",
|
|
81
|
+
"@testing-library/user-event": "^14.5.1",
|
|
82
|
+
"@types/jest": "^29.5.5",
|
|
83
|
+
"@types/react": "^18.2.21",
|
|
84
|
+
"@types/react-dom": "^18.2.7",
|
|
83
85
|
"@types/webpack-env": "^1.18.1",
|
|
84
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
85
|
-
"@typescript-eslint/parser": "^
|
|
86
|
+
"@typescript-eslint/eslint-plugin": "^6.7.0",
|
|
87
|
+
"@typescript-eslint/parser": "^6.7.0",
|
|
86
88
|
"css-loader": "^6.8.1",
|
|
87
|
-
"eslint": "^8.
|
|
88
|
-
"eslint-config-prettier": "^
|
|
89
|
+
"eslint": "^8.49.0",
|
|
90
|
+
"eslint-config-prettier": "^9.0.0",
|
|
89
91
|
"eslint-config-ts-react-important-stuff": "^3.0.0",
|
|
90
|
-
"eslint-plugin-
|
|
92
|
+
"eslint-plugin-playwright": "^0.16.0",
|
|
93
|
+
"eslint-plugin-prettier": "^5.0.0",
|
|
91
94
|
"husky": "^8.0.3",
|
|
92
|
-
"i18next": "^
|
|
93
|
-
"i18next-parser": "^
|
|
95
|
+
"i18next": "^23.5.1",
|
|
96
|
+
"i18next-parser": "^8.7.0",
|
|
94
97
|
"identity-obj-proxy": "^3.0.0",
|
|
95
|
-
"jest": "^29.
|
|
96
|
-
"jest-cli": "^29.
|
|
97
|
-
"jest-environment-jsdom": "^29.
|
|
98
|
+
"jest": "^29.7.0",
|
|
99
|
+
"jest-cli": "^29.7.0",
|
|
100
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
101
|
+
"lint-staged": "^14.0.1",
|
|
98
102
|
"openmrs": "next",
|
|
99
|
-
"prettier": "^
|
|
100
|
-
"pretty-quick": "^3.1.3",
|
|
103
|
+
"prettier": "^3.0.3",
|
|
101
104
|
"react": "^18.2.0",
|
|
102
105
|
"react-dom": "^18.2.0",
|
|
103
|
-
"react-error-boundary": "^4.0.
|
|
104
|
-
"react-i18next": "^
|
|
106
|
+
"react-error-boundary": "^4.0.11",
|
|
107
|
+
"react-i18next": "^13.2.2",
|
|
105
108
|
"rxjs": "^7.8.1",
|
|
106
109
|
"swc-loader": "^0.2.3",
|
|
107
|
-
"turbo": "^1.10.
|
|
110
|
+
"turbo": "^1.10.14",
|
|
108
111
|
"typescript": "^4.9.5",
|
|
109
|
-
"webpack": "^5.
|
|
112
|
+
"webpack": "^5.88.2",
|
|
110
113
|
"webpack-cli": "^5.1.4"
|
|
111
114
|
},
|
|
112
115
|
"packageManager": "yarn@3.6.0",
|
|
@@ -1,39 +1,26 @@
|
|
|
1
|
-
import React, { useState } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
import type { RouteParams, Schema } from "../../types";
|
|
15
|
-
import { publishForm, unpublishForm } from "../../forms.resource";
|
|
16
|
-
import { useForm } from "../../hooks/useForm";
|
|
17
|
-
import SaveFormModal from "../modals/save-form-modal.component";
|
|
18
|
-
import styles from "./action-buttons.scss";
|
|
19
|
-
|
|
20
|
-
type ActionButtonsProps = {
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Button, ComposedModal, InlineLoading, ModalBody, ModalFooter, ModalHeader } from '@carbon/react';
|
|
3
|
+
import type { TFunction } from 'i18next';
|
|
4
|
+
import { useParams } from 'react-router-dom';
|
|
5
|
+
import { showToast, showNotification } from '@openmrs/esm-framework';
|
|
6
|
+
|
|
7
|
+
import type { Schema } from '../../types';
|
|
8
|
+
import { publishForm, unpublishForm } from '../../forms.resource';
|
|
9
|
+
import { useForm } from '../../hooks/useForm';
|
|
10
|
+
import SaveFormModal from '../modals/save-form-modal.component';
|
|
11
|
+
import styles from './action-buttons.scss';
|
|
12
|
+
|
|
13
|
+
interface ActionButtonsProps {
|
|
21
14
|
schema: Schema;
|
|
22
15
|
t: TFunction;
|
|
23
|
-
}
|
|
16
|
+
}
|
|
24
17
|
|
|
25
|
-
type Status =
|
|
26
|
-
| "idle"
|
|
27
|
-
| "publishing"
|
|
28
|
-
| "published"
|
|
29
|
-
| "unpublishing"
|
|
30
|
-
| "unpublished"
|
|
31
|
-
| "error";
|
|
18
|
+
type Status = 'idle' | 'publishing' | 'published' | 'unpublishing' | 'unpublished' | 'error';
|
|
32
19
|
|
|
33
20
|
function ActionButtons({ schema, t }: ActionButtonsProps) {
|
|
34
|
-
const { formUuid } = useParams<
|
|
21
|
+
const { formUuid } = useParams<{ formUuid?: string }>();
|
|
35
22
|
const { form, mutate } = useForm(formUuid);
|
|
36
|
-
const [status, setStatus] = useState<Status>(
|
|
23
|
+
const [status, setStatus] = useState<Status>('idle');
|
|
37
24
|
const [showUnpublishModal, setShowUnpublishModal] = useState(false);
|
|
38
25
|
|
|
39
26
|
const launchUnpublishModal = () => {
|
|
@@ -41,56 +28,57 @@ function ActionButtons({ schema, t }: ActionButtonsProps) {
|
|
|
41
28
|
};
|
|
42
29
|
|
|
43
30
|
async function handlePublish() {
|
|
44
|
-
setStatus(
|
|
31
|
+
setStatus('publishing');
|
|
45
32
|
try {
|
|
46
33
|
await publishForm(form.uuid);
|
|
47
34
|
|
|
48
35
|
showToast({
|
|
49
|
-
title: t(
|
|
50
|
-
kind:
|
|
36
|
+
title: t('formPublished', 'Form published'),
|
|
37
|
+
kind: 'success',
|
|
51
38
|
critical: true,
|
|
52
|
-
description:
|
|
53
|
-
`${form.name} ` +
|
|
54
|
-
t("formPublishedSuccessfully", "form was published successfully"),
|
|
39
|
+
description: `${form.name} ` + t('formPublishedSuccessfully', 'form was published successfully'),
|
|
55
40
|
});
|
|
56
41
|
|
|
57
|
-
setStatus(
|
|
58
|
-
mutate();
|
|
42
|
+
setStatus('published');
|
|
43
|
+
await mutate();
|
|
59
44
|
} catch (error) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
45
|
+
if (error instanceof Error) {
|
|
46
|
+
showNotification({
|
|
47
|
+
title: t('errorPublishingForm', 'Error publishing form'),
|
|
48
|
+
kind: 'error',
|
|
49
|
+
critical: true,
|
|
50
|
+
description: error?.message,
|
|
51
|
+
});
|
|
52
|
+
setStatus('error');
|
|
53
|
+
}
|
|
67
54
|
}
|
|
68
55
|
}
|
|
69
56
|
|
|
70
57
|
async function handleUnpublish() {
|
|
71
|
-
setStatus(
|
|
58
|
+
setStatus('unpublishing');
|
|
59
|
+
|
|
72
60
|
try {
|
|
73
61
|
await unpublishForm(form.uuid);
|
|
74
62
|
|
|
75
63
|
showToast({
|
|
76
|
-
title: t(
|
|
77
|
-
kind:
|
|
64
|
+
title: t('formUnpublished', 'Form unpublished'),
|
|
65
|
+
kind: 'success',
|
|
78
66
|
critical: true,
|
|
79
|
-
description:
|
|
80
|
-
`${form.name} ` +
|
|
81
|
-
t("formUnpublishedSuccessfully", "form was unpublished successfully"),
|
|
67
|
+
description: `${form.name} ` + t('formUnpublishedSuccessfully', 'form was unpublished successfully'),
|
|
82
68
|
});
|
|
83
69
|
|
|
84
|
-
setStatus(
|
|
85
|
-
mutate();
|
|
70
|
+
setStatus('unpublished');
|
|
71
|
+
await mutate();
|
|
86
72
|
} catch (error) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
73
|
+
if (error instanceof Error) {
|
|
74
|
+
showNotification({
|
|
75
|
+
title: t('errorUnpublishingForm', 'Error unpublishing form'),
|
|
76
|
+
kind: 'error',
|
|
77
|
+
critical: true,
|
|
78
|
+
description: error?.message,
|
|
79
|
+
});
|
|
80
|
+
setStatus('error');
|
|
81
|
+
}
|
|
94
82
|
}
|
|
95
83
|
setShowUnpublishModal(false);
|
|
96
84
|
}
|
|
@@ -101,71 +89,47 @@ function ActionButtons({ schema, t }: ActionButtonsProps) {
|
|
|
101
89
|
|
|
102
90
|
<>
|
|
103
91
|
{form && !form.published ? (
|
|
104
|
-
<Button
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
disabled={status === "publishing"}
|
|
108
|
-
>
|
|
109
|
-
{status === "publishing" && !form?.published ? (
|
|
110
|
-
<InlineLoading
|
|
111
|
-
className={styles.spinner}
|
|
112
|
-
description={t("publishing", "Publishing") + "..."}
|
|
113
|
-
/>
|
|
92
|
+
<Button kind="secondary" onClick={handlePublish} disabled={status === 'publishing'}>
|
|
93
|
+
{status === 'publishing' && !form?.published ? (
|
|
94
|
+
<InlineLoading className={styles.spinner} description={t('publishing', 'Publishing') + '...'} />
|
|
114
95
|
) : (
|
|
115
|
-
<span>{t(
|
|
96
|
+
<span>{t('publishForm', 'Publish form')}</span>
|
|
116
97
|
)}
|
|
117
98
|
</Button>
|
|
118
99
|
) : null}
|
|
119
100
|
|
|
120
101
|
{form && form.published ? (
|
|
121
|
-
<Button
|
|
122
|
-
|
|
123
|
-
onClick={launchUnpublishModal}
|
|
124
|
-
disabled={status === "unpublishing"}
|
|
125
|
-
>
|
|
126
|
-
{t("unpublishForm", "Unpublish form")}
|
|
102
|
+
<Button kind="danger" onClick={launchUnpublishModal} disabled={status === 'unpublishing'}>
|
|
103
|
+
{t('unpublishForm', 'Unpublish form')}
|
|
127
104
|
</Button>
|
|
128
105
|
) : null}
|
|
129
106
|
|
|
130
107
|
{showUnpublishModal ? (
|
|
131
|
-
<ComposedModal
|
|
132
|
-
open={true}
|
|
133
|
-
onClose={() => setShowUnpublishModal(false)}
|
|
134
|
-
preventCloseOnClickOutside
|
|
135
|
-
>
|
|
108
|
+
<ComposedModal open={true} onClose={() => setShowUnpublishModal(false)} preventCloseOnClickOutside>
|
|
136
109
|
<ModalHeader
|
|
137
|
-
title={t(
|
|
138
|
-
"unpublishConfirmation",
|
|
139
|
-
"Are you sure you want to unpublish this form?"
|
|
140
|
-
)}
|
|
110
|
+
title={t('unpublishConfirmation', 'Are you sure you want to unpublish this form?')}
|
|
141
111
|
></ModalHeader>
|
|
142
112
|
<ModalBody>
|
|
143
113
|
<p>
|
|
144
114
|
{t(
|
|
145
|
-
|
|
146
|
-
|
|
115
|
+
'unpublishExplainerText',
|
|
116
|
+
'Unpublishing a form means you can no longer access it from your frontend. Unpublishing forms does not delete their associated schemas, it only affects whether or not you can access them in your frontend.',
|
|
147
117
|
)}
|
|
148
118
|
</p>
|
|
149
119
|
</ModalBody>
|
|
150
120
|
<ModalFooter>
|
|
151
|
-
<Button
|
|
152
|
-
|
|
153
|
-
onClick={() => setShowUnpublishModal(false)}
|
|
154
|
-
>
|
|
155
|
-
{t("cancel", "Cancel")}
|
|
121
|
+
<Button kind="secondary" onClick={() => setShowUnpublishModal(false)}>
|
|
122
|
+
{t('cancel', 'Cancel')}
|
|
156
123
|
</Button>
|
|
157
124
|
<Button
|
|
158
|
-
disabled={status ===
|
|
159
|
-
kind={status ===
|
|
125
|
+
disabled={status === 'unpublishing'}
|
|
126
|
+
kind={status === 'unpublishing' ? 'secondary' : 'danger'}
|
|
160
127
|
onClick={handleUnpublish}
|
|
161
128
|
>
|
|
162
|
-
{status ===
|
|
163
|
-
<InlineLoading
|
|
164
|
-
className={styles.spinner}
|
|
165
|
-
description={t("unpublishing", "Unpublishing") + "..."}
|
|
166
|
-
/>
|
|
129
|
+
{status === 'unpublishing' ? (
|
|
130
|
+
<InlineLoading className={styles.spinner} description={t('unpublishing', 'Unpublishing') + '...'} />
|
|
167
131
|
) : (
|
|
168
|
-
<span>{t(
|
|
132
|
+
<span>{t('confirm', 'Confirm')}</span>
|
|
169
133
|
)}
|
|
170
134
|
</Button>
|
|
171
135
|
</ModalFooter>
|