@kenyaemr/esm-admin-app 5.4.4-pre.7 → 5.4.4-pre.71
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/.turbo/turbo-build.log +5 -12
- package/dist/1074.js +1 -0
- package/dist/1074.js.map +1 -0
- package/dist/12.js +17 -0
- package/dist/12.js.map +1 -0
- package/dist/1201.js +1 -0
- package/dist/1201.js.map +1 -0
- package/dist/1242.js +1 -0
- package/dist/1242.js.map +1 -0
- package/dist/1311.js +1 -0
- package/dist/1311.js.map +1 -0
- package/dist/1425.js +1 -0
- package/dist/1425.js.map +1 -0
- package/dist/1462.js +1 -0
- package/dist/1462.js.map +1 -0
- package/dist/1469.js +1 -0
- package/dist/1469.js.map +1 -0
- package/dist/1506.js +13 -0
- package/dist/1506.js.map +1 -0
- package/dist/171.js +1 -0
- package/dist/171.js.map +1 -0
- package/dist/1718.js +1 -0
- package/dist/1718.js.map +1 -0
- package/dist/1722.js +1 -0
- package/dist/1722.js.map +1 -0
- package/dist/1772.js +1 -0
- package/dist/1772.js.map +1 -0
- package/dist/1889.js +1 -0
- package/dist/1889.js.map +1 -0
- package/dist/1972.js +1 -0
- package/dist/1972.js.map +1 -0
- package/dist/1990.js +1 -0
- package/dist/1990.js.map +1 -0
- package/dist/2080.js +1 -0
- package/dist/2080.js.map +1 -0
- package/dist/2096.js +1 -0
- package/dist/2096.js.map +1 -0
- package/dist/2153.js +1 -0
- package/dist/2153.js.map +1 -0
- package/dist/216.js +1 -0
- package/dist/216.js.map +1 -0
- package/dist/2270.js +1 -0
- package/dist/2270.js.map +1 -0
- package/dist/2294.js +1 -0
- package/dist/2294.js.map +1 -0
- package/dist/2345.js +1 -0
- package/dist/2345.js.map +1 -0
- package/dist/2402.js +1 -0
- package/dist/2402.js.map +1 -0
- package/dist/2500.js +1 -0
- package/dist/2500.js.map +1 -0
- package/dist/251.js +1 -0
- package/dist/251.js.map +1 -0
- package/dist/257.js +1 -0
- package/dist/257.js.map +1 -0
- package/dist/2586.js +1 -0
- package/dist/2586.js.map +1 -0
- package/dist/2625.js +1 -0
- package/dist/2625.js.map +1 -0
- package/dist/2652.js +1 -0
- package/dist/2652.js.map +1 -0
- package/dist/2685.js +1 -0
- package/dist/2685.js.map +1 -0
- package/dist/2948.js +1 -0
- package/dist/2948.js.map +1 -0
- package/dist/3089.js +1 -0
- package/dist/3089.js.map +1 -0
- package/dist/3190.js +1 -0
- package/dist/3190.js.map +1 -0
- package/dist/3224.js +1 -0
- package/dist/3224.js.map +1 -0
- package/dist/3366.js +1 -0
- package/dist/3366.js.map +1 -0
- package/dist/3548.js +1 -0
- package/dist/3548.js.map +1 -0
- package/dist/3571.js +1 -0
- package/dist/3571.js.map +1 -0
- package/dist/3691.js +1 -0
- package/dist/3691.js.map +1 -0
- package/dist/3775.js +1 -0
- package/dist/3775.js.map +1 -0
- package/dist/3816.js +1 -0
- package/dist/3816.js.map +1 -0
- package/dist/3852.js +1 -0
- package/dist/3852.js.map +1 -0
- package/dist/3906.js +1 -0
- package/dist/3906.js.map +1 -0
- package/dist/3963.js +1 -0
- package/dist/3963.js.map +1 -0
- package/dist/405.js +1 -0
- package/dist/405.js.map +1 -0
- package/dist/4296.js +1 -0
- package/dist/4296.js.map +1 -0
- package/dist/4337.js +1 -0
- package/dist/4337.js.map +1 -0
- package/dist/4735.js +1 -0
- package/dist/4735.js.map +1 -0
- package/dist/4744.js +1 -0
- package/dist/4744.js.map +1 -0
- package/dist/4813.js +2 -0
- package/dist/4813.js.map +1 -0
- package/dist/4858.js +1 -0
- package/dist/4858.js.map +1 -0
- package/dist/4970.js +1 -0
- package/dist/4970.js.map +1 -0
- package/dist/5202.js +1 -0
- package/dist/5202.js.map +1 -0
- package/dist/5294.js +1 -0
- package/dist/5294.js.map +1 -0
- package/dist/545.js +1 -0
- package/dist/545.js.map +1 -0
- package/dist/552.js +1 -0
- package/dist/552.js.map +1 -0
- package/dist/5592.js +1 -0
- package/dist/5592.js.map +1 -0
- package/dist/5669.js +1 -0
- package/dist/5669.js.map +1 -0
- package/dist/5884.js +1 -0
- package/dist/5884.js.map +1 -0
- package/dist/5940.js +1 -0
- package/dist/5940.js.map +1 -0
- package/dist/6092.js +1 -0
- package/dist/6092.js.map +1 -0
- package/dist/6155.js +1 -0
- package/dist/6155.js.map +1 -0
- package/dist/6178.js +1 -0
- package/dist/6178.js.map +1 -0
- package/dist/6399.js +1 -0
- package/dist/6399.js.map +1 -0
- package/dist/6456.js +1 -0
- package/dist/6466.js +3 -0
- package/dist/6466.js.map +1 -0
- package/dist/6492.js +1 -0
- package/dist/6492.js.map +1 -0
- package/dist/6676.js +1 -0
- package/dist/6676.js.map +1 -0
- package/dist/6800.js +1 -0
- package/dist/6800.js.map +1 -0
- package/dist/6976.js +1 -0
- package/dist/6976.js.map +1 -0
- package/dist/7005.js +1 -0
- package/dist/7005.js.map +1 -0
- package/dist/7201.js +1 -0
- package/dist/7201.js.map +1 -0
- package/dist/7210.js +1 -0
- package/dist/7210.js.map +1 -0
- package/dist/7234.js +1 -0
- package/dist/7234.js.map +1 -0
- package/dist/7261.js +1 -0
- package/dist/7261.js.map +1 -0
- package/dist/7326.js +1 -0
- package/dist/7463.js +1 -0
- package/dist/7463.js.map +1 -0
- package/dist/7528.js +1 -0
- package/dist/7528.js.map +1 -0
- package/dist/7584.js +1 -0
- package/dist/7584.js.map +1 -0
- package/dist/{127.js → 7607.js} +1 -1
- package/dist/7717.js +1 -0
- package/dist/7717.js.map +1 -0
- package/dist/7737.js +1 -0
- package/dist/7737.js.map +1 -0
- package/dist/7739.js +1 -0
- package/dist/7739.js.map +1 -0
- package/dist/7765.js +1 -0
- package/dist/7765.js.map +1 -0
- package/dist/7820.js +1 -0
- package/dist/7820.js.map +1 -0
- package/dist/7844.js +1 -0
- package/dist/7844.js.map +1 -0
- package/dist/7866.js +1 -0
- package/dist/7866.js.map +1 -0
- package/dist/7916.js +1 -0
- package/dist/7916.js.map +1 -0
- package/dist/7971.js +1 -0
- package/dist/7971.js.map +1 -0
- package/dist/8159.js +7 -0
- package/dist/8159.js.map +1 -0
- package/dist/8244.js +1 -0
- package/dist/8244.js.map +1 -0
- package/dist/8262.js +1 -0
- package/dist/8262.js.map +1 -0
- package/dist/834.js +1 -0
- package/dist/834.js.map +1 -0
- package/dist/8376.js +1 -0
- package/dist/8376.js.map +1 -0
- package/dist/845.js +1 -0
- package/dist/845.js.map +1 -0
- package/dist/8546.js +1 -0
- package/dist/8546.js.map +1 -0
- package/dist/8570.js +1 -0
- package/dist/8570.js.map +1 -0
- package/dist/87.js +1 -0
- package/dist/87.js.map +1 -0
- package/dist/8727.js +1 -0
- package/dist/8828.js +1 -0
- package/dist/8828.js.map +1 -0
- package/dist/8860.js +1 -0
- package/dist/8860.js.map +1 -0
- package/dist/9036.js +1 -0
- package/dist/9036.js.map +1 -0
- package/dist/9124.js +1 -0
- package/dist/9124.js.map +1 -0
- package/dist/9182.js +1 -0
- package/dist/921.js +1 -0
- package/dist/921.js.map +1 -0
- package/dist/9404.js +1 -0
- package/dist/9404.js.map +1 -0
- package/dist/9406.js +1 -0
- package/dist/9406.js.map +1 -0
- package/dist/9446.js +1 -0
- package/dist/9446.js.map +1 -0
- package/dist/9449.js +1 -0
- package/dist/9449.js.map +1 -0
- package/dist/9566.js +5 -0
- package/dist/9566.js.map +1 -0
- package/dist/9641.js +1 -0
- package/dist/9641.js.map +1 -0
- package/dist/9711.js +1 -0
- package/dist/9711.js.map +1 -0
- package/dist/9801.js +1 -0
- package/dist/9801.js.map +1 -0
- package/dist/9835.js +11 -0
- package/dist/9835.js.map +1 -0
- package/dist/kenyaemr-esm-admin-app.js +5 -5
- package/dist/kenyaemr-esm-admin-app.js.buildmanifest.json +2679 -156
- package/dist/kenyaemr-esm-admin-app.js.map +1 -1
- package/dist/main.js +5 -31
- package/dist/main.js.map +1 -1
- package/dist/routes.json +1 -1
- package/package.json +4 -6
- package/rspack.config.js +1 -1
- package/src/components/locations/forms/add-location/add-location.workspace.tsx +96 -95
- package/src/components/locations/forms/search-location/search-location.workspace.tsx +90 -85
- package/src/components/locations/tables/locations-table.component.tsx +117 -121
- package/src/components/users/manage-users/manage-user-role-scope/user-role-scope-workspace/user-role-scope.workspace.tsx +13 -13
- package/src/components/users/manage-users/user-list/user-list.component.tsx +22 -9
- package/src/components/users/manage-users/user-management.workspace.tsx +538 -531
- package/src/index.ts +51 -28
- package/src/root.component.tsx +11 -13
- package/src/routes.json +40 -40
- package/tsconfig.json +1 -1
- package/dist/267.js +0 -1
- package/dist/267.js.map +0 -1
- package/dist/281.js +0 -15
- package/dist/281.js.map +0 -1
- package/dist/329.js +0 -1
- package/dist/329.js.map +0 -1
- package/dist/40.js +0 -1
- package/dist/466.js +0 -1
- package/dist/466.js.map +0 -1
- package/dist/472.js +0 -1
- package/dist/472.js.map +0 -1
- package/dist/478.js +0 -1
- package/dist/478.js.map +0 -1
- package/dist/585.js +0 -1
- package/dist/585.js.map +0 -1
- package/dist/630.js +0 -1
- package/dist/630.js.map +0 -1
- package/dist/675.js +0 -1
- package/dist/675.js.map +0 -1
- package/dist/689.js +0 -1
- package/dist/689.js.map +0 -1
- package/dist/706.js +0 -27
- package/dist/706.js.map +0 -1
- package/dist/729.js +0 -17
- package/dist/729.js.map +0 -1
- package/dist/774.js +0 -1
- package/dist/774.js.map +0 -1
- package/dist/847.js +0 -1
- package/dist/847.js.map +0 -1
- package/dist/85.js +0 -1
- package/dist/85.js.map +0 -1
- package/dist/882.js +0 -1
- package/dist/91.js +0 -1
- package/dist/91.js.map +0 -1
- package/dist/916.js +0 -1
- package/dist/998.js +0 -1
- package/dist/998.js.map +0 -1
- package/jest.config.js +0 -8
package/dist/routes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"kenyaemrCharts":"^1.6.7"},"extensions":[{"component":"adminLeftPanelLink","name":"admin-left-panel-link","slot":"admin-left-panel-slot"},{"component":"userManagementLeftPannelLink","name":"user-management-left-panel-link","slot":"admin-left-panel-slot"},{"component":"etlAdministrationLeftPannelLink","name":"etl-administration-left-panel-link","slot":"admin-left-panel-slot"},{"component":"locationsLeftPanelLink","name":"locations-left-panel-link","slot":"admin-left-panel-slot"},{"component":"facilitySetupLeftPanelLink","name":"facility-setup-left-panel-link","slot":"admin-left-panel-slot"},{"component":"providerBanner","name":"provider-banner","slot":"provider-banner-info-slot","order":1}],"
|
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"kenyaemrCharts":"^1.6.7"},"extensions":[{"component":"adminLeftPanelLink","name":"admin-left-panel-link","slot":"admin-left-panel-slot"},{"component":"userManagementLeftPannelLink","name":"user-management-left-panel-link","slot":"admin-left-panel-slot"},{"component":"etlAdministrationLeftPannelLink","name":"etl-administration-left-panel-link","slot":"admin-left-panel-slot"},{"component":"locationsLeftPanelLink","name":"locations-left-panel-link","slot":"admin-left-panel-slot"},{"component":"facilitySetupLeftPanelLink","name":"facility-setup-left-panel-link","slot":"admin-left-panel-slot"},{"component":"providerBanner","name":"provider-banner","slot":"provider-banner-info-slot","order":1}],"modals":[{"component":"operationConfirmationModal","name":"operation-confirmation-modal"},{"component":"hwrConfirmationModal","name":"hwr-confirmation-modal"},{"component":"hwrEmptyModal","name":"hwr-empty-modal"},{"component":"hwrSyncModal","name":"hwr-syncing-modal"}],"workspaces2":[{"name":"manage-user-workspace","component":"manageUserWorkspace","window":"esm-admin-extra-wide-workspace-window"},{"name":"user-role-scope-workspace","component":"userRoleScopeWorkspace","window":"esm-admin-workspace-window"},{"name":"add-location-workspace","component":"addLocation","window":"esm-admin-workspace-window"},{"name":"search-location-workspace","component":"searchLocationWorkspace","window":"esm-admin-workspace-window"}],"workspaceWindows2":[{"name":"esm-admin-workspace-window","canMaximize":true,"group":"esm-admin-workspace-group"},{"name":"esm-admin-extra-wide-workspace-window","canMaximize":true,"group":"esm-admin-workspace-group","width":"extra-wide"}],"workspaceGroups2":[{"name":"esm-admin-workspace-group","scopePattern":"/admin","closeable":true}],"pages":[{"component":"root","route":"admin"}],"version":"5.4.4-pre.71"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kenyaemr/esm-admin-app",
|
|
3
|
-
"version": "5.4.4-pre.
|
|
3
|
+
"version": "5.4.4-pre.71",
|
|
4
4
|
"description": "Facilitates the management of ETL tables",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"openmrs"
|
|
@@ -18,16 +18,14 @@
|
|
|
18
18
|
"source": true,
|
|
19
19
|
"browser": "dist/kenyaemr-esm-admin-app.js",
|
|
20
20
|
"scripts": {
|
|
21
|
-
"analyze": "rspack --mode=production --
|
|
21
|
+
"analyze": "rspack build --mode=production --analyze",
|
|
22
22
|
"build": "rspack --mode=production",
|
|
23
|
-
"coverage": "
|
|
23
|
+
"coverage": "echo \"Jest has been removed; no unit test runner is configured\" && exit 0",
|
|
24
24
|
"debug": "npm run serve",
|
|
25
25
|
"extract-translations": "i18next 'src/**/*.component.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js",
|
|
26
26
|
"lint": "eslint src --ext ts,tsx",
|
|
27
27
|
"serve": "rspack serve --mode=development",
|
|
28
28
|
"start": "openmrs develop",
|
|
29
|
-
"test": "cross-env TZ=UTC jest --config jest.config.js --verbose false --passWithNoTests",
|
|
30
|
-
"test:watch": "cross-env TZ=UTC jest --watch --config jest.config.js",
|
|
31
29
|
"typescript": "tsc"
|
|
32
30
|
},
|
|
33
31
|
"browserslist": [
|
|
@@ -39,7 +37,7 @@
|
|
|
39
37
|
},
|
|
40
38
|
"peerDependencies": {
|
|
41
39
|
"@carbon/react": "1.x",
|
|
42
|
-
"@openmrs/esm-framework": "
|
|
40
|
+
"@openmrs/esm-framework": "9.x",
|
|
43
41
|
"react": "^18.1.0",
|
|
44
42
|
"react-i18next": "11.x",
|
|
45
43
|
"react-router-dom": "6.x",
|
package/rspack.config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = require('
|
|
1
|
+
module.exports = require('../../tools/rs-pack-code-spliting');
|
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
import React, { useEffect, useMemo } from 'react';
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import {
|
|
3
|
-
type DefaultWorkspaceProps,
|
|
4
3
|
ResponsiveWrapper,
|
|
5
|
-
|
|
6
|
-
showSnackbar,
|
|
7
|
-
useConfig,
|
|
4
|
+
Workspace2,
|
|
8
5
|
restBaseUrl,
|
|
6
|
+
showSnackbar,
|
|
7
|
+
useLayoutType,
|
|
8
|
+
type Workspace2DefinitionProps,
|
|
9
9
|
} from '@openmrs/esm-framework';
|
|
10
10
|
import { useTranslation } from 'react-i18next';
|
|
11
11
|
import { Controller, useForm } from 'react-hook-form';
|
|
12
12
|
import {
|
|
13
|
-
ButtonSet,
|
|
14
13
|
Button,
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
ButtonSet,
|
|
15
|
+
FilterableMultiSelect,
|
|
16
|
+
Form,
|
|
17
17
|
FormGroup,
|
|
18
|
+
InlineLoading,
|
|
18
19
|
Stack,
|
|
19
|
-
|
|
20
|
-
FilterableMultiSelect,
|
|
20
|
+
TextInput,
|
|
21
21
|
} from '@carbon/react';
|
|
22
|
-
import classNames from 'classnames';
|
|
23
|
-
import { z } from 'zod';
|
|
24
22
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
23
|
+
import { z } from 'zod';
|
|
24
|
+
import classNames from 'classnames';
|
|
25
|
+
import { mutate } from 'swr';
|
|
26
|
+
|
|
25
27
|
import styles from './add-location.workspace.scss';
|
|
26
28
|
import { type LocationResponse } from '../../types';
|
|
27
29
|
import { extractErrorMessagesFromResponse } from '../../helpers';
|
|
28
30
|
import { useLocationTags } from '../../hooks/useLocationTags';
|
|
29
|
-
import { mutate } from 'swr';
|
|
30
31
|
import { saveOrUpdateLocation } from '../../hooks/useLocation';
|
|
31
32
|
|
|
32
|
-
type AddLocationWorkspaceProps =
|
|
33
|
+
type AddLocationWorkspaceProps = {
|
|
33
34
|
location?: LocationResponse;
|
|
34
35
|
};
|
|
35
36
|
|
|
@@ -46,16 +47,14 @@ const locationFormSchema = z.object({
|
|
|
46
47
|
|
|
47
48
|
type LocationFormType = z.infer<typeof locationFormSchema>;
|
|
48
49
|
|
|
49
|
-
const AddLocationWorkspace: React.FC<AddLocationWorkspaceProps
|
|
50
|
+
const AddLocationWorkspace: React.FC<Workspace2DefinitionProps<AddLocationWorkspaceProps, {}, {}>> = ({
|
|
50
51
|
closeWorkspace,
|
|
51
|
-
|
|
52
|
-
promptBeforeClosing,
|
|
53
|
-
location,
|
|
52
|
+
workspaceProps: { location = {} as LocationResponse },
|
|
54
53
|
}) => {
|
|
55
54
|
const { t } = useTranslation();
|
|
56
55
|
const isTablet = useLayoutType() === 'tablet';
|
|
57
56
|
const { locationTagList: Tags } = useLocationTags();
|
|
58
|
-
|
|
57
|
+
const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);
|
|
59
58
|
const hasLocationAttributes = useMemo(() => {
|
|
60
59
|
return location?.attributes && location.attributes.length > 0;
|
|
61
60
|
}, [location?.attributes]);
|
|
@@ -105,7 +104,7 @@ const AddLocationWorkspace: React.FC<AddLocationWorkspaceProps> = ({
|
|
|
105
104
|
}),
|
|
106
105
|
});
|
|
107
106
|
handleMutation();
|
|
108
|
-
|
|
107
|
+
closeWorkspace({ discardUnsavedChanges: true });
|
|
109
108
|
} catch (error: any) {
|
|
110
109
|
const errorMessages = extractErrorMessagesFromResponse(error);
|
|
111
110
|
showSnackbar({
|
|
@@ -117,83 +116,85 @@ const AddLocationWorkspace: React.FC<AddLocationWorkspaceProps> = ({
|
|
|
117
116
|
};
|
|
118
117
|
|
|
119
118
|
useEffect(() => {
|
|
120
|
-
|
|
121
|
-
}, [isDirty,
|
|
119
|
+
setHasUnsavedChanges(true);
|
|
120
|
+
}, [isDirty, setHasUnsavedChanges]);
|
|
122
121
|
|
|
123
122
|
return (
|
|
124
|
-
<
|
|
125
|
-
<
|
|
126
|
-
<
|
|
127
|
-
<
|
|
128
|
-
<
|
|
129
|
-
<
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
<
|
|
150
|
-
<
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
{
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
{isSubmitting
|
|
187
|
-
|
|
188
|
-
{
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
123
|
+
<Workspace2 title={t('addLocation', 'Add Location')} hasUnsavedChanges={hasUnsavedChanges}>
|
|
124
|
+
<Form onSubmit={handleSubmit(onSubmit)} className={styles.form}>
|
|
125
|
+
<div className={styles.formContainer}>
|
|
126
|
+
<Stack gap={3}>
|
|
127
|
+
<ResponsiveWrapper>
|
|
128
|
+
<FormGroup legendText="">
|
|
129
|
+
<Controller
|
|
130
|
+
control={control}
|
|
131
|
+
name="name"
|
|
132
|
+
render={({ field }) => (
|
|
133
|
+
<TextInput
|
|
134
|
+
id="locationName"
|
|
135
|
+
placeholder={t('locationPlaceholder', 'Add a location')}
|
|
136
|
+
labelText={t('locationName', 'Location Name')}
|
|
137
|
+
value={field.value}
|
|
138
|
+
onChange={field.onChange}
|
|
139
|
+
invalid={!!errors.name?.message}
|
|
140
|
+
invalidText={errors.name?.message}
|
|
141
|
+
disabled={hasLocationAttributes}
|
|
142
|
+
/>
|
|
143
|
+
)}
|
|
144
|
+
/>
|
|
145
|
+
</FormGroup>
|
|
146
|
+
</ResponsiveWrapper>
|
|
147
|
+
|
|
148
|
+
<ResponsiveWrapper>
|
|
149
|
+
<FormGroup legendText="">
|
|
150
|
+
<Controller
|
|
151
|
+
control={control}
|
|
152
|
+
name="tags"
|
|
153
|
+
render={({ field: { onChange, value, ref } }) => (
|
|
154
|
+
<FilterableMultiSelect
|
|
155
|
+
id="locationTags"
|
|
156
|
+
titleText={t('selectTags', 'Select tag(s)')}
|
|
157
|
+
placeholder={t('selectTagPlaceholder', 'Select a tag')}
|
|
158
|
+
items={Tags || []}
|
|
159
|
+
selectedItems={(value || []).map(
|
|
160
|
+
(selected) => Tags?.find((tag) => tag.uuid === selected.uuid) || selected,
|
|
161
|
+
)}
|
|
162
|
+
onChange={({ selectedItems }) => onChange(selectedItems || [])}
|
|
163
|
+
itemToString={(item) => (item && typeof item === 'object' ? item.display : '')}
|
|
164
|
+
selectionFeedback="top-after-reopen"
|
|
165
|
+
invalid={!!errors.tags?.message}
|
|
166
|
+
invalidText={errors.tags?.message}
|
|
167
|
+
disabled={!Tags?.length}
|
|
168
|
+
ref={ref}
|
|
169
|
+
/>
|
|
170
|
+
)}
|
|
171
|
+
/>
|
|
172
|
+
</FormGroup>
|
|
173
|
+
</ResponsiveWrapper>
|
|
174
|
+
</Stack>
|
|
175
|
+
</div>
|
|
176
|
+
|
|
177
|
+
<ButtonSet
|
|
178
|
+
className={classNames({
|
|
179
|
+
[styles.tablet]: isTablet,
|
|
180
|
+
[styles.desktop]: !isTablet,
|
|
181
|
+
})}>
|
|
182
|
+
<Button className={styles.buttonContainer} kind="secondary" onClick={() => closeWorkspace()}>
|
|
183
|
+
{t('cancel', 'Cancel')}
|
|
184
|
+
</Button>
|
|
185
|
+
<Button className={styles.buttonContainer} disabled={isSubmitting || !isDirty} kind="primary" type="submit">
|
|
186
|
+
{isSubmitting ? (
|
|
187
|
+
<span className={styles.inlineLoading}>
|
|
188
|
+
{t('submitting', 'Submitting' + '...')}
|
|
189
|
+
<InlineLoading status="active" iconDescription="Loading" />
|
|
190
|
+
</span>
|
|
191
|
+
) : (
|
|
192
|
+
t('saveAndClose', 'Save & close')
|
|
193
|
+
)}
|
|
194
|
+
</Button>
|
|
195
|
+
</ButtonSet>
|
|
196
|
+
</Form>
|
|
197
|
+
</Workspace2>
|
|
197
198
|
);
|
|
198
199
|
};
|
|
199
200
|
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { mutate } from 'swr';
|
|
4
|
+
import classNames from 'classnames';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { Controller, useForm } from 'react-hook-form';
|
|
2
7
|
import { zodResolver } from '@hookform/resolvers/zod';
|
|
3
8
|
import {
|
|
4
|
-
|
|
9
|
+
Workspace2,
|
|
10
|
+
Workspace2DefinitionProps,
|
|
11
|
+
useLayoutType,
|
|
5
12
|
ResponsiveWrapper,
|
|
6
13
|
restBaseUrl,
|
|
7
14
|
showSnackbar,
|
|
8
|
-
useLayoutType,
|
|
9
15
|
} from '@openmrs/esm-framework';
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
import { Controller, useForm } from 'react-hook-form';
|
|
13
|
-
import { useTranslation } from 'react-i18next';
|
|
14
|
-
import { mutate } from 'swr';
|
|
15
|
-
import { z } from 'zod';
|
|
16
|
+
import { Button, ButtonSet, FilterableMultiSelect, Form, FormGroup, InlineLoading, Stack } from '@carbon/react';
|
|
17
|
+
|
|
16
18
|
import { LocationAutosuggest } from '../../auto-suggest/location-autosuggest.component';
|
|
17
19
|
import ResultsTile from '../../common/results-tile.component';
|
|
18
|
-
import { extractErrorMessagesFromResponse } from '../../helpers';
|
|
19
|
-
import { saveOrUpdateLocation } from '../../hooks/useLocation';
|
|
20
20
|
import { useLocationTags } from '../../hooks/useLocationTags';
|
|
21
|
+
import { saveOrUpdateLocation } from '../../hooks/useLocation';
|
|
22
|
+
import { extractErrorMessagesFromResponse } from '../../helpers';
|
|
21
23
|
import { LocationResponse } from '../../types';
|
|
22
24
|
import styles from './search-location.workspace.scss';
|
|
23
25
|
|
|
24
|
-
type AddLocationWorkspaceProps =
|
|
26
|
+
type AddLocationWorkspaceProps = {
|
|
25
27
|
location?: LocationResponse;
|
|
26
28
|
};
|
|
27
29
|
|
|
@@ -37,17 +39,15 @@ const locationFormSchema = z.object({
|
|
|
37
39
|
|
|
38
40
|
type LocationFormType = z.infer<typeof locationFormSchema>;
|
|
39
41
|
|
|
40
|
-
const SearchLocationWorkspace: React.FC<AddLocationWorkspaceProps
|
|
42
|
+
const SearchLocationWorkspace: React.FC<Workspace2DefinitionProps<AddLocationWorkspaceProps, {}, {}>> = ({
|
|
41
43
|
closeWorkspace,
|
|
42
|
-
|
|
43
|
-
promptBeforeClosing,
|
|
44
|
-
location,
|
|
44
|
+
workspaceProps: { location = {} as LocationResponse },
|
|
45
45
|
}) => {
|
|
46
46
|
const { t } = useTranslation();
|
|
47
47
|
const isTablet = useLayoutType() === 'tablet';
|
|
48
48
|
const { locationTagList: Tags } = useLocationTags();
|
|
49
49
|
const [selectedLocation, setSelectedLocation] = useState<LocationResponse | null>(null);
|
|
50
|
-
|
|
50
|
+
const [hasUnsavedChanges, setHasUnsavedChanges] = useState(false);
|
|
51
51
|
const handleMutation = () => {
|
|
52
52
|
const url = `${restBaseUrl}/location`;
|
|
53
53
|
mutate((key) => typeof key === 'string' && key.startsWith(url), undefined, { revalidate: true });
|
|
@@ -56,7 +56,6 @@ const SearchLocationWorkspace: React.FC<AddLocationWorkspaceProps> = ({
|
|
|
56
56
|
const {
|
|
57
57
|
handleSubmit,
|
|
58
58
|
control,
|
|
59
|
-
getValues,
|
|
60
59
|
setValue,
|
|
61
60
|
reset,
|
|
62
61
|
formState: { isSubmitting, isDirty, errors },
|
|
@@ -89,7 +88,7 @@ const SearchLocationWorkspace: React.FC<AddLocationWorkspaceProps> = ({
|
|
|
89
88
|
});
|
|
90
89
|
|
|
91
90
|
handleMutation();
|
|
92
|
-
|
|
91
|
+
closeWorkspace({ discardUnsavedChanges: true });
|
|
93
92
|
} catch (error: any) {
|
|
94
93
|
console.error('Error saving location:', error);
|
|
95
94
|
const errorMessages = extractErrorMessagesFromResponse(error);
|
|
@@ -137,78 +136,84 @@ const SearchLocationWorkspace: React.FC<AddLocationWorkspaceProps> = ({
|
|
|
137
136
|
};
|
|
138
137
|
|
|
139
138
|
useEffect(() => {
|
|
140
|
-
|
|
141
|
-
}, [isDirty,
|
|
139
|
+
setHasUnsavedChanges(true);
|
|
140
|
+
}, [isDirty, setHasUnsavedChanges]);
|
|
142
141
|
|
|
143
142
|
const isFormReady = (selectedLocation || location) && isDirty;
|
|
144
143
|
|
|
145
144
|
return (
|
|
146
|
-
<
|
|
147
|
-
<
|
|
148
|
-
<
|
|
149
|
-
<
|
|
150
|
-
<
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
) : (
|
|
158
|
-
renderSelectedLocationTile()
|
|
159
|
-
)}
|
|
160
|
-
</FormGroup>
|
|
161
|
-
</ResponsiveWrapper>
|
|
162
|
-
|
|
163
|
-
<ResponsiveWrapper>
|
|
164
|
-
<FormGroup legendText="">
|
|
165
|
-
<Controller
|
|
166
|
-
control={control}
|
|
167
|
-
name="tags"
|
|
168
|
-
render={({ field: { onChange, value, ref } }) => (
|
|
169
|
-
<FilterableMultiSelect
|
|
170
|
-
id="locationTags"
|
|
171
|
-
titleText={t('selectTags', 'Select tag(s)')}
|
|
172
|
-
placeholder={t('selectTagPlaceholder', 'Select a tag')}
|
|
173
|
-
items={Tags || []}
|
|
174
|
-
selectedItems={(value || []).map(
|
|
175
|
-
(selected) => Tags?.find((tag) => tag.uuid === selected.uuid) || selected,
|
|
176
|
-
)}
|
|
177
|
-
onChange={({ selectedItems }) => onChange(selectedItems || [])}
|
|
178
|
-
itemToString={(item) => (item && typeof item === 'object' ? item.display : '')}
|
|
179
|
-
selectionFeedback="top-after-reopen"
|
|
180
|
-
invalid={!!errors.tags?.message}
|
|
181
|
-
invalidText={errors.tags?.message}
|
|
182
|
-
disabled={!Tags?.length}
|
|
183
|
-
ref={ref}
|
|
145
|
+
<Workspace2 title={t('searchLocation', 'Search Location')} hasUnsavedChanges={hasUnsavedChanges}>
|
|
146
|
+
<Form onSubmit={handleSubmit(onSubmit)} className={styles.form}>
|
|
147
|
+
<div className={styles.formContainer}>
|
|
148
|
+
<Stack gap={3}>
|
|
149
|
+
<ResponsiveWrapper>
|
|
150
|
+
<FormGroup legendText="">
|
|
151
|
+
{!selectedLocation ? (
|
|
152
|
+
<LocationAutosuggest
|
|
153
|
+
onLocationSelected={handleLocationSelected}
|
|
154
|
+
labelText={t('searchForLocation', 'Search for location')}
|
|
155
|
+
placeholder={t('searchParentLocation', 'Search for location...')}
|
|
184
156
|
/>
|
|
157
|
+
) : (
|
|
158
|
+
renderSelectedLocationTile()
|
|
185
159
|
)}
|
|
186
|
-
|
|
187
|
-
</
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
160
|
+
</FormGroup>
|
|
161
|
+
</ResponsiveWrapper>
|
|
162
|
+
|
|
163
|
+
<ResponsiveWrapper>
|
|
164
|
+
<FormGroup legendText="">
|
|
165
|
+
<Controller
|
|
166
|
+
control={control}
|
|
167
|
+
name="tags"
|
|
168
|
+
render={({ field: { onChange, value, ref } }) => (
|
|
169
|
+
<FilterableMultiSelect
|
|
170
|
+
id="locationTags"
|
|
171
|
+
titleText={t('selectTags', 'Select tag(s)')}
|
|
172
|
+
placeholder={t('selectTagPlaceholder', 'Select a tag')}
|
|
173
|
+
items={Tags || []}
|
|
174
|
+
selectedItems={(value || []).map(
|
|
175
|
+
(selected) => Tags?.find((tag) => tag.uuid === selected.uuid) || selected,
|
|
176
|
+
)}
|
|
177
|
+
onChange={({ selectedItems }) => onChange(selectedItems || [])}
|
|
178
|
+
itemToString={(item) => (item && typeof item === 'object' ? item.display : '')}
|
|
179
|
+
selectionFeedback="top-after-reopen"
|
|
180
|
+
invalid={!!errors.tags?.message}
|
|
181
|
+
invalidText={errors.tags?.message}
|
|
182
|
+
disabled={!Tags?.length}
|
|
183
|
+
ref={ref}
|
|
184
|
+
/>
|
|
185
|
+
)}
|
|
186
|
+
/>
|
|
187
|
+
</FormGroup>
|
|
188
|
+
</ResponsiveWrapper>
|
|
189
|
+
</Stack>
|
|
190
|
+
</div>
|
|
191
|
+
|
|
192
|
+
<ButtonSet
|
|
193
|
+
className={classNames({
|
|
194
|
+
[styles.tablet]: isTablet,
|
|
195
|
+
[styles.desktop]: !isTablet,
|
|
196
|
+
})}>
|
|
197
|
+
<Button className={styles.buttonContainer} kind="secondary" onClick={() => closeWorkspace()}>
|
|
198
|
+
{t('cancel', 'Cancel')}
|
|
199
|
+
</Button>
|
|
200
|
+
<Button
|
|
201
|
+
className={styles.buttonContainer}
|
|
202
|
+
disabled={isSubmitting || !isFormReady}
|
|
203
|
+
kind="primary"
|
|
204
|
+
type="submit">
|
|
205
|
+
{isSubmitting ? (
|
|
206
|
+
<span className={styles.inlineLoading}>
|
|
207
|
+
{t('submitting', 'Submitting' + '...')}
|
|
208
|
+
<InlineLoading status="active" iconDescription="Loading" />
|
|
209
|
+
</span>
|
|
210
|
+
) : (
|
|
211
|
+
t('saveAndClose', 'Save & close')
|
|
212
|
+
)}
|
|
213
|
+
</Button>
|
|
214
|
+
</ButtonSet>
|
|
215
|
+
</Form>
|
|
216
|
+
</Workspace2>
|
|
212
217
|
);
|
|
213
218
|
};
|
|
214
219
|
|