-
Notifications
You must be signed in to change notification settings - Fork 3k
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
feat: Integrate report fields with backend #34483
Merged
Merged
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0f25f75
feat: save the report fields in backend
allroundexperts e089455
fix: revert canUseReportField beta
allroundexperts 04f4296
Merge branch 'main' into feat-34198
allroundexperts 7532fff
fix: lint errors
allroundexperts c91cde9
Merge branch 'main' into feat-34198
allroundexperts 389569d
Merge branch 'main' into feat-34198
allroundexperts b0f6f9b
include the whole reportfield object in the report
allroundexperts 827be79
merge with main
allroundexperts 06b2b16
create new types for the write commands
allroundexperts b58d85b
fix lint issues
allroundexperts 19cafde
fix: typechecks
allroundexperts 72b68c9
fix: remove leftover code
allroundexperts cd576d8
fix: update recently used field implementation
allroundexperts 623d1c2
fix: merge with main
allroundexperts 022efe3
fix: minor refactors to function names
allroundexperts db3738d
fix: lint issues
allroundexperts d0db92f
fix: use ucfirst str lib function and handle more lint issues
allroundexperts a761eb2
merge with main
allroundexperts 0c9939a
fix: include the whole report field object in the set report field call
allroundexperts 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 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 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 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 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 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 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 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 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 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 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,82 @@ | ||
import React, {useCallback, useRef} from 'react'; | ||
import {View} from 'react-native'; | ||
import DatePicker from '@components/DatePicker'; | ||
import FormProvider from '@components/Form/FormProvider'; | ||
import InputWrapper from '@components/Form/InputWrapper'; | ||
import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
import ScreenWrapper from '@components/ScreenWrapper'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
import CONST from '@src/CONST'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
|
||
type EditReportFieldDatePageProps = { | ||
/** Value of the policy report field */ | ||
fieldValue: string; | ||
|
||
/** Name of the policy report field */ | ||
fieldName: string; | ||
|
||
/** ID of the policy report field */ | ||
fieldID: string; | ||
|
||
/** Callback to fire when the Save button is pressed */ | ||
onSubmit: (form: Record<string, string>) => void; | ||
}; | ||
|
||
function EditReportFieldDatePage({fieldName, onSubmit, fieldValue, fieldID}: EditReportFieldDatePageProps) { | ||
const styles = useThemeStyles(); | ||
const {translate} = useLocalize(); | ||
const inputRef = useRef<HTMLInputElement>(null); | ||
|
||
const validate = useCallback( | ||
(value: Record<string, string>) => { | ||
const errors: Record<string, string> = {}; | ||
if (value[fieldID].trim() === '') { | ||
errors[fieldID] = 'common.error.fieldRequired'; | ||
} | ||
return errors; | ||
}, | ||
[fieldID], | ||
); | ||
|
||
return ( | ||
<ScreenWrapper | ||
includeSafeAreaPaddingBottom={false} | ||
shouldEnableMaxHeight | ||
onEntryTransitionEnd={() => inputRef.current?.focus()} | ||
testID={EditReportFieldDatePage.displayName} | ||
> | ||
<HeaderWithBackButton title={fieldName} /> | ||
{/* @ts-expect-error TODO: TS migration */} | ||
<FormProvider | ||
style={[styles.flexGrow1, styles.ph5]} | ||
formID={ONYXKEYS.FORMS.POLICY_REPORT_FIELD_EDIT_FORM} | ||
onSubmit={onSubmit} | ||
validate={validate} | ||
submitButtonText={translate('common.save')} | ||
enabledWhenOffline | ||
> | ||
<View style={styles.mb4}> | ||
<InputWrapper | ||
// @ts-expect-error TODO: TS migration | ||
InputComponent={DatePicker} | ||
inputID={fieldID} | ||
name={fieldID} | ||
defaultValue={fieldValue} | ||
label={fieldName} | ||
accessibilityLabel={fieldName} | ||
role={CONST.ROLE.PRESENTATION} | ||
maxDate={CONST.CALENDAR_PICKER.MAX_DATE} | ||
minDate={CONST.CALENDAR_PICKER.MIN_DATE} | ||
ref={inputRef} | ||
/> | ||
</View> | ||
</FormProvider> | ||
</ScreenWrapper> | ||
); | ||
} | ||
|
||
EditReportFieldDatePage.displayName = 'EditReportFieldDatePage'; | ||
|
||
export default EditReportFieldDatePage; |
This file contains 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,85 @@ | ||
import React, {useMemo, useState} from 'react'; | ||
import HeaderWithBackButton from '@components/HeaderWithBackButton'; | ||
import OptionsSelector from '@components/OptionsSelector'; | ||
import ScreenWrapper from '@components/ScreenWrapper'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useStyleUtils from '@hooks/useStyleUtils'; | ||
import useThemeStyles from '@hooks/useThemeStyles'; | ||
|
||
type EditReportFieldDropdownPageProps = { | ||
/** Value of the policy report field */ | ||
fieldValue: string; | ||
|
||
/** Name of the policy report field */ | ||
fieldName: string; | ||
|
||
/** ID of the policy report field */ | ||
fieldID: string; | ||
|
||
/** Options of the policy report field */ | ||
fieldOptions: string[]; | ||
|
||
/** Callback to fire when the Save button is pressed */ | ||
onSubmit: (form: Record<string, string>) => void; | ||
}; | ||
|
||
function EditReportFieldDropdownPage({fieldName, onSubmit, fieldID, fieldValue, fieldOptions}: EditReportFieldDropdownPageProps) { | ||
const [searchValue, setSearchValue] = useState(''); | ||
const styles = useThemeStyles(); | ||
const {getSafeAreaMargins} = useStyleUtils(); | ||
const {translate} = useLocalize(); | ||
|
||
const sections = useMemo(() => { | ||
const filteredOptions = fieldOptions.filter((option) => option.includes(searchValue)); | ||
return [ | ||
{ | ||
title: translate('common.recents'), | ||
shouldShow: true, | ||
data: [], | ||
}, | ||
{ | ||
title: translate('common.all'), | ||
shouldShow: true, | ||
data: filteredOptions.map((option) => ({ | ||
text: option, | ||
keyForList: option, | ||
searchText: option, | ||
tooltipText: option, | ||
})), | ||
}, | ||
]; | ||
}, [fieldOptions, searchValue, translate]); | ||
|
||
return ( | ||
<ScreenWrapper | ||
includeSafeAreaPaddingBottom={false} | ||
shouldEnableMaxHeight | ||
testID={EditReportFieldDropdownPage.displayName} | ||
> | ||
{({insets}) => ( | ||
<> | ||
<HeaderWithBackButton title={fieldName} /> | ||
<OptionsSelector | ||
// @ts-expect-error TODO: TS migration | ||
contentContainerStyles={[{paddingBottom: getSafeAreaMargins(insets).marginBottom}]} | ||
optionHoveredStyle={styles.hoveredComponentBG} | ||
sectionHeaderStyle={styles.mt5} | ||
selectedOptions={[{text: fieldValue}]} | ||
textInputLabel={translate('common.search')} | ||
boldStyle | ||
sections={sections} | ||
value={searchValue} | ||
onSelectRow={(option: Record<string, string>) => onSubmit({[fieldID]: option.text})} | ||
onChangeText={setSearchValue} | ||
highlightSelectedOptions | ||
isRowMultilineSupported | ||
/> | ||
</> | ||
)} | ||
</ScreenWrapper> | ||
); | ||
} | ||
|
||
EditReportFieldDropdownPage.displayName = 'EditReportFieldDropdownPage'; | ||
|
||
export default EditReportFieldDropdownPage; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we include all values from the policyField at this time? When OpenReport passes back the reports, it will have a reportField list that contains the reportFields at the time of creation.
So if the weights change later, this report should have the same report fields weights at the time of storage for historical context