Skip to content

Drupal Views components for Druxt with support for filters, pagination and sorting.

DruxtViewsSorts

View source on GitHub

DruxtViewsSorts

Used by the DruxtView component to render a Druxt Wrapper themeable sort.

Example

<DruxtViewsSorts
  :options="{}"
  :sorts="[{}]"
  type="basic"
/>

.sortBy(sort) ⇒ object

Returns a merged Route object with the provided sort.

Kind: instance method of DruxtViewsSorts

ParamTypeDescription
sortstringThe sort ID.

.error(err, [context])

Sets the component to render a DruxtDebug error message.

Kind: instance method of DruxtViewsSorts

ParamTypeDescription
errobjectThe error object.
[context]objectError context; carries the wrapper component data where the failure knows it.

.getModuleComponents() ⇒ Components

Get list of module wrapper components.

Kind: instance method of DruxtViewsSorts


.getModulePropsData(wrapperProps) ⇒ object

Get module propsData via modules druxt.propsData() callback.

Kind: instance method of DruxtViewsSorts

ParamTypeDescription
wrapperPropsobjectProps registered by the Wrapper component.

Example

{
  $attrs: { entity: {}, fields: {}, langcode: 'en', schema: {} },
  props: { value: {} },
  propsData: { entity: {}, fields: {}, langcode: 'en', schema: {}, value: {} },
}

.getScopedSlots() ⇒ object

Gets a Druxt modules scoped slots, and if there's no default slots, provides a develop mode debug default or passes through to a default template.

Kind: instance method of DruxtViewsSorts


.getWrapperData(component) ⇒ WrapperData

Get wrapper component data.

Kind: instance method of DruxtViewsSorts

ParamTypeDescription
componentstringThe Wrapper component name.

.props

Kind: static property of DruxtViewsSorts


.options : object

The Exposed form options.

Kind: static property of props


.sorts : Array.<object>

The Exposed Sort objects.

Kind: static property of props


.type : string

The Exposed form type.

Kind: static property of props


.langcode : string

The resource langcode.

Kind: static property of props
Example

@lang vue
<DruxtViewsSorts langcode="en" />

.v-model : mixed

The Vue.js v-model binding for the module.

Setting a value provides the module data directly, so the Drupal JSON:API fetch is skipped.

Kind: static property of props
Default:
Example

@lang vue
<template>
  <DruxtViewsSorts v-model="model" />
</template>

<script>
export default {
  data: () => ({ model: { foo: 'bar' } })
}
</script>

.wrapper : (boolean | object)

The wrapper component configuration.

Used to set the wrapper component, class, style and propsData.

Kind: static property of props
Default: () => undefined
Example

<DruxtViewsSorts
  :wrapper="{
    component: 'BCard',
    class: 'article-card',
    propsData: { noBody: true }
  }"
/>

.druxt

DruxtModule settings

Kind: static property of DruxtViewsSorts


.template

Druxt development template tool configuration.

Kind: static property of druxt


.componentOptions(context) ⇒ ComponentOptions

Provides the available component naming options for the DruxtWrapper.

Kind: static method of druxt

ParamTypeDescription
contextobjectThe module component ViewModel.
context.typestringThe Exposed form type.

.propsData(context) ⇒ PropsData

Provides propsData for the DruxtWrapper.

Kind: static method of druxt

ParamTypeDescription
contextobjectThe module component ViewModel.
context.modelstringThe selected sort ID.
context.optionsobjectThe Exposed form options.
context.sortsArray.<object>The Exposed Sort objects.
context.typestringThe Exposed form type.

.slots(h) ⇒ ScopedSlots

Provides the scoped slots object for the Module render function.

The default slot will render a list of sorts.

Kind: static method of druxt
Returns: ScopedSlots - The Scoped slots object.

ParamTypeDescription
hfunctionThe Vue createElement function.

.methods

Kind: static property of DruxtViewsSorts


.data(vm)

Kind: static method of DruxtViewsSorts

ParamTypeDescription
vmobjectThe component ViewModel.
vm.value*The module component model value.

Properties

NameTypeDescription
componentComponentDataThe wrapper component and propsData to be rendered.
model*The module component model value.

.fetch()

Loads the Druxt module data and applies a wrapper component as required.

Important: If your component has an existing fetch method, you must manually invoke the DruxtModule.fetch() hook.

Kind: static method of DruxtViewsSorts
Example (Manually invoking DruxtModule.fetch().)

import DruxtModule from 'druxt/components/DruxtModule.vue'
export default {
  name: 'DruxtCustomModule',
  extends: DruxtModule,
  async fetch() {
    await DruxtModule.fetch.call(this)
  },
  druxt: {
    componentOptions: () => ([['Default']]),
    propsData: ({ model }) => ({ value: model }),
  }
}

.lang(vm) ⇒ string

The current language code: the langcode prop if set, otherwise the route's langcode metadata.

Used by Druxt modules to fetch the correct resource translation.

Kind: static method of DruxtViewsSorts
Returns: string - The current language code.

ParamTypeDescription
vmobjectThe component ViewModel.
vm.langcodestringThe langcode prop.
vm.$routeobjectThe current route.

ComponentOptions : Array.<array>

Provides the available component naming options for the Druxt Wrapper.

Kind: global typedef
Example

[
  'DruxtViewsSorts[Type][Langcode]',
  'DruxtViewsSorts[Type]',
  'DruxtViewsSorts[Default][Langcode]',
  'DruxtViewsSorts[Default]'
]

Example

[
  'DruxtViewsSortsBasicEn',
  'DruxtViewsSortsBasic',
  'DruxtViewsSortsDefaultEn',
  'DruxtViewsSortsDefault'
]

PropsData : object

Provides propsData for the DruxtWrapper.

Kind: global typedef

ParamTypeDescription
optionsobjectThe Exposed form options.
sortsArray.<object>The Exposed Sort objects.
typestringThe Exposed form type.
valuestringThe selected sort ID.

Example

{
  options: {
    expose_sort_order: true,
    expose_sorts_label: 'Sort by',
    reset_button: false,
    ...
  },
  sorts: [{
    admin_label: '',
    expose: {},
    exposed: true,
    ...
  }],
  type: 'basic',
  value: undefined,
}

ScopedSlots : object

Provides scoped slots for use in the Wrapper component.

Kind: global typedef

ParamTypeDescription
defaultfunctionA list of sort links.

Inherited type definitions

Inherited from DruxtModule: ComponentData, Components, WrapperData.