API Documentation

DruxtEntity

entity

Modules

DruxtEntity

Renders a Drupal Content Entity by JSON:API resource type, UUID, view mode and schema type.

Fields are rendered as Druxt Field components, based on the Drupal display mode configuration.

Typedefs

ComponentOptions : Array.<array>

Provides the available naming options for the Wrapper component.

ModuleSettings : object

Provides settings for the Entity module, via the nuxt.config.js druxt.entity or the Wrapper component druxt object.

PropsData : object

Provides propsData for use in the Wrapper component.

ScopedSlots : object

Provides scoped slots for use in the Wrapper component.

DruxtEntity

Renders a Drupal Content Entity by JSON:API resource type, UUID, view mode and schema type.

Fields are rendered as Druxt Field components, based on the Drupal display mode configuration.

Example

<DruxtEntity
  type="node--article"
  :uuid="uuid"
  mode="teaser"
/>

.getQuery(settings) ⇒ boolean | object

Builds the query for the JSON:API request.

Kind: instance method of DruxtEntity

ParamTypeDescription
settingsModuleSettingsThe merged module and component settings object.

.isEmpty(value) ⇒ boolean

Checks if an Entity field is empty.

Kind: instance method of DruxtEntity

ParamTypeDescription
value*Field value.

.props

Kind: static property of DruxtEntity


.mode : string

Drupal display mode.

Kind: static property of props
Default: "default"


.type : string

JSON:API resource type.

Kind: static property of props


.uuid : string

Entity UUID.

Kind: static property of props


.schemaType : 'view' | 'form'

Drupal display schema type, 'view' or 'form'.

Kind: static property of props


.computed

Kind: static property of DruxtEntity


.entity ⇒ object

The Entity object.

Kind: static property of computed
Returns: object - .


.fields ⇒ object

Entity fields based on Display mode.

Kind: static property of computed


.druxt

DruxtModule settings

Kind: static property of DruxtEntity


.componentOptions(context) ⇒ ComponentOptions

Provides the available component naming options for the Druxt Wrapper.

Kind: static method of druxt

ParamTypeDescription
contextobjectThe module component ViewModel.

.propsData(context) ⇒ PropsData

Provides propsData for the DruxtWrapper.

Kind: static method of druxt

ParamTypeDescription
contextobjectThe module component ViewModel.

.slots() ⇒ ScopedSlots

Provides the scoped slots object for the Module render function.

A scoped slot is provided for each field being rendered, as per the current display mode.

Additionally, the default slot will render all fields as per the

Kind: static method of druxt
Returns: ScopedSlots - The Scoped slots object.
Example (DruxtEntityResourceType.vue)

<template>
  <div>
    <slot name="content" />
    <slot :name="field_name" />
  </div>
</template>

.data()

Kind: static method of DruxtEntity
Properties

NameTypeDescription
modelobjectThe model object.
schemaobjectThe DruxtSchema object.

.fetch()

Nuxt.js fetch method.

Kind: static method of DruxtEntity


ComponentOptions : Array.<array>

Provides the available naming options for the Wrapper component.

Kind: global typedef
Example

[
  'DruxtEntity[ResourceType][DisplayMode][SchemaType]',
  'DruxtEntity[ResourceType][DisplayMode]',
  'DruxtEntity[ResourceType]',
  'DruxtEntity[DisplayMode]',
]

Example (Article Node (default))

[
  'DruxtEntityNodeArticleDefaultView',
  'DruxtEntityNodeArticleDefault',
  'DruxtEntityNodeArticle',
  'DruxtEntityNodeDefault',
]

ModuleSettings : object

Provides settings for the Entity module, via the nuxt.config.js druxt.entity or the Wrapper component druxt object.

Kind: global typedef

ParamTypeDescription
fieldsArray.<string>An array of fields to filter from the JSON:API Resource.
schemabooleanWhether to automatically detect fields to filter, per the Display mode.

Example

{
  fields: [],
  schema: false,
}

Example

<script>
export default {
  druxt: {
    query: {
      fields: ['title']
      schema: true,
    },
  }
}

PropsData : object

Provides propsData for use in the Wrapper component.

Kind: global typedef

ParamTypeDescription
entityobjectThe Drupal Entity JSON:API resource data.
fieldsobjectDrupal Entity Fields data.
schemaobjectDruxtJS Schema object.
valueobjectThe Entity value.

Example

{
  entity: {
    attributes: {},
    id: '43118086-cca5-4c62-b11e-f1d870050ebd',
    links: {},
    relationships: {},
    type: 'node--article',
  },
  fields: {
    body: {},
    field_media_image: {},
    field_tags: {},
  },
  schema: {
    config: {},
    fields: {},
    groups: {},
    id: 'node--article--default--view',
    resourceType: 'node--article',
  },
  value: {},
}

ScopedSlots : object

Provides scoped slots for use in the Wrapper component.

Kind: global typedef

ParamTypeDescription
*functionSlot per field.
defaultfunctionAll fields per Display mode.

Example (DruxtEntityResourceType.vue)

<template>
  <div>
    <slot name="content" />
    <slot :name="field_name" />
  </div>
</template>