Icon Resolver
In certain situations, it may be necessary to define an icon based on a component’s tags. To do this, you can define an Icon Resolver to define the icon to be applied to a component. multiple Icon Resolvers can be defined, in which case the first one to respond with a value will be taken into account.
Icon Resolvers are used to resolve a component’s icon when it is displayed in FlowerDocs GUI.
Recording
An Icon Resolver can be registered using the function registerComponentIconResolver(resolver,tags)
exposed by JSAPI.get().getHelperFactory()
.
The resolver
parameter corresponds to a function accepting two parameters:
component
: the component whose icon is to be definedcallback
: object whoseonSuccess()
function must be called once the icon calculation has been completed (in the case where the icon is not defined by the Icon Resolver, theonSuccess()
function must be called with no value)
The tags
parameter corresponds to the list of tags according to which the icon will be resolved.
Example: To define an icon of type loupe for all components of class IncomingMail
, it is possible to register an Icon Resolver such as :
JSAPI.get().getHelperFactory().registerComponentIconResolver(function(component, callback){
if(component.getClassId() == 'IncomingMail'){
callback.onSuccess('fa fa-search');
}else{
callback.onSuccess(null);
}
});
Example: To define a loupe type icon for all components with the tag value TypeCourrier
equal to Order
and the Status
equal to TODO
, it is possible to register a Icon Resolver such as :
JSAPI.get().getHelperFactory().registerComponentIconResolver(function (component, callback) {
if (component.getTagValue('MailType') == 'Order' && component.getTagValue('Status') == ‘TODO') {
callback.onSuccess('fa fa-search');
} else {
callback.onSuccess(null);
}}, 'MailType', 'Status');