feat: autolabel fields when label is omitted (#42)

* feat: autolabel fields when omitted

* feat: handle autolabel in graphql mutation build

* feat: autolabel blocks

* test: add required slug field to blocks

* feat: handle graphql names when label is false

* feat: adds relationship field to test searchable input

* feat: handle block cell type labeling pluralization

* docs: remove all explicit labeling, no longer needed

* fix: falsey column labels, allows false array labels

* fix: client tests

* fix: auto-labels globals

* docs: globals auto-labeling and hooks clarification

* fix; proper object type naming

Co-authored-by: James <james@trbl.design>
This commit is contained in:
Elliot DeNolf
2021-04-16 22:37:08 -04:00
committed by GitHub
parent 21b2bd4b67
commit b383eb65c6
49 changed files with 277 additions and 150 deletions

View File

@@ -24,7 +24,7 @@ keywords: array, fields, config, configuration, documentation, Content Managemen
| Option | Description |
| ---------------- | ----------- |
| **`name`** * | To be used as the property name when stored and retrieved from the database. |
| **`label`** | Used as a heading in the Admin panel and to name the generated GraphQL type. |
| **`label`** | Used as a heading in the Admin panel and to name the generated GraphQL type. Auto-generated from name if not defined. |
| **`fields`** * | Array of field types to correspond to each row of the Array. |
| **`validate`** | Provide a custom validation function that will be executed on both the Admin panel and the backend. [More](/docs/fields/overview#validation) |
| **`saveToJWT`** | If this field is top-level and nested in a config supporting [Authentication](/docs/authentication/config), include its data in the user JWT. |
@@ -59,14 +59,12 @@ keywords: array, fields, config, configuration, documentation, Content Managemen
fields: [ // required
{
name: 'image',
label: 'Image',
type: 'upload',
relationTo: 'media',
required: true,
},
{
name: 'caption',
label: 'Caption',
type: 'text',
}
]

View File

@@ -53,7 +53,7 @@ Blocks are defined as separate configs of their own.
| ---------------- | ----------- |
| **`slug`** * | Identifier for this block type. Will be saved on each block as the `blockType` property. |
| **`fields`** * | Array of fields to be stored in this block. |
| **`labels`** | Customize the block labels that appear in the Admin dashboard. Also used to name corresponding GraphQL schema types. |
| **`labels`** | Customize the block labels that appear in the Admin dashboard. Also used to name corresponding GraphQL schema types. Auto-generated from slug if not defined. |
| **`imageURL`** | Provide a custom image thumbnail to help editors identify this block in the Admin UI. |
| **`imageAltText`** | Customize this block's image thumbnail alt text. |
@@ -79,14 +79,12 @@ const QuoteBlock = {
imageAltText: 'A nice thumbnail image to show what this block looks like',
fields: [ // required
{
name: 'text',
label: 'Quote Text',
name: 'quoteHeader',
type: 'text',
required: true,
},
{
name: 'text',
label: 'Quotee',
name: 'quoteText',
type: 'text',
},
]
@@ -98,13 +96,8 @@ const ExampleCollection = {
{
name: 'layout', // required
type: 'blocks', // required
label: 'layout',
minRows: 1,
maxRows: 20,
labels: {
singular: 'Layout',
plural: 'Layouts',
},
blocks: [ // required
QuoteBlock
]

View File

@@ -51,7 +51,6 @@ Currently, the `language` property only supports JavaScript syntax but more supp
{
name: 'trackingCode', // required
type: 'code', // required
label: 'Tracking Code',
required: true,
admin: {
language: 'js'

View File

@@ -37,9 +37,8 @@ keywords: group, fields, config, configuration, documentation, Content Managemen
slug: 'example-collection',
fields: [
{
name: 'meta', // required
name: 'pageMeta', // required
type: 'group', // required
label: 'Page Meta',
fields: [ // required
{
name: 'title',

View File

@@ -58,7 +58,6 @@ Set this property to a string that will be used for browser autocomplete.
{
name: 'age', // required
type: 'number', // required
label: 'Age',
required: true,
admin: {
step: 1,

View File

@@ -20,14 +20,12 @@ const Pages = {
slug: 'pages',
fields: [
{
name: 'my-field',
name: 'myField',
type: 'text', // highlight-line
label: 'My Field',
},
{
name: 'other-field',
name: 'otherField',
type: 'checkbox', // highlight-line
label: 'Other Field'
},
],
}

View File

@@ -53,7 +53,6 @@ The `layout` property allows for the radio group to be styled as a horizonally o
{
name: 'color', // required
type: 'radio', // required
label: 'color',
options: [ // required
{
label: 'Mint',

View File

@@ -54,7 +54,6 @@ keywords: relationship, fields, config, configuration, documentation, Content Ma
name: 'placedBy', // required
type: 'relationship', // required
relationTo: ['organizations', 'users'], // required
label: 'Placed By',
hasMany: false,
required: true,
}

View File

@@ -52,9 +52,8 @@ Set this property to a string that will be used for browser autocomplete.
slug: 'example-collection',
fields: [
{
name: 'title', // required
name: 'pageTitle', // required
type: 'text', // required
label: 'Page Title',
required: true,
}
]

View File

@@ -54,7 +54,6 @@ Set this property to a string that will be used for browser autocomplete.
{
name: 'metaDescription', // required
type: 'textarea', // required
label: 'Page Meta Description',
required: true,
}
]

View File

@@ -50,10 +50,9 @@ keywords: upload, images media, fields, config, configuration, documentation, Co
slug: 'example-collection',
fields: [
{
name: 'background', // required
name: 'backgroundImage', // required
type: 'upload', // required
relationTo: 'media', // required
label: 'Background Image',
required: true,
}
]