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 :
d2/sdk/utils/landingpage/default.widget.types.map
- static
- .addMaps(newEntries) ⇒
- .getMaps() ⇒
MapEntryReturnType
- inner
- ~MapEntry :
Object
- ~MapEntryReturnType :
Object
- ~MapEntry :
- static
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
Param | Type | Description |
---|---|---|
newEntries | Array.<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
Name | Type | Description |
---|---|---|
defaultType | string | Name of D2 Smart View default widget type |
d2WidgetType | string | Name of D2-Config widget type |
errMissingWidgetConfig | string | 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
Name | Type | Description |
---|---|---|
key | string | Default widget type name |
value | Object | The map |
value.type | string | D2 widget type name |
value.errMissingWidgetConfig | string | Error to be shown if widget config is not resolved |