Skip to content

Commit 00b2cb2

Browse files
O3-4278 Made stock transactions print button configurable. (#253)
1 parent 6760959 commit 00b2cb2

File tree

2 files changed

+28
-17
lines changed

2 files changed

+28
-17
lines changed

src/config-schema.ts

+6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ export const configSchema = {
55
_default: false,
66
_description: 'Whether to print item costs on the print out',
77
},
8+
enablePrintButton: {
9+
_type: Type.Boolean,
10+
_default: true,
11+
_description: 'Enable or disable the print button in the stock management UI',
12+
},
813
autoPopulateResponsiblePerson: {
914
type: Type.Boolean,
1015
_default: false,
@@ -61,6 +66,7 @@ export const configSchema = {
6166

6267
export type ConfigObject = {
6368
autoPopulateResponsiblePerson: boolean;
69+
enablePrintButton: boolean;
6470
printItemCost: boolean;
6571
printBalanceOnHand: boolean;
6672
packagingUnitsUUID: string;

src/stock-items/add-stock-item/transactions/printout/transactions-print-action.component.tsx

+22-17
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { Button, Stack, ComboButton, MenuItem } from '@carbon/react';
33
import { Printer } from '@carbon/react/icons';
44
import { useTranslation } from 'react-i18next';
55
import { useStockItem } from '../../../stock-items.resource';
6-
import { showModal } from '@openmrs/esm-framework';
6+
import { showModal, useConfig } from '@openmrs/esm-framework';
7+
import { type ConfigObject } from '../../../../config-schema';
78
import styles from './printable-transaction.scss';
89
import { useEffect, useMemo, useState } from 'react';
910
import { StockItemInventoryFilter, useStockItemTransactions } from '../../../stock-items.resource';
@@ -18,6 +19,8 @@ type Props = {
1819
const TransactionsPrintAction: React.FC<Props> = ({ columns, data, itemUuid }) => {
1920
const { t } = useTranslation();
2021

22+
const { enablePrintButton } = useConfig<ConfigObject>();
23+
2124
const [stockCardItemFilter, setStockCardItemFilter] = useState<StockItemInventoryFilter>({
2225
startIndex: 0,
2326
totalCount: true,
@@ -86,22 +89,24 @@ const TransactionsPrintAction: React.FC<Props> = ({ columns, data, itemUuid }) =
8689

8790
return (
8891
<>
89-
<ComboButton label="Print">
90-
<MenuItem
91-
label={t('printStockCard', 'Print Stock Card')}
92-
renderIcon={(props) => <Printer size={24} {...props} />}
93-
iconDescription="Print Stock Card"
94-
onClick={handleStockcardClick}
95-
disabled={isStockItemLoading || isStockCardLoading}
96-
/>
97-
<MenuItem
98-
label={t('printBinCard', 'Print Bin Card')}
99-
renderIcon={(props) => <Printer size={24} {...props} />}
100-
iconDescription="Print Bin Card"
101-
onClick={handleBincardClick}
102-
disabled={isStockItemLoading}
103-
/>
104-
</ComboButton>
92+
{enablePrintButton && (
93+
<ComboButton label="Print">
94+
<MenuItem
95+
label={t('printStockCard', 'Print Stock Card')}
96+
renderIcon={(props) => <Printer size={24} {...props} />}
97+
iconDescription="Print Stock Card"
98+
onClick={handleStockcardClick}
99+
disabled={isStockItemLoading || isStockCardLoading}
100+
/>
101+
<MenuItem
102+
label={t('printBinCard', 'Print Bin Card')}
103+
renderIcon={(props) => <Printer size={24} {...props} />}
104+
iconDescription="Print Bin Card"
105+
onClick={handleBincardClick}
106+
disabled={isStockItemLoading}
107+
/>
108+
</ComboButton>
109+
)}
105110
</>
106111
);
107112
};

0 commit comments

Comments
 (0)