feat(payload, ui): adds disableListColumn & disableListFilter to fields admin props (#6238)
This commit is contained in:
@@ -141,6 +141,22 @@ const TextFields: CollectionConfig = {
|
||||
hasMany: true,
|
||||
maxRows: 4,
|
||||
},
|
||||
{
|
||||
name: 'disableListColumnText',
|
||||
type: 'text',
|
||||
admin: {
|
||||
disableListColumn: true,
|
||||
disableListFilter: false,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'disableListFilterText',
|
||||
type: 'text',
|
||||
admin: {
|
||||
disableListColumn: false,
|
||||
disableListFilter: true,
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,8 @@ export const textFieldsSlug = 'text-fields'
|
||||
export const textDoc: Partial<TextField> = {
|
||||
text: 'Seeded text document',
|
||||
localizedText: 'Localized text',
|
||||
disableListColumnText: 'Disable List Column Text',
|
||||
disableListFilterText: 'Disable List Filter Text',
|
||||
}
|
||||
|
||||
export const anotherTextDoc: Partial<TextField> = {
|
||||
|
||||
@@ -10,6 +10,7 @@ import type { Config } from './payload-types.js'
|
||||
|
||||
import {
|
||||
ensureAutoLoginAndCompilationIsDone,
|
||||
exactText,
|
||||
initPageConsoleErrorCatch,
|
||||
navigateToListCellLink,
|
||||
openDocDrawer,
|
||||
@@ -89,6 +90,60 @@ describe('fields', () => {
|
||||
await expect(textCell).toHaveText(textDoc.text)
|
||||
})
|
||||
|
||||
test('should hide field in column selector when admin.disableListColumn', async () => {
|
||||
await page.goto(url.list)
|
||||
await page.locator('.list-controls__toggle-columns').click()
|
||||
|
||||
await expect(page.locator('.column-selector')).toBeVisible()
|
||||
|
||||
// Check if "Disable List Column Text" is not present in the column options
|
||||
await expect(
|
||||
page.locator(`.column-selector .column-selector__column`, {
|
||||
hasText: exactText('Disable List Column Text'),
|
||||
}),
|
||||
).toBeHidden()
|
||||
})
|
||||
|
||||
test('should show field in filter when admin.disableListColumn is true', async () => {
|
||||
await page.goto(url.list)
|
||||
await page.locator('.list-controls__toggle-where').click()
|
||||
await page.locator('.where-builder__add-first-filter').click()
|
||||
|
||||
const initialField = page.locator('.condition__field')
|
||||
await initialField.click()
|
||||
|
||||
await expect(
|
||||
initialField.locator(`.rs__menu-list:has-text("Disable List Column Text")`),
|
||||
).toBeVisible()
|
||||
})
|
||||
|
||||
test('should display field in list view column selector if admin.disableListColumn is false and admin.disableListFilter is true', async () => {
|
||||
await page.goto(url.list)
|
||||
await page.locator('.list-controls__toggle-columns').click()
|
||||
|
||||
await expect(page.locator('.column-selector')).toBeVisible()
|
||||
|
||||
// Check if "Disable List Filter Text" is present in the column options
|
||||
await expect(
|
||||
page.locator(`.column-selector .column-selector__column`, {
|
||||
hasText: exactText('Disable List Filter Text'),
|
||||
}),
|
||||
).toBeVisible()
|
||||
})
|
||||
|
||||
test('should hide field in filter when admin.disableListFilter is true', async () => {
|
||||
await page.goto(url.list)
|
||||
await page.locator('.list-controls__toggle-where').click()
|
||||
await page.locator('.where-builder__add-first-filter').click()
|
||||
|
||||
const initialField = page.locator('.condition__field')
|
||||
await initialField.click()
|
||||
|
||||
await expect(
|
||||
initialField.locator(`.rs__option :has-text("Disable List Filter Text")`),
|
||||
).toBeHidden()
|
||||
})
|
||||
|
||||
test('should display i18n label in cells when missing field data', async () => {
|
||||
await page.goto(url.list)
|
||||
const textCell = page.locator('.row-1 .cell-i18nText')
|
||||
|
||||
@@ -698,6 +698,8 @@ export interface TextField {
|
||||
localizedHasMany?: string[] | null;
|
||||
withMinRows?: string[] | null;
|
||||
withMaxRows?: string[] | null;
|
||||
disableListColumnText?: string | null;
|
||||
disableListFilterText?: string | null;
|
||||
updatedAt: string;
|
||||
createdAt: string;
|
||||
}
|
||||
@@ -1411,6 +1413,6 @@ export interface LexicalBlocksRadioButtonsBlock {
|
||||
|
||||
|
||||
declare module 'payload' {
|
||||
// @ts-ignore
|
||||
// @ts-ignore
|
||||
export interface GeneratedTypes extends Config {}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user