Implementing a Custom Widget Configurator
/**
* Copyright (c) DecisionBrain SAS. All Rights Reserved.
*
* This is the base interface of dynamic widget parameters.
*/
export interface GeneWidgetConfiguration {}
For example, we will make the "title" of the Sample Widget configurable.
/**
* Sample Widget configuration class
*/
export interface SampleWidgetConfiguration extends GeneWidgetConfiguration {
// Current widget instance title
title?:string;
}
The configurator component will integrate with the Platform by dispatching GeneWidgetConfigurationEvent events each time the user modify the configuration. The configurator is responsible for providing validation status of the edited configuration through those events. The Platform will not let the user save a Widget configuration that is invalid. See sample-widget-configurator.component.ts in the sample widget source code.
/**
* Copyright (c) DecisionBrain SAS. All Rights Reserved.
*
* This interface describes a component that can be instantiated dynamically (e.g. custom dashboard) and
* initialized through a context object.
*
* By implementing this interface you make sure that a component is Custom Dashboard "ready"
*/
export interface GeneWidgetConfigurationAware<T extends GeneWidgetConfiguration> extends GeneWidgetContextAware {
...
}
/**
* Copyright (c) DecisionBrain SAS. All Rights Reserved.
*
* Event class, describes the events triggered by a DynamicWidgetConfigurator each time
* the context is modified by the user
*/
export class GeneWidgetConfigurationEvent<T extends GeneWidgetConfiguration> {
/**
* The current configured context
*/
public configuration: T;
/**
* Event type
*/
public type: GeneWidgetConfigurationEventType;
/**
* This object contains information about configuration validity and
* potential error message if not valid.
*/
public validationResult?: ValidationResult;
}
/**
* Copyright (c) DecisionBrain SAS. All Rights Reserved.
*
* Type of events for GeneWidgetConfigurationEvent
*/
export enum GeneWidgetConfigurationEventType {
CONFIGURATION_CHANGED
}