feat: add isSortable to arrays and blocks (#5962)
This commit is contained in:
@@ -155,6 +155,21 @@ const ArrayFields: CollectionConfig = {
|
||||
minRows: 2,
|
||||
type: 'array',
|
||||
},
|
||||
{
|
||||
name: 'disableSortItems',
|
||||
defaultValue: arrayDefaultValue,
|
||||
admin: {
|
||||
isSortable: false,
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: 'text',
|
||||
required: true,
|
||||
type: 'text',
|
||||
},
|
||||
],
|
||||
type: 'array',
|
||||
},
|
||||
],
|
||||
slug: arrayFieldsSlug,
|
||||
versions: true,
|
||||
|
||||
@@ -63,4 +63,15 @@ export const anotherArrayDoc: Partial<ArrayField> = {
|
||||
text: 'second row',
|
||||
},
|
||||
],
|
||||
disableSortItems: [
|
||||
{
|
||||
text: 'un-sortable item 1',
|
||||
},
|
||||
{
|
||||
text: 'un-sortable item 2',
|
||||
},
|
||||
{
|
||||
text: 'un-sortable item 3',
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ const BlockFields: CollectionConfig = {
|
||||
name: 'collapsedByDefaultBlocks',
|
||||
admin: {
|
||||
initCollapsed: true,
|
||||
isSortable: false,
|
||||
},
|
||||
localized: true,
|
||||
},
|
||||
|
||||
@@ -696,6 +696,12 @@ describe('fields', () => {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
test('should have disabled admin sorting', async () => {
|
||||
await page.goto(url.create)
|
||||
const field = page.locator('#field-collapsedByDefaultBlocks .array-actions__action-chevron')
|
||||
expect(await field.count()).toEqual(0)
|
||||
})
|
||||
})
|
||||
|
||||
describe('array', () => {
|
||||
@@ -716,6 +722,12 @@ describe('fields', () => {
|
||||
await expect(field).toHaveValue('defaultValue')
|
||||
})
|
||||
|
||||
test('should have disabled admin sorting', async () => {
|
||||
await page.goto(url.create)
|
||||
const field = page.locator('#field-disableSortItems .array-actions__action-chevron')
|
||||
expect(await field.count()).toEqual(0)
|
||||
})
|
||||
|
||||
test('should render RowLabel using a function', async () => {
|
||||
const label = 'custom row label as function'
|
||||
await page.goto(url.create)
|
||||
|
||||
@@ -265,6 +265,10 @@ export interface ArrayField {
|
||||
id?: string | null
|
||||
}[]
|
||||
| null
|
||||
disableSortItems?: {
|
||||
text: string
|
||||
id?: string | null
|
||||
}[]
|
||||
updatedAt: string
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user