Skip to main content

default.widget.types.map

DefaultWidgetsMap : d2/sdk/utils/landingpage/default.widget.types.map

An extensible map that assigns a D2-Config widget type to a D2 Smart View default widget type

New mapping entries could be added using extension

Extends: Object
Example (to register an extension, add in extension.json)

{
"d2/sdk/utils/landingpage/default.widget.types.map": {
"extensions": {
"mybundle": {
"mybundle/utils/landingpage/my.default.widget.types"
}
}
}
}

Example (whereas my.default.widget.types.js is defined as)

define([], function(){
'use strict';

return [
{defaultType: 'svcustomtype1', d2WidgetType: 'FavoritesWidget'}, // uses default error if the widget configuration can't be resolved
{defaultType: 'svcustomtype2', d2WidgetType: 'FavoritesWidget', errMissingWidgetConfig: 'Widget for svcustomtype2 is not found'}, //custom error
// Got more maps ? keep appending here.
];
});

DefaultWidgetsMap.addMaps(newEntries) ⇒

Add new mapping entries. Recommended way is to get it added via extension mechanism, see example from above.

Kind: static method of DefaultWidgetsMap
Returns: void

ParamTypeDescription
newEntriesArray.<MapEntry>

Entries to be added

Example (New types could be added as)

// It has to be made sure that this AMD module is loaded by some other module.
define(['d2/sdk/utils/landingpage/default.widget.types.map'], function(widgetTypesMap){
'use strict';

widgetTypesMap.addMaps([
{defaultType: 'svcustomtype1', d2WidgetType: 'FavoritesWidget'},
{defaultType: 'svcustomtype2', d2WidgetType: 'FavoritesWidget', errMissingWidgetConfig: 'Widget for svcustomtype2 is not found'}
// More entries could be added.
]);

// some other code
});

DefaultWidgetsMap.getMaps() ⇒ MapEntryReturnType

Get existing map entries

Kind: static method of DefaultWidgetsMap

DefaultWidgetsMap~MapEntry : Object

Kind: inner typedef of DefaultWidgetsMap
Properties

NameTypeDescription
defaultTypestring

Name of D2 Smart View default widget type

d2WidgetTypestring

Name of D2-Config widget type

errMissingWidgetConfigstring

Error to be shown in the UI if the mapped widget type from D2-Config is not resolved.

DefaultWidgetsMap~MapEntryReturnType : Object

Return type. Each key in this object represents a default widget type name in D2 Smart View.

Kind: inner typedef of DefaultWidgetsMap
Properties

NameTypeDescription
keystring

Default widget type name

valueObject

The map

value.typestring

D2 widget type name

value.errMissingWidgetConfigstring

Error to be shown if widget config is not resolved