chore: further refinements

This commit is contained in:
James
2022-09-11 20:57:30 -07:00
parent ad4f7a5fff
commit 21eb19edd1
10 changed files with 100 additions and 40 deletions

View File

@@ -5,33 +5,52 @@
* and re-run `payload generate:types` to regenerate this file.
*/
export interface Config { }
export interface Config {}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "autosave-global".
* via the `definition` "posts".
*/
export interface AutosaveGlobal {
export interface Post {
id: string;
_status?: 'draft' | 'published';
title: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "autosave-posts".
*/
export interface AutosavePost {
id: string;
_status?: 'draft' | 'published';
title: string;
description: string;
restrictedField?: string;
createdAt: string;
updatedAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "draft-posts".
* via the `definition` "restricted".
*/
export interface DraftPost {
export interface Restricted {
id: string;
name?: string;
createdAt: string;
updatedAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "read-only-collection".
*/
export interface ReadOnlyCollection {
id: string;
name?: string;
createdAt: string;
updatedAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "restricted-versions".
*/
export interface RestrictedVersion {
id: string;
name?: string;
createdAt: string;
updatedAt: string;
}
/**
* This interface was referenced by `Config`'s JSON-Schema
* via the `definition` "sibling-data".
*/
export interface SiblingDatum {
id: string;
array: {
allowPublicReadability?: boolean;

View File

@@ -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: [

View File

@@ -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 () => {

View File

@@ -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;
}

View File

@@ -75,6 +75,8 @@ export interface UnstoredMedia {
filename?: string;
mimeType?: string;
filesize?: number;
width?: number;
height?: number;
createdAt: string;
updatedAt: string;
}