Repository navigation
[No QA] Allow editing fields of Request #20206
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
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
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
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,59 @@ | ||
| import React, {useRef} from 'react'; | ||
| import {View} from 'react-native'; | ||
| import PropTypes from 'prop-types'; | ||
| import TextInput from '../components/TextInput'; | ||
| import withLocalize, {withLocalizePropTypes} from '../components/withLocalize'; | ||
| import ScreenWrapper from '../components/ScreenWrapper'; | ||
| import HeaderWithBackButton from '../components/HeaderWithBackButton'; | ||
| import Form from '../components/Form'; | ||
| import ONYXKEYS from '../ONYXKEYS'; | ||
| import styles from '../styles/styles'; | ||
| import Navigation from '../libs/Navigation/Navigation'; | ||
|
|
||
| const propTypes = { | ||
| ...withLocalizePropTypes, | ||
|
|
||
| /** Transaction description default value */ | ||
| defaultDescription: PropTypes.string.isRequired, | ||
|
|
||
| /** Callback to fire when the Save button is pressed */ | ||
| onSubmit: PropTypes.func.isRequired, | ||
| }; | ||
|
|
||
| function EditRequestDescriptionPage(props) { | ||
| const descriptionInputRef = useRef(null); | ||
| return ( | ||
| <ScreenWrapper | ||
| includeSafeAreaPaddingBottom={false} | ||
| shouldEnableMaxHeight | ||
| onEntryTransitionEnd={() => descriptionInputRef.current && descriptionInputRef.current.focus()} | ||
| > | ||
| <HeaderWithBackButton | ||
| title={props.translate('common.description')} | ||
| onBackButtonPress={() => Navigation.goBack()} | ||
| /> | ||
| <Form | ||
| style={[styles.flexGrow1, styles.ph5]} | ||
| formID={ONYXKEYS.FORMS.MONEY_REQUEST_DESCRIPTION_FORM} | ||
| onSubmit={props.onSubmit} | ||
| submitButtonText={props.translate('common.save')} | ||
| enabledWhenOffline | ||
| > | ||
| <View style={styles.mb4}> | ||
| <TextInput | ||
| inputID="modifiedComment" | ||
| name="modifiedComment" | ||
| defaultValue={props.defaultDescription} | ||
| label={props.translate('moneyRequestConfirmationList.whatsItFor')} | ||
| ref={descriptionInputRef} | ||
| /> | ||
| </View> | ||
| </Form> | ||
| </ScreenWrapper> | ||
| ); | ||
| } | ||
|
|
||
| EditRequestDescriptionPage.propTypes = propTypes; | ||
| EditRequestDescriptionPage.displayName = 'EditRequestDescriptionPage'; | ||
|
|
||
| export default withLocalize(EditRequestDescriptionPage); |
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,77 @@ | ||
| import React from 'react'; | ||
| import PropTypes from 'prop-types'; | ||
| import lodashGet from 'lodash/get'; | ||
| import {withOnyx} from 'react-native-onyx'; | ||
| import CONST from '../CONST'; | ||
| import Navigation from '../libs/Navigation/Navigation'; | ||
| import compose from '../libs/compose'; | ||
| import withLocalize, {withLocalizePropTypes} from '../components/withLocalize'; | ||
| import ONYXKEYS from '../ONYXKEYS'; | ||
| import * as ReportActionsUtils from '../libs/ReportActionsUtils'; | ||
| import EditRequestDescriptionPage from './EditRequestDescriptionPage'; | ||
| import reportPropTypes from './reportPropTypes'; | ||
| import * as ReportUtils from '../libs/ReportUtils'; | ||
|
|
||
| const propTypes = { | ||
| ...withLocalizePropTypes, | ||
|
|
||
| /** Route from navigation */ | ||
| route: PropTypes.shape({ | ||
| /** Params from the route */ | ||
| params: PropTypes.shape({ | ||
| /** Which field we are editing */ | ||
| field: PropTypes.string, | ||
|
|
||
| /** reportID for the "transaction thread" */ | ||
| threadReportID: PropTypes.string, | ||
| }), | ||
| }).isRequired, | ||
|
|
||
| /** The report object for the thread report */ | ||
| report: reportPropTypes, | ||
| }; | ||
|
|
||
| const defaultProps = { | ||
| report: {}, | ||
| }; | ||
|
|
||
| function EditRequestPage(props) { | ||
| const parentReportAction = ReportActionsUtils.getParentReportAction(props.report); | ||
| const moneyRequestReportAction = ReportUtils.getMoneyRequestAction(parentReportAction); | ||
| const transactionDescription = moneyRequestReportAction.comment; | ||
| const field = lodashGet(props, ['route', 'params', 'field'], ''); | ||
|
|
||
| function updateTransactionWithChanges(changes) { | ||
| // Update the transaction... | ||
| // eslint-disable-next-line no-console | ||
| console.log({changes}); | ||
|
|
||
| // Note: The "modal" we are dismissing is the MoneyRequestAmountPage | ||
| Navigation.dismissModal(); | ||
| } | ||
|
|
||
| if (field === CONST.EDIT_REQUEST_FIELD.DESCRIPTION) { | ||
| return ( | ||
| <EditRequestDescriptionPage | ||
| defaultDescription={transactionDescription} | ||
| onSubmit={(changes) => { | ||
| updateTransactionWithChanges(changes); | ||
| }} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| EditRequestPage.displayName = 'EditRequestPage'; | ||
| EditRequestPage.propTypes = propTypes; | ||
| EditRequestPage.defaultProps = defaultProps; | ||
| export default compose( | ||
| withLocalize, | ||
| withOnyx({ | ||
| report: { | ||
| key: ({route}) => `${ONYXKEYS.COLLECTION.REPORT}${route.params.threadReportID}`, | ||
| }, | ||
| }), | ||
| )(EditRequestPage); |
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.