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

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": 4777297,
90
90
  "sizes": {
91
91
  "consume-shared": 252,
92
- "javascript": 4754422,
92
+ "javascript": 4755348,
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": "d00e98111ae7bcb5",
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": 1086116,
168
168
  "sizes": {
169
- "javascript": 1084980,
169
+ "javascript": 1085906,
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": "1ff42f34b5dc4bd2",
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.453"}
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.453",
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,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