@openmrs/esm-stock-management-app 1.0.1-pre.451 → 1.0.1-pre.455

Sign up to get free protection for your applications and to get access to all the features.
@@ -86,10 +86,10 @@
86
86
  "initial": true,
87
87
  "entry": true,
88
88
  "recorded": false,
89
- "size": 4776371,
89
+ "size": 4778213,
90
90
  "sizes": {
91
91
  "consume-shared": 252,
92
- "javascript": 4754422,
92
+ "javascript": 4756264,
93
93
  "share-init": 252,
94
94
  "runtime": 21445
95
95
  },
@@ -106,7 +106,7 @@
106
106
  "auxiliaryFiles": [
107
107
  "main.js.map"
108
108
  ],
109
- "hash": "a0d720ed4bc49f02",
109
+ "hash": "39f7c5ec0dbf836c",
110
110
  "childrenByOrder": {}
111
111
  },
112
112
  {
@@ -164,9 +164,9 @@
164
164
  "initial": false,
165
165
  "entry": false,
166
166
  "recorded": false,
167
- "size": 1085190,
167
+ "size": 1087032,
168
168
  "sizes": {
169
- "javascript": 1084980,
169
+ "javascript": 1086822,
170
170
  "consume-shared": 210
171
171
  },
172
172
  "names": [],
@@ -180,7 +180,7 @@
180
180
  "auxiliaryFiles": [
181
181
  "457.js.map"
182
182
  ],
183
- "hash": "a82fbdde638d7656",
183
+ "hash": "163eee371c885016",
184
184
  "childrenByOrder": {}
185
185
  },
186
186
  {
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-management-dashboard","slot":"stock-management-dashboard-slot","component":"stockManagementDashboard"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-operation-dialog","component":"stockOperationDialog"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsDialog"},{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"pages":[{"component":"stockManagement","route":"stock-management"}],"version":"1.0.1-pre.451"}
1
+ {"$schema":"https://json.openmrs.org/routes.schema.json","backendDependencies":{"fhir2":">=1.2","webservices.rest":"^2.24.0"},"extensions":[{"name":"stock-management-dashboard","slot":"stock-management-dashboard-slot","component":"stockManagementDashboard"},{"name":"stock-management-admin-card-link","slot":"system-admin-page-card-link-slot","component":"stockManagementAdminCardLink"},{"name":"stock-operation-dialog","component":"stockOperationDialog"},{"name":"import-bulk-stock-items","component":"importBulkStockItemsDialog"},{"name":"delete-stock-modal","component":"deleteStockModal"},{"name":"delete-stock-user-scope-modal","component":"deleteUserScopeModal"},{"name":"stock-management-app-menu-item","component":"stockManagementAppMenuItem","slot":"app-menu-item-slot","meta":{"name":" Stock Management"}},{"name":"delete-stock-rule-modal","component":"deleteStockRuleModal"},{"name":"delete-packaging-unit-modal","component":"deletePackagingUnitModal"},{"name":"delete-packaging-unit-button","component":"deletePackagingUnitButton"}],"pages":[{"component":"stockManagement","route":"stock-management"}],"version":"1.0.1-pre.455"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-stock-management-app",
3
- "version": "1.0.1-pre.451",
3
+ "version": "1.0.1-pre.455",
4
4
  "license": "MPL-2.0",
5
5
  "description": "Stock management microfrontend for OpenMRS 3.x",
6
6
  "browser": "dist/openmrs-esm-stock-management-app.js",
@@ -14,6 +14,7 @@ interface StockItemCategorySelectorProps<T> {
14
14
  placeholder?: string;
15
15
  invalid?: boolean;
16
16
  invalidText?: ReactNode;
17
+ itemType?: string;
17
18
 
18
19
  // Control
19
20
  controllerName: string;
@@ -32,6 +33,10 @@ const StockItemCategorySelector = <T,>(
32
33
  isLoading,
33
34
  } = useConcept(stockItemCategoryUUID);
34
35
 
36
+ const filteredCategories = props.itemType
37
+ ? categories?.filter((c) => c.display === props?.itemType)
38
+ : categories;
39
+
35
40
  if (isLoading) return <TextInputSkeleton />;
36
41
 
37
42
  return (
@@ -46,7 +51,7 @@ const StockItemCategorySelector = <T,>(
46
51
  controllerName={props.controllerName}
47
52
  id={props.name}
48
53
  size={"md"}
49
- items={categories || []}
54
+ items={filteredCategories || []}
50
55
  onChange={(data: { selectedItem: Concept }) => {
51
56
  props.onCategoryUuidChange?.(data.selectedItem);
52
57
  onChange(data.selectedItem?.uuid);
@@ -61,10 +61,18 @@ const StockItemDetails = forwardRef<never, StockItemDetailsProps>(
61
61
 
62
62
  const [isSaving, setIsSaving] = useState(false);
63
63
  const [isDrug, setIsDrug] = useState(false);
64
+ const [selectedItemType, setSelectedItemType] = useState("");
64
65
  const [hasExpiration, setHasExpiration] = useState(false);
65
66
 
66
67
  useEffect(() => {
67
68
  setIsDrug(model.isDrug ?? false);
69
+ setSelectedItemType(
70
+ model.isDrug === true
71
+ ? "Pharmaceuticals"
72
+ : model.isDrug === false
73
+ ? "Non Pharmaceuticals"
74
+ : undefined
75
+ );
68
76
  setHasExpiration(model.hasExpiration ?? false);
69
77
  }, [model.hasExpiration, model.isDrug]);
70
78
 
@@ -85,7 +93,12 @@ const StockItemDetails = forwardRef<never, StockItemDetailsProps>(
85
93
  invalid={!!errors.isDrug}
86
94
  invalidText={errors.isDrug && errors?.isDrug?.message}
87
95
  onChange={(selection: boolean) => {
96
+ const selectedOption = radioOptions.find(
97
+ (option) => option.value === selection
98
+ );
99
+ const selectedLabel = selectedOption ? selectedOption.label : "";
88
100
  setIsDrug(selection);
101
+ setSelectedItemType(selectedLabel);
89
102
  }}
90
103
  options={radioOptions} // Pass radioOptions directly
91
104
  />
@@ -201,6 +214,13 @@ const StockItemDetails = forwardRef<never, StockItemDetailsProps>(
201
214
  name="categoryUuid"
202
215
  controllerName="categoryUuid"
203
216
  control={control}
217
+ itemType={
218
+ selectedItemType === "Pharmaceuticals"
219
+ ? "Drugs"
220
+ : selectedItemType === "Non Pharmaceuticals"
221
+ ? "Non Drugs"
222
+ : undefined
223
+ }
204
224
  title={t("category:", "Category") + ":"}
205
225
  placeholder={t("chooseACategory", "Choose a category")}
206
226
  invalid={!!errors.categoryUuid}
@@ -14,7 +14,7 @@ import {
14
14
  Select,
15
15
  SelectItem,
16
16
  } from "@carbon/react";
17
- import React, { ChangeEvent, useState } from "react";
17
+ import React, { ChangeEvent, useEffect, useState } from "react";
18
18
  import styles from "./add-stock-user-role-scope.scss";
19
19
  import {
20
20
  useRoles,
@@ -56,10 +56,12 @@ const MinDate: Date = today();
56
56
 
57
57
  interface AddStockUserRoleScopeProps {
58
58
  model?: UserRoleScope;
59
+ editMode?: boolean;
59
60
  }
60
61
 
61
62
  const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
62
63
  model,
64
+ editMode,
63
65
  }) => {
64
66
  const { t } = useTranslation();
65
67
  const currentUser = useSession();
@@ -136,6 +138,11 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
136
138
  setFilteredItems(filtered);
137
139
  }
138
140
  };
141
+ useEffect(() => {
142
+ if (model?.userUuid) {
143
+ setSelectedUserUuid(model.userUuid);
144
+ }
145
+ }, [model]);
139
146
 
140
147
  const handleSearchQueryChange = (query: string) => {
141
148
  setSearchQuery(query);
@@ -330,7 +337,7 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
330
337
  id="userName"
331
338
  size="md"
332
339
  labelText={t("user", "User")}
333
- items={filteredItems}
340
+ items={filteredItems.length ? filteredItems : usersResults}
334
341
  onChange={onUserChanged}
335
342
  shouldFilterItem={() => true}
336
343
  itemToString={(item) =>
@@ -338,6 +345,11 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
338
345
  }
339
346
  onInputChange={handleSearchQueryChange}
340
347
  placeholder="Filter..."
348
+ initialSelectedItem={
349
+ usersResults.find(
350
+ (user) => user.uuid === model?.userUuid
351
+ ) ?? null
352
+ }
341
353
  />
342
354
  </>
343
355
  )}
@@ -359,15 +371,24 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
359
371
  value="placeholder-item"
360
372
  text={t("Choose a role")}
361
373
  />
362
- {(user?.roles ?? roles)?.map((role) => {
363
- return (
364
- <SelectItem
365
- key={role.display}
366
- value={role.display}
367
- text={role.display}
368
- />
369
- );
370
- })}
374
+
375
+ {editMode ? (
376
+ <SelectItem
377
+ key={formModel?.role}
378
+ value={formModel?.role}
379
+ text={formModel?.role}
380
+ />
381
+ ) : (
382
+ (user?.roles ?? roles)?.map((role) => {
383
+ return (
384
+ <SelectItem
385
+ key={role.display}
386
+ value={role.display}
387
+ text={role.display}
388
+ />
389
+ );
390
+ })
391
+ )}
371
392
  </Select>
372
393
  </div>
373
394
  </section>
@@ -376,7 +397,7 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
376
397
  <Checkbox
377
398
  onChange={onEnabledChanged}
378
399
  checked={formModel?.enabled}
379
- labelText={t(`Enabled ?`)}
400
+ labelText={t("enabled", "Enabled ?")}
380
401
  value={model?.enabled}
381
402
  id="chk-userEnabled"
382
403
  />
@@ -385,7 +406,7 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
385
406
  name="isPermanent"
386
407
  checked={formModel?.permanent}
387
408
  value={model?.permanent}
388
- labelText={t(`Permanent ?`)}
409
+ labelText={t("permanent", "Permanent ?")}
389
410
  id="chk-userPermanent"
390
411
  />
391
412
 
@@ -19,7 +19,7 @@ const EditStockUserRoleActionsMenu: React.FC<
19
19
  const handleClick = useCallback(() => {
20
20
  launchOverlay(
21
21
  "Edit Stock User Role",
22
- <AddStockUserRoleScope model={data} />
22
+ <AddStockUserRoleScope model={data} editMode={true} />
23
23
  );
24
24
  }, [data]);
25
25