Stream
Description
Class for handling list of timeline elements.
BX.UI.Timeline.Stream
All timeline elements - descendant for Item class.
All editors - descendants for Editor.
Timeline consists of four parts:
- editors;
- scheduled;
- attached;
- all elements.
Elements from Scheduled section are not displayed in general list, they cannot be attached.
Elements from the Attached list are duplicates of elements from general list (i. e. single element has two instances, one in general list, second in attached list).
These elements will have the same identifier, but they are two different objects.
Elements in general section are grouped by days, with separator at the start of each day (it has separate methods to handle it).
The timeline itself only performs the rendering, it doesn't executes any queries. User actions call events, and handlers for these events execute their ajax queries.
Methods
Method | Description | Available from version |
---|---|---|
constructor(params: {}) | Constructor.
Параметры:
| |
createItem(data: {}, itemClassName: ?Function): ?Item | Creates new element, when passing correct data. | |
addItem(item: Item): Stream | Adds a new element into array of elements. When required, element is cloned into attached element list.
| |
getItems(): Array | Returns array of all elements. | |
getItem(id: string|number): ?Item | Returns element by its ID.
| |
getPinnedItems(): Array | Returns array of all attached elements. | |
getPinnedItem(id: string|number): ?Item | Returns attached element by its ID.
| |
getTasks(): Array | Returns array of all elements from array Scheduled. | |
getPinnedItem(id: string|number): ?Item | Returns element from Scheduled section by its ID.
| |
render(): Element | Renders timeline and returns DOM element. | |
getContainer(): ?Element | Returns container with rendered timeline (when it was rendered). | |
updateTasks(tasks: Array) | Fully re-renders Scheduled section with new elements. Animation is used for deleting old and adding new elements.
| |
static getDayFromDate(date: Date): ?string | Returns string day presentation for the date
| |
getDateSeparator(day: string): ?Elemen | Returns existing separator, if available.
| |
createDateSeparator(day: string): Element | Creates new separator, but won't be placed in DOM.
| |
static isToday(date: Date): boolean | Returns true , when date is today.
| |
insertItem(item: Item): this | Adds new element item to start of animation. When required, adds a separator.
| |
pinItem(item: Item): Stream | Adds an element item to the list of attached elements with animation. | |
unPinItem(item: Item): Stream | Removes item element from the list of attached items with animation. | |
deleteItem(item: Item) | Deletes item element with animation, despite in which section its located. | |
startProgress() | Shows loader and saves ajax query processing status. | |
stopProgress() | Hides loader and resets ajax query processing status. | |
getLoader() | Returns object BX.Loader . | |
enableLoadOnScroll() | Enables scroll event handling for element list. When scrolling to the end of the list, calls the event onScrollToTheBottom . | |
disableLoadOnScroll() | Disables scrolling event handling for element list. |
Events
Event | Description |
---|---|
namespace: BX.UI.Timeline.Stream | |
onAfterInit | Throws event at the end of constructor execution. It can be used to get access to list object.
For example, you have elements with To do that, register event handler: ```javascript BX.Event.EventEmitter.subscribe('BX.UI.Timeline.Stream:onAfterInit', (event) => { const stream = event.getData().stream; stream.itemClasses.set('delete_section', MyModule.Timeline.DeleteSection); }); ``` To capture the rest of events, an available object is required. That's why the handler ```javascript stream.subscribe('onAfterRender', () => { const container = stream.getContainer(); // all the rest of nodes are located in stream.layout }); ``` |
onAfterRender | Event is thrown after timeline rendering.
Event handler can get container via the method |
onScrollToTheBottom | Event is thrown when scrolling to bottom end of general element list. |
onPinClick | Event is thrown when clicking on element pin symbol.
|