Component Options: Rule Helpers

   MaestroThe UI design product.  |    Form Builder  |  All versions This feature is related to all versions.

Maestro allows you to create new and update existing rule helpers for components using Component Options. You can use these rule helpers to add methods to a component right click event in the rule editor, so a rule helper will appear as a selectable option. Also, rule helpers are for when you right click on a component when writing a script, it gives you pre-defined actions relating to that object, for example, if you right click on a dialog, it has an option Open Dialog.

To create a new rule helper using Component Options:

  1. Open a project in your organization.
  2. Select a component in the Component folder and click Edit Version.
  3. Click Component Options and select Rule Helpers.
    Maestro view rule helpers
  4. Click New Rule Helper to create a new rule helper.
  5. Type a name for a Label to identify the rule helper when a user right-clicks the component in the editor tree and click Create Script.
    Maestro create a rule helper
  6. Enter a JavaScript for the new rule helper.
    Maestro populate a rule helper JavaScript code

    A JavaScript can follow this pattern: Form.fireRule ("name of the Component Template", Form.items.component_ID, data), for example, Form.fireRule("testRule", Form.items.componentRuleTestID, data);.

    In this example, testRule is the name of the component rule template and componentRuleTestID is the component ID of the component that the rule helper is associated with. When a user right-clicks the component with the component ID componentRuleTestID, this rule helper becomes available as a selectable option.

    Note

    You can use the insert-item keyword to reference the item selected from the tree, so it populates it with component's ID.

    The example of the insert-item is shown below:

    "ruleHelpers": [
        {
    	"label": "Open Dialog",
    	"name": "openDialog",
            "value": "Form.showDialog(\"insert-id\")"
        },
    ]
  7. Click Done and then click Save.

Next, learn how to add rule templates.