@openmrs/esm-form-builder-app 2.0.2-pre.574 → 2.0.2-pre.597
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/draggable-question.scss +2 -2
- 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
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { useTranslation } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
ModalBody,
|
|
7
|
-
ModalFooter,
|
|
8
|
-
ModalHeader,
|
|
9
|
-
} from "@carbon/react";
|
|
10
|
-
import { showNotification, showToast } from "@openmrs/esm-framework";
|
|
11
|
-
import type { Schema } from "../../types";
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { Button, ComposedModal, ModalBody, ModalFooter, ModalHeader } from '@carbon/react';
|
|
4
|
+
import { showNotification, showToast } from '@openmrs/esm-framework';
|
|
5
|
+
import type { Schema } from '../../types';
|
|
12
6
|
|
|
13
|
-
|
|
7
|
+
interface DeleteQuestionModal {
|
|
14
8
|
onModalChange: (showModal: boolean) => void;
|
|
15
9
|
onSchemaChange: (schema: Schema) => void;
|
|
16
10
|
resetIndices: () => void;
|
|
@@ -19,7 +13,7 @@ type DeleteQuestionModal = {
|
|
|
19
13
|
questionIndex: number;
|
|
20
14
|
schema: Schema;
|
|
21
15
|
showModal: boolean;
|
|
22
|
-
}
|
|
16
|
+
}
|
|
23
17
|
|
|
24
18
|
const DeleteQuestionModal: React.FC<DeleteQuestionModal> = ({
|
|
25
19
|
onModalChange,
|
|
@@ -33,56 +27,40 @@ const DeleteQuestionModal: React.FC<DeleteQuestionModal> = ({
|
|
|
33
27
|
}) => {
|
|
34
28
|
const { t } = useTranslation();
|
|
35
29
|
|
|
36
|
-
const deleteQuestion = (
|
|
37
|
-
pageIndex: number,
|
|
38
|
-
sectionIndex: number,
|
|
39
|
-
questionIndex: number
|
|
40
|
-
) => {
|
|
30
|
+
const deleteQuestion = (pageIndex: number, sectionIndex: number, questionIndex: number) => {
|
|
41
31
|
try {
|
|
42
|
-
schema.pages[pageIndex].sections[sectionIndex].questions.splice(
|
|
43
|
-
questionIndex,
|
|
44
|
-
1
|
|
45
|
-
);
|
|
32
|
+
schema.pages[pageIndex].sections[sectionIndex].questions.splice(questionIndex, 1);
|
|
46
33
|
|
|
47
34
|
onSchemaChange({ ...schema });
|
|
48
35
|
resetIndices();
|
|
49
36
|
|
|
50
37
|
showToast({
|
|
51
|
-
title: t(
|
|
52
|
-
kind:
|
|
38
|
+
title: t('success', 'Success!'),
|
|
39
|
+
kind: 'success',
|
|
53
40
|
critical: true,
|
|
54
|
-
description: t(
|
|
41
|
+
description: t('QuestionDeleted', 'Question deleted'),
|
|
55
42
|
});
|
|
56
43
|
} catch (error) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
44
|
+
if (error instanceof Error) {
|
|
45
|
+
showNotification({
|
|
46
|
+
title: t('errorDeletingQuestion', 'Error deleting question'),
|
|
47
|
+
kind: 'error',
|
|
48
|
+
critical: true,
|
|
49
|
+
description: error?.message,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
63
52
|
}
|
|
64
53
|
};
|
|
65
54
|
|
|
66
55
|
return (
|
|
67
|
-
<ComposedModal
|
|
68
|
-
|
|
69
|
-
onClose={() => onModalChange(false)}
|
|
70
|
-
preventCloseOnClickOutside
|
|
71
|
-
>
|
|
72
|
-
<ModalHeader
|
|
73
|
-
title={t(
|
|
74
|
-
"deleteQuestionConfirmation",
|
|
75
|
-
"Are you sure you want to delete this question?"
|
|
76
|
-
)}
|
|
77
|
-
/>
|
|
56
|
+
<ComposedModal open={showModal} onClose={() => onModalChange(false)} preventCloseOnClickOutside>
|
|
57
|
+
<ModalHeader title={t('deleteQuestionConfirmation', 'Are you sure you want to delete this question?')} />
|
|
78
58
|
<ModalBody>
|
|
79
|
-
<p>
|
|
80
|
-
{t("deleteQuestionExplainerText", "This action cannot be undone.")}
|
|
81
|
-
</p>
|
|
59
|
+
<p>{t('deleteQuestionExplainerText', 'This action cannot be undone.')}</p>
|
|
82
60
|
</ModalBody>
|
|
83
61
|
<ModalFooter>
|
|
84
62
|
<Button kind="secondary" onClick={() => onModalChange(false)}>
|
|
85
|
-
{t(
|
|
63
|
+
{t('cancel', 'Cancel')}
|
|
86
64
|
</Button>
|
|
87
65
|
<Button
|
|
88
66
|
kind="danger"
|
|
@@ -91,7 +69,7 @@ const DeleteQuestionModal: React.FC<DeleteQuestionModal> = ({
|
|
|
91
69
|
onModalChange(false);
|
|
92
70
|
}}
|
|
93
71
|
>
|
|
94
|
-
<span>{t(
|
|
72
|
+
<span>{t('deleteQuestion', 'Delete question')}</span>
|
|
95
73
|
</Button>
|
|
96
74
|
</ModalFooter>
|
|
97
75
|
</ComposedModal>
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { useTranslation } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
ModalBody,
|
|
7
|
-
ModalFooter,
|
|
8
|
-
ModalHeader,
|
|
9
|
-
} from "@carbon/react";
|
|
10
|
-
import { showNotification, showToast } from "@openmrs/esm-framework";
|
|
11
|
-
import type { Schema } from "../../types";
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { Button, ComposedModal, ModalBody, ModalFooter, ModalHeader } from '@carbon/react';
|
|
4
|
+
import { showNotification, showToast } from '@openmrs/esm-framework';
|
|
5
|
+
import type { Schema } from '../../types';
|
|
12
6
|
|
|
13
|
-
|
|
7
|
+
interface DeleteSectionModal {
|
|
14
8
|
onModalChange: (showModal: boolean) => void;
|
|
15
9
|
onSchemaChange: (schema: Schema) => void;
|
|
16
10
|
resetIndices: () => void;
|
|
@@ -18,7 +12,7 @@ type DeleteSectionModal = {
|
|
|
18
12
|
sectionIndex: number;
|
|
19
13
|
schema: Schema;
|
|
20
14
|
showModal: boolean;
|
|
21
|
-
}
|
|
15
|
+
}
|
|
22
16
|
|
|
23
17
|
const DeleteSectionModal: React.FC<DeleteSectionModal> = ({
|
|
24
18
|
onModalChange,
|
|
@@ -39,44 +33,37 @@ const DeleteSectionModal: React.FC<DeleteSectionModal> = ({
|
|
|
39
33
|
resetIndices();
|
|
40
34
|
|
|
41
35
|
showToast({
|
|
42
|
-
title: t(
|
|
43
|
-
kind:
|
|
36
|
+
title: t('success', 'Success!'),
|
|
37
|
+
kind: 'success',
|
|
44
38
|
critical: true,
|
|
45
|
-
description: t(
|
|
39
|
+
description: t('SectionDeleted', 'Section deleted'),
|
|
46
40
|
});
|
|
47
41
|
} catch (error) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
42
|
+
if (error instanceof Error) {
|
|
43
|
+
showNotification({
|
|
44
|
+
title: t('errorDeletingSection', 'Error deleting section'),
|
|
45
|
+
kind: 'error',
|
|
46
|
+
critical: true,
|
|
47
|
+
description: error?.message,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
54
50
|
}
|
|
55
51
|
};
|
|
56
52
|
|
|
57
53
|
return (
|
|
58
|
-
<ComposedModal
|
|
59
|
-
|
|
60
|
-
onClose={() => onModalChange(false)}
|
|
61
|
-
preventCloseOnClickOutside
|
|
62
|
-
>
|
|
63
|
-
<ModalHeader
|
|
64
|
-
title={t(
|
|
65
|
-
"deleteSectionConfirmation",
|
|
66
|
-
"Are you sure you want to delete this section?"
|
|
67
|
-
)}
|
|
68
|
-
/>
|
|
54
|
+
<ComposedModal open={showModal} onClose={() => onModalChange(false)} preventCloseOnClickOutside>
|
|
55
|
+
<ModalHeader title={t('deleteSectionConfirmation', 'Are you sure you want to delete this section?')} />
|
|
69
56
|
<ModalBody>
|
|
70
57
|
<p>
|
|
71
58
|
{t(
|
|
72
|
-
|
|
73
|
-
|
|
59
|
+
'deleteSectionExplainerText',
|
|
60
|
+
'Deleting this section will delete all the questions associated with it. This action cannot be undone.',
|
|
74
61
|
)}
|
|
75
62
|
</p>
|
|
76
63
|
</ModalBody>
|
|
77
64
|
<ModalFooter>
|
|
78
65
|
<Button kind="secondary" onClick={() => onModalChange(false)}>
|
|
79
|
-
{t(
|
|
66
|
+
{t('cancel', 'Cancel')}
|
|
80
67
|
</Button>
|
|
81
68
|
<Button
|
|
82
69
|
kind="danger"
|
|
@@ -85,7 +72,7 @@ const DeleteSectionModal: React.FC<DeleteSectionModal> = ({
|
|
|
85
72
|
onModalChange(false);
|
|
86
73
|
}}
|
|
87
74
|
>
|
|
88
|
-
<span>{t(
|
|
75
|
+
<span>{t('deleteSection', 'Delete section')}</span>
|
|
89
76
|
</Button>
|
|
90
77
|
</ModalFooter>
|
|
91
78
|
</ComposedModal>
|
|
@@ -1,26 +1,22 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { useDraggable } from
|
|
3
|
-
import { CSS } from
|
|
4
|
-
import { useTranslation } from
|
|
5
|
-
import { Button, CopyButton } from
|
|
6
|
-
import { Draggable, Edit, TrashCan } from
|
|
7
|
-
import type { Question } from
|
|
8
|
-
import styles from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useDraggable } from '@dnd-kit/core';
|
|
3
|
+
import { CSS } from '@dnd-kit/utilities';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
5
|
+
import { Button, CopyButton } from '@carbon/react';
|
|
6
|
+
import { Draggable, Edit, TrashCan } from '@carbon/react/icons';
|
|
7
|
+
import type { Question } from '../../types';
|
|
8
|
+
import styles from './draggable-question.scss';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
interface DraggableQuestionProps {
|
|
11
11
|
question: Question;
|
|
12
12
|
pageIndex: number;
|
|
13
13
|
sectionIndex: number;
|
|
14
14
|
questionIndex: number;
|
|
15
|
-
handleDuplicateQuestion: (
|
|
16
|
-
question: Question,
|
|
17
|
-
pageId: number,
|
|
18
|
-
sectionId: number
|
|
19
|
-
) => void;
|
|
15
|
+
handleDuplicateQuestion: (question: Question, pageId: number, sectionId: number) => void;
|
|
20
16
|
handleEditButtonClick: (question: Question) => void;
|
|
21
17
|
handleDeleteButtonClick: (question: Question) => void;
|
|
22
18
|
questionCount: number;
|
|
23
|
-
}
|
|
19
|
+
}
|
|
24
20
|
|
|
25
21
|
export const DraggableQuestion: React.FC<DraggableQuestionProps> = ({
|
|
26
22
|
question,
|
|
@@ -35,11 +31,10 @@ export const DraggableQuestion: React.FC<DraggableQuestionProps> = ({
|
|
|
35
31
|
const { t } = useTranslation();
|
|
36
32
|
const draggableId = `question-${pageIndex}-${sectionIndex}-${questionIndex}`;
|
|
37
33
|
|
|
38
|
-
const { attributes, listeners, transform, isDragging, setNodeRef } =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
34
|
+
const { attributes, listeners, transform, isDragging, setNodeRef } = useDraggable({
|
|
35
|
+
id: draggableId,
|
|
36
|
+
disabled: questionCount <= 1,
|
|
37
|
+
});
|
|
43
38
|
|
|
44
39
|
const style = {
|
|
45
40
|
transform: CSS.Translate.toString(transform),
|
|
@@ -50,12 +45,7 @@ export const DraggableQuestion: React.FC<DraggableQuestionProps> = ({
|
|
|
50
45
|
return (
|
|
51
46
|
<div className={dragStyles} style={style}>
|
|
52
47
|
<div className={styles.iconAndName}>
|
|
53
|
-
<div
|
|
54
|
-
className={styles.dragIconContainer}
|
|
55
|
-
ref={setNodeRef}
|
|
56
|
-
{...attributes}
|
|
57
|
-
{...listeners}
|
|
58
|
-
>
|
|
48
|
+
<div className={styles.dragIconContainer} ref={setNodeRef} {...attributes} {...listeners}>
|
|
59
49
|
<Draggable className={styles.dragIcon} size={16} />
|
|
60
50
|
</div>
|
|
61
51
|
<p className={styles.questionLabel}>{question.label}</p>
|
|
@@ -64,18 +54,15 @@ export const DraggableQuestion: React.FC<DraggableQuestionProps> = ({
|
|
|
64
54
|
<CopyButton
|
|
65
55
|
align="top"
|
|
66
56
|
className="cds--btn--sm"
|
|
67
|
-
feedback={t(
|
|
68
|
-
iconDescription={t(
|
|
57
|
+
feedback={t('duplicated', 'Duplicated') + '!'}
|
|
58
|
+
iconDescription={t('duplicateQuestion', 'Duplicate question')}
|
|
69
59
|
kind="ghost"
|
|
70
|
-
onClick={() =>
|
|
71
|
-
!isDragging &&
|
|
72
|
-
handleDuplicateQuestion(question, pageIndex, sectionIndex)
|
|
73
|
-
}
|
|
60
|
+
onClick={() => !isDragging && handleDuplicateQuestion(question, pageIndex, sectionIndex)}
|
|
74
61
|
/>
|
|
75
62
|
<Button
|
|
76
63
|
enterDelayMs={300}
|
|
77
64
|
hasIconOnly
|
|
78
|
-
iconDescription={t(
|
|
65
|
+
iconDescription={t('editQuestion', 'Edit question')}
|
|
79
66
|
kind="ghost"
|
|
80
67
|
onClick={() => {
|
|
81
68
|
if (!isDragging) {
|
|
@@ -88,7 +75,7 @@ export const DraggableQuestion: React.FC<DraggableQuestionProps> = ({
|
|
|
88
75
|
<Button
|
|
89
76
|
enterDelayMs={300}
|
|
90
77
|
hasIconOnly
|
|
91
|
-
iconDescription={t(
|
|
78
|
+
iconDescription={t('deleteQuestion', 'Delete question')}
|
|
92
79
|
kind="ghost"
|
|
93
80
|
onClick={handleDeleteButtonClick}
|
|
94
81
|
renderIcon={(props) => <TrashCan size={16} {...props} />}
|
|
@@ -33,14 +33,14 @@
|
|
|
33
33
|
cursor: pointer;
|
|
34
34
|
|
|
35
35
|
:hover {
|
|
36
|
-
background-color: colors.$
|
|
36
|
+
background-color: colors.$gray-20;
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
.dragIcon {
|
|
41
41
|
margin: 0 layout.$spacing-03;
|
|
42
42
|
padding: 0.25rem;
|
|
43
|
-
color: colors.$gray-
|
|
43
|
+
color: colors.$gray-80;
|
|
44
44
|
margin-top: 0.25rem;
|
|
45
45
|
width: 1.5rem;
|
|
46
46
|
height: 1.5rem;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { useDroppable } from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useDroppable } from '@dnd-kit/core';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface DroppableProps {
|
|
5
5
|
id: string;
|
|
6
6
|
children: React.ReactNode;
|
|
7
|
-
}
|
|
7
|
+
}
|
|
8
8
|
|
|
9
9
|
export function Droppable({ id, children }: DroppableProps) {
|
|
10
10
|
const { isOver, setNodeRef } = useDroppable({
|
|
@@ -12,7 +12,7 @@ export function Droppable({ id, children }: DroppableProps) {
|
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
const style = {
|
|
15
|
-
border: `1px solid ${isOver ?
|
|
15
|
+
border: `1px solid ${isOver ? '#005d5d' : 'transparent'}`,
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
return (
|