feat/add support for setting collapsable fields (array, block, collapsable… (#1057)

Co-authored-by: liorix <liorix@gmail.com>
Co-authored-by: Elliot DeNolf <denolfe@gmail.com>
This commit is contained in:
Dan Ribbens
2022-09-12 13:39:49 -04:00
committed by GitHub
parent ca434b8a92
commit 834f4ebd38
12 changed files with 191 additions and 77 deletions

View File

@@ -23,6 +23,20 @@ const ArrayFields: CollectionConfig = {
},
],
},
{
name: 'collapsedArray',
type: 'array',
fields: [
{
name: 'text',
type: 'text',
required: true,
},
],
admin: {
initCollapsed: true,
},
},
{
name: 'localized',
type: 'array',
@@ -92,6 +106,11 @@ export const arrayDoc = {
text: 'sixth row',
},
],
collapsedArray: [
{
text: 'initialize collapsed',
},
],
};
export default ArrayFields;

View File

@@ -1,6 +1,36 @@
import type { CollectionConfig } from '../../../../src/collections/config/types';
import { Field } from '../../../../src/fields/config/types';
export const blocksFieldSeedData = [
{
blockName: 'First block',
blockType: 'text',
text: 'first block',
richText: [],
},
{
blockName: 'Second block',
blockType: 'number',
number: 342,
},
{
blockName: 'Sub-block demonstration',
blockType: 'subBlocks',
subBlocks: [
{
blockName: 'First sub block',
blockType: 'number',
number: 123,
},
{
blockName: 'Second sub block',
blockType: 'text',
text: 'second sub block',
},
],
},
] as const;
export const blocksField: Field = {
name: 'blocks',
type: 'blocks',
@@ -104,12 +134,21 @@ export const blocksField: Field = {
],
},
],
defaultValue: blocksFieldSeedData,
};
const BlockFields: CollectionConfig = {
slug: 'block-fields',
fields: [
blocksField,
{
...blocksField,
name: 'collapsedByDefaultBlocks',
localized: true,
admin: {
initCollapsed: true,
},
},
{
...blocksField,
name: 'localizedBlocks',
@@ -118,36 +157,6 @@ const BlockFields: CollectionConfig = {
],
};
export const blocksFieldSeedData = [
{
blockName: 'First block',
blockType: 'text',
text: 'first block',
richText: [],
},
{
blockName: 'Second block',
blockType: 'number',
number: 342,
},
{
blockName: 'Sub-block demonstration',
blockType: 'subBlocks',
subBlocks: [
{
blockName: 'First sub block',
blockType: 'number',
number: 123,
},
{
blockName: 'Second sub block',
blockType: 'text',
text: 'second sub block',
},
],
},
] as const;
export const blocksDoc = {
blocks: blocksFieldSeedData,
localizedBlocks: blocksFieldSeedData,

View File

@@ -9,6 +9,7 @@ const CollapsibleFields: CollectionConfig = {
type: 'collapsible',
admin: {
description: 'This is a collapsible field.',
initCollapsed: false,
},
fields: [
{
@@ -38,6 +39,40 @@ const CollapsibleFields: CollectionConfig = {
},
],
},
{
label: 'Collapsible Field - Collapsed by Default',
type: 'collapsible',
admin: {
description: 'This is a collapsible field.',
initCollapsed: true,
},
fields: [
{
name: 'someText',
type: 'text',
},
{
name: 'group',
type: 'group',
fields: [
{
name: 'textWithinGroup',
type: 'text',
},
{
name: 'subGroup',
type: 'group',
fields: [
{
name: 'textWithinSubGroup',
type: 'text',
},
],
},
],
},
],
},
],
};