# rn-bulk-update-dialog URL: /docs/native/docyrus/bulk-update-dialog Bottom-sheet dialog that overwrites one or more fields on every selected record of a Docyrus data source in a single bulk PATCH. Field values are edited with the native form fields. API-aligned with the web BulkUpdateDialog. ## Installation ```bash pnpm dlx @docyrus/cli add @docyrus/rn-bulk-update-dialog ``` **Dependencies:** - [@tanstack/react-query](https://www.npmjs.com/package/@tanstack/react-query) - [@docyrus/api-client](https://www.npmjs.com/package/@docyrus/api-client) - [@docyrus/app-utils](https://www.npmjs.com/package/@docyrus/app-utils) - [expo-document-picker (optional)](https://www.npmjs.com/package/expo-document-picker) This is a **Docyrus-connected** component. It needs an authenticated `RestApiClient` and a `QueryClientProvider` above it. `expo-document-picker` (and `expo-image-picker` for image fields) are optional peers, used only when the user edits a file or image field. The dialog: - loads the data source schema through [`useDocyrusDataSourceFields`](/docs/native/hooks/use-docyrus-data-source-fields) while it is open (cache-first through the shared inventory, so there is no extra request after the post-sign-in warm-up) - lists only editable fields. System slugs (`id`, `autonumber_id`, `created_on`, `created_by`, `last_modified_on`, `last_modified_by`), computed types (`field-formula`, `field-relatedField`, `field-button`, `field-autonumber`), read-only fields and fields without a native editor are left out. - renders one row per field in a `SchemaRepeater`: a `Select` picks the field (fields already added are disabled) and `DocyFieldDynamic` edits its value. Enum options come from the field. User fields load the shared `/v1/users` list, relation fields get a searchable, paged record picker, and file / image fields upload to Docyrus storage (`/v1/apps/{app}/data-sources/{ds}/files/upload`). - sends `PATCH /v1/apps/{appSlug}/data-sources/{dataSourceSlug}/items/bulk` with `{ records: [{ id, ...updates }], enableAutomation, enableChangeLogging }`. Companion values (money currency, phone country, status description, …) are included. - shows a success or error toast, calls `onSuccess`, resets and closes. While the request runs, the sheet cannot be dismissed. ## Usage ```tsx import { useState } from 'react'; import { useDocyrusClient } from '@docyrus/signin/react-native'; import { BulkUpdateDialog } from '@/components/docyrus-native/bulk-update-dialog'; import { Button } from '@/components/docyrus-native/button'; export function BulkEditTasks({ selectedRows }: { selectedRows: Array<{ id: string }> }) { const client = useDocyrusClient(); const [open, setOpen] = useState(false); return ( <> refetch()} /> ); } ``` ## API Reference ### BulkUpdateDialogProps | Prop | Type | Default | Description | |------|------|---------|-------------| | `open` | `boolean` | — | Dialog visibility (required). | | `onOpenChange` | `(open: boolean) => void` | — | Visibility change handler (required). | | `client` | `RestApiClient` | — | Authenticated Docyrus client (required). | | `appSlug` | `string` | — | App slug (required). | | `dataSourceSlug` | `string` | — | Data source slug (required). | | `records` | `ReadonlyArray` | — | The selected rows. Only `id` is read (required). | | `enableAutomation` | `boolean` | `true` | Run downstream automations on every updated row. | | `enableChangeLogging` | `boolean` | `true` | Write change-log entries. | | `onSuccess` | `(data: BulkUpdateRecord[]) => void` | — | Called after the PATCH resolves, with the server rows (`response.data` unwrapped). | | `allowedFieldSlugs` | `ReadonlyArray` | — | Restrict the field picker to these slugs. | | `dataSourceId` | `string` | — | Accepted for web parity. Not used on either platform. | | `className` | `string` | — | Extra classes for the dialog body. | ### BulkUpdateRecord | Field | Type | Description | |-------|------|-------------| | `id` | `string` | Record id (required by the bulk endpoint). | | `[key: string]` | `unknown` | Any other row fields (ignored). | ## Native differences - The dialog is a bottom-sheet `AwesomeDialog` (`size="xl"`) instead of a centered modal. - Web renders value editors through `useDocyrusFormView`. Native uses the lightweight `useDocyrusDataSourceFields` schema hook plus per-field option loaders (users, relation records, storage uploads), so only the options of the picked fields are fetched. - Desktop-only editors (fields that map to `DocyFieldReadOnlyValue` on native) cannot be bulk-edited. ## Translation keys `ui.bulkUpdate.title`, `recordUnit`, `description`, `fieldUpdates`, `addField`, `chooseField`, `field`, `alreadyAdded`, `cancel`, `submit`, `success`, `error`. ## Components | Component | Description | |-----------|-------------| | `BulkUpdateDialog` | The bulk-update sheet. | ## Type Exports | Type | Description | |------|-------------| | `BulkUpdateDialogProps` | Props for `BulkUpdateDialog`. | | `BulkUpdateRecord` | `{ id: string; [key: string]: unknown }`. |