-
Notifications
You must be signed in to change notification settings - Fork 1
Rerequest ILLDEV-530 #60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| import React from 'react'; | ||
| import { FormattedMessage } from 'react-intl'; | ||
| import { useHistory, useLocation } from 'react-router-dom'; | ||
| import { useIsActionPending } from '@projectreshare/stripes-reshare'; | ||
| import { Button, Icon } from '@folio/stripes/components'; | ||
|
|
||
| import actionMeta from '../actionMeta'; | ||
|
|
||
| // Opens the revision form; the form posts the action itself on submit. | ||
| const Rerequest = ({ request }) => { | ||
| const history = useHistory(); | ||
| const location = useLocation(); | ||
| const actionPending = !!useIsActionPending(request.id); | ||
|
|
||
| const open = () => history.push({ | ||
| // Relative: replaces the flow route's last segment. | ||
| pathname: 'rerequest', | ||
| search: location.search, | ||
| state: { direct: true }, | ||
| }); | ||
|
|
||
| return ( | ||
| <Button buttonStyle="dropdownItem" onClick={open} disabled={actionPending}> | ||
| <Icon icon={actionMeta.rerequest.icon}> | ||
| <FormattedMessage id="stripes-reshare.actions.rerequest" /> | ||
| </Icon> | ||
| </Button> | ||
| ); | ||
| }; | ||
|
|
||
| export default Rerequest; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
ui-rs/src/components/PatronRequestForm/PatronRequestFormPane.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import React from 'react'; | ||
| import { FormattedMessage } from 'react-intl'; | ||
| import { useForm, useFormState } from 'react-final-form'; | ||
| import { Prompt } from 'react-router-dom'; | ||
| import { Button, Pane, Paneset, PaneFooter } from '@folio/stripes/components'; | ||
|
|
||
| const PatronRequestFormPane = ({ | ||
| titleId, | ||
| submitLabelId = titleId, | ||
| submitDisabled = false, | ||
| onClose, | ||
| children, | ||
| }) => { | ||
| const form = useForm(); | ||
| const { pristine, submitting, submitSucceeded } = useFormState({ | ||
| subscription: { pristine: true, submitting: true, submitSucceeded: true }, | ||
| }); | ||
|
|
||
| // The submit button is in the footer, outside the form element, so both route | ||
| // through here. Also applies submitDisabled to an Enter-key submit. | ||
| const submit = (e) => { | ||
| e.preventDefault(); | ||
| e.stopPropagation(); | ||
| if (submitting || submitDisabled) return undefined; | ||
| return form.submit(); | ||
| }; | ||
|
|
||
| return ( | ||
| <Paneset> | ||
| <Pane | ||
| defaultWidth="100%" | ||
| centerContent | ||
| onClose={onClose} | ||
| dismissible={!submitting} | ||
| paneTitle={<FormattedMessage id={titleId} />} | ||
| footer={ | ||
| <PaneFooter | ||
| renderStart={ | ||
| <Button | ||
| id="clickable-cancel-request-form" | ||
| buttonStyle="default mega" | ||
| marginBottom0 | ||
| onClick={onClose} | ||
| disabled={submitting} | ||
| > | ||
| <FormattedMessage id="stripes-core.button.cancel" /> | ||
| </Button> | ||
| } | ||
| renderEnd={ | ||
| <Button | ||
| type="submit" | ||
| disabled={submitting || submitDisabled} | ||
| onClick={submit} | ||
| buttonStyle="primary mega" | ||
| marginBottom0 | ||
| > | ||
| <FormattedMessage id={submitLabelId} /> | ||
| </Button> | ||
| } | ||
| /> | ||
| } | ||
| > | ||
| <form onSubmit={submit}> | ||
| {children} | ||
| </form> | ||
| <FormattedMessage id="ui-rs.confirmDirtyNavigate"> | ||
| {prompt => <Prompt when={!pristine && !(submitting || submitSucceeded)} message={prompt[0]} />} | ||
| </FormattedMessage> | ||
| </Pane> | ||
| </Paneset> | ||
| ); | ||
| }; | ||
|
|
||
| export default PatronRequestFormPane; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import React from 'react'; | ||
| import { FormattedMessage } from 'react-intl'; | ||
| import { FORM_ERROR } from 'final-form'; | ||
| import { KeyValue } from '@folio/stripes/components'; | ||
|
|
||
| // Return from onSubmit: Final Form then counts the submit as failed, which keeps | ||
| // the leave prompt armed. | ||
| const submissionError = (callout, labelId, err) => { | ||
| callout.sendCallout({ | ||
| type: 'error', | ||
| message: ( | ||
| <KeyValue | ||
| label={<FormattedMessage id={labelId} />} | ||
| value={err?.message || ''} | ||
| /> | ||
| ), | ||
| }); | ||
| return { [FORM_ERROR]: err?.message || labelId }; | ||
| }; | ||
|
|
||
| export default submissionError; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.