# Modules

DruxtEntity

The <DruxtEntity /> component fetches the Entity JSON:API resource and schema data to render the Entities fields based on the Drupal Display Mode configuration.

Features:

  • Display mode based field system
  • Scoped slots
  • Query settings

# 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

The <DruxtEntity /> component fetches the Entity JSON:API resource and schema data to render the Entities fields based on the Drupal Display Mode configuration.

Features:

  • Display mode based field system
  • Scoped slots
  • Query settings

Example

<DruxtEntity
  type="node--article"
  :uuid="uuid"
  mode="teaser"
/>
1
2
3
4
5

# .getQuery(settings) ⇒ boolean | object

Builds the query for the JSON:API request.

Kind: instance method of DruxtEntity

Param Type Description
settings ModuleSettings The merged module and component settings object.

# .isEmpty(value) ⇒ boolean

Checks if an Entity field is empty.

Kind: instance method of DruxtEntity

Param Type Description
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

Param Type Description
context object The module component ViewModel.

# .propsData(context) ⇒ PropsData

Provides propsData for the DruxtWrapper.

Kind: static method of druxt

Param Type Description
context object The 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>
1
2
3
4
5
6

# .fetch()

Nuxt.js fetch method.

Kind: static method of DruxtEntity


# .data()

Kind: static method of DruxtEntity
Properties

Name Type Description
model object The model object.
schema object The DruxtSchema object.

# 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]',
]
1
2
3
4
5
6

Example (Article Node (default))

[
  'DruxtEntityNodeArticleDefaultView',
  'DruxtEntityNodeArticleDefault',
  'DruxtEntityNodeArticle',
  'DruxtEntityNodeDefault',
]
1
2
3
4
5
6

# ModuleSettings : object

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

Kind: global typedef

Param Type Description
fields Array.<string> An array of fields to filter from the JSON:API Resource.
schema boolean Whether to automatically detect fields to filter, per the Display mode.

Example

{
  fields: [],
  schema: false,
}
1
2
3
4

Example

<script>
export default {
  druxt: {
    query: {
      fields: ['title']
      schema: true,
    },
  }
}
1
2
3
4
5
6
7
8
9

# PropsData : object

Provides propsData for use in the Wrapper component.

Kind: global typedef

Param Type Description
entity object The Drupal Entity JSON:API resource data.
fields object Drupal Entity Fields data.
schema object DruxtJS Schema object.
value object The 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: {},
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

# ScopedSlots : object

Provides scoped slots for use in the Wrapper component.

Kind: global typedef

Param Type Description
* function Slot per field.
default function All fields per Display mode.

Example (DruxtEntityResourceType.vue)

<template>
  <div>
    <slot name="content" />
    <slot :name="field_name" />
  </div>
</template>
1
2
3
4
5
6