Basic information
The task form provides an API that facilitates basic operations for adapt it to the client's needs.
Services
All services are available directly on the global scope (based on their name) - from the system version 3.2.5 or to be download by ServiceFactory.
- ActivityInfoService- responsible for storing basic information about the task, available from the global scope using a call:
var activityInfoService = ServiceFactory.getActivityInfoService();
- CommentService- responsible for task comments, available from the global scope using a call:
var commentsService = ServiceFactory.getCommentsService();
- FormService- responsible for the form tab with form variables, available from the global scope using a call:
var formService = ServiceFactory.getFormService();
- MessageService- responsible for displaying messages in the form of animated "clouds" for the user currently using the form, available from the global scope using a call:
var messageService = ServiceFactory.getMessageService();
- VariableService- responsible for managing form variables that are not in dynamic tables, available from the global scope using a call:
var variableService = ServiceFactory.getVariableService();
- VariableSetService- responsible for managing dynamic tables and variables located in them, available from the global scope using a call:
var variableSetService = ServiceFactory.getVariableSetService();
SuncodeFormService
The API form also has an additional SuncodeFormService service. It is also available on the global scope (window) and is supported independently of other services.
Form readiness events
The addOnReadyEvent function gives ability to add any actions number that will be taken after the form has been built (all components on the form will be available). This function is called addOnReadyEvent. The exemple use is as follows:
SuncodeFormService.addOnReadyEvent( function() { alert( 'First action' ); } ); SuncodeFormService.addOnReadyEvent( function() { alert( 'Second action' ); } );
Using the service in the above way will result in the following messages being displayed successively after the form has been built: 'First action' and 'Second action'. The order in which actions are performed depends on the scripts loading, and within one file, from the order of adding actions.
Function addOnReadyEvent takes one parameter:
- event (Function type) - function JavaScript made after building the form
This function does not return any results.
Grouping actions to calculate the appearance of a form
From version 3.1.6 it is possible to additional group actions changing the layout of the form (layout). Such grouping of layout changes is much fasterthan performing these actions separately.
SuncodeFormService.suspendLayouts(); try { // many actions variableService.hide('a'); variableSetService.hide('a'); } finally { SuncodeFormService.resumeLayouts(); }
From version 3.1.22it is possible to call group actions without using tryand finally blocks by specifying parameters in the call. Instead of the function, you must specify the function which will be called, and then the scope of calling this function
SuncodeFormService.suspendLayouts(function, scope);
Configuration settings for the form
In version 3.1.10 form setting mechanism has been introduced. It allows dynamic setting of property data through the API:
// setting property SuncodeFormService.setConfig('config.key', 'value'); // getting property var conf = SuncodeFormService.getConfig('config.key'); // you can also specify a default value, returned if the property is not set var conf = SuncodeFormService.getConfig('config.key', 'default value');
The table contains all available configuration options for the form
Name | Type | Default value | Available from | Description |
---|---|---|---|---|
autoupdate.blurifchange | Boolean | false | 3.1.10 | By default, AutoUpdate is always performed on a blur event, even if you do not change the field value In order for AutoUpdate to be called after leaving the field, if its value has changed since entering this field, the code should be called: SuncodeFormService.setConfig('autoupdate.blurifchange', true); |
variableset.copyrow.target | String | bottom | 3.1.13 | Valid values: bottom, below In order to the copied row will be inserted below the selected one, the code should be called: SuncodeFormService.setConfig('variableset.copyrow.target', 'below'); If this option is not set or set to 'bottom', the copied row will be added at the bottom of the table. |
variable.variabletoview.genericformat | Boolean | false | 3.2.0 | By default, for non-editable variables, the function: VariableService.getValue('id'); // or VariableService.getValue('id', false); Returns total, floating point, amount, date, and "date and time" variables in text format. That the numeric and dates variables will be returned in the corresponding JavaScript type:
Call the code: SuncodeFormService.setConfig('variable.variabletoview.genericformat', true); |