Adding a custom property editor
You can add a custom graphical interface for your business-specific rule properties with a custom property editor in the Business console.
ExtensionMixin.addPropertyEditor: function( /* String*/ propertyName, /* Object */ editorDefinition )
This function associates a property editor with the property of a rule, as defined in the rule model.
- propertyName
- The name of the property for which the property editor must be used. This is the name that is given to the property in the rule model. For example, for the property Effective date, the name is effectiveDate.
- editorDefinition
- The definition of the property editor, represented as a JavaScript object with the following fields:
- widget
- The name of the Dojo widget to use as the property editor. An instance of this widget is created
each time the property is edited. This widget must implement the mixin
ExtendedPropertyEditorMixin, which is described in the next section. - arguments
- An array of values that are passed as arguments to the constructor of the widget. This allows you to use the same widget with different configurations.
- tab
- The name of the tab where to display the custom property editor. This tab is displayed within the Details dialog, accessible from the edit view of a project element, which contains a set of predefined tabs: Properties, Tags, and Overridden Rules. By default, all custom property editors are placed in the Properties tab, in a column layout. You can place your custom property editor in a different tab, by specifying a different name, and a new tab containing the property editor is created.
- defaultStyling
- A Boolean value that indicates if the widget must be styled with the default property editor styling, as used in the Properties tab, or without any predefined styling.
Example
/* override */ declareExtensions: function(data) {
this.addPropertyEditor('MyProperty', { widget: MyWidget, tab: "My Tab" } );
}ExtendedPropertyEditorMixin
Any widget used as a property editor must be a Dojo widget deriving from this class. It might redefine some of the following functions:
setValue: function(/* String */ value) {
this.set('value', value);
},
- Summary:
This function is called when the property editor is initialized. This sets the value in the property editor.
- Parameter:
value: the current value of the corresponding property, represented as a string.
getValue: function(/* Object */ value) {
return this.get('value');
},
- Summary:
This function is called when the property editor is closed. This returns the current value in the property editor, represented as a string.
- Returns:
The current value in the editor, represented as a string.
isValid: function () {
return true;
},
- Summary:
Checks if the current value in the editor is a valid one, or if the editor is in a valid state. This can be used for additional checking on the user input. If the value is not valid, it is ignored and not set on the edited rule. By default, this returns true.
- Returns:
trueif the editor is in a valid state,falseotherwise.
generateHTML: function(/* Object */ value) {
return String(value);
},
- Summary:
Generates an HTML string representing the value. This HTML string is used to display the value in property sheets. By default, this returns the value converted to a string with
String(value). - Parameter:
value: the value to display (this is the current value of the property). - Returns:
An HTML string representation of the value.