Implement Custom Actions
EitanBlumin opened this issue · 5 comments
After Action Links management is implemented in the admin section, we'll need to implement their usage in dataview.asp
Generic Framework:
- Actions and Action Parameters JavaScript object collections (i.e. "dt_Actions"), each action object would have action parameters collection same structures as "dt_Columns" collection.
- Action Parameters Modal
- Action Parameters Modal Rendering Function
- Action Parameters Modal Re-Fill Function
- Action Execution Wrapper Functions (for DataTable button: one for inline and one for toolbar)
Action Types:
- HTTP Link
- DB Procedure
- DB Ad-Hoc Command
- JavaScript Function
- HTTP REST API Request
Action Properties:
- Is Per Row
- Require Confirmation
- Open (HTTP Link) in New Window
- Send (Selected) DataTable Row(s) as Parameter (XML/JSON?)
- REST Method (GET / POST / PUT / PATCH / DELETE)
This type of script may give a good direction for dynamically creating and destroying modals:
https://deepasp.wordpress.com/2015/10/18/dynamically-creating-and-showing-bootstrap-modal/
Basically, the modal could be created using regular strings or jQuery, and then it's appended as a child to the body element. After that, event listeners are attached and possibly other extensions (tooltip and summer note?).
When the modal is closed, it's removed from the body element entirely using removeChild method.
If this works well in practice, we could use this methodology for all other modals as well.
I should start with a simple standalone POC of creating a modal with a form, form elements and buttons, turn the form into an Ajax form, and attach event listeners. See how it works.
The POC is completed successfully, with all data manipulation modals converted to dynamic modals.
Next step is to prepare wrapper functions in JavaScript for custom action buttons.
Simple http and JavaScript actions are working well without parameters. Now need to implement modal for parameters functionality.
Added issue tasks for new action type: API Call: #126 , #127
This new action type will work similarly to HTTP link action type, except that instead of opening the URL in the browser window, it will perform a REST request and display the output in a modal.
We may need to be able to support multiple REST methods (GET, POST, PUT, PATCH, DELETE).
Not sure how would distinguish between the different methods...
Adding another field for actions called "method" might seem too much hassle for just a single action type.
Perhaps create separate action type for each method?