@@ -37,7 +38,7 @@ const PrintContent = forwardRef(({
});
PrintContent.propTypes = {
- printContentTestId: PropTypes.string.isRequired,
+ id: PropTypes.string,
dataSource: PropTypes.arrayOf(PropTypes.object).isRequired,
template: PropTypes.string.isRequired,
};
diff --git a/src/components/PrintContent/PrintContent.test.js b/src/components/PrintContent/PrintContent.test.js
index dc6682cf..0501a511 100644
--- a/src/components/PrintContent/PrintContent.test.js
+++ b/src/components/PrintContent/PrintContent.test.js
@@ -28,7 +28,7 @@ describe('PrintContent', () => {
},
}
],
- printContentTestId: testIds.printContent,
+ id: testIds.printContent,
};
afterEach(() => {
diff --git a/src/routes/RequestsRoute.js b/src/routes/RequestsRoute.js
index 8cd5b84d..73e96b1f 100644
--- a/src/routes/RequestsRoute.js
+++ b/src/routes/RequestsRoute.js
@@ -401,14 +401,12 @@ class RequestsRoute extends React.Component {
type: 'okapi',
records: 'pickSlips',
path: 'circulation/pick-slips/%{currentServicePoint.id}',
- fetch: true,
throwErrors: false,
},
searchSlips: {
type: 'okapi',
records: 'searchSlips',
path: 'circulation/search-slips/%{currentServicePoint.id}',
- fetch: true,
throwErrors: false,
},
printHoldRequests: {
@@ -1074,7 +1072,8 @@ class RequestsRoute extends React.Component {
getPrintTemplate(slipType) {
const staffSlips = get(this.props.resources, 'staffSlips.records', []);
- const slipTemplate = staffSlips.find(slip => slip.name.toLowerCase() === slipType.toLowerCase());
+ const slipTypeInLowerCase = slipType.toLowerCase();
+ const slipTemplate = staffSlips.find(slip => slip.name.toLowerCase() === slipTypeInLowerCase);
return get(slipTemplate, 'template', '');
}
@@ -1133,6 +1132,16 @@ class RequestsRoute extends React.Component {
);
};
+ onBeforeGetContentForPrintButton = (onToggle) => (
+ new Promise(resolve => {
+ this.context.sendCallout({ message:
});
+ onToggle();
+ // without the timeout the printing process starts right away
+ // and the callout and onToggle above are blocked
+ setTimeout(() => resolve(), 1000);
+ })
+ );
+
render() {
const {
resources,
@@ -1157,7 +1166,7 @@ class RequestsRoute extends React.Component {
holdsShelfReportPending,
createTitleLevelRequestsByDefault,
} = this.state;
- const printHoldRequestsEnabled = getPrintHoldRequestsEnabled(resources.printHoldRequests);
+ const isPrintHoldRequestsEnabled = getPrintHoldRequestsEnabled(resources.printHoldRequests);
const { name: servicePointName } = this.getCurrentServicePointInfo();
const pickSlips = get(resources, 'pickSlips.records', []);
const searchSlips = get(resources, 'searchSlips.records', []);
@@ -1173,11 +1182,11 @@ class RequestsRoute extends React.Component {
createTitleLevelRequest: createTitleLevelRequestsByDefault,
};
- const pickSlipsArePending = resources?.pickSlips?.isPending;
- const searchSlipsArePending = resources?.searchSlips?.isPending;
+ const isPickSlipsArePending = resources?.pickSlips?.isPending;
+ const isSearchSlipsArePending = resources?.searchSlips?.isPending;
const requestsEmpty = isEmpty(requests);
- const pickSlipsEmpty = isEmpty(pickSlips);
- const searchSlipsEmpty = isEmpty(searchSlips);
+ const isPickSlipsEmpty = isEmpty(pickSlips);
+ const isSearchSlipsEmpty = isEmpty(searchSlips);
const pickSlipsPrintTemplate = this.getPrintTemplate(SLIPS_TYPE.PICK_SLIP);
const searchSlipsPrintTemplate = this.getPrintTemplate(SLIPS_TYPE.SEARCH_SLIP_HOLD_REQUESTS);
const pickSlipsData = convertToSlipData(pickSlips, intl, timezone, locale, SLIPS_TYPE.PICK_SLIP);
@@ -1215,7 +1224,7 @@ class RequestsRoute extends React.Component {
}
{
- pickSlipsArePending ?
+ isPickSlipsArePending ?
:
@@ -1238,18 +1247,10 @@ class RequestsRoute extends React.Component {
new Promise(resolve => {
- this.context.sendCallout({ message: });
- onToggle();
- // without the timeout the printing process starts right away
- // and the callout and onToggle above are blocked
- setTimeout(() => resolve(), 1000);
- })
- }
+ onBeforeGetContent={() => this.onBeforeGetContentForPrintButton(onToggle)}
>
}
{
- printHoldRequestsEnabled &&
+ isPrintHoldRequestsEnabled &&
<>
{
- searchSlipsArePending ?
+ isSearchSlipsArePending ?
:
new Promise(resolve => {
- this.context.sendCallout({ message: });
- onToggle();
- // without the timeout the printing process starts right away
- // and the callout and onToggle above are blocked
- setTimeout(() => resolve(), 1000);
- })
- }
+ onBeforeGetContent={() => this.onBeforeGetContentForPrintButton(onToggle)}
>
{
- printHoldRequestsEnabled &&
+ isPrintHoldRequestsEnabled &&