Interface: CanvasAPI

CanvasAPI

API class that is used to control the content and behavior of a dashboard canvas.

Example

dashboard.getFeature('Canvas')

Methods

addContent(options, transactionToken) → {Promise.<ContentAPI>}

Adds content options to the canvas.
Parameters:
Name Type Description
options Object Contains the options for adding content to the canvas.
Properties
Name Type Description
containerId String Container ID specifying where to add the content. By default, the system selects the position.
position Number Index specifying where to add the content. By default, the system selects the position.
properties Object An object of property names and values to apply to the content.
type String Content provider type to use. Must provide a spec or content, if not defined.
spec Object Layout, widget, or fragment spec.
content ContentAPI ContentAPI object to be added to the canvas.
transactionToken TransactionToken
Returns:
new content
Type
Promise.<ContentAPI>

deselectContent(idList-)

Deselects the content that matches the specified IDs.
Parameters:
Name Type Description
idList- Array.<String> Array of IDs to deselect

findContent(selector) → {Array.<ContentAPI>}

Returns a list of content that matches the specified selector.
Parameters:
Name Type Description
selector Object Selector object; returns all widgets if undefined.
Properties
Name Type Description
type String Selector type
properties Object
Returns:
Array of content
Type
Array.<ContentAPI>
Example
canvas.findContent({
   properties: {
      title: 'My page'
   }
});
canvas.findContent({
   type: 'page'
});

getContent(id) → {ContentAPI}

Returns the content that matches the specified ID.
Parameters:
Name Type Description
id String ID of the content
Returns:
Type
ContentAPI

getContentActionList(idList) → {Array.<Object>}

Returns a list of toolbar actions.
Parameters:
Name Type Description
idList Array.<String>
Returns:
Array of actions
Type
Array.<Object>
Example
{
    name: 'group',
    label: stringResources.get('toolbarActionGroup'),
    icon: 'dashboard-group',
    type: 'Button',
    action: () => {}
 }

getPropertiesNameList() → {Array.<String>}

Returns an object of property objects.
Returns:
Array of property objects
Type
Array.<String>

getPropertyLayoutList() → {Array.<Object>}

Returns:
Array of layout and properties used to render the properties UI.
Type
Array.<Object>

getPropertyValue(name) → {Object}

Gets the value for a property.
Parameters:
Name Type Description
name String Name of the property
Returns:
Value of the property
Type
Object

getSelectedContentList(selector) → {Array.<ContentAPI>}

Returns the list of content that is selected.
Parameters:
Name Type Description
selector Object Optional, returns groups and widgets by default.
Properties
Name Type Description
type String Selector string
Returns:
contentList - Array of content
Type
Array.<ContentAPI>

moveContent(containerId, contentIdList, transactionToken) → {Array.<ContentAPI>}

Moves the contents specified in @contentIdList to new container @containerId.
Parameters:
Name Type Description
containerId String Specifies the container ID.
contentIdList * Contains the content ID list.
transactionToken * Transaction token for this action.
Returns:
the list of contentAPIs correnponding to @contentIdList
Type
Array.<ContentAPI>

off(name, name)

Deregisters a canvas event handler.
Parameters:
Name Type Description
name String Event name
name function Event handler

on(name, handler) → {Object}

Registers a canvas event handler.
Parameters:
Name Type Description
name String Event name
handler function Event handler
Returns:
Object that has a remove function to remove the event handler.
Type
Object
Example
canvas.on('all', (event) => { console.log(event); });
canvas.on('change:content:selections', (event) => { console.log(event.info.events); });
canvas.on('change:content:selections:clearAll', (event) => { console.log(event); });

removeContent(id, transactionToken)

Removes the content with the specified ID.
Parameters:
Name Type Description
id String ID of the content
transactionToken TransactionToken Transaction token for this action

selectContent(idList-)

Selects the content that matches the specified IDs.
Parameters:
Name Type Description
idList- Array.<String> Array of IDs to select

setPropertyValue(name, value, transactionToken)

Sets the value for a property.
Parameters:
Name Type Description
name String Name of the property to set
value Object Value to set
transactionToken TransactionToken