Skip to content

Commit

Permalink
add documentation for new fields
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Nov 10, 2022
1 parent 50ab463 commit abc5cc4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docs/pages/docs/fields/relationship.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@ Read our [relationships guide](../guides/relationships) for details on Keystone
- `displayMode` (default: `'select'`): Controls the mode used to display the field in the item view. The mode `'select'` displays related items in a select component, while `'cards'` displays the related items in a card layout. Each display mode supports further configuration.
- `ui.displayMode === 'select'` options:
- `labelField`: The field path from the related list to use for item labels in the select. Defaults to the `labelField` configured on the related list.
{% if $nextRelease %}
- `searchFields`: The fields used by the UI to search for this item, in context of this relationship field. Defaults to `searchFields` configured on the related list.
{% /if %}
- `ui.displayMode === 'cards'` options:
- `cardFields`: A list of field paths from the related list to render in the card component. Defaults to `'id'` and the `labelField` configured on the related list.
- `linkToItem` (default `false`): If `true`, the default card component will render as a link to navigate to the related item.
- `removeMode` (default: `'disconnect'`): Controls whether the `Remove` button is present in the card. If `'disconnect'`, the button will be present. If `'none'`, the button will not be present.
- `inlineCreate` (default: `null`): If not `null`, an object of the form `{ fields: [...] }`, where `fields` is a list of field paths from the related list should be provided. An inline `Create` button will be included in the cards allowing a new related item to be created based on the configured field paths.
- `inlineEdit` (default: `null`): If not `null`, an object of the form `{ fields: [...] }`, where `fields` is a list of field paths from the related list should be provided. An `Edit` button will be included in each card, allowing the configured fields to be edited for each related item.
- `inlineConnect` (default: `false`): If `true`, an inline `Link existing item` button will be present, allowing existing items of the related list to be connected in this field.
{% if $nextRelease %}
Alternatively this can be an object with the properties:
- `labelField`: The field path from the related list to use for item labels in select. Defaults to the `labelField` configured on the related list.
- `searchFields`: The fields used by the UI to search for this item, in context of this relationship field. Defaults to `searchFields` configured on the related list.
{% /if %}
- `ui.displayMode === 'count'` only supports `many` relationships

```typescript
Expand Down
5 changes: 4 additions & 1 deletion packages/core/src/admin-ui/system/createAdminMeta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,19 @@ export function createAdminMeta(
// Disabling this entirely for now until we properly decide what the Admin UI
// should do when `omit: ['read']` is used.
if (field.graphql.isEnabled.read === false) continue;
let search = searchFields.has(fieldKey) ? possibleSearchFields.get(fieldKey) ?? null : null;

const search = searchFields.has(fieldKey) ? possibleSearchFields.get(fieldKey) ?? null : null;
if (searchFields.has(fieldKey) && search === null) {
throw new Error(
`The ui.searchFields option on the ${key} list includes '${fieldKey}' but that field doesn't have a contains filter that accepts a GraphQL String`
);
}

assertValidView(
field.views,
`The \`views\` on the implementation of the field type at lists.${key}.fields.${fieldKey}`
);

const baseOrderFilterArgs = { fieldKey, listKey: list.listKey };
adminMetaRoot.listsByKey[key].fields.push({
label: field.label ?? humanize(fieldKey),
Expand Down

0 comments on commit abc5cc4

Please sign in to comment.