Skip to main content

tiles

TileCollection : d2/sdk/utils/landingpage/tiles

Tile definition collection. Each tile definition describes its priority, association type, pre-requisite and finally a view that is used as the representation of the tile. Based on priority a particular definition is picked from this collection to finally render D2 Smart View landing page.

Extends: Backbone.Collection
See: WidgetConstants for some related pre-defined constants.

New definitions could be added to this collection by means of extension.
Example (to register an extension, add in extension.json)

{
"d2/sdk/utils/landingpage/tiles": {
"extensions": {
"mybundle": {
"mybundle/utils/landingpage/my.tiles"
}
}
}
}

Example (whereas my.tiles.js is defined as)

define(['d2/sdk/utils/widget.constants', 'i18n!mybundle/utils/landingpage/impl/nls/lang'], function(widgetConstants, lang){
'use strict';

function validateURLShortcutConfig(widgetConfig, options) {
var validation = {status: true};
if (!widgetConfig.widgetParams && !widgetConfig.widgetParams.open_url) {
validation.status = false; // It will be considered as a validation error
validation.errorMessage = lang.openUrlWidgetMissing;
}
return validation;
}

// See 'LandingTile' documentation for all possible properties with their usage
return [
{type: 'CreateFile', icon: 'icon-new', isShortcut: true, tileConfigType: widgetConstants.TileConfigTypes.NONE}, // widget configuration-less shortcut tile
{type: 'OpenURLWidget', icon: 'icon-url', isShortcut: true, validateConfig: validateURLShortcutConfig}, // shortcut tile that needs & validates a widget configuration
{
// A widget tile that relies on the default widget validation
type: 'CheckoutDocumentWidget',
icon: 'title-checkout',
tileView: 'mybundle/widgets/newcheckout',
errMissingWidgetConfig: lang.checkoutWidgetMissing,
applicationScope: 'checkedout'
}
// Any other definition
];
});

TileCollection~ShortcutType : enum

OOTB D2SV shortcut types

Kind: inner enum of TileCollection
Properties

NameDescription
CreateFile

New file shortcut

UploadFile

Import files shortcut

CreateUploadFile

Combined New/Import file shortcut

UploadFolder

Import folder shortcut

QueryFormObject

Query form shortcur

QueryObject

Saved query/search shortcut

TileCollection~LandingTile : Object

Kind: inner typedef of TileCollection
Properties

NameTypeDefaultDescription
[sequence]number1000

Priority of this definition. For matching type property values, the definition with least value for sequence will be used.

typestring

Association type of this tile. It should be set with a value from the enumeration ShortcutType, or any D2 widget type name. Additional shortcut types or widget types declared by a D2 plugin also could be used.

iconstring

CSS class name of the icon to be shown on the tile. For non-shortcut tiles, the icon is shown in the tile header.

[isShortcut]booleanfalse

Whether it's shortcut tile or widget tile? true indicates a shortcut.

[tileConfigType]TileConfigTypesTileConfigTypes.WIDGET

Tiles that don't require a widget config should set it to TileConfigTypes.NONE. See TileConfigTypes.

[tileView]string

Not required for shortcut tiles. For other tiles it should point to a folder implementing the view to be associated with this tile. E.g For a path mybundle/widget/somefolder the runtime will look for a somefolder.view.js within the somefolder directory. Alternatively it can be specified as just a name like mytile, in that case the tile's view will be resolved as<bundle_src_folder>/widgets/mytile/mytile.view.js.

[clickHandler]ShortcutClickHandler

Callback to be executed only for those shortcut tiles that neither specifies an applicationScope (see below) nor a matching shortcut behavior is found in the registry. See ShortcutBehaviors.

[validateConfig]ConfigValidatorCallback

Callback to validate the resolved widget config.

[buildTileOptions]TileOptionBuilderCallback

Callback to build tile options that would be passed to the tileView while constructing.

[errMissingWidgetName]string

The error to be shown if a tile definition requires a widget config but the corresponding D2 Smart View landing page configuraiton fails to specify a name for it. If unspecified, a generic error message is shown.

[errMissingWidgetConfig]string

The error to be shown if a tile definition requires a widget config but a suitable widget configuration could not be resolved for some reason.

[applicationScope]string

The application scope in which this tile will expand into. Tile expansion is enabled only if this value matches one of the registered application scope perspectives's id. See ApplicationScopePerspectives. For shortcut tiles, clicking anywhere in the tile activates the expansion. For list type of tiles, the tile header or a dedicated 'Expand' button could be clicked to activate the expansion.

TileCollection~ConfigValidatorCallback ⇒ ConfigValidatorReturnType

Callback function that validates a widget configuration for a tile

Kind: inner typedef of TileCollection

ParamTypeDescription
widgetConfigObject

The widget configuration being validated

[options]Object

Any additional context specific data that is not part of widgetConfig but might be relevant for validation

TileCollection~ConfigValidatorReturnType : Object

Kind: inner typedef of TileCollection
Properties

NameTypeDescription
statusboolean

true indicates validation succeeded, false otherwise.

[errorMessage]string

Error message to be shown in UI if the validation failed.

TileCollection~TileOptionBuilderCallback ⇒ void

Callback function that builds options for a tile

Kind: inner typedef of TileCollection

ParamTypeDescription
tileObject

Parsed tile object from D2 Smart View landing page configuration. New properties could be attached to this object as part of forming additional option.

[widgetConfig]Object

Any relevant wieget configuration, applicable only if the tile requires a widget configuration.

TileCollection~ShortcutClickHandler ⇒ void

Callback to handle click event for a shortcut tile

Kind: inner typedef of TileCollection

ParamTypeDescription
optionsobject

The options container.

options.contextContext

context object associated with the runtime. See Context.

options.widgetNamestring

Name of the widget configuration if the shortcut is of type TileConfigTypes.WIDGET. See TileConfigTypes.

options.widgetParamsobject

Any parameters associated with the resolved widget configuration. Applicable only if the shortcut is of type TileConfigTypes.WIDGET. See TileConfigTypes.