We are currently integrating the dmn-js Modeler into our application as a way of allowing the user to define very flexible system configurations.
By convention we expect certain outputs (identified by their name and type) and provide a number of input variables the user can access.
To improve the overall usability in those scenarios, we intend to do the following:
- Disable adding a new output column.
- Disable removing an existing output column.
- Disable changing an output column’s output name.
- Disable changing an output column’s type.
- Offer additional input column types in the respective dropdowns (to match the ones we added to the DMN engine’s configuration).
- Limit the available hit policies (including a subset of the
Collect
policy). - Limit the available script languages for input expressions (to match the ones we actually provide on the classpath).
As I understand it, all this should theoretically be possible already.
Unfortunately the only documentation on this topic I could find was the comment on the Modeler.js
file (on GitHub):
Extending the Modeler
In order to extend the viewer pass extension modules to bootstrap via the
additionalModules
option.
An extension module is an object that exposes named services.
The following example depicts the integration of a simple logging component that integrates with interaction events:
// logging component function InteractionLogger(eventBus) { eventBus.on('element.hover', function(event) { console.log() }) }
InteractionLogger.$inject = [ ‘eventBus’ ]; // minification save
// extension module
var extensionModule = {
init: [ ‘interactionLogger’ ],
interactionLogger: [ ‘type’, InteractionLogger ]
};
// extend the viewer
var dmnModeler = new Modeler({ additionalModules: [ extensionModule ] });
dmnModeler.importXML(…);
Customizing / Replacing Components
You can replace individual table components by redefining them in override modules.
This works for all components, including those defined in the core.
Pass in override modules via the
options.additionalModules
flag like this:
function CustomContextPadProvider(contextPad) {
contextPad.registerProvider(this);
this.getContextPadEntries = function(element) {
// no entries, effectively disable the context pad
return {};
};
}
CustomContextPadProvider.$inject = [ ‘contextPad’ ];
var overrideModule = {
contextPadProvider: [ ‘type’, CustomContextPadProvider ]
};
var dmnModeler = new Modeler({ additionalModules: [ overrideModule ]});
Are there any more examples or a more specific documentation on customization (rather than just replacing components) that might help us achieve those mentioned changes?
Or do we really have to copy-paste the original components, perform the (minor) changes, and then override the original ones via the additionalModules
parameter?
Ideally I’d expect a second (optional) parameter on the Modeler
function such as an options.configuration
array which would be forwarded to all core components. The respective core components could then check for specific keys in that array, e.g. configuration['input-script-languages']
holding a list of supported script languages.
Over time, the core components could be updated (via multiple pull requests) to become more and more configurable without the need for any copy-paste-change-replace stunts (especially if multiple versions of the same component would be required, e.g. in case of meaningful hit policies).