chore: further refinements
This commit is contained in:
@@ -190,10 +190,9 @@ const TabsFields: CollectionConfig = {
|
||||
},
|
||||
],
|
||||
afterChange: [
|
||||
({ data = {} }) => {
|
||||
if (!data.hooksTab) data.hooksTab = {};
|
||||
data.hooksTab.afterChange = true;
|
||||
return data.hooksTab;
|
||||
({ originalDoc }) => {
|
||||
originalDoc.hooksTab.afterChange = true;
|
||||
return originalDoc.hooksTab;
|
||||
},
|
||||
],
|
||||
afterRead: [
|
||||
|
||||
@@ -357,14 +357,14 @@ describe('Fields', () => {
|
||||
});
|
||||
|
||||
it('should allow hooks on a named tab', async () => {
|
||||
document = await payload.findByID({
|
||||
const newDocument = await payload.create<TabsField>({
|
||||
collection: tabsSlug,
|
||||
id: document.id,
|
||||
data: tabsDoc,
|
||||
});
|
||||
expect(document.hooksTab.beforeValidate).toBe(true);
|
||||
expect(document.hooksTab.beforeChange).toBe(true);
|
||||
expect(document.hooksTab.afterChange).toBe(true);
|
||||
expect(document.hooksTab.afterRead).toBe(true);
|
||||
expect(newDocument.hooksTab.beforeValidate).toBe(true);
|
||||
expect(newDocument.hooksTab.beforeChange).toBe(true);
|
||||
expect(newDocument.hooksTab.afterChange).toBe(true);
|
||||
expect(newDocument.hooksTab.afterRead).toBe(true);
|
||||
});
|
||||
|
||||
it('should return empty object for groups when no data present', async () => {
|
||||
|
||||
@@ -72,6 +72,13 @@ export interface BlockField {
|
||||
blockName?: string;
|
||||
blockType: 'subBlocks';
|
||||
}
|
||||
| {
|
||||
textInCollapsible?: string;
|
||||
textInRow?: string;
|
||||
id?: string;
|
||||
blockName?: string;
|
||||
blockType: 'tabs';
|
||||
}
|
||||
)[];
|
||||
localizedBlocks: (
|
||||
| {
|
||||
@@ -108,6 +115,13 @@ export interface BlockField {
|
||||
blockName?: string;
|
||||
blockType: 'subBlocks';
|
||||
}
|
||||
| {
|
||||
textInCollapsible?: string;
|
||||
textInRow?: string;
|
||||
id?: string;
|
||||
blockName?: string;
|
||||
blockType: 'tabs';
|
||||
}
|
||||
)[];
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
@@ -273,12 +287,25 @@ export interface TabsField {
|
||||
blockName?: string;
|
||||
blockType: 'subBlocks';
|
||||
}
|
||||
| {
|
||||
textInCollapsible?: string;
|
||||
textInRow?: string;
|
||||
id?: string;
|
||||
blockName?: string;
|
||||
blockType: 'tabs';
|
||||
}
|
||||
)[];
|
||||
group: {
|
||||
number: number;
|
||||
};
|
||||
textInRow: string;
|
||||
numberInRow: number;
|
||||
text?: string;
|
||||
defaultValue?: string;
|
||||
beforeValidate?: boolean;
|
||||
beforeChange?: boolean;
|
||||
afterChange?: boolean;
|
||||
afterRead?: boolean;
|
||||
textarea?: string;
|
||||
anotherText: string;
|
||||
createdAt: string;
|
||||
@@ -325,6 +352,8 @@ export interface Upload {
|
||||
filename?: string;
|
||||
mimeType?: string;
|
||||
filesize?: number;
|
||||
width?: number;
|
||||
height?: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user