Module: alfresco/lists/views/layouts/_MultiItemRendererMixin

alfresco/lists/views/layouts/_MultiItemRendererMixin

This mixin provides the capability to a widget to iterate over the data that is returned by making a request to the Alfresco Repository for a list of nodes to be displayed in a Document Library. This should be mixed into any widget that will process a JSON model of widgets because it extends the createWidget function to pass the details of the item that is currently being rendered to all of its processed widgets. It also overrides the default allWidgetsProcessed function to make a call to render the next item in the currentData attribute (if applicable).
Author:
  • Dave Draper
License:
Source:

Extends

  • module:aikau/core/ChildProcessing

Members

_renderedItemWidgets :array

Records all the widgets that are processed for each item. This differs from the _processedWidgets attribute because that captures the widgets processed for the last item (i.e. the data is replaced on each item iteration)
Type:
  • array
Default Value:
  • null
Source:

cssRequirements :object[]

An array of the CSS files to use with this widget.
Type:
  • object[]
Default Value:
  • [{cssFile:"./css/_MultiItemRendererMixin.css"}]
Source:

currentData :Object[]

This should be set to the data to iterate over. This should be an object that contains an "items" attribute.
Type:
  • Object[]
Default Value:
  • null
Source:

currentIndex :number

The index of the item in currentData items array that is currently being rendered
Type:
  • number
Default Value:
  • null
Source:

currentItem :Object

The current item being rendered
Type:
  • Object
Default Value:
  • null
Source:

focusHighlighting :boolean

Indicates whether or not focused items should have a highlight style applied to them.
Type:
  • boolean
Default Value:
  • false
Source:

itemKey :string

This is the property that should be used to compare unique keys when comparing items. This will default to "nodeRef" if not set.
Type:
  • string
Default Value:
  • "nodeRef"
Source:

rootViewWidget :Object

This is the widget that acts as the root of the view. By default this will be instantiated as a Table.
Type:
  • Object
Default Value:
  • null
Source:

rootWidgetSubscriptions :object[]

Type:
  • object[]
Default Value:
  • null
Source:

Methods

allItemsRendered()

Source:

allWidgetsProcessed(widgets, processWidgetsId)

Overrides the default implementation to start the rendering of the next item.
Parameters:
Name Type Description
widgets Object[]
processWidgetsId string An optional ID that might have been provided to map the results of multiple calls to processWidgets
Source:

clearData()

Reset the current Data object.
Source:

compareItems(item1, item2) → {boolean}

Compares the nodeRef attribute of both item arguments. This has been abstracted to a separate function to allow simpler overriding when comparing items. This function is called by the onItemSelection function to determine whether the item currently selected is the item represented by the current widget.
Parameters:
Name Type Description
item1 object The first item to compare
item2 object The second item to compare
Source:
Returns:
true if the items are the same and false otherwise.
Type
boolean

createWidget(config, domNode, callback, callbackArgs)

Overrides the default implementation of create widget to update the widget configuration with the current item being rendered. This ensures that each widget has access to all the data about that item.
Parameters:
Name Type Description
config Object The configuration to pass as an instantiation argument to the widget
domNode element The DOM node to attach the widget to
callback function A function to call once the widget has been instantiated
callbackArgs Array An array of arguments to pass to the callback function
Source:

getData() → {Object[]}

Return the current data object.
Source:
Returns:
Type
Object[]

onFocusClick(evt)

This function has been added to that mixing modules can ensure that they request focus from their respective container. This ensures that focus is given to the correct item and is not just given to the first child in the container when focus returns to it.
Parameters:
Name Type Description
evt object The click event that gave focus.
Source:

onItemDeselection(payload)

Removes the "selected" CSS class to the root widget if it has been de-selected.
Parameters:
Name Type Description
payload object The details of the selected item
Source:

onItemSelection(payload)

Adds the "selected" CSS class to the root widget if it has been selected.
Parameters:
Name Type Description
payload object The details of the selected item
Source:

renderData()

This function should be called to iterate over new data. It sets the currentData object and resets the index back to zero. When processWidgets function is called it will being set currentItem as the first element in the items attribute belonging to currentData
Source:

renderNextItem()

Calls processWidgets to instantiate the widgets defined in the JSON model for currentItem
Source:

rootWidgetProcessing(widget, index)

Adds the "alfresco-lists-views-layout-_MultiItemRendererMixin__item" class to the root DOM node of the widget and additionally subscribes to item selection publications so that additional CSS classes can be added when an item is selected (so that they can be visually indicate selection).
Parameters:
Name Type Description
widget object The widget to add the styling to
index number The index of the widget
Source:

setData(data)

A setter for currentData
Parameters:
Name Type Description
data Object The data to set
Source:

<inner> augmentData(newData)

An advanced setter forcurrentData It intelligently merges the new data to the old data
Parameters:
Name Type Description
newData object data to add to the existing data
Source: