@openmrs/esm-form-builder-app 2.0.2-pre.559 → 2.0.2-pre.568
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/150.js +1 -1
- package/dist/150.js.map +1 -1
- package/dist/153.js +1 -1
- package/dist/252.js +2 -0
- package/dist/252.js.map +1 -0
- package/dist/256.js +1 -1
- package/dist/256.js.map +1 -1
- package/dist/447.js +1 -1
- package/dist/447.js.map +1 -1
- package/dist/879.js +2 -0
- package/dist/879.js.map +1 -0
- package/dist/main.js +1 -1
- package/dist/openmrs-esm-form-builder-app.js.buildmanifest.json +198 -198
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/components/dashboard/dashboard.component.tsx +0 -1
- package/src/components/form-editor/form-editor.component.tsx +48 -5
- package/src/components/form-editor/form-editor.scss +6 -0
- package/src/components/interactive-builder/draggable-question.component.tsx +23 -24
- package/src/components/interactive-builder/edit-question-modal.component.tsx +308 -317
- package/src/components/interactive-builder/editable-value.component.tsx +1 -1
- package/src/components/interactive-builder/interactive-builder.component.tsx +29 -31
- package/dist/682.js +0 -2
- package/dist/682.js.map +0 -1
- package/dist/990.js +0 -2
- package/dist/990.js.map +0 -1
- /package/dist/{682.js.LICENSE.txt → 252.js.LICENSE.txt} +0 -0
- /package/dist/{990.js.LICENSE.txt → 879.js.LICENSE.txt} +0 -0
|
@@ -2,24 +2,24 @@ import React from "react";
|
|
|
2
2
|
import { useDraggable } from "@dnd-kit/core";
|
|
3
3
|
import { CSS } from "@dnd-kit/utilities";
|
|
4
4
|
import { useTranslation } from "react-i18next";
|
|
5
|
-
import { Button } from "@carbon/react";
|
|
6
|
-
import {
|
|
5
|
+
import { Button, CopyButton } from "@carbon/react";
|
|
6
|
+
import { Draggable, Edit, TrashCan } from "@carbon/react/icons";
|
|
7
7
|
import type { Question } from "../../types";
|
|
8
8
|
import styles from "./draggable-question.scss";
|
|
9
9
|
|
|
10
10
|
type DraggableQuestionProps = {
|
|
11
|
-
allQuestions: Array<Question>;
|
|
12
11
|
question: Question;
|
|
13
12
|
pageIndex: number;
|
|
14
13
|
sectionIndex: number;
|
|
15
14
|
questionIndex: number;
|
|
16
|
-
|
|
15
|
+
handleDuplicateQuestion: (
|
|
17
16
|
question: Question,
|
|
18
17
|
pageId: number,
|
|
19
18
|
sectionId: number
|
|
20
19
|
) => void;
|
|
21
20
|
handleEditButtonClick: (question: Question) => void;
|
|
22
21
|
handleDeleteButtonClick: (question: Question) => void;
|
|
22
|
+
questionCount: number;
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
export const DraggableQuestion: React.FC<DraggableQuestionProps> = ({
|
|
@@ -27,10 +27,10 @@ export const DraggableQuestion: React.FC<DraggableQuestionProps> = ({
|
|
|
27
27
|
pageIndex,
|
|
28
28
|
sectionIndex,
|
|
29
29
|
questionIndex,
|
|
30
|
-
|
|
30
|
+
handleDuplicateQuestion,
|
|
31
31
|
handleDeleteButtonClick,
|
|
32
32
|
handleEditButtonClick,
|
|
33
|
-
|
|
33
|
+
questionCount,
|
|
34
34
|
}) => {
|
|
35
35
|
const { t } = useTranslation();
|
|
36
36
|
const draggableId = `question-${pageIndex}-${sectionIndex}-${questionIndex}`;
|
|
@@ -38,8 +38,9 @@ export const DraggableQuestion: React.FC<DraggableQuestionProps> = ({
|
|
|
38
38
|
const { attributes, listeners, transform, isDragging, setNodeRef } =
|
|
39
39
|
useDraggable({
|
|
40
40
|
id: draggableId,
|
|
41
|
-
disabled:
|
|
41
|
+
disabled: questionCount <= 1,
|
|
42
42
|
});
|
|
43
|
+
|
|
43
44
|
const style = {
|
|
44
45
|
transform: CSS.Translate.toString(transform),
|
|
45
46
|
};
|
|
@@ -60,40 +61,38 @@ export const DraggableQuestion: React.FC<DraggableQuestionProps> = ({
|
|
|
60
61
|
<p className={styles.questionLabel}>{question.label}</p>
|
|
61
62
|
</div>
|
|
62
63
|
<div className={styles.buttonsContainer}>
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
<CopyButton
|
|
65
|
+
align="top"
|
|
66
|
+
className="cds--btn--sm"
|
|
67
|
+
feedback={t("duplicated", "Duplicated") + "!"}
|
|
67
68
|
iconDescription={t("duplicateQuestion", "Duplicate question")}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
renderIcon={(props) => <Replicate size={16} {...props} />}
|
|
74
|
-
hasIconOnly
|
|
69
|
+
kind="ghost"
|
|
70
|
+
onClick={() =>
|
|
71
|
+
!isDragging &&
|
|
72
|
+
handleDuplicateQuestion(question, pageIndex, sectionIndex)
|
|
73
|
+
}
|
|
75
74
|
/>
|
|
76
75
|
<Button
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
enterDelayMs={200}
|
|
76
|
+
enterDelayMs={300}
|
|
77
|
+
hasIconOnly
|
|
80
78
|
iconDescription={t("editQuestion", "Edit question")}
|
|
79
|
+
kind="ghost"
|
|
81
80
|
onClick={() => {
|
|
82
81
|
if (!isDragging) {
|
|
83
82
|
handleEditButtonClick(question);
|
|
84
83
|
}
|
|
85
84
|
}}
|
|
86
85
|
renderIcon={(props) => <Edit size={16} {...props} />}
|
|
87
|
-
|
|
86
|
+
size="md"
|
|
88
87
|
/>
|
|
89
88
|
<Button
|
|
89
|
+
enterDelayMs={300}
|
|
90
90
|
hasIconOnly
|
|
91
|
-
enterDelayMs={200}
|
|
92
91
|
iconDescription={t("deleteQuestion", "Delete question")}
|
|
93
92
|
kind="ghost"
|
|
94
93
|
onClick={handleDeleteButtonClick}
|
|
95
94
|
renderIcon={(props) => <TrashCan size={16} {...props} />}
|
|
96
|
-
size="
|
|
95
|
+
size="md"
|
|
97
96
|
/>
|
|
98
97
|
</div>
|
|
99
98
|
</div>
|