Skip to content

Commit

Permalink
Add info on client-side button actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinpovolny committed May 23, 2017
1 parent b945868 commit 38f338f
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions ui/button_actions.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
### Button Actions

When a toolbar button is pressed current controller's `button` or `x_button` method is called. This is tru with the exception of some client-side only actions.
Toolbar button actions can be server-side or client-side.

Currently most buttons are server-side but the preferred way of writing new
code is calling the API from client-side button actions.

#### Server-side Button Actions

When a toolbar button is pressed current controller's `button` or `x_button`
method is called.

The identifier of the button that was pressed is passed in `params[:pressed]`.

Expand All @@ -12,6 +20,14 @@ The `x_button` or `button` handlers should follow this pattern:
end
```

Meaning that just a lookup in the list of valid actions for the controller is done and the action is called if found. Nothing else.
Meaning that just a lookup in the list of valid actions for the controller is
done and the action is called if found. Nothing else.

Cleaning up the handlers to this form will allow us to do furter refactorings
and make the button actions plugable.

#### Client-side Button Actions
In [Toolbars and Buttons](toolbars.md#javascript-only-buttons) you can see how to define javascript-only buttons.

Cleaning up the handlers to this form will allow us to do furter refactorings and make the button actions plugable.
Such button can perform changes in the UI or it can call the ManageIQ REST API
to get work done. See [Calling the API](calling_api.md).

0 comments on commit 38f338f

Please sign in to comment.