Code Effects rule editor comes with rich client functionality that can be used in client-centric web applications. Aside from the server-side code that helps it process business rules, the Rule Editor is written as a client-side class that encapsulates a lot of functionality, and expresses it through a relatively small number of public functions available to any other client code. Code Effects client script declares only two global (public) variables, $rule and $ce, and keeps everything else inside the scope of its instance. This makes it safe to add Rule Editor to any markup with any kind of client code.
Rule Editor is a self-contained library. It doesn't depend on any client or server frameworks or libraries. It is compatible with all modern versions of all major browsers.
-
clear() Returns: Rule Editor instance
Parameters: None
Removes all elements of the current rule from the Rule Area.
-
deleted(String)
Returns: Rule Editor instance
Parameters:
- id, String - ID of the rule that is being deleted. Required.
Calling this function after deleting a rule is necessary in order to remove that rule from the Rules and context menus. See the related demo project for details on managing rules in Rule Editor.
-
disable() Returns: Rule Editor instance
Parameters: None
Removes ability to add new rules or modify the rule currently loaded in the Rule Area.
-
dispose() Returns: Rule Editor instance
Parameters: None
Disposes all resources used by Rule Editor and removes it from the current context.
-
enable() Returns: Rule Editor instance
Parameters: None
Restores ability to add new rules or modify the rule currently loaded in the Rule Area.
-
extract() Returns: String
Parameters: None
Returns a JSON string that contains the current rule, and whether or not it’s valid. Returns an empty object if the Rule Area is empty.
-
isAltered()
Returns: Boolean
Parameters: None
Returns True if the user altered either an existing rule after it has been loaded into the Rule Area or a new rule after its creation has been initiated. Otherwise, returns False.
-
isEmpty(String)
Returns: Boolean
Parameters:
- includeFormattingElements, Boolean - Indicates whether to count the formatting elements of the rule such as tabs and new lines. This is an optional parameter. The default value is True.
Returns True if the Rule Area currently contains no rule elements. Otherwise, returns False.
-
isEvaluationType()
Returns: Boolean
Parameters: None
Returns True if the loaded rule is of the evaluation type, or if the rule author selected the New evaluation type rule option from the Rules menu of the Toolbar. This function does not check what kind of rule elements the rule author has added to the Rule Area so far.
-
getRuleId() Returns: String
Parameters: None
Returns the string ID of the current rule assigned by Rule Editor. The editor calls .NET's System.Guid.NewGuid().ToString() to get new IDs for rules. Returns null if no rules have been loaded into the Rule Editor yet, or if Rule Editor hasn't assigned an ID to the current rule yet, or if the Rule Area is empty.
-
loadInvalids(String)
Returns: Rule Editor instance
Parameters:
- data, String - JSON string received from the server-side GetClientInvalidData() method of the RuleEditor class. Download related demo project to see details on loading invalid rule data into the Rule Editor. This is a required parameter.
Call this function to load data of the invalid rule into the Rule Editor.
-
loadRule(String)
Returns: Rule Editor instance
Parameters:
- data, String - JSON string received from the server-side GetClientRuleData() method of the RuleEditor class. Download related demo project to see details of use of this function. This is a required parameter.
Call this function to load a rule into the Rule Editor.
-
loadSettings(String)
Returns: Rule Editor instance
Parameters:
- data, String - JSON string received from the server-side GetClientSettings() method of the RuleEditor class. Download related demo project to see details of use of this function. This is a required parameter.
Call this function to load Rule Editor client settings. You also need to call this function every time the rule author requests a change in any of the Rule Editor settings such as Help String visibility and so on.
-
saved(String)
Returns: Rule Editor instance
Parameters:
- id, String - ID of the rule that has been saved or updated. This parameter is required for new rules but optional for updates.
Calling this function after saving a new rule or updating an existing one is necessary in order to refresh the Rules and context menus with the new or updated values. Download related demo project to see for details on saving rules.
-
setClientActions(Function, Function, Function)
Returns: Rule Editor instance
Parameters:
- loadRule, Function - callback that handles loading a rule. This delegate must declare a single parameter of String type. Rule Editor calls this function and passes it the ID of the rule when rule author selects that rule from the Toolbar's Rules menu. This is a required parameter.
- deleteRule, Function - callback that handles deleting a rule. This delegate must declare a single parameter of String type. Rule Editor calls this function and passes it the ID of the rule when rule author clicks the Delete button on the Toolbar. This is a required parameter.
- saveRule, Function - callback that handles saving of a rule. This delegate must declare a single parameter of Object type. Rule Editor calls this function and passes it an object that contains the rule data when rule author clicks the Save button on the Toolbar. This callback works in tandem with the LoadClientData() method of RuleEditor class. See related demo project for details on rule management. This parameter is required.
Call this function while initializing your page to tell Rule Editor which functions to call when rule author wants to load, delete, or save a rule. Don't call it if Toolbar is disabled.