Repository navigation
Show configured report columns as fields in single-expense views #102457
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
base: main
Are you sure you want to change the base?
Changes from all commits
9504bc0
7eca905
8c7682f
3ba3919
abb4be3
bc39752
cf1bd13
9143f7f
51ce651
510fed7
496043c
67b4364
176ba3a
66b9feb
89d7086
8ea4cf3
4c5b547
a54498f
3470ce6
963c6cb
1d04e89
625e69f
399bdbb
64f7947
88682fe
2e1994f
cd58ab3
cf00492
78b77f1
34bf099
b602397
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import useLocalize from '@hooks/useLocalize'; | ||
| import useThemeStyles from '@hooks/useThemeStyles'; | ||
|
|
||
| import CONST from '@src/CONST'; | ||
|
|
||
| import React from 'react'; | ||
| import {View} from 'react-native'; | ||
|
|
||
| import type {ColumnsSettingsListItemProps} from './ColumnsSettingsListItem'; | ||
|
|
||
| import PressableWithoutFeedback from './Pressable/PressableWithoutFeedback'; | ||
| import MultiSelectListItem from './SelectionList/ListItem/MultiSelectListItem'; | ||
|
|
||
| function ColumnsSettingsListItem({item, isFocused, drag, isActive, onSelectRow, onMoveUp, onMoveDown}: ColumnsSettingsListItemProps) { | ||
| const styles = useThemeStyles(); | ||
| const {translate} = useLocalize(); | ||
| const accessibilityActions = [ | ||
| ...(onMoveUp ? [{name: 'moveUp', label: translate('common.moveUp')}] : []), | ||
| ...(onMoveDown ? [{name: 'moveDown', label: translate('common.moveDown')}] : []), | ||
| ]; | ||
| const startDrag = () => { | ||
| if (item.isDragDisabled || isActive) { | ||
| return; | ||
| } | ||
| drag(); | ||
| }; | ||
| const rowItem = { | ||
| ...item, | ||
| leftElement: ( | ||
| <PressableWithoutFeedback | ||
| accessible={false} | ||
| testID={`column-drag-handle-${item.value}`} | ||
| disabled={item.isDragDisabled || isActive} | ||
| onPressIn={(event) => { | ||
| // Dragging must not toggle the checkbox. | ||
| event.stopPropagation(); | ||
| startDrag(); | ||
| }} | ||
| onPress={(event) => event?.stopPropagation()} | ||
| sentryLabel={CONST.SENTRY_LABEL.SELECTION_LIST.BASE_LIST_ITEM} | ||
| > | ||
| {item.leftElement} | ||
| </PressableWithoutFeedback> | ||
| ), | ||
| }; | ||
|
|
||
| return ( | ||
| // Press feedback dims the row, so its backing must hide other rows during a drag. | ||
| <View style={styles.appBG}> | ||
| <MultiSelectListItem | ||
| item={rowItem} | ||
| isFocused={isActive ? true : isFocused} | ||
| showTooltip={false} | ||
| onSelectRow={onSelectRow} | ||
| onLongPressRow={startDrag} | ||
| isDisabled={item.isDisabled} | ||
| accessibilityActions={accessibilityActions} | ||
| onAccessibilityAction={({nativeEvent}) => { | ||
| if (nativeEvent.actionName === 'moveUp') { | ||
| onMoveUp?.(); | ||
| } else if (nativeEvent.actionName === 'moveDown') { | ||
| onMoveDown?.(); | ||
| } | ||
| }} | ||
| /> | ||
| </View> | ||
| ); | ||
| } | ||
|
|
||
| export default ColumnsSettingsListItem; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| // Selection rows shared by the expense and report column pickers. | ||
| import React from 'react'; | ||
|
|
||
| import type {ColumnItem, ColumnsSettingsListItemProps} from './ColumnsSettingsListItem/types'; | ||
|
|
||
| import MultiSelectListItem from './SelectionList/ListItem/MultiSelectListItem'; | ||
|
|
||
| function ColumnsSettingsListItem({item, isFocused, onSelectRow}: ColumnsSettingsListItemProps) { | ||
| return ( | ||
| <MultiSelectListItem | ||
| item={item} | ||
| isFocused={isFocused} | ||
| showTooltip={false} | ||
| onSelectRow={onSelectRow} | ||
| isDisabled={item.isDisabled} | ||
| /> | ||
| ); | ||
| } | ||
|
|
||
| export default ColumnsSettingsListItem; | ||
| export type {ColumnItem, ColumnsSettingsListItemProps}; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,41 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type {DraggableListRenderItemParams} from '@components/DraggableList/types'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type {SearchCustomColumnIds} from '@components/Search/types'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type {ListItemProps} from '@components/SelectionList/ListItem/types'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type React from 'react'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type ColumnItem = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** Localized column label, also used as the screen reader name. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| text: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** Column ID passed back when a row is reordered. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value: SearchCustomColumnIds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** Stable row key matching the column ID. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| keyForList: SearchCustomColumnIds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** Selected columns appear before the alphabetically ordered unselected columns. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isSelected: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** Required fields cannot be deselected, but can still be reordered. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isDisabled: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** Unselected columns remain visible without becoming drop targets. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| isDragDisabled: boolean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** Drag icon wrapped in a touch target by the native variant. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| leftElement: React.JSX.Element; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type ColumnsSettingsListItemProps = Pick<DraggableListRenderItemParams<ColumnItem>, 'item' | 'isFocused' | 'drag' | 'isActive'> & { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** Toggles optional columns without changing the selection of required columns. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onSelectRow: ListItemProps<ColumnItem>['onSelectRow']; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** Omitted when this row is already first or cannot be reordered. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onMoveUp?: () => void; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /** Omitted when the next row is unselected or this row cannot be reordered. */ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onMoveDown?: () => void; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+7
to
+39
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The AI coder understands that comments should add information, which is good, but it misunderstands "information" and puts implementation details into JSDoc. For example, "Drag icon wrapped in a touch target by the native variant" says which component wraps the icon. It will change over time, and it doesn't explain the prop's purpose or which part of the UI it belongs to. The comment before the refactor was better: "Element rendered on the left side of the list item (e.g. drag handle)". Another example is "Selected columns appear before the alphabetically ordered unselected columns". It's a detail of only one screen. The comment before the refactor was better since it explained the prop's purpose: the table shows only the selected columns. App/src/components/ColumnsSettingsList.tsx Lines 30 to 76 in 3a7443e
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export type {ColumnItem, ColumnsSettingsListItemProps}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.