Mixin for store management that creates render items from store items after querying the store. The receiving class must extend decor/Evented or delite/Widget.
Classes extending this mixin automatically create render items that are consumable
from store items after querying the store. This happens each time the store, query or
queryOptions properties are set. If that store is Trackable it will be observed and render items
will be automatically updated, added or deleted based on store notifications.
Members
-
query :Object
-
A query filter to apply to the store.
Type:
- Object
- Default Value:
- {}
- Source:
-
renderItems :Array.<Object>
-
The render items corresponding to the store items for this widget. This is filled from the store and is not supposed to be modified directly. Initially null.
Type:
- Array.<Object>
- Default Value:
- null
- Source:
-
store :dstore/Store
-
The store that contains the items to display.
Type:
- dstore/Store
- Default Value:
- null
- Source:
Methods
-
<protected> _itemRemoved(event)
-
When the store is observed and an item is removed in the store this method is called to remove the corresponding render item. This can be redefined but must not be called directly.
Parameters:
Name Type Description eventEvent The "remove"
dstore/Trackableevent. -
<protected> computeProperties(props)
-
If the store parameters are invalidated, queries the store, creates the render items and calls initItems() when ready. If an error occurs a 'query-error' event will be fired.
Parameters:
Name Type Description props -
<protected> fetch(collection)
-
Called to perform the fetch operation on the collection.
Parameters:
Name Type Description collectiondstore/Collection Items to be displayed.
-
<protected> initItems(renderItems) → {Array.<Object>}
-
This method is called once the query has been executed to initialize the renderItems array with the list of initial render items.
This method sets the renderItems property to the render items array passed as parameter. Once done, it fires a 'query-success' event.
Parameters:
Name Type Description renderItemsArray.<Object> The array of initial render items to be set in the renderItems property.
Returns:
the renderItems array.
- Type
- Array.<Object>
-
<protected> itemAdded(index, renderItem, renderItems)
-
This method is called when an item is added in an observable store. The default implementation actually adds the renderItem to the renderItems array. This can be redefined but must not be called directly.
Parameters:
Name Type Description indexnumber The index where to add the render item.
renderItemObject The render item to be added.
renderItemsArray.<Object> The array of render items to add the render item to.
-
<protected> itemMoved(previousIndex, newIndex, renderItem, renderItems)
-
This method is called when an item is moved in an observable store. The default implementation actually moves the renderItem in the renderItems array. This can be redefined but must not be called directly.
Parameters:
Name Type Description previousIndexnumber The previous index of the render item.
newIndexnumber The new index of the render item.
renderItemObject The render item to be moved.
renderItemsArray.<Object> The array of render items to render item to be moved is part of.
-
<protected> itemRemoved(index, renderItems)
-
This method is called when an item is removed from an observable store. The default implementation actually removes a renderItem from the renderItems array. This can be redefined but must not be called directly.
Parameters:
Name Type Description indexnumber The index of the render item to remove.
renderItemsArray.<Object> The array of render items to remove the render item from.
-
<protected> itemToRenderItem(item) → {Object}
-
Returns the widget internal item for a given store item. By default it returns the store item itself.
Parameters:
Name Type Description itemObject The store item.
Returns:
- Type
- Object
-
<protected> itemUpdated(index, renderItem, renderItems)
-
This method is called when an item is updated in an observable store. The default implementation actually updates the renderItem in the renderItems array. This can be redefined but must not be called directly.
Parameters:
Name Type Description indexnumber The index of the render item to update.
renderItemObject The render item data the render item must be updated with.
renderItemsArray.<Object> The array of render items to render item to be updated is part of.
-
<protected> processCollection(collection)
-
Called to process the items returned after querying the store.
Parameters:
Name Type Description collectiondstore/Collection Items to be displayed.
-
processQueryResult()
-
A function that processes the collection returned by the store query and returns a new collection (to sort it, etc...). This processing is applied before potentially tracking the store for modifications (if Trackable). Changing this function on the instance will not automatically refresh the class.
- Default Value:
- identity function
- Source:
-
<protected> queryStoreAndInitItems(processQueryResult) → {Promise}
-
Queries the store, creates the render items and calls initItems() when ready. If an error occurs a 'query-error' event will be fired.
This method is not supposed to be called by application developer. It will be called automatically when modifying the store related properties or by the subclass if needed.
Parameters:
Name Type Description processQueryResultA function that processes the collection returned by the store query and returns a new collection (to sort it, etc...)., applied before tracking.
Returns:
If store to be processed is not null a promise that will be resolved when the loading process will be finished.
- Type
- Promise
-
renderItemToItem(renderItem) → {Object}
-
Creates a store item based from the widget internal item.
Parameters:
Name Type Description renderItemObject The render item.
Returns:
- Type
- Object