@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
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React, { useCallback, useMemo, useState } from
|
|
2
|
-
import { TFunction
|
|
1
|
+
import React, { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import type { TFunction } from 'i18next';
|
|
3
|
+
import { useTranslation } from 'react-i18next';
|
|
3
4
|
import {
|
|
4
5
|
Button,
|
|
5
6
|
ComposedModal,
|
|
@@ -24,33 +25,27 @@ import {
|
|
|
24
25
|
TableToolbarSearch,
|
|
25
26
|
Tag,
|
|
26
27
|
Tile,
|
|
27
|
-
} from
|
|
28
|
+
} from '@carbon/react';
|
|
29
|
+
import { Add, DocumentImport, Download, Edit, TrashCan } from '@carbon/react/icons';
|
|
28
30
|
import {
|
|
29
|
-
|
|
30
|
-
DocumentImport,
|
|
31
|
-
Download,
|
|
32
|
-
Edit,
|
|
33
|
-
TrashCan,
|
|
34
|
-
} from "@carbon/react/icons";
|
|
35
|
-
import {
|
|
36
|
-
FetchResponse,
|
|
31
|
+
type FetchResponse,
|
|
37
32
|
navigate,
|
|
38
33
|
showNotification,
|
|
39
34
|
showToast,
|
|
40
35
|
useConfig,
|
|
41
36
|
useLayoutType,
|
|
42
37
|
usePagination,
|
|
43
|
-
} from
|
|
44
|
-
import type { KeyedMutator } from
|
|
45
|
-
|
|
46
|
-
import type { Form as FormType } from
|
|
47
|
-
import { deleteForm } from
|
|
48
|
-
import { FormBuilderPagination } from
|
|
49
|
-
import { useClobdata } from
|
|
50
|
-
import { useForms } from
|
|
51
|
-
import EmptyState from
|
|
52
|
-
import ErrorState from
|
|
53
|
-
import styles from
|
|
38
|
+
} from '@openmrs/esm-framework';
|
|
39
|
+
import type { KeyedMutator } from 'swr';
|
|
40
|
+
|
|
41
|
+
import type { Form as FormType } from '../../types';
|
|
42
|
+
import { deleteForm } from '../../forms.resource';
|
|
43
|
+
import { FormBuilderPagination } from '../pagination';
|
|
44
|
+
import { useClobdata } from '../../hooks/useClobdata';
|
|
45
|
+
import { useForms } from '../../hooks/useForms';
|
|
46
|
+
import EmptyState from '../empty-state/empty-state.component';
|
|
47
|
+
import ErrorState from '../error-state/error-state.component';
|
|
48
|
+
import styles from './dashboard.scss';
|
|
54
49
|
|
|
55
50
|
type Mutator = KeyedMutator<{
|
|
56
51
|
data: {
|
|
@@ -58,44 +53,39 @@ type Mutator = KeyedMutator<{
|
|
|
58
53
|
};
|
|
59
54
|
}>;
|
|
60
55
|
|
|
61
|
-
|
|
56
|
+
interface ActionButtonsProps {
|
|
62
57
|
form: FormType;
|
|
63
58
|
mutate: Mutator;
|
|
64
59
|
responsiveSize: string;
|
|
65
60
|
t: TFunction;
|
|
66
|
-
}
|
|
61
|
+
}
|
|
67
62
|
|
|
68
|
-
|
|
63
|
+
interface FormsListProps {
|
|
69
64
|
forms: Array<FormType>;
|
|
70
65
|
isValidating: boolean;
|
|
71
66
|
mutate: Mutator;
|
|
72
67
|
t: TFunction;
|
|
73
|
-
}
|
|
68
|
+
}
|
|
74
69
|
|
|
75
|
-
function CustomTag({ condition }: { condition
|
|
70
|
+
function CustomTag({ condition }: { condition?: boolean }) {
|
|
76
71
|
const { t } = useTranslation();
|
|
77
72
|
|
|
78
73
|
if (condition) {
|
|
79
74
|
return (
|
|
80
75
|
<Tag type="green" size="md" title="Clear Filter" data-testid="yes-tag">
|
|
81
|
-
{t(
|
|
76
|
+
{t('yes', 'Yes')}
|
|
82
77
|
</Tag>
|
|
83
78
|
);
|
|
84
79
|
}
|
|
85
80
|
|
|
86
81
|
return (
|
|
87
82
|
<Tag type="red" size="md" title="Clear Filter" data-testid="no-tag">
|
|
88
|
-
{t(
|
|
83
|
+
{t('no', 'No')}
|
|
89
84
|
</Tag>
|
|
90
85
|
);
|
|
91
86
|
}
|
|
92
87
|
|
|
93
|
-
function ActionButtons({
|
|
94
|
-
form,
|
|
95
|
-
mutate,
|
|
96
|
-
responsiveSize,
|
|
97
|
-
t,
|
|
98
|
-
}: ActionButtonsProps) {
|
|
88
|
+
function ActionButtons({ form, mutate, responsiveSize, t }: ActionButtonsProps) {
|
|
99
89
|
const { clobdata } = useClobdata(form);
|
|
100
90
|
const formResources = form?.resources;
|
|
101
91
|
const [showDeleteFormModal, setShowDeleteFormModal] = useState(false);
|
|
@@ -104,51 +94,47 @@ function ActionButtons({
|
|
|
104
94
|
const downloadableSchema = useMemo(
|
|
105
95
|
() =>
|
|
106
96
|
new Blob([JSON.stringify(clobdata, null, 2)], {
|
|
107
|
-
type:
|
|
97
|
+
type: 'application/json',
|
|
108
98
|
}),
|
|
109
|
-
[clobdata]
|
|
99
|
+
[clobdata],
|
|
110
100
|
);
|
|
111
101
|
|
|
112
102
|
const handleDeleteForm = useCallback(
|
|
113
103
|
(formUuid: string) => {
|
|
114
104
|
deleteForm(formUuid)
|
|
115
|
-
.then((res: FetchResponse) => {
|
|
105
|
+
.then(async (res: FetchResponse) => {
|
|
116
106
|
if (res.status === 204) {
|
|
117
107
|
showToast({
|
|
118
|
-
title: t(
|
|
119
|
-
kind:
|
|
108
|
+
title: t('formDeleted', 'Form deleted'),
|
|
109
|
+
kind: 'success',
|
|
120
110
|
critical: true,
|
|
121
|
-
description:
|
|
122
|
-
`${form.name} ` +
|
|
123
|
-
t("formDeletedSuccessfully", "deleted successfully"),
|
|
111
|
+
description: `${form.name} ` + t('formDeletedSuccessfully', 'deleted successfully'),
|
|
124
112
|
});
|
|
125
113
|
|
|
126
|
-
mutate();
|
|
114
|
+
await mutate();
|
|
127
115
|
setShowDeleteFormModal(false);
|
|
128
116
|
}
|
|
129
117
|
})
|
|
130
118
|
.catch((e: Error) =>
|
|
131
119
|
showNotification({
|
|
132
|
-
title: t(
|
|
133
|
-
kind:
|
|
120
|
+
title: t('errorDeletingForm', 'Error deleting form'),
|
|
121
|
+
kind: 'error',
|
|
134
122
|
critical: true,
|
|
135
123
|
description: e?.message,
|
|
136
|
-
})
|
|
124
|
+
}),
|
|
137
125
|
)
|
|
138
126
|
.finally(() => setIsDeleting(false));
|
|
139
127
|
},
|
|
140
|
-
[form.name, mutate, t]
|
|
128
|
+
[form.name, mutate, t],
|
|
141
129
|
);
|
|
142
130
|
|
|
143
131
|
const ImportButton = () => {
|
|
144
132
|
return (
|
|
145
133
|
<Button
|
|
146
134
|
renderIcon={DocumentImport}
|
|
147
|
-
onClick={() =>
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
kind={"ghost"}
|
|
151
|
-
iconDescription={t("import", "Import")}
|
|
135
|
+
onClick={() => navigate({ to: `${window.spaBase}/form-builder/edit/${form.uuid}` })}
|
|
136
|
+
kind={'ghost'}
|
|
137
|
+
iconDescription={t('import', 'Import')}
|
|
152
138
|
hasIconOnly
|
|
153
139
|
size={responsiveSize}
|
|
154
140
|
/>
|
|
@@ -165,8 +151,8 @@ function ActionButtons({
|
|
|
165
151
|
to: `${window.spaBase}/form-builder/edit/${form.uuid}`,
|
|
166
152
|
})
|
|
167
153
|
}
|
|
168
|
-
kind={
|
|
169
|
-
iconDescription={t(
|
|
154
|
+
kind={'ghost'}
|
|
155
|
+
iconDescription={t('editSchema', 'Edit schema')}
|
|
170
156
|
hasIconOnly
|
|
171
157
|
size={responsiveSize}
|
|
172
158
|
tooltipAlignment="start"
|
|
@@ -176,15 +162,12 @@ function ActionButtons({
|
|
|
176
162
|
|
|
177
163
|
const DownloadSchemaButton = () => {
|
|
178
164
|
return (
|
|
179
|
-
<a
|
|
180
|
-
download={`${form?.name}.json`}
|
|
181
|
-
href={window.URL.createObjectURL(downloadableSchema)}
|
|
182
|
-
>
|
|
165
|
+
<a download={`${form?.name}.json`} href={window.URL.createObjectURL(downloadableSchema)}>
|
|
183
166
|
<Button
|
|
184
167
|
enterDelayMs={300}
|
|
185
168
|
renderIcon={Download}
|
|
186
|
-
kind={
|
|
187
|
-
iconDescription={t(
|
|
169
|
+
kind={'ghost'}
|
|
170
|
+
iconDescription={t('downloadSchema', 'Download schema')}
|
|
188
171
|
hasIconOnly
|
|
189
172
|
size={responsiveSize}
|
|
190
173
|
tooltipAlignment="start"
|
|
@@ -199,8 +182,8 @@ function ActionButtons({
|
|
|
199
182
|
enterDelayMs={300}
|
|
200
183
|
renderIcon={TrashCan}
|
|
201
184
|
onClick={() => setShowDeleteFormModal(true)}
|
|
202
|
-
kind={
|
|
203
|
-
iconDescription={t(
|
|
185
|
+
kind={'ghost'}
|
|
186
|
+
iconDescription={t('deleteSchema', 'Delete schema')}
|
|
204
187
|
hasIconOnly
|
|
205
188
|
size={responsiveSize}
|
|
206
189
|
tooltipAlignment="start"
|
|
@@ -216,23 +199,15 @@ function ActionButtons({
|
|
|
216
199
|
onClose={() => setShowDeleteFormModal(false)}
|
|
217
200
|
preventCloseOnClickOutside
|
|
218
201
|
>
|
|
219
|
-
<ModalHeader title={t(
|
|
220
|
-
<Form onSubmit={(event) => event.preventDefault()}>
|
|
202
|
+
<ModalHeader title={t('deleteForm', 'Delete form')} />
|
|
203
|
+
<Form onSubmit={(event: React.SyntheticEvent) => event.preventDefault()}>
|
|
221
204
|
<ModalBody>
|
|
222
|
-
<p>
|
|
223
|
-
{t(
|
|
224
|
-
"deleteFormConfirmation",
|
|
225
|
-
"Are you sure you want to delete this form?"
|
|
226
|
-
)}
|
|
227
|
-
</p>
|
|
205
|
+
<p>{t('deleteFormConfirmation', 'Are you sure you want to delete this form?')}</p>
|
|
228
206
|
</ModalBody>
|
|
229
207
|
</Form>
|
|
230
208
|
<ModalFooter>
|
|
231
|
-
<Button
|
|
232
|
-
|
|
233
|
-
onClick={() => setShowDeleteFormModal(false)}
|
|
234
|
-
>
|
|
235
|
-
{t("cancel", "Cancel")}
|
|
209
|
+
<Button kind="secondary" onClick={() => setShowDeleteFormModal(false)}>
|
|
210
|
+
{t('cancel', 'Cancel')}
|
|
236
211
|
</Button>
|
|
237
212
|
<Button
|
|
238
213
|
disabled={isDeleting}
|
|
@@ -243,12 +218,9 @@ function ActionButtons({
|
|
|
243
218
|
}}
|
|
244
219
|
>
|
|
245
220
|
{isDeleting ? (
|
|
246
|
-
<InlineLoading
|
|
247
|
-
className={styles.spinner}
|
|
248
|
-
description={t("deleting", "Deleting") + "..."}
|
|
249
|
-
/>
|
|
221
|
+
<InlineLoading className={styles.spinner} description={t('deleting', 'Deleting') + '...'} />
|
|
250
222
|
) : (
|
|
251
|
-
<span>{t(
|
|
223
|
+
<span>{t('delete', 'Delete')}</span>
|
|
252
224
|
)}
|
|
253
225
|
</Button>
|
|
254
226
|
</ModalFooter>
|
|
@@ -267,17 +239,17 @@ function ActionButtons({
|
|
|
267
239
|
</>
|
|
268
240
|
)}
|
|
269
241
|
<DeleteButton />
|
|
270
|
-
{
|
|
242
|
+
{showDeleteFormModal && <DeleteFormModal />}
|
|
271
243
|
</>
|
|
272
244
|
);
|
|
273
245
|
}
|
|
274
246
|
|
|
275
247
|
function FormsList({ forms, isValidating, mutate, t }: FormsListProps) {
|
|
276
248
|
const config = useConfig();
|
|
277
|
-
const isTablet = useLayoutType() ===
|
|
278
|
-
const responsiveSize = isTablet ?
|
|
279
|
-
const [filter, setFilter] = useState(
|
|
280
|
-
const [searchString, setSearchString] = useState(
|
|
249
|
+
const isTablet = useLayoutType() === 'tablet';
|
|
250
|
+
const responsiveSize = isTablet ? 'lg' : 'sm';
|
|
251
|
+
const [filter, setFilter] = useState('');
|
|
252
|
+
const [searchString, setSearchString] = useState('');
|
|
281
253
|
const pageSize = 10;
|
|
282
254
|
|
|
283
255
|
const filteredRows = useMemo(() => {
|
|
@@ -285,11 +257,11 @@ function FormsList({ forms, isValidating, mutate, t }: FormsListProps) {
|
|
|
285
257
|
return forms;
|
|
286
258
|
}
|
|
287
259
|
|
|
288
|
-
if (filter ===
|
|
260
|
+
if (filter === 'Published') {
|
|
289
261
|
return forms.filter((form) => form.published);
|
|
290
262
|
}
|
|
291
263
|
|
|
292
|
-
if (filter ===
|
|
264
|
+
if (filter === 'Unpublished') {
|
|
293
265
|
return forms.filter((form) => !form.published);
|
|
294
266
|
}
|
|
295
267
|
|
|
@@ -298,69 +270,53 @@ function FormsList({ forms, isValidating, mutate, t }: FormsListProps) {
|
|
|
298
270
|
|
|
299
271
|
const tableHeaders = [
|
|
300
272
|
{
|
|
301
|
-
header: t(
|
|
302
|
-
key:
|
|
273
|
+
header: t('name', 'Name'),
|
|
274
|
+
key: 'name',
|
|
303
275
|
},
|
|
304
276
|
{
|
|
305
|
-
header: t(
|
|
306
|
-
key:
|
|
277
|
+
header: t('version', 'Version'),
|
|
278
|
+
key: 'version',
|
|
307
279
|
},
|
|
308
280
|
{
|
|
309
|
-
header: t(
|
|
310
|
-
key:
|
|
281
|
+
header: t('published', 'Published'),
|
|
282
|
+
key: 'published',
|
|
311
283
|
},
|
|
312
284
|
{
|
|
313
|
-
header: t(
|
|
314
|
-
key:
|
|
285
|
+
header: t('retired', 'Retired'),
|
|
286
|
+
key: 'retired',
|
|
315
287
|
},
|
|
316
288
|
{
|
|
317
|
-
header: t(
|
|
318
|
-
key:
|
|
289
|
+
header: t('schemaActions', 'Schema actions'),
|
|
290
|
+
key: 'actions',
|
|
319
291
|
},
|
|
320
292
|
];
|
|
321
293
|
|
|
322
294
|
const searchResults = useMemo(() => {
|
|
323
|
-
if (searchString && searchString.trim() !==
|
|
324
|
-
return filteredRows.filter((form) =>
|
|
325
|
-
form.name.toLowerCase().includes(searchString.toLowerCase())
|
|
326
|
-
);
|
|
295
|
+
if (searchString && searchString.trim() !== '') {
|
|
296
|
+
return filteredRows.filter((form) => form.name.toLowerCase().includes(searchString.toLowerCase()));
|
|
327
297
|
}
|
|
328
298
|
|
|
329
299
|
return filteredRows;
|
|
330
300
|
}, [searchString, filteredRows]);
|
|
331
301
|
|
|
332
|
-
const { paginated, goTo, results, currentPage } = usePagination(
|
|
333
|
-
searchResults,
|
|
334
|
-
pageSize
|
|
335
|
-
);
|
|
302
|
+
const { paginated, goTo, results, currentPage } = usePagination(searchResults, pageSize);
|
|
336
303
|
|
|
337
304
|
const tableRows = results?.map((form: FormType) => ({
|
|
338
305
|
...form,
|
|
339
306
|
id: form?.uuid,
|
|
340
|
-
published: <CustomTag condition={form
|
|
341
|
-
retired: <CustomTag condition={form
|
|
342
|
-
actions:
|
|
343
|
-
<ActionButtons
|
|
344
|
-
form={form}
|
|
345
|
-
mutate={mutate}
|
|
346
|
-
responsiveSize={responsiveSize}
|
|
347
|
-
t={t}
|
|
348
|
-
/>
|
|
349
|
-
),
|
|
307
|
+
published: <CustomTag condition={form.published} />,
|
|
308
|
+
retired: <CustomTag condition={form.retired} />,
|
|
309
|
+
actions: <ActionButtons form={form} mutate={mutate} responsiveSize={responsiveSize} t={t} />,
|
|
350
310
|
}));
|
|
351
311
|
|
|
352
|
-
const handlePublishStatusChange = ({
|
|
353
|
-
selectedItem,
|
|
354
|
-
}: {
|
|
355
|
-
selectedItem: string;
|
|
356
|
-
}) => setFilter(selectedItem);
|
|
312
|
+
const handlePublishStatusChange = ({ selectedItem }: { selectedItem: string }) => setFilter(selectedItem);
|
|
357
313
|
|
|
358
314
|
const handleSearch = useCallback(
|
|
359
|
-
(e) => {
|
|
315
|
+
(e: React.ChangeEvent<HTMLInputElement>) => {
|
|
360
316
|
goTo(1);
|
|
361
317
|
setSearchString(e.target.value);
|
|
362
318
|
},
|
|
363
|
-
[goTo, setSearchString]
|
|
319
|
+
[goTo, setSearchString],
|
|
364
320
|
);
|
|
365
321
|
|
|
366
322
|
return (
|
|
@@ -371,8 +327,8 @@ function FormsList({ forms, isValidating, mutate, t }: FormsListProps) {
|
|
|
371
327
|
kind="info"
|
|
372
328
|
lowContrast
|
|
373
329
|
title={t(
|
|
374
|
-
|
|
375
|
-
"The dev3 server is ephemeral at best and can't be relied upon to save your schemas permanently. To avoid losing your work, please save your schemas to your local machine. Alternatively, upload your schema to the distro repo to have it persisted across server resets."
|
|
330
|
+
'schemaSaveWarningMessage',
|
|
331
|
+
"The dev3 server is ephemeral at best and can't be relied upon to save your schemas permanently. To avoid losing your work, please save your schemas to your local machine. Alternatively, upload your schema to the distro repo to have it persisted across server resets.",
|
|
376
332
|
)}
|
|
377
333
|
/>
|
|
378
334
|
)}
|
|
@@ -380,14 +336,12 @@ function FormsList({ forms, isValidating, mutate, t }: FormsListProps) {
|
|
|
380
336
|
<div className={styles.filterContainer}>
|
|
381
337
|
<Dropdown
|
|
382
338
|
id="publishStatusFilter"
|
|
383
|
-
initialSelectedItem={
|
|
339
|
+
initialSelectedItem={'All'}
|
|
384
340
|
label=""
|
|
385
|
-
titleText={
|
|
386
|
-
t("filterByPublishedStatus", "Filter by publish status") + ":"
|
|
387
|
-
}
|
|
341
|
+
titleText={t('filterByPublishedStatus', 'Filter by publish status') + ':'}
|
|
388
342
|
size={responsiveSize}
|
|
389
343
|
type="inline"
|
|
390
|
-
items={[
|
|
344
|
+
items={['All', 'Published', 'Unpublished']}
|
|
391
345
|
onChange={handlePublishStatusChange}
|
|
392
346
|
/>
|
|
393
347
|
</div>
|
|
@@ -395,33 +349,22 @@ function FormsList({ forms, isValidating, mutate, t }: FormsListProps) {
|
|
|
395
349
|
<span>{isValidating ? <InlineLoading /> : null}</span>
|
|
396
350
|
</div>
|
|
397
351
|
</div>
|
|
398
|
-
<DataTable
|
|
399
|
-
rows={tableRows}
|
|
400
|
-
headers={tableHeaders}
|
|
401
|
-
size={isTablet ? "lg" : "sm"}
|
|
402
|
-
useZebraStyles
|
|
403
|
-
>
|
|
352
|
+
<DataTable rows={tableRows} headers={tableHeaders} size={isTablet ? 'lg' : 'sm'} useZebraStyles>
|
|
404
353
|
{({ rows, headers, getTableProps, getHeaderProps, getRowProps }) => (
|
|
405
354
|
<>
|
|
406
|
-
<TableContainer
|
|
407
|
-
className={styles.tableContainer}
|
|
408
|
-
data-testid="forms-table"
|
|
409
|
-
>
|
|
355
|
+
<TableContainer className={styles.tableContainer} data-testid="forms-table">
|
|
410
356
|
<div className={styles.toolbarWrapper}>
|
|
411
|
-
<TableToolbar
|
|
412
|
-
className={styles.tableToolbar}
|
|
413
|
-
size={responsiveSize}
|
|
414
|
-
>
|
|
357
|
+
<TableToolbar className={styles.tableToolbar} size={responsiveSize}>
|
|
415
358
|
<TableToolbarContent className={styles.headerContainer}>
|
|
416
359
|
<TableToolbarSearch
|
|
417
360
|
className={styles.searchbox}
|
|
418
361
|
onChange={handleSearch}
|
|
419
|
-
placeholder={t(
|
|
362
|
+
placeholder={t('searchThisList', 'Search this list')}
|
|
420
363
|
/>
|
|
421
364
|
<Button
|
|
422
365
|
kind="primary"
|
|
423
|
-
iconDescription={t(
|
|
424
|
-
renderIcon={(
|
|
366
|
+
iconDescription={t('createNewForm', 'Create a new form')}
|
|
367
|
+
renderIcon={() => <Add size={16} />}
|
|
425
368
|
size={responsiveSize}
|
|
426
369
|
onClick={() =>
|
|
427
370
|
navigate({
|
|
@@ -429,7 +372,7 @@ function FormsList({ forms, isValidating, mutate, t }: FormsListProps) {
|
|
|
429
372
|
})
|
|
430
373
|
}
|
|
431
374
|
>
|
|
432
|
-
{t(
|
|
375
|
+
{t('createNewForm', 'Create a new form')}
|
|
433
376
|
</Button>
|
|
434
377
|
</TableToolbarContent>
|
|
435
378
|
</TableToolbar>
|
|
@@ -438,18 +381,13 @@ function FormsList({ forms, isValidating, mutate, t }: FormsListProps) {
|
|
|
438
381
|
<TableHead>
|
|
439
382
|
<TableRow>
|
|
440
383
|
{headers.map((header) => (
|
|
441
|
-
<TableHeader {...getHeaderProps({ header })}>
|
|
442
|
-
{header.header}
|
|
443
|
-
</TableHeader>
|
|
384
|
+
<TableHeader {...getHeaderProps({ header })}>{header.header}</TableHeader>
|
|
444
385
|
))}
|
|
445
386
|
</TableRow>
|
|
446
387
|
</TableHead>
|
|
447
388
|
<TableBody>
|
|
448
|
-
{rows.map((row
|
|
449
|
-
<TableRow
|
|
450
|
-
{...getRowProps({ row })}
|
|
451
|
-
data-testid={`form-row-${row.id}`}
|
|
452
|
-
>
|
|
389
|
+
{rows.map((row) => (
|
|
390
|
+
<TableRow key="row.id" {...getRowProps({ row })} data-testid={`form-row-${row.id}`}>
|
|
453
391
|
{row.cells.map((cell) => (
|
|
454
392
|
<TableCell key={cell.id}>{cell.value}</TableCell>
|
|
455
393
|
))}
|
|
@@ -462,15 +400,8 @@ function FormsList({ forms, isValidating, mutate, t }: FormsListProps) {
|
|
|
462
400
|
<div className={styles.tileContainer}>
|
|
463
401
|
<Tile className={styles.tile}>
|
|
464
402
|
<div className={styles.tileContent}>
|
|
465
|
-
<p className={styles.content}>
|
|
466
|
-
|
|
467
|
-
"noMatchingFormsToDisplay",
|
|
468
|
-
"No matching forms to display"
|
|
469
|
-
)}
|
|
470
|
-
</p>
|
|
471
|
-
<p className={styles.helper}>
|
|
472
|
-
{t("checkFilters", "Check the filters above")}
|
|
473
|
-
</p>
|
|
403
|
+
<p className={styles.content}>{t('noMatchingFormsToDisplay', 'No matching forms to display')}</p>
|
|
404
|
+
<p className={styles.helper}>{t('checkFilters', 'Check the filters above')}</p>
|
|
474
405
|
</div>
|
|
475
406
|
</Tile>
|
|
476
407
|
</div>
|
|
@@ -499,7 +430,7 @@ const Dashboard: React.FC = () => {
|
|
|
499
430
|
|
|
500
431
|
return (
|
|
501
432
|
<div className={styles.container}>
|
|
502
|
-
<h3 className={styles.heading}>{t(
|
|
433
|
+
<h3 className={styles.heading}>{t('formBuilder', 'Form Builder')}</h3>
|
|
503
434
|
{(() => {
|
|
504
435
|
if (error) {
|
|
505
436
|
return <ErrorState error={error} />;
|
|
@@ -513,14 +444,7 @@ const Dashboard: React.FC = () => {
|
|
|
513
444
|
return <EmptyState />;
|
|
514
445
|
}
|
|
515
446
|
|
|
516
|
-
return
|
|
517
|
-
<FormsList
|
|
518
|
-
forms={forms}
|
|
519
|
-
isValidating={isValidating}
|
|
520
|
-
mutate={mutate}
|
|
521
|
-
t={t}
|
|
522
|
-
/>
|
|
523
|
-
);
|
|
447
|
+
return <FormsList forms={forms} isValidating={isValidating} mutate={mutate} t={t} />;
|
|
524
448
|
})()}
|
|
525
449
|
</div>
|
|
526
450
|
);
|