@openmrs/esm-stock-management-app 3.1.1-pre.1074 → 3.1.1-pre.1077
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 +2 -2
- package/dist/5125.js +1 -1
- package/dist/5125.js.map +1 -1
- package/dist/9186.js +1 -1
- package/dist/9186.js.map +1 -1
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/dist/openmrs-esm-stock-management-app.js.buildmanifest.json +9 -9
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/config-schema.ts +45 -45
- package/src/stock-items/add-stock-item/concepts-selector/concepts-selector.component.tsx +29 -28
- package/src/stock-items/add-stock-item/dispensing-unit-selector/dispensing-unit-selector.component.tsx +30 -30
- package/src/stock-items/add-stock-item/packaging-units-concept-selector/packaging-units-concept-selector.component.tsx +2 -2
|
@@ -847,9 +847,9 @@
|
|
|
847
847
|
"initial": false,
|
|
848
848
|
"entry": false,
|
|
849
849
|
"recorded": false,
|
|
850
|
-
"size":
|
|
850
|
+
"size": 1193875,
|
|
851
851
|
"sizes": {
|
|
852
|
-
"javascript":
|
|
852
|
+
"javascript": 1193875
|
|
853
853
|
},
|
|
854
854
|
"names": [],
|
|
855
855
|
"idHints": [],
|
|
@@ -862,7 +862,7 @@
|
|
|
862
862
|
"auxiliaryFiles": [
|
|
863
863
|
"5125.js.map"
|
|
864
864
|
],
|
|
865
|
-
"hash": "
|
|
865
|
+
"hash": "a8605db42d7160df",
|
|
866
866
|
"childrenByOrder": {}
|
|
867
867
|
},
|
|
868
868
|
{
|
|
@@ -1539,10 +1539,10 @@
|
|
|
1539
1539
|
"initial": true,
|
|
1540
1540
|
"entry": true,
|
|
1541
1541
|
"recorded": false,
|
|
1542
|
-
"size":
|
|
1542
|
+
"size": 5542519,
|
|
1543
1543
|
"sizes": {
|
|
1544
1544
|
"consume-shared": 210,
|
|
1545
|
-
"javascript":
|
|
1545
|
+
"javascript": 5520284,
|
|
1546
1546
|
"share-init": 336,
|
|
1547
1547
|
"runtime": 21689
|
|
1548
1548
|
},
|
|
@@ -1559,7 +1559,7 @@
|
|
|
1559
1559
|
"auxiliaryFiles": [
|
|
1560
1560
|
"main.js.map"
|
|
1561
1561
|
],
|
|
1562
|
-
"hash": "
|
|
1562
|
+
"hash": "a9adc5f3fa83c00b",
|
|
1563
1563
|
"childrenByOrder": {}
|
|
1564
1564
|
},
|
|
1565
1565
|
{
|
|
@@ -1567,9 +1567,9 @@
|
|
|
1567
1567
|
"initial": false,
|
|
1568
1568
|
"entry": false,
|
|
1569
1569
|
"recorded": false,
|
|
1570
|
-
"size":
|
|
1570
|
+
"size": 216707,
|
|
1571
1571
|
"sizes": {
|
|
1572
|
-
"javascript":
|
|
1572
|
+
"javascript": 216707
|
|
1573
1573
|
},
|
|
1574
1574
|
"names": [],
|
|
1575
1575
|
"idHints": [],
|
|
@@ -1583,7 +1583,7 @@
|
|
|
1583
1583
|
"auxiliaryFiles": [
|
|
1584
1584
|
"9186.js.map"
|
|
1585
1585
|
],
|
|
1586
|
-
"hash": "
|
|
1586
|
+
"hash": "2d43ab620ea08fc4",
|
|
1587
1587
|
"childrenByOrder": {}
|
|
1588
1588
|
},
|
|
1589
1589
|
{
|
package/dist/routes.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-nav-menu","slot":"stock-sidebar-slot","component":"stockNavMenu","online":true,"offline":true},{"name":"overview-db-link","slot":"stock-page-dashboard-slot","component":"stockOverviewLink","meta":{"name":"overview","slot":"overview-dashboard-slot","title":"overview"},"order":0,"online":true,"offline":true},{"name":"stock-overview-db","slot":"overview-dashboard-slot","component":"stockOverview"},{"name":"operations-db-link","slot":"stock-page-dashboard-slot","component":"stockOperationsLink","meta":{"name":"operations","slot":"operations-dashboard-slot","title":"operations"},"order":2,"online":true,"offline":true},{"name":"stock-operations-db","slot":"operations-dashboard-slot","component":"stockOperations"},{"name":"items-db-link","slot":"stock-page-dashboard-slot","component":"stockItemsLink","meta":{"name":"items","slot":"items-dashboard-slot","title":"items"},"order":1,"online":true,"offline":true},{"name":"stock-items-db","slot":"items-dashboard-slot","component":"stockItems"},{"name":"user-scopes-db-link","slot":"stock-page-dashboard-slot","component":"stockUserScopesLink","meta":{"name":"user-scopes","slot":"user-scopes-dashboard-slot","title":"user-scopes"},"order":3,"online":true,"offline":true},{"name":"stock-user-scopes-db","slot":"user-scopes-dashboard-slot","component":"stockUserScopes"},{"name":"sources-db-link","slot":"stock-page-dashboard-slot","component":"stockSourcesLink","meta":{"name":"sources","slot":"sources-dashboard-slot","title":"Sources"},"order":2,"online":true,"offline":true},{"name":"stock-sources-db","slot":"sources-dashboard-slot","component":"stockSources"},{"name":"reports-db-link","slot":"stock-page-dashboard-slot","component":"stockReportsLink","meta":{"name":"reports","slot":"reports-dashboard-slot","title":"Reports"},"order":5,"online":true,"offline":true},{"name":"stock-reports-db","slot":"reports-dashboard-slot","component":"stockReports"},{"name":"settings-db-link","slot":"stock-page-dashboard-slot","component":"stockSettingsLink","meta":{"name":"settings","slot":"settings-dashboard-slot","title":"Settings"},"order":6,"online":true,"offline":true},{"name":"stock-settings-db","slot":"settings-dashboard-slot","component":"stockSettings"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"modals":[{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"expired-stock-modal","component":"expiredStockModal"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsModal"},{"name":"receiving-stock-modal","component":"receivingStockModal"},{"name":"stock-operations-modal","component":"stockOperationsModal"},{"name":"transactions-print-bincard-preview-modal","component":"transactionBincardPrintPreviewModal"},{"name":"transactions-print-stockcard-preview-modal","component":"transactionStockcardPrintPreviewModal"}],"workspaces":[{"name":"stock-operation-form-workspace","component":"stockOperationFormWorkspace","title":"Stock Operation","type":"form","canMaximize":true,"width":"extra-wide"},{"name":"stock-item-rules-form-workspace","component":"stockItemRulesFormWorkspace","title":"Stock Item Rules","type":"form"},{"name":"stock-item-form-workspace","component":"stockItemFormWorkspace","title":"Stock Items","type":"form","canMaximize":true,"width":"extra-wide"},{"name":"stock-sources-form-workspace","component":"stockSourcesFormWorkspace","title":"Stock Sources","type":"form","canMaximize":true,"width":"extra-wide"},{"name":"stock-location-form-workspace","component":"stockLocationsFormWorkspace","title":"Stock Locations","type":"form","canMaximize":true,"width":"extra-wide"},{"name":"stock-user-role-scopes-form-workspace","component":"stockUserScopesFormWorkspace","title":"User Role Scopes","type":"form","canMaximize":true,"width":"extra-wide"},{"name":"stock-reports-form-workspace","component":"stockReportsFormWorkspace","title":"Reports","type":"form","canMaximize":true,"width":"extra-wide"}],"pages":[{"component":"root","route":"stock-management"}],"version":"3.1.1-pre.
|
|
1
|
+
{"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-nav-menu","slot":"stock-sidebar-slot","component":"stockNavMenu","online":true,"offline":true},{"name":"overview-db-link","slot":"stock-page-dashboard-slot","component":"stockOverviewLink","meta":{"name":"overview","slot":"overview-dashboard-slot","title":"overview"},"order":0,"online":true,"offline":true},{"name":"stock-overview-db","slot":"overview-dashboard-slot","component":"stockOverview"},{"name":"operations-db-link","slot":"stock-page-dashboard-slot","component":"stockOperationsLink","meta":{"name":"operations","slot":"operations-dashboard-slot","title":"operations"},"order":2,"online":true,"offline":true},{"name":"stock-operations-db","slot":"operations-dashboard-slot","component":"stockOperations"},{"name":"items-db-link","slot":"stock-page-dashboard-slot","component":"stockItemsLink","meta":{"name":"items","slot":"items-dashboard-slot","title":"items"},"order":1,"online":true,"offline":true},{"name":"stock-items-db","slot":"items-dashboard-slot","component":"stockItems"},{"name":"user-scopes-db-link","slot":"stock-page-dashboard-slot","component":"stockUserScopesLink","meta":{"name":"user-scopes","slot":"user-scopes-dashboard-slot","title":"user-scopes"},"order":3,"online":true,"offline":true},{"name":"stock-user-scopes-db","slot":"user-scopes-dashboard-slot","component":"stockUserScopes"},{"name":"sources-db-link","slot":"stock-page-dashboard-slot","component":"stockSourcesLink","meta":{"name":"sources","slot":"sources-dashboard-slot","title":"Sources"},"order":2,"online":true,"offline":true},{"name":"stock-sources-db","slot":"sources-dashboard-slot","component":"stockSources"},{"name":"reports-db-link","slot":"stock-page-dashboard-slot","component":"stockReportsLink","meta":{"name":"reports","slot":"reports-dashboard-slot","title":"Reports"},"order":5,"online":true,"offline":true},{"name":"stock-reports-db","slot":"reports-dashboard-slot","component":"stockReports"},{"name":"settings-db-link","slot":"stock-page-dashboard-slot","component":"stockSettingsLink","meta":{"name":"settings","slot":"settings-dashboard-slot","title":"Settings"},"order":6,"online":true,"offline":true},{"name":"stock-settings-db","slot":"settings-dashboard-slot","component":"stockSettings"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"modals":[{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"expired-stock-modal","component":"expiredStockModal"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsModal"},{"name":"receiving-stock-modal","component":"receivingStockModal"},{"name":"stock-operations-modal","component":"stockOperationsModal"},{"name":"transactions-print-bincard-preview-modal","component":"transactionBincardPrintPreviewModal"},{"name":"transactions-print-stockcard-preview-modal","component":"transactionStockcardPrintPreviewModal"}],"workspaces":[{"name":"stock-operation-form-workspace","component":"stockOperationFormWorkspace","title":"Stock Operation","type":"form","canMaximize":true,"width":"extra-wide"},{"name":"stock-item-rules-form-workspace","component":"stockItemRulesFormWorkspace","title":"Stock Item Rules","type":"form"},{"name":"stock-item-form-workspace","component":"stockItemFormWorkspace","title":"Stock Items","type":"form","canMaximize":true,"width":"extra-wide"},{"name":"stock-sources-form-workspace","component":"stockSourcesFormWorkspace","title":"Stock Sources","type":"form","canMaximize":true,"width":"extra-wide"},{"name":"stock-location-form-workspace","component":"stockLocationsFormWorkspace","title":"Stock Locations","type":"form","canMaximize":true,"width":"extra-wide"},{"name":"stock-user-role-scopes-form-workspace","component":"stockUserScopesFormWorkspace","title":"User Role Scopes","type":"form","canMaximize":true,"width":"extra-wide"},{"name":"stock-reports-form-workspace","component":"stockReportsFormWorkspace","title":"Reports","type":"form","canMaximize":true,"width":"extra-wide"}],"pages":[{"component":"root","route":"stock-management"}],"version":"3.1.1-pre.1077"}
|
package/package.json
CHANGED
package/src/config-schema.ts
CHANGED
|
@@ -1,77 +1,77 @@
|
|
|
1
1
|
import { Type } from '@openmrs/esm-framework';
|
|
2
2
|
export const configSchema = {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
autoPopulateResponsiblePerson: {
|
|
4
|
+
_type: Type.Boolean,
|
|
5
5
|
_default: false,
|
|
6
|
-
_description: '
|
|
6
|
+
_description: 'Auto-populate responsible person in stock operations with the currently logged-in user',
|
|
7
|
+
},
|
|
8
|
+
dispensingUnitsUUID: {
|
|
9
|
+
_type: Type.ConceptUuid,
|
|
10
|
+
_description: 'UUID for the stock dispensing units',
|
|
11
|
+
_default: '162402AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA',
|
|
7
12
|
},
|
|
8
13
|
enablePrintButton: {
|
|
9
14
|
_type: Type.Boolean,
|
|
10
15
|
_default: true,
|
|
11
16
|
_description: 'Enable or disable the print button in the stock management UI',
|
|
12
17
|
},
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
logo: {
|
|
19
|
+
src: {
|
|
20
|
+
_type: Type.String,
|
|
21
|
+
_default: null,
|
|
22
|
+
_description: 'A path or URL to an image',
|
|
23
|
+
},
|
|
24
|
+
alt: {
|
|
25
|
+
_type: Type.String,
|
|
26
|
+
_default: 'Logo',
|
|
27
|
+
_description: 'Alt text shown on hover',
|
|
28
|
+
},
|
|
29
|
+
name: {
|
|
30
|
+
_type: Type.String,
|
|
31
|
+
_default: null,
|
|
32
|
+
_description: 'The organization name displayed when image is absent',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
packingUnitsUUID: {
|
|
36
|
+
_type: Type.ConceptUuid,
|
|
37
|
+
_description: 'UUID for the packaging unit',
|
|
38
|
+
_default: 'a6d438fe-05c1-4d4d-9755-c11cf6b0b3b9',
|
|
17
39
|
},
|
|
18
40
|
printBalanceOnHand: {
|
|
19
|
-
|
|
41
|
+
_type: Type.Boolean,
|
|
20
42
|
_default: false,
|
|
21
|
-
_description: 'Whether to
|
|
43
|
+
_description: 'Whether to include balance on hand on the printout',
|
|
22
44
|
},
|
|
23
|
-
|
|
24
|
-
_type: Type.
|
|
25
|
-
|
|
26
|
-
|
|
45
|
+
printItemCost: {
|
|
46
|
+
_type: Type.Boolean,
|
|
47
|
+
_default: false,
|
|
48
|
+
_description: 'Whether to include item costs on the printout',
|
|
27
49
|
},
|
|
28
50
|
stockAdjustmentReasonUUID: {
|
|
29
51
|
_type: Type.ConceptUuid,
|
|
30
52
|
_description: 'UUID for the stock adjustment reasons',
|
|
31
|
-
_default: '
|
|
53
|
+
_default: '3a9021d1-d6c1-4fc2-8e30-ca8e204e44de',
|
|
32
54
|
},
|
|
33
|
-
|
|
55
|
+
stockItemCategoryUUID: {
|
|
34
56
|
_type: Type.ConceptUuid,
|
|
35
|
-
_description: 'UUID for the stock
|
|
36
|
-
_default: '
|
|
57
|
+
_description: 'UUID for the stock item category',
|
|
58
|
+
_default: '8ccf6066-9297-4d76-aaf3-00aa3714d198',
|
|
37
59
|
},
|
|
38
60
|
stockSourceTypeUUID: {
|
|
39
61
|
_type: Type.ConceptUuid,
|
|
40
62
|
_description: 'UUID for the stock source types',
|
|
41
|
-
_default: '
|
|
63
|
+
_default: '937a0440-95f7-42f6-aaef-16cf611fcf10',
|
|
42
64
|
},
|
|
43
|
-
|
|
65
|
+
stockTakeReasonUUID: {
|
|
44
66
|
_type: Type.ConceptUuid,
|
|
45
|
-
_description: 'UUID for the stock
|
|
46
|
-
_default: '
|
|
67
|
+
_description: 'UUID for the stock take reasons',
|
|
68
|
+
_default: 'faa466c5-0953-4d4f-8ea7-d9a06341c3f3',
|
|
47
69
|
},
|
|
48
70
|
useItemCommonNameAsDisplay: {
|
|
49
71
|
_type: Type.Boolean,
|
|
50
|
-
_description: '
|
|
72
|
+
_description: 'Use item common name as display (true) or drug name as display (false)',
|
|
51
73
|
_default: true,
|
|
52
74
|
},
|
|
53
|
-
stockItemCategoryUUID: {
|
|
54
|
-
_type: Type.ConceptUuid,
|
|
55
|
-
_description: 'UUID for the stock item category',
|
|
56
|
-
_default: '6d24eb6e-b42f-4706-ab2d-ae4472161f6a',
|
|
57
|
-
},
|
|
58
|
-
logo: {
|
|
59
|
-
src: {
|
|
60
|
-
_type: Type.String,
|
|
61
|
-
_default: null,
|
|
62
|
-
_description: 'A path or URL to an image.',
|
|
63
|
-
},
|
|
64
|
-
alt: {
|
|
65
|
-
_type: Type.String,
|
|
66
|
-
_default: 'Logo',
|
|
67
|
-
_description: 'Alt text, shown on hover',
|
|
68
|
-
},
|
|
69
|
-
name: {
|
|
70
|
-
_type: Type.String,
|
|
71
|
-
_default: null,
|
|
72
|
-
_description: 'The organization name displayed when image is absent',
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
75
|
};
|
|
76
76
|
|
|
77
77
|
export type ConfigObject = {
|
|
@@ -83,7 +83,7 @@ export type ConfigObject = {
|
|
|
83
83
|
alt: string;
|
|
84
84
|
name: string;
|
|
85
85
|
};
|
|
86
|
-
|
|
86
|
+
packingUnitsUUID: string;
|
|
87
87
|
printBalanceOnHand: boolean;
|
|
88
88
|
printItemCost: boolean;
|
|
89
89
|
stockAdjustmentReasonUUID: string;
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import React, { type ReactNode, useMemo, useState } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ComboBox, TextInputSkeleton } from '@carbon/react';
|
|
3
3
|
import { type Control, Controller, type FieldValues } from 'react-hook-form';
|
|
4
|
+
import { type Concept } from '../../../core/api/types/concept/Concept';
|
|
4
5
|
import { useConcepts } from '../../../stock-lookups/stock-lookups.resource';
|
|
5
|
-
import { ComboBox, TextInputSkeleton } from '@carbon/react';
|
|
6
6
|
|
|
7
7
|
interface ConceptsSelectorProps<T> {
|
|
8
8
|
conceptUuid?: string;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
placeholder?: string;
|
|
9
|
+
control: Control<FieldValues, T>;
|
|
10
|
+
controllerName: string;
|
|
12
11
|
invalid?: boolean;
|
|
13
12
|
invalidText?: ReactNode;
|
|
14
|
-
|
|
15
|
-
// Control
|
|
16
|
-
controllerName: string;
|
|
17
13
|
name: string;
|
|
18
|
-
|
|
14
|
+
onConceptUuidChange?: (unit: Concept) => void;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
title?: string;
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
const ConceptsSelector = <T,>(props: ConceptsSelectorProps<T>) => {
|
|
@@ -24,7 +22,8 @@ const ConceptsSelector = <T,>(props: ConceptsSelectorProps<T>) => {
|
|
|
24
22
|
isLoading,
|
|
25
23
|
} = useConcepts({});
|
|
26
24
|
const [inputValue, setInputValue] = useState('');
|
|
27
|
-
|
|
25
|
+
|
|
26
|
+
const handleInputChange = (value: string) => {
|
|
28
27
|
setInputValue(value);
|
|
29
28
|
};
|
|
30
29
|
|
|
@@ -34,34 +33,36 @@ const ConceptsSelector = <T,>(props: ConceptsSelectorProps<T>) => {
|
|
|
34
33
|
: concepts.filter((concept) => concept.display?.toLowerCase().includes(inputValue.trim()?.toLowerCase()));
|
|
35
34
|
}, [inputValue, concepts]);
|
|
36
35
|
|
|
37
|
-
if (isLoading)
|
|
36
|
+
if (isLoading) {
|
|
37
|
+
return <TextInputSkeleton />;
|
|
38
|
+
}
|
|
38
39
|
|
|
39
40
|
return (
|
|
40
41
|
<Controller
|
|
41
|
-
name={props.controllerName}
|
|
42
42
|
control={props.control}
|
|
43
|
-
|
|
43
|
+
name={props.controllerName}
|
|
44
|
+
render={({ field: { onChange, value, ref } }) => (
|
|
44
45
|
<ComboBox
|
|
45
|
-
titleText={props.title}
|
|
46
|
-
name={props.name}
|
|
47
|
-
control={props.control}
|
|
48
|
-
controllerName={props.controllerName}
|
|
49
46
|
id={props.name}
|
|
50
|
-
|
|
47
|
+
invalid={props.invalid}
|
|
48
|
+
invalidText={props.invalidText}
|
|
51
49
|
items={filteredConcepts}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
itemToString={(item?: Concept) => item?.display ?? ''}
|
|
51
|
+
name={props.name}
|
|
52
|
+
onChange={(data: { selectedItem: Concept | null }) => {
|
|
53
|
+
if (data.selectedItem) {
|
|
54
|
+
props.onConceptUuidChange?.(data.selectedItem);
|
|
55
|
+
onChange(data.selectedItem.uuid);
|
|
56
|
+
} else {
|
|
57
|
+
onChange('');
|
|
58
|
+
}
|
|
55
59
|
}}
|
|
56
|
-
|
|
57
|
-
itemToString={(item?: Concept) => (item && item?.display ? `${item?.display}` : '')}
|
|
58
|
-
shouldFilterItem={() => true}
|
|
59
|
-
onInputChange={(event) => handleInputChange(event)}
|
|
60
|
-
inputValue={inputValue}
|
|
60
|
+
onInputChange={handleInputChange}
|
|
61
61
|
placeholder={props.placeholder}
|
|
62
62
|
ref={ref}
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
selectedItem={concepts?.find((p) => p.uuid === value) ?? null}
|
|
64
|
+
size="md"
|
|
65
|
+
titleText={props.title}
|
|
65
66
|
/>
|
|
66
67
|
)}
|
|
67
68
|
/>
|
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
import React, { type ReactNode } from 'react';
|
|
2
2
|
import { ComboBox, TextInputSkeleton } from '@carbon/react';
|
|
3
|
-
import { useConcept } from '../../../stock-lookups/stock-lookups.resource';
|
|
4
|
-
import { type Concept } from '../../../core/api/types/concept/Concept';
|
|
5
3
|
import { type Control, Controller, type FieldValues } from 'react-hook-form';
|
|
6
|
-
import { type ConfigObject } from '../../../config-schema';
|
|
7
4
|
import { useConfig } from '@openmrs/esm-framework';
|
|
5
|
+
import { type Concept } from '../../../core/api/types/concept/Concept';
|
|
6
|
+
import { type ConfigObject } from '../../../config-schema';
|
|
7
|
+
import { useConcept } from '../../../stock-lookups/stock-lookups.resource';
|
|
8
8
|
|
|
9
9
|
interface DispensingUnitSelectorProps<T> {
|
|
10
|
+
control: Control<FieldValues, T>;
|
|
11
|
+
controllerName: string;
|
|
10
12
|
dispensingUnitUuid?: string;
|
|
11
|
-
onDispensingUnitChange?: (unit: Concept) => void;
|
|
12
|
-
title?: string;
|
|
13
|
-
placeholder?: string;
|
|
14
13
|
invalid?: boolean;
|
|
15
14
|
invalidText?: ReactNode;
|
|
16
|
-
|
|
17
|
-
// Control
|
|
18
|
-
controllerName: string;
|
|
19
15
|
name: string;
|
|
20
|
-
|
|
16
|
+
onDispensingUnitChange?: (unit: Concept) => void;
|
|
17
|
+
placeholder?: string;
|
|
18
|
+
title?: string;
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
const DispensingUnitSelector = <T,>(props: DispensingUnitSelectorProps<T>) => {
|
|
24
|
-
const {
|
|
22
|
+
const { packingUnitsUUID } = useConfig<ConfigObject>();
|
|
25
23
|
const {
|
|
26
|
-
items: {
|
|
24
|
+
items: { answers: packingUnits },
|
|
27
25
|
isLoading,
|
|
28
|
-
} = useConcept(
|
|
26
|
+
} = useConcept(packingUnitsUUID);
|
|
29
27
|
|
|
30
|
-
if (isLoading)
|
|
28
|
+
if (isLoading) {
|
|
29
|
+
return <TextInputSkeleton />;
|
|
30
|
+
}
|
|
31
31
|
|
|
32
32
|
return (
|
|
33
33
|
<Controller
|
|
34
|
-
name={props.controllerName}
|
|
35
34
|
control={props.control}
|
|
35
|
+
name={props.controllerName}
|
|
36
36
|
render={({ field: { onChange, value, ref } }) => (
|
|
37
37
|
<ComboBox
|
|
38
|
-
titleText={props.title}
|
|
39
|
-
name={props.name}
|
|
40
|
-
control={props.control}
|
|
41
|
-
controllerName={props.controllerName}
|
|
42
38
|
id={props.name}
|
|
43
|
-
|
|
44
|
-
items={
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
39
|
+
name={props.name}
|
|
40
|
+
items={packingUnits || []}
|
|
41
|
+
selectedItem={packingUnits?.find((p) => p.uuid === value) ?? null}
|
|
42
|
+
invalid={props.invalid}
|
|
43
|
+
invalidText={props.invalidText}
|
|
44
|
+
itemToString={(item?: Concept) => item?.display ?? ''}
|
|
45
|
+
onChange={(data: { selectedItem: Concept | null }) => {
|
|
46
|
+
if (data.selectedItem) {
|
|
47
|
+
props.onDispensingUnitChange?.(data.selectedItem);
|
|
48
|
+
onChange(data.selectedItem.uuid);
|
|
49
|
+
} else {
|
|
50
|
+
onChange('');
|
|
51
|
+
}
|
|
48
52
|
}}
|
|
49
|
-
initialSelectedItem={dispensingUnits?.find((p) => p.uuid === props.dispensingUnitUuid) || {}}
|
|
50
|
-
itemToString={(item?: Concept) => (item && item?.display ? `${item?.display}` : '')}
|
|
51
|
-
shouldFilterItem={() => true}
|
|
52
|
-
value={dispensingUnits?.find((p) => p.uuid === value)?.display ?? ''}
|
|
53
53
|
placeholder={props.placeholder}
|
|
54
54
|
ref={ref}
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
size="md"
|
|
56
|
+
titleText={props.title}
|
|
57
57
|
/>
|
|
58
58
|
)}
|
|
59
59
|
/>
|
|
@@ -22,12 +22,12 @@ interface PackagingUnitsConceptSelectorProps<T> {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const PackagingUnitsConceptSelector = <T,>(props: PackagingUnitsConceptSelectorProps<T>) => {
|
|
25
|
-
const {
|
|
25
|
+
const { packingUnitsUUID } = useConfig<ConfigObject>();
|
|
26
26
|
|
|
27
27
|
const {
|
|
28
28
|
items: { answers: dispensingUnits },
|
|
29
29
|
isLoading,
|
|
30
|
-
} = useConcept(
|
|
30
|
+
} = useConcept(packingUnitsUUID);
|
|
31
31
|
|
|
32
32
|
if (isLoading) return <TextInputSkeleton />;
|
|
33
33
|
|