Skip to content

Commit

Permalink
UIREQ-508: Add feedback after print button is clicked (#626)
Browse files Browse the repository at this point in the history
* UIREQ-508: Add feedback after print button is clicked
  • Loading branch information
mkuklis authored and zburke committed Aug 25, 2020
1 parent 9eb387c commit 7e30f51
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

* Add loading indicator when service point is switched. Fixes UIREQ-508.
* Improve performance issues with preview for print pick slips. Fixes UIREQ-507.
* Add feedback after print button is clicked. Fixes UIREQ-508.
* Escape values passed to `react-to-print`. Fixes UIREQ-510.

## [3.0.4](https://github.com/folio-org/ui-requests/tree/v3.0.4) (2020-07-15)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
"react-fast-compare": "^3.2.0",
"react-hot-loader": "^4.3.12",
"react-router-prop-types": "^1.0.4",
"react-to-print": "^2.3.2",
"react-to-print": "^2.9.0",
"redux-form": "^7.0.3"
},
"peerDependencies": {
Expand Down
4 changes: 4 additions & 0 deletions src/components/PrintButton/PrintButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ class PrintButton extends React.Component {
children: PropTypes.node.isRequired,
onAfterPrint: PropTypes.func,
onBeforePrint: PropTypes.func,
onBeforeGetContent: PropTypes.func,
contentRef: PropTypes.object,
};

static defaultProps = {
onAfterPrint: noop,
onBeforePrint: noop,
onBeforeGetContent: noop,
};

getContent = () => {
Expand All @@ -40,6 +42,7 @@ class PrintButton extends React.Component {
const {
onAfterPrint,
onBeforePrint,
onBeforeGetContent,
} = this.props;

return (
Expand All @@ -49,6 +52,7 @@ class PrintButton extends React.Component {
trigger={this.renderTriggerButton}
onAfterPrint={onAfterPrint}
onBeforePrint={onBeforePrint}
onBeforeGetContent={onBeforeGetContent}
/>
);
}
Expand Down
13 changes: 12 additions & 1 deletion src/routes/RequestsRoute.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
AppIcon,
stripesConnect,
IfPermission,
CalloutContext,
} from '@folio/stripes/core';
import {
Button,
Expand Down Expand Up @@ -81,6 +82,8 @@ const urls = {
};

class RequestsRoute extends React.Component {
static contextType = CalloutContext;

static manifest = {
addressTypes: {
type: 'okapi',
Expand Down Expand Up @@ -769,7 +772,15 @@ class RequestsRoute extends React.Component {
disabled={pickSlipsEmpty}
template={printTemplate}
contentRef={this.printContentRef}
onBeforePrint={onToggle}
onBeforeGetContent={
() => new Promise(resolve => {
this.context.sendCallout({ message: <FormattedMessage id="ui-requests.printInProgress" /> });
onToggle();
// without the timeout the printing process starts right away
// and the callout and onToggle above are blocked
setTimeout(() => resolve(), 1000);
})
}
>
<FormattedMessage
id="ui-requests.printPickSlips"
Expand Down
3 changes: 2 additions & 1 deletion translations/ui-requests/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,6 @@
"permission.view": "Requests: View",
"permission.create": "Requests: View, create",
"permission.edit": "Requests: View, edit, cancel",
"pickSlipsLoading": "Pick slips are loading, please wait"
"pickSlipsLoading": "Pick slips are loading, please wait",
"printInProgress": "Print options loading in progress. It might take a few seconds, please be patient."
}

0 comments on commit 7e30f51

Please sign in to comment.