@openmrs/esm-stock-management-app 1.0.1-pre.467 → 1.0.1-pre.473

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": 4763480,
89
+ "size": 4770791,
90
90
  "sizes": {
91
91
  "consume-shared": 252,
92
- "javascript": 4741531,
92
+ "javascript": 4748842,
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": "1b25ee6a5d6d7b6e",
109
+ "hash": "137fc6c0e5d30a79",
110
110
  "childrenByOrder": {}
111
111
  },
112
112
  {
@@ -138,9 +138,9 @@
138
138
  "initial": false,
139
139
  "entry": false,
140
140
  "recorded": false,
141
- "size": 1091768,
141
+ "size": 1099079,
142
142
  "sizes": {
143
- "javascript": 1091558,
143
+ "javascript": 1098869,
144
144
  "consume-shared": 210
145
145
  },
146
146
  "names": [],
@@ -154,7 +154,7 @@
154
154
  "auxiliaryFiles": [
155
155
  "474.js.map"
156
156
  ],
157
- "hash": "7bb203dc9788e158",
157
+ "hash": "0f9bb5a017f33892",
158
158
  "childrenByOrder": {}
159
159
  },
160
160
  {
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":"locations-db-link","slot":"stock-page-dashboard-slot","component":"stockLocationsLink","meta":{"name":"locations","slot":"locations-dashboard-slot","title":"Locations"},"order":4,"online":true,"offline":true},{"name":"stock-locations-db","slot":"locations-dashboard-slot","component":"stockLocations"},{"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-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":"root","route":"stock-management"}],"version":"1.0.1-pre.467"}
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":"locations-db-link","slot":"stock-page-dashboard-slot","component":"stockLocationsLink","meta":{"name":"locations","slot":"locations-dashboard-slot","title":"Locations"},"order":4,"online":true,"offline":true},{"name":"stock-locations-db","slot":"locations-dashboard-slot","component":"stockLocations"},{"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-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":"root","route":"stock-management"}],"version":"1.0.1-pre.473"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openmrs/esm-stock-management-app",
3
- "version": "1.0.1-pre.467",
3
+ "version": "1.0.1-pre.473",
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",
@@ -35,6 +35,23 @@ export const configSchema = {
35
35
  _description: "UUID for the stock item category",
36
36
  _default: "6d24eb6e-b42f-4706-ab2d-ae4472161f6a",
37
37
  },
38
+ logo: {
39
+ src: {
40
+ _type: Type.String,
41
+ _default: null,
42
+ _description: "A path or URL to an image.",
43
+ },
44
+ alt: {
45
+ _type: Type.String,
46
+ _default: "Logo",
47
+ _description: "Alt text, shown on hover",
48
+ },
49
+ name: {
50
+ _type: Type.String,
51
+ _default: null,
52
+ _description: "The organization name displayed when image is absent",
53
+ },
54
+ },
38
55
  };
39
56
 
40
57
  export type ConfigObject = {
@@ -45,4 +62,9 @@ export type ConfigObject = {
45
62
  stockSourceTypeUUID: string;
46
63
  dispensingUnitsUUID: string;
47
64
  stockItemCategoryUUID: string;
65
+ logo: {
66
+ src: string;
67
+ alt: string;
68
+ name: string;
69
+ };
48
70
  };
@@ -1,6 +1,7 @@
1
1
  import { PrintCss } from "./PrintStyles";
2
- import { PRINT_LOGO_TEXT, PRINT_LOGO } from "../../constants";
2
+ import { PRINT_LOGO } from "../../constants";
3
3
  import { GetPrintLogo, PrintLogoData } from "../utils/imageUtils";
4
+ import { getConfig } from "@openmrs/esm-framework";
4
5
 
5
6
  export const GetPrintTemplate = (
6
7
  body: string,
@@ -27,6 +28,8 @@ ${PrintCss}
27
28
  };
28
29
 
29
30
  export const GetLogoSection = async () => {
31
+ const config = await getConfig("@openmrs/esm-stock-management-app");
32
+ const logoText = config?.logo?.name;
30
33
  let printLogoData: PrintLogoData | null = null;
31
34
  if (PRINT_LOGO) {
32
35
  try {
@@ -35,7 +38,7 @@ export const GetLogoSection = async () => {
35
38
  console.info(e);
36
39
  }
37
40
  }
38
- return printLogoData || PRINT_LOGO_TEXT
41
+ return printLogoData || logoText
39
42
  ? `
40
43
  <div class="logo" >
41
44
  ${
@@ -45,11 +48,7 @@ export const GetLogoSection = async () => {
45
48
  : `<img alt='' src='${printLogoData.image}' />`
46
49
  : ""
47
50
  }
48
- ${
49
- PRINT_LOGO_TEXT
50
- ? `<span class='logo-text text'>${PRINT_LOGO_TEXT}</span>`
51
- : ""
52
- }
51
+ ${logoText ? `<span class='logo-text text'>${logoText}</span>` : ""}
53
52
  </div>
54
53
  `
55
54
  : "";
@@ -1,12 +1,12 @@
1
- import { URL_PRINT_LOGO } from "../../constants";
2
-
1
+ import { getConfig } from "@openmrs/esm-framework";
3
2
  export interface PrintLogoData {
4
3
  image: string;
5
4
  isSvg: boolean;
6
5
  }
7
6
 
8
- export const GetPrintLogo = (): Promise<PrintLogoData | null> => {
9
- const printLogoUrl: string = URL_PRINT_LOGO();
7
+ export const GetPrintLogo = async (): Promise<PrintLogoData | null> => {
8
+ const config = await getConfig("@openmrs/esm-stock-management-app");
9
+ const printLogoUrl = config?.logo?.src;
10
10
  return new Promise((resolve, reject) => {
11
11
  if (!printLogoUrl) {
12
12
  resolve(null);
@@ -22,6 +22,7 @@ import { Drug } from "../core/api/types/concept/Drug";
22
22
  import { Patient } from "../core/api/types/identity/Patient";
23
23
  import { useMemo } from "react";
24
24
  import { uniqBy } from "lodash-es";
25
+ import { UserRoleScope } from "../core/api/types/identity/UserRoleScope";
25
26
 
26
27
  export type PatientFilterCriteria = ResourceFilterCriteria;
27
28
 
@@ -304,3 +305,9 @@ export const useUserRoles = () => {
304
305
  error,
305
306
  };
306
307
  };
308
+ export function getUserRoleScopes(): Promise<
309
+ FetchResponse<PageableResult<UserRoleScope>>
310
+ > {
311
+ const apiUrl = `${restBaseUrl}/stockmanagement/userrolescope`;
312
+ return openmrsFetch(apiUrl);
313
+ }
@@ -23,8 +23,10 @@ import {
23
23
  import {
24
24
  getParties,
25
25
  getStockOperationTypes,
26
+ getUserRoleScopes,
26
27
  } from "../../stock-lookups/stock-lookups.resource";
27
28
  import { Party } from "../../core/api/types/Party";
29
+ import { getCurrentUser } from "@openmrs/esm-framework";
28
30
 
29
31
  export async function initializeNewStockOperation(
30
32
  currentStockOperationType: StockOperationType,
@@ -36,7 +38,15 @@ export async function initializeNewStockOperation(
36
38
  const isNew = !!stockOperation;
37
39
  const newItemsToCopy: StockOperationItemDTO[] = [];
38
40
  const showQuantityRequested = false;
39
-
41
+ const currentUserUuid = await new Promise((resolve, reject) => {
42
+ getCurrentUser().subscribe({
43
+ next: (user) => {
44
+ const userUuid = user?.user?.uuid;
45
+ resolve(userUuid);
46
+ },
47
+ error: (err) => reject(err),
48
+ });
49
+ });
40
50
  let operationTypes = stockOperationTypes;
41
51
  const canIssueStock =
42
52
  stockOperation?.permission?.isRequisitionAndCanIssueStock ?? false;
@@ -68,69 +78,27 @@ export async function initializeNewStockOperation(
68
78
  operationTypeUuid: currentStockOperationType?.uuid,
69
79
  operationType: currentStockOperationType?.operationType,
70
80
  });
71
-
72
- if (
73
- currentStockOperationType.operationType ==
74
- OperationType.STOCK_ISSUE_OPERATION_TYPE
75
- ) {
76
- // requisition = urlQueryParams?.get("requisition");
77
- // if (requisition) {
78
- // const response = await getStockOperation(requisition);
79
- // if (!response.ok) {
80
- // return;
81
- // }
82
- //
83
- // const requisitionStockOperation = response.data;
84
- //
85
- // if (
86
- // !requisitionStockOperation.responsiblePersonUuid &&
87
- // requisitionStockOperation.responsiblePersonOther
88
- // ) {
89
- // requisitionStockOperation.responsiblePersonUuid = "Other";
90
- // }
91
- //
92
- // if (
93
- // requisitionStockOperation &&
94
- // requisitionStockOperation.stockOperationItems
95
- // ) {
96
- // let hasQtyRequested = false;
97
- // requisitionStockOperation.stockOperationItems.forEach((si) => {
98
- // if (si.quantity && si.stockItemPackagingUOMName) {
99
- // hasQtyRequested = true;
100
- // }
101
- //
102
- // const itemId = `new-item-${getStockOperationUniqueId()}`;
103
- // si.id = itemId;
104
- // si.uuid = itemId;
105
- // newItemsToCopy.push({
106
- // ...si,
107
- // quantityRequested: si.quantity,
108
- // quantityRequestedPackagingUOMUuid: si.stockItemPackagingUOMUuid,
109
- // quantityRequestedPackagingUOMName: si.stockItemPackagingUOMName,
110
- // });
111
- // });
112
- // if (hasQtyRequested) {
113
- // showQuantityRequested = true;
114
- // }
115
- // }
116
- // newItemsToCopy.push({ uuid: `new-item-1`, id: `new-item-1` });
117
- // model.destinationUuid = requisitionStockOperation.sourceUuid;
118
- // model.destinationName = requisitionStockOperation.sourceName;
119
- // model.responsiblePersonUuid =
120
- // requisitionStockOperation.responsiblePersonUuid;
121
- // model.responsiblePersonOther =
122
- // requisitionStockOperation.responsiblePersonOther;
123
- // model.responsiblePersonFamilyName =
124
- // requisitionStockOperation.responsiblePersonFamilyName;
125
- // model.responsiblePersonGivenName =
126
- // requisitionStockOperation.responsiblePersonGivenName;
127
- // model.remarks = requisitionStockOperation.remarks;
128
- // }
129
- }
130
81
  const partyList = await getParties();
82
+ const userRoleScopes = await getUserRoleScopes();
83
+ const currentUserRoleScope = userRoleScopes.data?.results?.filter(
84
+ (role) => role.userUuid === currentUserUuid
85
+ );
86
+ const userRoleScopeLocations = [
87
+ ...new Set(
88
+ currentUserRoleScope.flatMap((role) =>
89
+ role?.locations?.map((l) => l.locationUuid)
90
+ )
91
+ ),
92
+ ];
93
+
131
94
  if (!partyList.ok) throw Error("Error loading parties");
95
+ const filteredPartyList = partyList.data?.results?.filter(
96
+ (party) =>
97
+ userRoleScopeLocations.includes(party.locationUuid) ||
98
+ party.stockSourceUuid !== null
99
+ );
132
100
 
133
- sourcePartyList = partyList?.data?.results?.filter(
101
+ sourcePartyList = filteredPartyList?.filter(
134
102
  (p) =>
135
103
  (p.locationUuid &&
136
104
  currentStockOperationType?.sourceType === LocationTypeLocation &&
@@ -1,7 +1,6 @@
1
1
  import React from "react";
2
2
 
3
3
  import { Button } from "@carbon/react";
4
- import { useConfig } from "@openmrs/esm-framework";
5
4
  import { useTranslation } from "react-i18next";
6
5
  import { Printer } from "@carbon/react/icons";
7
6
  import { StockOperationDTO } from "../../core/api/types/stockOperation/StockOperationDTO";
@@ -29,11 +28,6 @@ const StockOperationPrintButton: React.FC<StockOperationCancelButtonProps> = ({
29
28
  }) => {
30
29
  const { t } = useTranslation();
31
30
 
32
- const { config } = useConfig();
33
-
34
- // const { printItemCost, printBalanceOnHand } = config;
35
-
36
- // on print stock operation
37
31
  const onPrintStockOperation = async () => {
38
32
  try {
39
33
  let parentOperation: StockOperationDTO | null | undefined;
@@ -152,7 +146,7 @@ const StockOperationPrintButton: React.FC<StockOperationCancelButtonProps> = ({
152
146
  kind="tertiary"
153
147
  renderIcon={(props) => <Printer size={16} {...props} />}
154
148
  >
155
- {t("print", "Print ")}
149
+ {t("print", "Print")}
156
150
  </Button>
157
151
  );
158
152
  };
@@ -59,7 +59,6 @@ import {
59
59
  StockFilters,
60
60
  } from "../constants";
61
61
  import { handleMutate } from "../utils";
62
-
63
62
  interface StockOperationsTableProps {
64
63
  status?: string;
65
64
  }