app.scope.perspectives
ApplicationScopePerspectives : d2/sdk/utils/perspectives/app.scope.perspectives
Application scope collection. Each navigable area within the D2 Smart View application page is called a perspective. E.g the area shown immediate after a user login is called landing perpsective.
An application scope is the immediate next navigable area from the landing perspective. It can be activated by user interacting with a tile in landing perspective or by direct URL. Once activated, depending on how the application scope is defined, one or several view components are going to take over the screen space and provide a holistic UI with related functional features for the perspective.
This collection is a registry of all such scope definitions and could be extended by extension
Extends: Backbone.Collection
Example (to register an extension, add in extension.json)
{
"d2/sdk/utils/perspectives/app.scope.perspectives": {
"extensions": {
"mybundle": {
"mybundle/utils/perspectives/my.app.scopes"
}
}
}
}
Example (whereas my.app.scopes.js is defined as)
define(['i18n!mybundle/utils/landingpage/impl/nls/lang'], function(lang){
'use strict';
function openURLWidgetConfigValidator(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.openUrlWidgetValidationFailed;
}
return validation;
}
// See 'AppScope' documentation for all possible properties with their usage
return [
{applicationScope: 'sample1'}, // widget-less application scope where the perspective descriptor location is inferred
{applicationScope: 'sample2', perspectiveJson: 'sample2.perspective.json'}, // widget-less application scope where the perspective descriptor location is partially inferred
{
// scope that requires widget config and declares explicit location of perspective descriptor
applicationScope: 'sample3',
perspectiveJson: 'mybundle/utils/perspectives/sample3.perspective.json',
widgetType: 'OpenURLWidget',
validateConfig: openURLWidgetConfigValidator
}
// Any other definition
];
});
- ApplicationScopePerspectives :
d2/sdk/utils/perspectives/app.scope.perspectives
- ~AppScope :
Object
- ~ConfigValidatorCallback ⇒
ConfigValidatorReturnType
- ~ConfigValidatorReturnType :
Object
- ~AppScope :
ApplicationScopePerspectives~AppScope : Object
Kind: inner typedef of ApplicationScopePerspectives
Properties
Name | Type | Default | Description |
---|---|---|---|
[sequence] | number | 1000 | Priority of this definition. For matching |
applicationScope | string | ID of this scope. Also used in forming the URL that links to this application scope directly. | |
[perspectiveJson] | string | Path to the descriptor JSON file for this perspective. It can be specified explicitly as | |
[defaultTitle] | string | The value to be passed as | |
[defaultWidgetType] | string | If activating this application scope demands a default widget configuration, then specify the type in this property. This should be specified only if an application scope requires a widget configuration and allows direct URL navigation. A value from the OOTB default widget types could be used, see DEFAULT or any new default widget types introduced by a D2 plugin could be used. | |
[widgetType] | string | Type of the D2-Config widget associated with this application scope. Needs to be specified only if this scope requires a widget configuration. If omitted even when this scope requires a widget configuration, value for this property is deduced from | |
[validateConfig] | ConfigValidatorCallback | Callback to validate the resolved config for this scope. Applicable only if this scope has specified one of | |
[beforeActivateScope] | callback | A no-argument callback invoked right before this application scope is just about to get activated. The callback should return | |
[afterDeactivateScope] | callback | A no-argument callback invoked if this application scope was enabled earlier and now being swapped out because a different application scope has been activated. |
ApplicationScopePerspectives~ConfigValidatorCallback ⇒ ConfigValidatorReturnType
Callback function that validates widget configuration for an application scope
Kind: inner typedef of ApplicationScopePerspectives
Param | Type | Description |
---|---|---|
widgetConfig | Object | The widget configuration being validated |
[options] | Object | Any additional context specific data that is not part of |
ApplicationScopePerspectives~ConfigValidatorReturnType : Object
Kind: inner typedef of ApplicationScopePerspectives
Properties
Name | Type | Description |
---|---|---|
status | boolean |
|
[errorMessage] | string | Error message to be shown in UI if the validation failed. |