From d13b5ea7343aa29886ebb401d2244d0c90a54db0 Mon Sep 17 00:00:00 2001 From: Artem Makushov Date: Tue, 2 Jul 2024 14:16:48 +0200 Subject: [PATCH 1/7] added bulk operations, translations --- src/CONST.ts | 3 + src/languages/en.ts | 4 +- src/languages/es.ts | 6 +- .../WorkspaceReportFieldsPage.tsx | 74 ++++++++++++++++--- 4 files changed, 72 insertions(+), 15 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index d5502841c7d1..018af005728d 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1740,6 +1740,9 @@ const CONST = { DISABLE: 'disable', ENABLE: 'enable', }, + REPORT_FIELDS_BULK_ACTION_TYPES: { + DELETE: 'delete', + }, DISTANCE_RATES_BULK_ACTION_TYPES: { DELETE: 'delete', DISABLE: 'disable', diff --git a/src/languages/en.ts b/src/languages/en.ts index e36333e7b51d..9407521293ab 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2313,7 +2313,9 @@ export default { reportFields: { addField: 'Add field', delete: 'Delete field', - deleteConfirmation: 'Are you sure that you want to delete this field?', + deleteFields: 'Delete fields', + deleteConfirmation: 'Are you sure you want to delete this report field?', + deleteFieldsConfirmation: 'Are you sure you want to delete these report fields?', emptyReportFields: { title: "You haven't created any report fields", subtitle: 'Add a custom field (text, date, or dropdown) that appears on reports.', diff --git a/src/languages/es.ts b/src/languages/es.ts index aa28b0e0298b..48ff071a069e 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2345,8 +2345,10 @@ export default { }, reportFields: { addField: 'Añadir campo', - delete: 'Eliminar campos', - deleteConfirmation: '¿Estás seguro de que quieres eliminar esta campos?', + delete: 'Eliminar campo', + deleteFields: 'Eliminar campos', + deleteConfirmation: '¿Está seguro de que desea eliminar este campo del informe?', + deleteFieldsConfirmation: '¿Está seguro de que desea eliminar estos campos del informe?', emptyReportFields: { title: 'No has creado ningún campo de informe', subtitle: 'Añade un campo personalizado (texto, fecha o desplegable) que aparezca en los informes.', diff --git a/src/pages/workspace/reportFields/WorkspaceReportFieldsPage.tsx b/src/pages/workspace/reportFields/WorkspaceReportFieldsPage.tsx index 1b35b8b4e8b3..e07cbddde145 100644 --- a/src/pages/workspace/reportFields/WorkspaceReportFieldsPage.tsx +++ b/src/pages/workspace/reportFields/WorkspaceReportFieldsPage.tsx @@ -5,6 +5,9 @@ import React, {useEffect, useMemo, useState} from 'react'; import {ActivityIndicator, View} from 'react-native'; import {useOnyx} from 'react-native-onyx'; import Button from '@components/Button'; +import ButtonWithDropdownMenu from '@components/ButtonWithDropdownMenu'; +import type {DropdownOption} from '@components/ButtonWithDropdownMenu/types'; +import ConfirmModal from '@components/ConfirmModal'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import * as Expensicons from '@components/Icon/Expensicons'; import * as Illustrations from '@components/Icon/Illustrations'; @@ -16,6 +19,7 @@ import type {ListItem} from '@components/SelectionList/types'; import Text from '@components/Text'; import WorkspaceEmptyStateSection from '@components/WorkspaceEmptyStateSection'; import useLocalize from '@hooks/useLocalize'; +import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; @@ -24,11 +28,13 @@ import Navigation from '@libs/Navigation/Navigation'; import type {FullScreenNavigatorParamList} from '@libs/Navigation/types'; import * as ReportUtils from '@libs/ReportUtils'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; +import * as ReportField from '@userActions/Policy/ReportField'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; import type SCREENS from '@src/SCREENS'; import type {PolicyReportField} from '@src/types/onyx/Policy'; +import type DeepValueOf from '@src/types/utils/DeepValueOf'; type ReportFieldForList = ListItem & { value: string; @@ -43,6 +49,7 @@ function WorkspaceReportFieldsPage({ params: {policyID}, }, }: WorkspaceReportFieldsPageProps) { + const {shouldUseNarrowLayout} = useResponsiveLayout(); const {isSmallScreenWidth} = useWindowDimensions(); const styles = useThemeStyles(); const theme = useTheme(); @@ -56,6 +63,7 @@ function WorkspaceReportFieldsPage({ return Object.fromEntries(Object.entries(policy.fieldList).filter(([key]) => key !== 'text_title')); }, [policy]); const [selectedReportFields, setSelectedReportFields] = useState([]); + const [deleteReportFieldsConfirmModalVisible, setDeleteReportFieldsConfirmModalVisible] = useState(false); useEffect(() => { if (isFocused) { @@ -94,18 +102,50 @@ function WorkspaceReportFieldsPage({ const isLoading = reportFieldsList === undefined; const shouldShowEmptyState = Object.values(filteredPolicyFieldList).length <= 0 && !isLoading; - const getHeaderButtons = () => ( - -