@openmrs/esm-fast-data-entry-app 1.0.0-pre.9 → 1.0.1-pre.10
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/.eslintrc.js +10 -0
- package/.husky/pre-push +1 -6
- package/.tx/config +9 -0
- package/.yarn/plugins/@yarnpkg/plugin-version.cjs +550 -0
- package/.yarn/versions/45b499b6.yml +0 -0
- package/README.md +39 -12
- package/dist/openmrs-esm-fast-data-entry-app.js +1 -1
- package/docs/config-icrc-forms.png +0 -0
- package/docs/config-other-forms.png +0 -0
- package/docs/configuring-form-categories.md +77 -0
- package/docs/fde-workflow.mov +0 -0
- package/docs/form-workflow-state-diagram.png +0 -0
- package/jest.config.json +20 -18
- package/package.json +97 -106
- package/src/FormBootstrap.tsx +151 -0
- package/src/Root.tsx +14 -3
- package/src/add-group-modal/AddGroupModal.tsx +209 -0
- package/src/add-group-modal/styles.scss +35 -0
- package/src/config-schema.ts +63 -31
- package/src/context/FormWorkflowContext.tsx +114 -0
- package/src/context/FormWorkflowReducer.ts +277 -0
- package/src/context/GroupFormWorkflowContext.tsx +141 -0
- package/src/context/GroupFormWorkflowReducer.ts +272 -0
- package/src/empty-state/EmptyDataIllustration.tsx +51 -0
- package/src/empty-state/EmptyState.tsx +33 -0
- package/src/empty-state/styles.scss +55 -0
- package/src/form-entry-workflow/FormEntryWorkflow.tsx +230 -0
- package/src/form-entry-workflow/form-review-card/FormReviewCard.tsx +50 -0
- package/src/form-entry-workflow/form-review-card/index.ts +3 -0
- package/src/form-entry-workflow/form-review-card/styles.scss +39 -0
- package/src/form-entry-workflow/index.ts +3 -0
- package/src/form-entry-workflow/patient-banner/PatientBanner.test.tsx +9 -0
- package/src/form-entry-workflow/patient-banner/PatientBanner.tsx +86 -0
- package/src/form-entry-workflow/patient-banner/index.ts +3 -0
- package/src/form-entry-workflow/patient-banner/styles.scss +45 -0
- package/src/form-entry-workflow/patient-search-header/PatientSearchHeader.tsx +63 -0
- package/src/form-entry-workflow/patient-search-header/index.ts +3 -0
- package/src/form-entry-workflow/patient-search-header/styles.scss +22 -0
- package/src/form-entry-workflow/styles.scss +64 -0
- package/src/form-entry-workflow/workflow-review/WorkflowReview.tsx +35 -0
- package/src/form-entry-workflow/workflow-review/index.ts +3 -0
- package/src/form-entry-workflow/workflow-review/styles.scss +34 -0
- package/src/forms-app-menu-link.tsx +3 -2
- package/src/forms-page/FormsPage.tsx +129 -0
- package/src/forms-page/forms-table/FormsTable.tsx +131 -0
- package/src/forms-page/forms-table/index.ts +3 -0
- package/src/forms-page/forms-table/styles.scss +20 -0
- package/src/forms-page/index.ts +3 -0
- package/src/forms-page/styles.scss +11 -0
- package/src/group-form-entry-workflow/GroupFormEntryWorkflow.tsx +413 -0
- package/src/group-form-entry-workflow/group-banner/GroupBanner.test.tsx +9 -0
- package/src/group-form-entry-workflow/group-banner/GroupBanner.tsx +45 -0
- package/src/group-form-entry-workflow/group-banner/index.ts +3 -0
- package/src/group-form-entry-workflow/group-banner/styles.scss +60 -0
- package/src/group-form-entry-workflow/group-search/CompactGroupResults.tsx +106 -0
- package/src/group-form-entry-workflow/group-search/CompactGroupSearch.tsx +63 -0
- package/src/group-form-entry-workflow/group-search/GroupSearch.tsx +93 -0
- package/src/group-form-entry-workflow/group-search/compact-group-result.scss +64 -0
- package/src/group-form-entry-workflow/group-search/compact-group-search.scss +35 -0
- package/src/group-form-entry-workflow/group-search/group-search.scss +94 -0
- package/src/group-form-entry-workflow/group-search/mock-group-data.ts +79 -0
- package/src/group-form-entry-workflow/group-search/useGroupSearch.ts +14 -0
- package/src/group-form-entry-workflow/group-search-header/GroupSearchHeader.tsx +42 -0
- package/src/group-form-entry-workflow/group-search-header/index.ts +3 -0
- package/src/group-form-entry-workflow/group-search-header/styles.scss +20 -0
- package/src/group-form-entry-workflow/index.ts +3 -0
- package/src/group-form-entry-workflow/styles.scss +86 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/useFormState.ts +23 -0
- package/src/hooks/useGetAllForms.ts +45 -0
- package/src/hooks/useGetEncounter.ts +21 -0
- package/src/hooks/useGetPatient.ts +23 -0
- package/src/hooks/useKeyPress.ts +31 -0
- package/src/hooks/usePostCohort.ts +18 -0
- package/src/index.ts +20 -4
- package/src/patient-card/PatientCard.tsx +67 -0
- package/src/patient-card/index.ts +3 -0
- package/src/patient-card/styles.scss +45 -0
- package/translations/en.json +49 -4
- package/tsconfig.json +26 -23
- package/.eslintrc +0 -4
- package/.github/workflows/node.js.yml +0 -79
- package/.husky/pre-commit +0 -6
- package/dist/24.js +0 -3
- package/dist/24.js.LICENSE.txt +0 -16
- package/dist/24.js.map +0 -1
- package/dist/294.js +0 -3
- package/dist/294.js.LICENSE.txt +0 -14
- package/dist/294.js.map +0 -1
- package/dist/296.js +0 -2
- package/dist/296.js.map +0 -1
- package/dist/299.js +0 -2
- package/dist/299.js.map +0 -1
- package/dist/382.js +0 -3
- package/dist/382.js.LICENSE.txt +0 -8
- package/dist/382.js.map +0 -1
- package/dist/415.js +0 -2
- package/dist/415.js.map +0 -1
- package/dist/574.js +0 -1
- package/dist/595.js +0 -3
- package/dist/595.js.LICENSE.txt +0 -1
- package/dist/595.js.map +0 -1
- package/dist/69.js +0 -2
- package/dist/69.js.map +0 -1
- package/dist/735.js +0 -3
- package/dist/735.js.LICENSE.txt +0 -29
- package/dist/735.js.map +0 -1
- package/dist/777.js +0 -2
- package/dist/777.js.map +0 -1
- package/dist/860.js +0 -2
- package/dist/860.js.map +0 -1
- package/dist/906.js +0 -2
- package/dist/906.js.map +0 -1
- package/dist/openmrs-esm-fast-data-entry-app.js.buildmanifest.json +0 -369
- package/dist/openmrs-esm-fast-data-entry-app.js.map +0 -1
- package/dist/openmrs-esm-fast-data-entry-app.old +0 -2
- package/src/boxes/extensions/blue-box.tsx +0 -15
- package/src/boxes/extensions/box.scss +0 -23
- package/src/boxes/extensions/brand-box.tsx +0 -15
- package/src/boxes/extensions/red-box.tsx +0 -15
- package/src/boxes/slot/boxes.css +0 -23
- package/src/boxes/slot/boxes.tsx +0 -19
- package/src/forms/FormsRoot.tsx +0 -32
- package/src/forms/FormsTable.tsx +0 -64
- package/src/forms/mockData.ts +0 -43
- package/src/greeter/greeter.css +0 -4
- package/src/greeter/greeter.test.tsx +0 -29
- package/src/greeter/greeter.tsx +0 -25
- package/src/hello.css +0 -3
- package/src/hello.test.tsx +0 -45
- package/src/hello.tsx +0 -30
- package/src/patient-getter/patient-getter.resource.ts +0 -31
- package/src/patient-getter/patient-getter.test.tsx +0 -28
- package/src/patient-getter/patient-getter.tsx +0 -28
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
@use '@carbon/styles/scss/spacing';
|
|
2
|
+
// @use '@carbon/colors';
|
|
3
|
+
// @use '@carbon/styles/scss/type';
|
|
4
|
+
@import '~@openmrs/esm-styleguide/src/vars';
|
|
5
|
+
|
|
6
|
+
.searchHeaderContainer {
|
|
7
|
+
height: spacing.$spacing-11;
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
background-color: $ui-02;
|
|
11
|
+
border-top: 0.0125rem solid $ui-03;
|
|
12
|
+
border-bottom: 0.0125rem solid $ui-03;
|
|
13
|
+
padding: 0 spacing.$spacing-05;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.searchBarWrapper {
|
|
17
|
+
min-width: 35rem;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.padded {
|
|
21
|
+
padding: spacing.$spacing-05;
|
|
22
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
@use '@carbon/styles/scss/spacing';
|
|
2
|
+
@use '@carbon/colors';
|
|
3
|
+
@use '@carbon/styles/scss/type';
|
|
4
|
+
@import '~@openmrs/esm-styleguide/src/vars';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
.breadcrumbsContainer > div > div > nav {
|
|
8
|
+
background-color: $ui-02;
|
|
9
|
+
padding: spacing.$spacing-04 spacing.$spacing-05;
|
|
10
|
+
height: spacing.$spacing-08;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.workspaceWrapper {
|
|
14
|
+
display: flex;
|
|
15
|
+
justify-content: center;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.workspace {
|
|
19
|
+
width: 1100px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.selectPatientMessage {
|
|
23
|
+
@include type.type-style('productive-heading-03');
|
|
24
|
+
margin: spacing.$spacing-07;
|
|
25
|
+
text-align: center;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.formMainContent {
|
|
29
|
+
display: flex;
|
|
30
|
+
text-align: center;
|
|
31
|
+
margin-top: spacing.$spacing-05;
|
|
32
|
+
column-gap: spacing.$spacing-05;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.formContainer {
|
|
36
|
+
flex-grow: 1;
|
|
37
|
+
max-height: calc(100vh - 14rem);
|
|
38
|
+
overflow-y: scroll;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.formContainer :global(.cds--form-item) :global(.question-area) {
|
|
42
|
+
max-width: 100%;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.rightPanel {
|
|
46
|
+
width: 13rem;
|
|
47
|
+
text-align: left;
|
|
48
|
+
overflow-y: scroll;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.patientCardsSection {
|
|
52
|
+
margin: spacing.$spacing-05 0;
|
|
53
|
+
border-bottom: 1px solid colors.$gray-10;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.rightPanelActionButtons {
|
|
57
|
+
display: flex;
|
|
58
|
+
flex-direction: column;
|
|
59
|
+
row-gap: spacing.$spacing-03;
|
|
60
|
+
& button {
|
|
61
|
+
width: 100%;
|
|
62
|
+
text-decoration: "none";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Button } from "@carbon/react";
|
|
2
|
+
import React, { useContext } from "react";
|
|
3
|
+
import { useNavigate } from "react-router-dom";
|
|
4
|
+
import FormWorkflowContext from "../../context/FormWorkflowContext";
|
|
5
|
+
import FormReviewCard from "../form-review-card";
|
|
6
|
+
import styles from "./styles.scss";
|
|
7
|
+
|
|
8
|
+
const WorkflowReview = () => {
|
|
9
|
+
const { patientUuids } = useContext(FormWorkflowContext);
|
|
10
|
+
const navigate = useNavigate();
|
|
11
|
+
return (
|
|
12
|
+
<div className={styles.workspaceWrapper}>
|
|
13
|
+
<div className={styles.workspace}>
|
|
14
|
+
<div className={styles.leftPanel}>
|
|
15
|
+
<h4>Review</h4>
|
|
16
|
+
<div className={styles.navButtons}>
|
|
17
|
+
<Button kind="primary" onClick={() => navigate("/")}>
|
|
18
|
+
Save & Close
|
|
19
|
+
</Button>
|
|
20
|
+
<Button kind="tertiary" onClick={() => navigate("/")}>
|
|
21
|
+
Cancel
|
|
22
|
+
</Button>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
<div className={styles.formContainer}>
|
|
26
|
+
{patientUuids.map((patientUuid) => (
|
|
27
|
+
<FormReviewCard patientUuid={patientUuid} key={patientUuid} />
|
|
28
|
+
))}
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default WorkflowReview;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
@import "~@openmrs/esm-styleguide/src/vars";
|
|
2
|
+
@import "~carbon-components/src/globals/scss/vars";
|
|
3
|
+
@import "~carbon-components/src/globals/scss/mixins";
|
|
4
|
+
|
|
5
|
+
.workspaceWrapper {
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.workspace {
|
|
11
|
+
display: flex;
|
|
12
|
+
width: 800px;
|
|
13
|
+
margin-top: 1rem;
|
|
14
|
+
column-gap: 1rem;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.leftPanel {
|
|
18
|
+
width: 13rem;
|
|
19
|
+
overflow-y: scroll;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.navButtons {
|
|
23
|
+
margin-top: 1rem;
|
|
24
|
+
display: flex;
|
|
25
|
+
flex-direction: column;
|
|
26
|
+
row-gap: 0.5rem;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.formContainer {
|
|
30
|
+
flex-grow: 1;
|
|
31
|
+
max-height: calc(100vh - 14rem);
|
|
32
|
+
overflow-y: scroll;
|
|
33
|
+
row-gap: 1rem;
|
|
34
|
+
}
|
|
@@ -2,11 +2,12 @@ import React from "react";
|
|
|
2
2
|
import { useTranslation } from "react-i18next";
|
|
3
3
|
import { ConfigurableLink } from "@openmrs/esm-framework";
|
|
4
4
|
|
|
5
|
-
export default function
|
|
5
|
+
export default function FormsAppMenuLink() {
|
|
6
6
|
const { t } = useTranslation();
|
|
7
7
|
return (
|
|
8
|
+
// eslint-disable-next-line
|
|
8
9
|
<ConfigurableLink to="${openmrsSpaBase}/forms">
|
|
9
|
-
{t("formsAppMenuLink", "
|
|
10
|
+
{t("formsAppMenuLink", "Fast Data Entry")}
|
|
10
11
|
</ConfigurableLink>
|
|
11
12
|
);
|
|
12
13
|
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { useConfig } from "@openmrs/esm-framework";
|
|
2
|
+
import { Tab, Tabs, TabList, TabPanels, TabPanel } from "@carbon/react";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { Config } from "../config-schema";
|
|
5
|
+
import { useGetAllForms } from "../hooks";
|
|
6
|
+
import FormsTable from "./forms-table";
|
|
7
|
+
import styles from "./styles.scss";
|
|
8
|
+
import { useTranslation } from "react-i18next";
|
|
9
|
+
import {
|
|
10
|
+
fdeWorkflowStorageName,
|
|
11
|
+
fdeWorkflowStorageVersion,
|
|
12
|
+
} from "../context/FormWorkflowReducer";
|
|
13
|
+
import {
|
|
14
|
+
fdeGroupWorkflowStorageName,
|
|
15
|
+
fdeGroupWorkflowStorageVersion,
|
|
16
|
+
} from "../context/GroupFormWorkflowReducer";
|
|
17
|
+
|
|
18
|
+
// helper function useful for debugging
|
|
19
|
+
// given a list of forms, it will organize into permissions
|
|
20
|
+
// and list which forms are associated with that permission
|
|
21
|
+
export const getFormPermissions = (forms) => {
|
|
22
|
+
const output = {};
|
|
23
|
+
forms?.forEach(
|
|
24
|
+
(form) =>
|
|
25
|
+
(output[form.encounterType.editPrivilege.display] = [
|
|
26
|
+
...(output[form.encounterType.editPrivilege.display] || []),
|
|
27
|
+
form.display,
|
|
28
|
+
])
|
|
29
|
+
);
|
|
30
|
+
return output;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// Function adds `id` field to rows so they will be accepted by DataTable
|
|
34
|
+
// "display" is prefered for display name if present, otherwise fall back on "name'"
|
|
35
|
+
const prepareRowsForTable = (rawFormData) => {
|
|
36
|
+
if (rawFormData) {
|
|
37
|
+
return rawFormData?.map((form) => ({
|
|
38
|
+
...form,
|
|
39
|
+
id: form.uuid,
|
|
40
|
+
display: form.display || form.name,
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const FormsPage = () => {
|
|
47
|
+
const config = useConfig() as Config;
|
|
48
|
+
const { t } = useTranslation();
|
|
49
|
+
const { formCategories, formCategoriesToShow } = config;
|
|
50
|
+
const { forms, isLoading, error } = useGetAllForms();
|
|
51
|
+
const cleanRows = prepareRowsForTable(forms);
|
|
52
|
+
const savedFormsData = localStorage.getItem(fdeWorkflowStorageName);
|
|
53
|
+
const savedGroupFormsData = localStorage.getItem(fdeGroupWorkflowStorageName);
|
|
54
|
+
const activeForms = [];
|
|
55
|
+
const activeGroupForms = [];
|
|
56
|
+
|
|
57
|
+
if (
|
|
58
|
+
savedFormsData &&
|
|
59
|
+
JSON.parse(savedFormsData)?.["_storageVersion"] ===
|
|
60
|
+
fdeWorkflowStorageVersion
|
|
61
|
+
) {
|
|
62
|
+
Object.entries(JSON.parse(savedFormsData).forms).forEach(
|
|
63
|
+
([formUuid, form]: [string, { [key: string]: unknown }]) => {
|
|
64
|
+
if (form.workflowState) activeForms.push(formUuid);
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
if (
|
|
69
|
+
savedGroupFormsData &&
|
|
70
|
+
JSON.parse(savedGroupFormsData)?.["_storageVersion"] ===
|
|
71
|
+
fdeGroupWorkflowStorageVersion
|
|
72
|
+
) {
|
|
73
|
+
Object.entries(JSON.parse(savedGroupFormsData).forms).forEach(
|
|
74
|
+
([formUuid, form]: [string, { [key: string]: unknown }]) => {
|
|
75
|
+
if (form.workflowState) activeGroupForms.push(formUuid);
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const categoryRows = formCategoriesToShow.map((name) => {
|
|
81
|
+
const category = formCategories.find((category) => category.name === name);
|
|
82
|
+
let rows = [];
|
|
83
|
+
if (category && cleanRows && cleanRows.length) {
|
|
84
|
+
const uuids = category.forms?.map((form) => form.formUUID);
|
|
85
|
+
rows = cleanRows.filter((row) => uuids.includes(row.uuid));
|
|
86
|
+
}
|
|
87
|
+
return { ...{ name, rows } };
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<div className={styles.mainContent}>
|
|
92
|
+
<h3 className={styles.pageTitle}>
|
|
93
|
+
{t("fastDataEntry", "Fast Data Entry")}
|
|
94
|
+
</h3>
|
|
95
|
+
<Tabs>
|
|
96
|
+
<TabList>
|
|
97
|
+
<Tab label={t("allForms", "All Forms")}>
|
|
98
|
+
{`${t("allForms", "All Forms")} (${
|
|
99
|
+
cleanRows ? cleanRows?.length : "??"
|
|
100
|
+
})`}
|
|
101
|
+
</Tab>
|
|
102
|
+
{categoryRows?.map((category, index) => (
|
|
103
|
+
<Tab label={category.name} key={index}>
|
|
104
|
+
{`${category.name} (${category.rows.length})`}
|
|
105
|
+
</Tab>
|
|
106
|
+
))}
|
|
107
|
+
</TabList>
|
|
108
|
+
<TabPanels>
|
|
109
|
+
<TabPanel>
|
|
110
|
+
<FormsTable
|
|
111
|
+
rows={cleanRows}
|
|
112
|
+
{...{ error, isLoading, activeForms, activeGroupForms }}
|
|
113
|
+
/>
|
|
114
|
+
</TabPanel>
|
|
115
|
+
{categoryRows?.map((category, index) => (
|
|
116
|
+
<TabPanel key={index}>
|
|
117
|
+
<FormsTable
|
|
118
|
+
rows={category.rows}
|
|
119
|
+
{...{ error, isLoading, activeForms, activeGroupForms }}
|
|
120
|
+
/>
|
|
121
|
+
</TabPanel>
|
|
122
|
+
))}
|
|
123
|
+
</TabPanels>
|
|
124
|
+
</Tabs>
|
|
125
|
+
</div>
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export default FormsPage;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { ErrorState } from "@openmrs/esm-framework";
|
|
2
|
+
import {
|
|
3
|
+
DataTable,
|
|
4
|
+
DataTableSkeleton,
|
|
5
|
+
Table,
|
|
6
|
+
TableBody,
|
|
7
|
+
TableCell,
|
|
8
|
+
TableContainer,
|
|
9
|
+
TableHead,
|
|
10
|
+
TableHeader,
|
|
11
|
+
TableRow,
|
|
12
|
+
TableToolbar,
|
|
13
|
+
TableToolbarContent,
|
|
14
|
+
TableToolbarSearch,
|
|
15
|
+
} from "@carbon/react";
|
|
16
|
+
import React from "react";
|
|
17
|
+
import { useTranslation } from "react-i18next";
|
|
18
|
+
import { Link } from "react-router-dom";
|
|
19
|
+
import EmptyState from "../../empty-state/EmptyState";
|
|
20
|
+
import styles from "./styles.scss";
|
|
21
|
+
|
|
22
|
+
const FormsTable = ({
|
|
23
|
+
rows,
|
|
24
|
+
error,
|
|
25
|
+
isLoading,
|
|
26
|
+
activeForms,
|
|
27
|
+
activeGroupForms,
|
|
28
|
+
}) => {
|
|
29
|
+
const { t } = useTranslation();
|
|
30
|
+
|
|
31
|
+
const formsHeader = [
|
|
32
|
+
{
|
|
33
|
+
key: "display",
|
|
34
|
+
header: t("formName", "Form Name"),
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
key: "actions",
|
|
38
|
+
header: t("actions", "Actions"),
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
key: "actions2",
|
|
42
|
+
header: "",
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
const augmenteRows = rows?.map((row) => ({
|
|
47
|
+
...row,
|
|
48
|
+
actions: (
|
|
49
|
+
<Link to={`form/${row.uuid}`}>
|
|
50
|
+
{activeForms.includes(row.uuid)
|
|
51
|
+
? t("resumeSession", "Resume Session")
|
|
52
|
+
: t("fillForm", "Fill Form")}
|
|
53
|
+
</Link>
|
|
54
|
+
),
|
|
55
|
+
actions2: (
|
|
56
|
+
<Link to={`groupform/${row.uuid}`}>
|
|
57
|
+
{activeGroupForms.includes(row.uuid)
|
|
58
|
+
? t("resumeGroupSession", "Resume Group Session")
|
|
59
|
+
: t("startGroupSession", "Start Group Session")}
|
|
60
|
+
</Link>
|
|
61
|
+
),
|
|
62
|
+
}));
|
|
63
|
+
|
|
64
|
+
if (isLoading) return <DataTableSkeleton />;
|
|
65
|
+
if (error) {
|
|
66
|
+
return (
|
|
67
|
+
<ErrorState
|
|
68
|
+
headerTitle={t("errorLoadingData", "Error Loading Data")}
|
|
69
|
+
error={error}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
if (augmenteRows.length === 0) {
|
|
74
|
+
return (
|
|
75
|
+
<EmptyState
|
|
76
|
+
headerTitle={t("noFormsFound", "No Forms To Show")}
|
|
77
|
+
displayText={t(
|
|
78
|
+
"noFormsFoundMessage",
|
|
79
|
+
"No forms could be found for this category. Please double check the form concept uuids and access permissions."
|
|
80
|
+
)}
|
|
81
|
+
/>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
return (
|
|
85
|
+
<DataTable rows={augmenteRows} headers={formsHeader} isSortable>
|
|
86
|
+
{({
|
|
87
|
+
rows,
|
|
88
|
+
headers,
|
|
89
|
+
getTableProps,
|
|
90
|
+
getHeaderProps,
|
|
91
|
+
getRowProps,
|
|
92
|
+
onInputChange,
|
|
93
|
+
}) => {
|
|
94
|
+
return (
|
|
95
|
+
<TableContainer>
|
|
96
|
+
<div className={styles.toolbarWrapper}>
|
|
97
|
+
<TableToolbar className={styles.tableToolbar}>
|
|
98
|
+
<TableToolbarContent>
|
|
99
|
+
<TableToolbarSearch onChange={onInputChange} />
|
|
100
|
+
</TableToolbarContent>
|
|
101
|
+
</TableToolbar>
|
|
102
|
+
</div>
|
|
103
|
+
<Table {...getTableProps()}>
|
|
104
|
+
<TableHead>
|
|
105
|
+
<TableRow>
|
|
106
|
+
{headers.map((header) => (
|
|
107
|
+
<TableHeader {...getHeaderProps({ header })}>
|
|
108
|
+
{header.header}
|
|
109
|
+
</TableHeader>
|
|
110
|
+
))}
|
|
111
|
+
</TableRow>
|
|
112
|
+
</TableHead>
|
|
113
|
+
<TableBody>
|
|
114
|
+
{rows?.map((row) => (
|
|
115
|
+
<TableRow {...getRowProps({ row })}>
|
|
116
|
+
{row.cells.map((cell) => (
|
|
117
|
+
<TableCell key={cell.id}>{cell.value}</TableCell>
|
|
118
|
+
))}
|
|
119
|
+
</TableRow>
|
|
120
|
+
))}
|
|
121
|
+
</TableBody>
|
|
122
|
+
</Table>
|
|
123
|
+
</TableContainer>
|
|
124
|
+
);
|
|
125
|
+
}}
|
|
126
|
+
</DataTable>
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
export default FormsTable;
|
|
131
|
+
export { FormsTable };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
@import "~@openmrs/esm-styleguide/src/vars";
|
|
2
|
+
@import "~carbon-components/src/globals/scss/vars";
|
|
3
|
+
@import "~carbon-components/src/globals/scss/mixins";
|
|
4
|
+
|
|
5
|
+
.toolbarWrapper {
|
|
6
|
+
position: relative;
|
|
7
|
+
display: flex;
|
|
8
|
+
height: $spacing-09;
|
|
9
|
+
justify-content: flex-end;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.tableToolbar {
|
|
13
|
+
width: 20%;
|
|
14
|
+
min-width: 12.5rem;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.inactiveLink {
|
|
18
|
+
color: $carbon--gray-40;
|
|
19
|
+
cursor: not-allowed;
|
|
20
|
+
}
|