@openmrs/esm-stock-management-app 1.0.1-pre.448 → 1.0.1-pre.453
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/457.js +1 -1
- package/dist/457.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 +6 -6
- package/dist/routes.json +1 -1
- package/package.json +1 -1
- package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.component.tsx +46 -21
- package/src/stock-user-role-scopes/edit-stock-user-scope/edit-stock-user-scope-action-menu.component.tsx +1 -1
- package/src/stock-user-role-scopes/stock-user-role-scopes-items-table.component.tsx +9 -8
@@ -86,10 +86,10 @@
|
|
86
86
|
"initial": true,
|
87
87
|
"entry": true,
|
88
88
|
"recorded": false,
|
89
|
-
"size":
|
89
|
+
"size": 4777297,
|
90
90
|
"sizes": {
|
91
91
|
"consume-shared": 252,
|
92
|
-
"javascript":
|
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": "
|
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":
|
167
|
+
"size": 1086116,
|
168
168
|
"sizes": {
|
169
|
-
"javascript":
|
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": "
|
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.
|
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
package/src/stock-user-role-scopes/add-stock-user-scope/add-stock-user-role-scope.component.tsx
CHANGED
@@ -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,
|
@@ -32,6 +32,7 @@ import {
|
|
32
32
|
restBaseUrl,
|
33
33
|
showNotification,
|
34
34
|
showToast,
|
35
|
+
useSession,
|
35
36
|
} from "@openmrs/esm-framework";
|
36
37
|
import { UserRoleScopeOperationType } from "../../core/api/types/identity/UserRoleScopeOperationType";
|
37
38
|
import { UserRoleScopeLocation } from "../../core/api/types/identity/UserRoleScopeLocation";
|
@@ -55,18 +56,21 @@ const MinDate: Date = today();
|
|
55
56
|
|
56
57
|
interface AddStockUserRoleScopeProps {
|
57
58
|
model?: UserRoleScope;
|
59
|
+
editMode?: boolean;
|
58
60
|
}
|
59
61
|
|
60
62
|
const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
61
63
|
model,
|
64
|
+
editMode,
|
62
65
|
}) => {
|
63
66
|
const { t } = useTranslation();
|
64
|
-
|
67
|
+
const currentUser = useSession();
|
65
68
|
const [formModel, setFormModel] = useState<UserRoleScope>({ ...model });
|
66
69
|
|
67
70
|
const [roles, setRoles] = useState<Role[]>([]);
|
68
71
|
|
69
72
|
const [showItems, setShowItems] = useState(false);
|
73
|
+
const loggedInUserUuid = currentUser?.user?.uuid;
|
70
74
|
|
71
75
|
// operation types
|
72
76
|
const {
|
@@ -125,13 +129,20 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
|
125
129
|
setShowItems(false);
|
126
130
|
} else {
|
127
131
|
setShowItems(true);
|
128
|
-
const filtered = usersResults
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
+
const filtered = usersResults
|
133
|
+
.filter((item: any) => item.uuid !== loggedInUserUuid)
|
134
|
+
.filter((item: any) => {
|
135
|
+
const displayName = item?.person?.display ?? item?.display ?? "";
|
136
|
+
return displayName.toLowerCase().includes(query.toLowerCase());
|
137
|
+
});
|
132
138
|
setFilteredItems(filtered);
|
133
139
|
}
|
134
140
|
};
|
141
|
+
useEffect(() => {
|
142
|
+
if (model?.userUuid) {
|
143
|
+
setSelectedUserUuid(model.userUuid);
|
144
|
+
}
|
145
|
+
}, [model]);
|
135
146
|
|
136
147
|
const handleSearchQueryChange = (query: string) => {
|
137
148
|
setSearchQuery(query);
|
@@ -215,9 +226,9 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
|
215
226
|
INVENTORY_ADMNISTRATOR_ROLE_UUID,
|
216
227
|
];
|
217
228
|
|
218
|
-
const filteredStockRoles = data.selectedItem?.roles
|
219
|
-
stockRolesUUIDs.includes(role.uuid)
|
220
|
-
|
229
|
+
const filteredStockRoles = data.selectedItem?.roles
|
230
|
+
.filter((role) => stockRolesUUIDs.includes(role.uuid))
|
231
|
+
.filter((role) => role.uuid !== loggedInUserUuid);
|
221
232
|
setFormModel({ ...formModel, userUuid: data.selectedItem?.uuid });
|
222
233
|
setRoles(filteredStockRoles ?? []);
|
223
234
|
setSelectedUserUuid(data?.selectedItem?.uuid);
|
@@ -326,7 +337,7 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
|
326
337
|
id="userName"
|
327
338
|
size="md"
|
328
339
|
labelText={t("user", "User")}
|
329
|
-
items={filteredItems}
|
340
|
+
items={filteredItems.length ? filteredItems : usersResults}
|
330
341
|
onChange={onUserChanged}
|
331
342
|
shouldFilterItem={() => true}
|
332
343
|
itemToString={(item) =>
|
@@ -334,6 +345,11 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
|
334
345
|
}
|
335
346
|
onInputChange={handleSearchQueryChange}
|
336
347
|
placeholder="Filter..."
|
348
|
+
initialSelectedItem={
|
349
|
+
usersResults.find(
|
350
|
+
(user) => user.uuid === model?.userUuid
|
351
|
+
) ?? null
|
352
|
+
}
|
337
353
|
/>
|
338
354
|
</>
|
339
355
|
)}
|
@@ -355,15 +371,24 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
|
355
371
|
value="placeholder-item"
|
356
372
|
text={t("Choose a role")}
|
357
373
|
/>
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
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
|
+
)}
|
367
392
|
</Select>
|
368
393
|
</div>
|
369
394
|
</section>
|
@@ -372,7 +397,7 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
|
372
397
|
<Checkbox
|
373
398
|
onChange={onEnabledChanged}
|
374
399
|
checked={formModel?.enabled}
|
375
|
-
labelText={t(
|
400
|
+
labelText={t("enabled", "Enabled ?")}
|
376
401
|
value={model?.enabled}
|
377
402
|
id="chk-userEnabled"
|
378
403
|
/>
|
@@ -381,7 +406,7 @@ const AddStockUserRoleScope: React.FC<AddStockUserRoleScopeProps> = ({
|
|
381
406
|
name="isPermanent"
|
382
407
|
checked={formModel?.permanent}
|
383
408
|
value={model?.permanent}
|
384
|
-
labelText={t(
|
409
|
+
labelText={t("permanent", "Permanent ?")}
|
385
410
|
id="chk-userPermanent"
|
386
411
|
/>
|
387
412
|
|
@@ -108,6 +108,7 @@ function StockUserRoleScopesItems() {
|
|
108
108
|
|
109
109
|
const tableRows = useMemo(() => {
|
110
110
|
return items?.map((userRoleScope, index) => {
|
111
|
+
const isCurrentUser = currentUser.user.uuid === userRoleScope.userUuid;
|
111
112
|
return {
|
112
113
|
...userRoleScope,
|
113
114
|
id: userRoleScope?.uuid,
|
@@ -141,18 +142,18 @@ function StockUserRoleScopesItems() {
|
|
141
142
|
return operation?.operationTypeName;
|
142
143
|
})
|
143
144
|
?.join(", "),
|
144
|
-
permanent: userRoleScope?.permanent
|
145
|
-
? t("stockmanagement.yes", "Yes")
|
146
|
-
: t("stockmanagement.no", "No"),
|
145
|
+
permanent: userRoleScope?.permanent ? t("yes", "Yes") : t("no", "No"),
|
147
146
|
activeFrom: formatDisplayDate(userRoleScope?.activeFrom) ?? "Not Set",
|
148
147
|
activeTo: formatDisplayDate(userRoleScope?.activeTo) ?? "Not Set",
|
149
|
-
enabled: userRoleScope?.enabled
|
150
|
-
? t("stockmanagement.yes", "Yes")
|
151
|
-
: t("stockmanagement.no", "No"),
|
148
|
+
enabled: userRoleScope?.enabled ? t("yes", "Yes") : t("no", "No"),
|
152
149
|
actions: (
|
153
150
|
<div style={{ display: "flex" }}>
|
154
|
-
|
155
|
-
|
151
|
+
{!isCurrentUser && (
|
152
|
+
<>
|
153
|
+
<EditStockUserRoleActionsMenu data={items[index]} />
|
154
|
+
<StockUserScopeDeleteActionMenu uuid={items[index].uuid} />
|
155
|
+
</>
|
156
|
+
)}
|
156
157
|
</div>
|
157
158
|
),
|
158
159
|
};
|