@openmrs/esm-form-builder-app 2.0.2-pre.536 → 2.0.2-pre.548
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/openmrs-esm-form-builder-app.js.buildmanifest.json +3 -3
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/components/dashboard/dashboard.component.tsx +29 -5
- package/src/components/dashboard/dashboard.scss +42 -11
- package/src/components/empty-state/empty-state.scss +5 -5
- package/src/components/error-state/error-state.scss +5 -5
- package/src/components/form-editor/form-editor.component.tsx +147 -28
- package/src/components/form-editor/form-editor.scss +27 -3
- package/src/components/form-renderer/form-renderer.component.tsx +25 -35
- package/src/components/form-renderer/form-renderer.scss +2 -3
- package/src/components/interactive-builder/draggable-question.scss +10 -9
- package/src/components/interactive-builder/editable-value.scss +0 -1
- package/src/components/interactive-builder/interactive-builder.component.tsx +5 -8
- package/src/components/interactive-builder/interactive-builder.scss +3 -7
- package/src/components/interactive-builder/question-modal.scss +13 -13
- package/src/components/pagination/pagination.scss +5 -5
- package/src/components/schema-editor/schema-editor.component.tsx +7 -145
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
} from "@dnd-kit/core";
|
|
15
15
|
|
|
16
16
|
import type { Question, RouteParams, Schema } from "../../types";
|
|
17
|
-
import ActionButtons from "../action-buttons/action-buttons.component";
|
|
18
17
|
import AddQuestionModal from "./add-question-modal.component";
|
|
19
18
|
import DeleteSectionModal from "./delete-section-modal.component";
|
|
20
19
|
import DeletePageModal from "./delete-page-modal.component";
|
|
@@ -42,7 +41,7 @@ const InteractiveBuilder: React.FC<InteractiveBuilderProps> = ({
|
|
|
42
41
|
}) => {
|
|
43
42
|
const mouseSensor = useSensor(MouseSensor, {
|
|
44
43
|
activationConstraint: {
|
|
45
|
-
distance: 10, // Enable sort function when dragging 10px
|
|
44
|
+
distance: 10, // Enable sort function when dragging 10px 💡 here!!!
|
|
46
45
|
},
|
|
47
46
|
});
|
|
48
47
|
const keyboardSensor = useSensor(KeyboardSensor);
|
|
@@ -301,8 +300,6 @@ const InteractiveBuilder: React.FC<InteractiveBuilderProps> = ({
|
|
|
301
300
|
/>
|
|
302
301
|
) : null}
|
|
303
302
|
|
|
304
|
-
<ActionButtons schema={schema} t={t} />
|
|
305
|
-
|
|
306
303
|
{showNewFormModal ? (
|
|
307
304
|
<NewFormModal
|
|
308
305
|
schema={schema}
|
|
@@ -422,7 +419,7 @@ const InteractiveBuilder: React.FC<InteractiveBuilderProps> = ({
|
|
|
422
419
|
</p>
|
|
423
420
|
</div>
|
|
424
421
|
<Button
|
|
425
|
-
kind="
|
|
422
|
+
kind="ghost"
|
|
426
423
|
renderIcon={Add}
|
|
427
424
|
onClick={addPage}
|
|
428
425
|
iconDescription={t("addPage", "Add Page")}
|
|
@@ -453,7 +450,7 @@ const InteractiveBuilder: React.FC<InteractiveBuilderProps> = ({
|
|
|
453
450
|
<Button
|
|
454
451
|
onClick={launchNewFormModal}
|
|
455
452
|
className={styles.startButton}
|
|
456
|
-
kind="
|
|
453
|
+
kind="ghost"
|
|
457
454
|
>
|
|
458
455
|
{t("startBuilding", "Start building")}
|
|
459
456
|
</Button>
|
|
@@ -559,7 +556,7 @@ const InteractiveBuilder: React.FC<InteractiveBuilderProps> = ({
|
|
|
559
556
|
|
|
560
557
|
<Button
|
|
561
558
|
className={styles.addQuestionButton}
|
|
562
|
-
kind="
|
|
559
|
+
kind="ghost"
|
|
563
560
|
renderIcon={Add}
|
|
564
561
|
onClick={() => {
|
|
565
562
|
addQuestion();
|
|
@@ -590,7 +587,7 @@ const InteractiveBuilder: React.FC<InteractiveBuilderProps> = ({
|
|
|
590
587
|
</div>
|
|
591
588
|
<Button
|
|
592
589
|
className={styles.addSectionButton}
|
|
593
|
-
kind="
|
|
590
|
+
kind="ghost"
|
|
594
591
|
renderIcon={Add}
|
|
595
592
|
onClick={() => {
|
|
596
593
|
addSection();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
@use '@carbon/styles/scss/colors';
|
|
1
2
|
@use '@carbon/styles/scss/type';
|
|
2
|
-
@import '~@openmrs/esm-styleguide/src/vars';
|
|
3
3
|
|
|
4
4
|
.container {
|
|
5
5
|
:global(.cds--modal-content:focus) {
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
|
|
52
52
|
.editableFieldsContainer {
|
|
53
53
|
margin: 1rem 0;
|
|
54
|
-
border-bottom: 1px solid
|
|
54
|
+
border-bottom: 1px solid colors.$gray-20;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
.addQuestionButton {
|
|
@@ -96,10 +96,6 @@
|
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
98
|
|
|
99
|
-
.questionLabel {
|
|
100
|
-
@include type.type-style('body-01');
|
|
101
|
-
}
|
|
102
|
-
|
|
103
99
|
.addSectionButton {
|
|
104
|
-
margin:
|
|
100
|
+
margin: 1rem 1rem;
|
|
105
101
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
@use '@carbon/styles/scss/colors';
|
|
1
2
|
@use '@carbon/styles/scss/type';
|
|
2
|
-
@import '~@openmrs/esm-styleguide/src/vars';
|
|
3
3
|
|
|
4
4
|
.label {
|
|
5
5
|
margin-bottom: 0.5rem;
|
|
@@ -18,20 +18,20 @@
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
.conceptList {
|
|
21
|
-
background: white;
|
|
21
|
+
background: colors.$white-0;
|
|
22
22
|
max-height: 14rem;
|
|
23
23
|
overflow-y: auto;
|
|
24
|
-
border: 1px solid
|
|
24
|
+
border: 1px solid colors.$gray-20;
|
|
25
25
|
border-top: none;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
.conceptList li:hover {
|
|
29
|
-
background-color:
|
|
29
|
+
background-color: colors.$gray-20;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
.concept {
|
|
33
33
|
padding: 0.75rem;
|
|
34
|
-
border-bottom: 1px solid
|
|
34
|
+
border-bottom: 1px solid colors.$gray-20;
|
|
35
35
|
|
|
36
36
|
&:last-of-type {
|
|
37
37
|
border-bottom: none;
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
|
|
41
41
|
.emptyResults {
|
|
42
42
|
@include type.type-style("body-compact-01");
|
|
43
|
-
color:
|
|
43
|
+
color: colors.$gray-70;
|
|
44
44
|
min-height: 1rem;
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -49,15 +49,15 @@
|
|
|
49
49
|
display: flex;
|
|
50
50
|
justify-content: space-between;
|
|
51
51
|
align-items: center;
|
|
52
|
-
background-color:
|
|
52
|
+
background-color: colors.$gray-50;
|
|
53
53
|
|
|
54
54
|
p {
|
|
55
|
-
color:
|
|
55
|
+
color: colors.$white-0;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
.oclLink {
|
|
60
|
-
color:
|
|
60
|
+
color: colors.$blue-10;
|
|
61
61
|
display: flex;
|
|
62
62
|
align-items: center;
|
|
63
63
|
|
|
@@ -70,13 +70,13 @@
|
|
|
70
70
|
width: 100%;
|
|
71
71
|
|
|
72
72
|
tr {
|
|
73
|
-
background-color:
|
|
74
|
-
border: 1px solid
|
|
73
|
+
background-color: colors.$white-0;
|
|
74
|
+
border: 1px solid colors.$gray-20;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
td, th {
|
|
78
78
|
padding: 0.25rem;
|
|
79
|
-
border: 1px solid
|
|
79
|
+
border: 1px solid colors.$gray-20;
|
|
80
80
|
max-width: 10rem;
|
|
81
81
|
text-align: left;
|
|
82
82
|
}
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
tbody > tr:nth-child(odd) {
|
|
93
|
-
background-color:
|
|
93
|
+
background-color: colors.$gray-10;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
@use '@carbon/styles/scss/colors';
|
|
1
2
|
@use '@carbon/styles/scss/spacing';
|
|
2
3
|
@use '@carbon/styles/scss/type';
|
|
3
|
-
@import '~@openmrs/esm-styleguide/src/vars';
|
|
4
4
|
|
|
5
5
|
.bodyShort01 {
|
|
6
6
|
@include type.type-style("body-compact-01");
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
@include type.type-style('body-compact-01');
|
|
11
11
|
display: flex;
|
|
12
12
|
justify-content: space-between;
|
|
13
|
-
color:
|
|
14
|
-
background-color:
|
|
13
|
+
color: colors.$gray-70;
|
|
14
|
+
background-color: colors.$white-0;
|
|
15
15
|
padding-left: 1rem;
|
|
16
16
|
align-items: center;
|
|
17
17
|
}
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
|
|
49
49
|
.pagination {
|
|
50
50
|
@include type.type-style('body-compact-01');
|
|
51
|
-
background-color:
|
|
52
|
-
color:
|
|
51
|
+
background-color: colors.$white-0;
|
|
52
|
+
color: colors.$gray-70;
|
|
53
53
|
display: flex;
|
|
54
54
|
}
|
|
55
55
|
|
|
@@ -1,164 +1,26 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import { useParams } from "react-router-dom";
|
|
1
|
+
import React from "react";
|
|
3
2
|
import AceEditor from "react-ace";
|
|
4
3
|
import "ace-builds/webpack-resolver";
|
|
5
4
|
import "ace-builds/src-noconflict/ext-language_tools";
|
|
6
|
-
import { Button, InlineLoading } from "@carbon/react";
|
|
7
5
|
import { useTranslation } from "react-i18next";
|
|
8
|
-
import { OHRIFormSchema } from "@openmrs/openmrs-form-engine-lib";
|
|
9
|
-
|
|
10
|
-
import { RouteParams, Schema } from "../../types";
|
|
11
6
|
import styles from "./schema-editor.scss";
|
|
12
7
|
|
|
13
8
|
type SchemaEditorProps = {
|
|
14
9
|
isLoading: boolean;
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
invalidJsonErrorMessage: string;
|
|
11
|
+
onSchemaChange: (stringifiedSchema: string) => void;
|
|
12
|
+
stringifiedSchema: string;
|
|
17
13
|
};
|
|
18
14
|
|
|
19
15
|
const SchemaEditor: React.FC<SchemaEditorProps> = ({
|
|
20
|
-
|
|
16
|
+
invalidJsonErrorMessage,
|
|
21
17
|
onSchemaChange,
|
|
22
|
-
|
|
18
|
+
stringifiedSchema,
|
|
23
19
|
}) => {
|
|
24
20
|
const { t } = useTranslation();
|
|
25
|
-
const { formUuid } = useParams<RouteParams>();
|
|
26
|
-
const isNewSchema = !formUuid;
|
|
27
|
-
|
|
28
|
-
const [stringifiedSchema, setStringifiedSchema] = useState(
|
|
29
|
-
schema ? JSON.stringify(schema, null, 2) : ""
|
|
30
|
-
);
|
|
31
|
-
const [invalidJsonErrorMessage, setInvalidJsonErrorMessage] = useState("");
|
|
32
|
-
const [isRendering, setIsRendering] = useState(false);
|
|
33
|
-
|
|
34
|
-
const resetErrorMessage = useCallback(() => {
|
|
35
|
-
setInvalidJsonErrorMessage("");
|
|
36
|
-
}, []);
|
|
37
|
-
|
|
38
|
-
const handleSchemaChange = useCallback((updatedSchema: string) => {
|
|
39
|
-
setStringifiedSchema(updatedSchema);
|
|
40
|
-
}, []);
|
|
41
|
-
|
|
42
|
-
const inputDummySchema = useCallback(() => {
|
|
43
|
-
const dummySchema: OHRIFormSchema = {
|
|
44
|
-
encounterType: "",
|
|
45
|
-
name: "Sample Form",
|
|
46
|
-
processor: "EncounterFormProcessor",
|
|
47
|
-
referencedForms: [],
|
|
48
|
-
uuid: "",
|
|
49
|
-
version: "1.0",
|
|
50
|
-
pages: [
|
|
51
|
-
{
|
|
52
|
-
label: "First Page",
|
|
53
|
-
sections: [
|
|
54
|
-
{
|
|
55
|
-
label: "A Section",
|
|
56
|
-
isExpanded: "true",
|
|
57
|
-
questions: [
|
|
58
|
-
{
|
|
59
|
-
label: "A Question of type obs that renders a text input",
|
|
60
|
-
type: "obs",
|
|
61
|
-
questionOptions: {
|
|
62
|
-
rendering: "text",
|
|
63
|
-
concept: "a-system-defined-concept-uuid",
|
|
64
|
-
},
|
|
65
|
-
id: "sampleQuestion",
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
label: "Another Section",
|
|
71
|
-
isExpanded: "true",
|
|
72
|
-
questions: [
|
|
73
|
-
{
|
|
74
|
-
label:
|
|
75
|
-
"Another Question of type obs whose answers get rendered as radio inputs",
|
|
76
|
-
type: "obs",
|
|
77
|
-
questionOptions: {
|
|
78
|
-
rendering: "radio",
|
|
79
|
-
concept: "system-defined-concept-uuid",
|
|
80
|
-
answers: [
|
|
81
|
-
{
|
|
82
|
-
concept: "another-system-defined-concept-uuid",
|
|
83
|
-
label: "Choice 1",
|
|
84
|
-
conceptMappings: [],
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
concept: "yet-another-system-defined-concept-uuid",
|
|
88
|
-
label: "Choice 2",
|
|
89
|
-
conceptMappings: [],
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
concept: "yet-one-more-system-defined-concept-uuid",
|
|
93
|
-
label: "Choice 3",
|
|
94
|
-
conceptMappings: [],
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
id: "anotherSampleQuestion",
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
},
|
|
102
|
-
],
|
|
103
|
-
},
|
|
104
|
-
],
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
setStringifiedSchema(JSON.stringify(dummySchema, null, 2));
|
|
108
|
-
onSchemaChange({ ...dummySchema });
|
|
109
|
-
}, [onSchemaChange]);
|
|
110
|
-
|
|
111
|
-
const renderSchemaChanges = useCallback(() => {
|
|
112
|
-
setIsRendering(true);
|
|
113
|
-
resetErrorMessage();
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
const parsedJson: Schema = JSON.parse(stringifiedSchema);
|
|
117
|
-
onSchemaChange(parsedJson);
|
|
118
|
-
setStringifiedSchema(JSON.stringify(parsedJson, null, 2));
|
|
119
|
-
} catch (error) {
|
|
120
|
-
setInvalidJsonErrorMessage(error.message);
|
|
121
|
-
}
|
|
122
|
-
setIsRendering(false);
|
|
123
|
-
}, [stringifiedSchema, onSchemaChange, resetErrorMessage]);
|
|
124
|
-
|
|
125
|
-
useEffect(() => {
|
|
126
|
-
setStringifiedSchema(JSON.stringify(schema, null, 2));
|
|
127
|
-
}, [schema]);
|
|
128
21
|
|
|
129
22
|
return (
|
|
130
23
|
<>
|
|
131
|
-
<div className={styles.actionButtons}>
|
|
132
|
-
{isLoading ? (
|
|
133
|
-
<InlineLoading
|
|
134
|
-
description={t("loadingSchema", "Loading schema") + "..."}
|
|
135
|
-
/>
|
|
136
|
-
) : null}
|
|
137
|
-
|
|
138
|
-
{isNewSchema && !stringifiedSchema ? (
|
|
139
|
-
<Button kind="secondary" onClick={inputDummySchema}>
|
|
140
|
-
{t("inputDummySchema", "Input dummy schema")}
|
|
141
|
-
</Button>
|
|
142
|
-
) : null}
|
|
143
|
-
|
|
144
|
-
{schema ? (
|
|
145
|
-
<Button
|
|
146
|
-
disabled={isRendering}
|
|
147
|
-
kind="primary"
|
|
148
|
-
onClick={renderSchemaChanges}
|
|
149
|
-
>
|
|
150
|
-
{isRendering ? (
|
|
151
|
-
<InlineLoading
|
|
152
|
-
className={styles.spinner}
|
|
153
|
-
description={t("render", "Render" + "...")}
|
|
154
|
-
/>
|
|
155
|
-
) : (
|
|
156
|
-
<span>{t("renderChanges", "Render changes")}</span>
|
|
157
|
-
)}
|
|
158
|
-
</Button>
|
|
159
|
-
) : null}
|
|
160
|
-
</div>
|
|
161
|
-
|
|
162
24
|
{invalidJsonErrorMessage ? (
|
|
163
25
|
<div className={styles.errorContainer}>
|
|
164
26
|
<p className={styles.heading}>
|
|
@@ -173,7 +35,7 @@ const SchemaEditor: React.FC<SchemaEditorProps> = ({
|
|
|
173
35
|
mode="json"
|
|
174
36
|
theme="textmate"
|
|
175
37
|
name="schemaEditor"
|
|
176
|
-
onChange={
|
|
38
|
+
onChange={onSchemaChange}
|
|
177
39
|
fontSize={15}
|
|
178
40
|
showPrintMargin={false}
|
|
179
41
|
showGutter={true}
|