Allow specifying an interaction in the session state such as clicking on a record to open a URL.
|Assignee:||Kyle Monico||% Done:|
|Category:||Internal Code Refactoring||Estimated time:||(Total: 65.00 h)|
|Required by:||Grand Rapids, Michigan|
Example interactions for record click:
- open a URL corresponding to that record
- pop up a box with more information on that record (show values in a table from a long list of columns)
The main idea of this feature is that we are specifying the behavior of Weave in the session state. This feature request is about the architectural change required to be able to specify this type of customizable interaction.
#7 Updated by Kyle Monico about 6 years ago
There's a demo here
Look in the session state under WeaveProperties. There's a LinkableHashMap named "eventListeners". Each LinkableEventListener has 3 fields
1. event - The name of the event to trigger the listener.
2. target - The relevant tool for this listener. If this is empty, the script is always executed.
3. script - This is code for the Weave Compiler. This code is executed only if the event occurred on the target or if the event occurred but the target is empty. If the target is specified, then the script will receive the target object (a MapTool or CompoundBarChartTool, for example) as the this pointer.
This line in the script is tricky:
issueString && (urlRequestInstance.url = "http://bugs.oicweave.org/issues/" + issueString) && navigateToURL(urlRequestInstance);
That statement first checks issueString evaluates to true. Then it checks the second param which is assigning the url to the URLRequest variable. Then it executes the navigateToURL code. The compiler doesn't have support for if statements yet, but this works for the time being.
Let me know if you have any questions.