fix(ui): disableBulkEdit on ui fields, defaults to true (#8540)
Fixes https://github.com/payloadcms/payload/issues/8534 UI fields are now excluded by default from the bulk edit view fields options. If you need to have the UI field there, you can provide: ```ts admin: { disableBulkEdit: false } ```
This commit is contained in:
@@ -41,7 +41,7 @@ export const CollectionConfig: CollectionConfig = {
|
|||||||
The following options are available:
|
The following options are available:
|
||||||
|
|
||||||
| Option | Description |
|
| Option | Description |
|
||||||
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| **`condition`** | Programmatically show / hide fields based on other fields. [More details](../admin/fields#conditional-logic). |
|
| **`condition`** | Programmatically show / hide fields based on other fields. [More details](../admin/fields#conditional-logic). |
|
||||||
| **`components`** | All Field Components can be swapped out for [Custom Components](../admin/components) that you define. [More details](../admin/fields). |
|
| **`components`** | All Field Components can be swapped out for [Custom Components](../admin/components) that you define. [More details](../admin/fields). |
|
||||||
| **`description`** | Helper text to display alongside the field to provide more information for the editor. [More details](../admin/fields#description). |
|
| **`description`** | Helper text to display alongside the field to provide more information for the editor. [More details](../admin/fields#description). |
|
||||||
@@ -51,7 +51,7 @@ The following options are available:
|
|||||||
| **`className`** | Attach a [CSS class attribute](https://developer.mozilla.org/en-US/docs/Web/CSS/Class_selectors) to the root DOM element of a field. |
|
| **`className`** | Attach a [CSS class attribute](https://developer.mozilla.org/en-US/docs/Web/CSS/Class_selectors) to the root DOM element of a field. |
|
||||||
| **`readOnly`** | Setting a field to `readOnly` has no effect on the API whatsoever but disables the admin component's editability to prevent editors from modifying the field's value. |
|
| **`readOnly`** | Setting a field to `readOnly` has no effect on the API whatsoever but disables the admin component's editability to prevent editors from modifying the field's value. |
|
||||||
| **`disabled`** | If a field is `disabled`, it is completely omitted from the [Admin Panel](../admin/overview). |
|
| **`disabled`** | If a field is `disabled`, it is completely omitted from the [Admin Panel](../admin/overview). |
|
||||||
| **`disableBulkEdit`** | Set `disableBulkEdit` to `true` to prevent fields from appearing in the select options when making edits for multiple documents. |
|
| **`disableBulkEdit`** | Set `disableBulkEdit` to `true` to prevent fields from appearing in the select options when making edits for multiple documents. Defaults to `true` for UI fields. |
|
||||||
| **`disableListColumn`** | Set `disableListColumn` to `true` to prevent fields from appearing in the list view column selector. |
|
| **`disableListColumn`** | Set `disableListColumn` to `true` to prevent fields from appearing in the list view column selector. |
|
||||||
| **`disableListFilter`** | Set `disableListFilter` to `true` to prevent fields from appearing in the list view filter options. |
|
| **`disableListFilter`** | Set `disableListFilter` to `true` to prevent fields from appearing in the list view filter options. |
|
||||||
| **`hidden`** | Will transform the field into a `hidden` input type. Its value will still submit with requests in the Admin Panel, but the field itself will not be visible to editors. |
|
| **`hidden`** | Will transform the field into a `hidden` input type. Its value will still submit with requests in the Admin Panel, but the field itself will not be visible to editors. |
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export const MyUIField: Field = {
|
|||||||
## Config Options
|
## Config Options
|
||||||
|
|
||||||
| Option | Description |
|
| Option | Description |
|
||||||
| ------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
||||||
| **`name`** \* | A unique identifier for this field. |
|
| **`name`** \* | A unique identifier for this field. |
|
||||||
| **`label`** | Human-readable label for this UI field. |
|
| **`label`** | Human-readable label for this UI field. |
|
||||||
| **`admin.components.Field`** \* | React component to be rendered for this field within the Edit View. [More](../admin/components/#field-component) |
|
| **`admin.components.Field`** \* | React component to be rendered for this field within the Edit View. [More](../admin/components/#field-component) |
|
||||||
|
|||||||
@@ -289,6 +289,10 @@ export const sanitizeFields = async ({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (field.type === 'ui' && typeof field.admin.disableBulkEdit === 'undefined') {
|
||||||
|
field.admin.disableBulkEdit = true
|
||||||
|
}
|
||||||
|
|
||||||
if ('_sanitized' in field) {
|
if ('_sanitized' in field) {
|
||||||
field._sanitized = true
|
field._sanitized = true
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -832,6 +832,10 @@ export type UIField = {
|
|||||||
condition?: Condition
|
condition?: Condition
|
||||||
/** Extension point to add your custom data. Available in server and client. */
|
/** Extension point to add your custom data. Available in server and client. */
|
||||||
custom?: Record<string, any>
|
custom?: Record<string, any>
|
||||||
|
/**
|
||||||
|
* Set `false` make the UI field appear in the list view column selector. `true` by default for UI fields.
|
||||||
|
* @default true
|
||||||
|
*/
|
||||||
disableBulkEdit?: boolean
|
disableBulkEdit?: boolean
|
||||||
/**
|
/**
|
||||||
* Shows / hides fields from appearing in the list view column selector.
|
* Shows / hides fields from appearing in the list view column selector.
|
||||||
|
|||||||
@@ -90,9 +90,9 @@ const reduceFields = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
return fields?.reduce((fieldsToUse, field) => {
|
return fields?.reduce((fieldsToUse, field) => {
|
||||||
// escape for a variety of reasons
|
// escape for a variety of reasons, include ui fields as they have `name`.
|
||||||
if (
|
if (
|
||||||
fieldAffectsData(field) &&
|
(fieldAffectsData(field) || field.type === 'ui') &&
|
||||||
(field.admin.disableBulkEdit ||
|
(field.admin.disableBulkEdit ||
|
||||||
field.unique ||
|
field.unique ||
|
||||||
field.admin.hidden ||
|
field.admin.hidden ||
|
||||||
|
|||||||
Reference in New Issue
Block a user