5.2 Configuration
Copy
The configuration options for Item Reference Configuration allow:
- The identification of an alternate Form to be used for Property Updates
- A Method used to pre-populate Item Properties
- A Method used to validate Item Properties
- The option to bypass the display of the Item Form
This configuration is specified using JSON for the XML Schema Element associated with the Item Document Element.
The Editor Parameters input form is configured for displaying JSON content. Syntactical errors will be displayed if the text content doesn’t conform to JSON formatting. To set the Item Reference Configuration, a single JSON object is used with the following properties:
{
"itemCreation": {
"formId": "<id of Form Item to use as alternate>",
"onBeforeInit": "<beforeInit Method Name>",
"onAfterInit": "<afterInit Method Name>",
"initializerType": "<initializer type>",
"fileAccept": “<true/false>”,
"allowedMIMETypes": “<[comma-delimited array of mime type text]>”,
}
| JSON Property | Description |
| itemCreation | JSON Object Name for Item Creation options. |
| formId | (Optional): Identifies an alternate Form to use for specifying Item Properties. The default Form is used for the referenced ItemType if this is not used. |
| onBeforeInit | (Optional): Specifies the name of a JavaScript client Method to be called prior to the Form displayed to the User. |
| onAfterInit | (Optional): Specifies the name of a JavaScript client Method to be called after the Form displayed to the User. |
| initializerType | (Optional): Accepts values: ‘base’ and ‘formDialog’ when used for non-Image ItemType references. ‘formDialog’ is the default and is used when a Form should be displayed to the author/user. ‘base’ is used to suppress the Form display. When ‘base’ is specified the before and after initialization Method will still be executed if they are specified. When this Property is used for Image Document Elements for file Drag and Drop support, a value of ‘coreLocalFileImage’ should be used to generate a tp_Image Itemtype. |
| fileAccept | Used for Drag and Drop of Image Files to auto-create Image Document Elements. When ‘true’, the system will accept image file drag/drop onto the Editor to auto-create an Image Document Element. ‘false’ (or not included) to not allow image creation via Drag and Drop |
| allowedMIMETypes | (Optional): list of image MIME Types that are allowed. If not included, all image types supported by the system will be allowed. |
5.2.1 onBeforeInit Method
The purpose of the onBeforeInit Method is solely to pre-populate selected Properties of the Item being created. It is meant to provide a convenient mechanism to ensure consistent data for Items and should execute quickly, without excessive memory or processing. The onBeforeInit Method is a JavaScript Method that will be passed two parameters – inDom and inArgs – and must return the inDom input object. The context object of the Method is the Item being created. Thus ‘this’ refers to the Item Object and the standard IOM Item API applies. The inDom parameter represents the XML content of the Item being created also. As such, methods like aras.setItemProperty(inDom, …) will work as well. The inArgs parameter is an object with two properties: documentItem and viewModel. documentItem contains the XML representation of the Technical Document Item in which the Document Element is being created. This object can be used to retrieve information about the Technical Document Item. Likewise, methods like aras.getItemProperty(inArgs.documentItem, …) will work. The viewModel object represents the API for the Technical Document Editor.
- onAfterInit Method
The purpose of the onAfterInit Method is solely to validate selected Properties of the Item being created. It is meant to provide a convenient mechanism to ensure consistent data for Items and should execute quickly, without excessive memory or processing. The onAfterInit Method is a JavaScript Method that will be passed two parameters – inDom and inArgs – and must return the inDom input object. The context object of the Method is the Item being created. Thus ‘this’ refers to the Item Object and the standard IOM Item API applies. The inDom parameter represents the XML content of the Item being created also. As such, methods like aras.getItemProperty(inDom, …) will work as well. The inArgs parameter is an object with two properties: documentItem and viewModel. documentItem contains the XML representation of the Technical Document Item in which the Document Element is being created. This object can be used to retrieve information about the Technical Document Item. Likewise, methods like aras.getItemProperty(inArgs.documentItem, …) will work. The viewModel object represents the API for the Technical Document Editor.
If there is a validation error, an alert/message should be displayed, and null should be returned. When ‘base’ is used for the initializerType in the configuration, returning null will prevent the Item from being created.