Actions
Actions are operations that run in response to user interactions. They enable your app to create, update, and delete data, navigate between views, and provide feedback to users.
What are Actions?
Section titled “What are Actions?”Actions are reusable operations that can be:
- Triggered by button clicks
- Executed on row clicks in lists
- Chained together for complex workflows
- Configured with dynamic values using formulas
Action Types
Section titled “Action Types”EmberBlocks provides several built-in action types:
| Action | Description | Common Use Cases |
|---|---|---|
| Create Row | Insert a new record | Adding new items, creating orders |
| Update Row | Modify an existing record | Editing details, changing status |
| Delete Row | Remove a record | Deleting items, cleanup |
| Navigate | Go to another view | Page navigation, detail views |
| Open URL | Open an external link | External resources, documents |
| Show Message | Display a notification | Success/error feedback |
| Run Formula | Execute a formula | Calculations, data validation |
Creating Actions
Section titled “Creating Actions”To create a new action:
- Open your app and go to the Actions tab
- Click + Create in the sidebar
- Configure the action settings
- Save and use in your components
Action Configuration
Section titled “Action Configuration”Create Row
Section titled “Create Row”Insert a new record into a table:
| Setting | Description |
|---|---|
| Table | The target table for the new row |
| Field Values | Values to set for each field |
Field Values
Section titled “Field Values”For each field, you can specify:
- Static Value - A fixed value like “pending” or “0”
- Formula - A dynamic value like
{{$user.id}}orNOW()
Example configuration:
Table: ordersField Values: - customer_id: {{$user.id}} - status: "pending" - created_at: NOW() - total: 0Update Row
Section titled “Update Row”Modify an existing record:
| Setting | Description |
|---|---|
| Table | The table containing the row |
| Row Reference | Which row to update (usually $row) |
| Field Values | Fields to update with new values |
Example configuration:
Table: ordersRow: {{$row}}Field Values: - status: "completed" - completed_at: NOW() - completed_by: {{$user.id}}Delete Row
Section titled “Delete Row”Remove a record from a table:
| Setting | Description |
|---|---|
| Table | The table containing the row |
| Row Reference | Which row to delete |
Example configuration:
Table: ordersRow: {{$row}}Navigate
Section titled “Navigate”Go to another view in your app:
| Setting | Description |
|---|---|
| Target View | The view to navigate to |
| Parameters | URL parameters to pass |
Example configuration:
Target View: order-detailsParameters: - id: {{$row.id}}The target view can access parameters via $params:
{{$params.id}}Open URL
Section titled “Open URL”Open an external URL in a new tab:
| Setting | Description |
|---|---|
| URL | The URL to open (supports formulas) |
Example configuration:
URL: https://maps.google.com/?q={{$row.address}}Show Message
Section titled “Show Message”Display a notification to the user:
| Setting | Description |
|---|---|
| Message | The text to display (supports formulas) |
| Type | success, error, info, or warning |
Example configuration:
Message: "Order #{{$row.id}} has been updated"Type: successRun Formula
Section titled “Run Formula”Execute a formula and optionally store the result:
| Setting | Description |
|---|---|
| Formula | The formula expression to evaluate |
Example:
Formula: SUM(FILTER(items, items.order_id = $row.id).price)Using Actions
Section titled “Using Actions”With Buttons
Section titled “With Buttons”The most common way to trigger actions:
- Add a Button component to your view
- In the button settings, select Action
- Choose the action to trigger
- Configure any action-specific settings
Button Settings for Actions
Section titled “Button Settings for Actions”| Setting | Description |
|---|---|
| Action | Select the action to trigger |
| Disabled Condition | Formula for when button is disabled |
| Confirm Dialog | Show confirmation before running |
| Confirm Message | Custom confirmation message |
With List Components
Section titled “With List Components”Actions can trigger on row interactions:
| Setting | Description |
|---|---|
| Row Click Action | Action when a row is clicked |
| Row Double Click | Action on double-click |
Confirmation Dialogs
Section titled “Confirmation Dialogs”For destructive or important actions, enable confirmation:
- In the button settings, enable Confirm Dialog
- Set a custom Confirm Message
- Users must click “Confirm” before the action runs
Example message:
Are you sure you want to delete "{{$row.name}}"? This cannot be undone.Action Context
Section titled “Action Context”Actions have access to context variables when executed:
| Variable | Description | Availability |
|---|---|---|
$row | Current row (in list context) | List row click, row actions |
$selectedRows | Selected rows | Bulk action buttons |
$user | Current authenticated user | All actions |
$app | Current app metadata | All actions |
$params | URL parameters | All actions |
Bulk Actions
Section titled “Bulk Actions”Perform actions on multiple selected rows:
- Enable row selection in your List component
- Add a button with an action that uses
$selectedRows - The action runs for each selected row
Example - Delete Selected:
Table: itemsRow: {{$selectedRows}}The action will delete all selected items.
Action Chaining (Advanced)
Section titled “Action Chaining (Advanced)”Chain multiple actions to run in sequence:
- Create individual actions for each step
- Use the Action Chain configuration
- Define the execution order
- Optionally add conditions between steps
Example workflow:
- Validate - Check required fields
- Create Order - Insert the order record
- Create Items - Insert order line items
- Show Message - Display success notification
- Navigate - Go to order confirmation
Chain Configuration
Section titled “Chain Configuration”| Setting | Description |
|---|---|
| Actions | Ordered list of actions to run |
| Stop on Error | Stop chain if any action fails |
| Condition | Optional condition before each action |
Error Handling
Section titled “Error Handling”Built-in Error Handling
Section titled “Built-in Error Handling”EmberBlocks provides automatic error handling:
- Failed actions show an error notification
- Database errors display user-friendly messages
- Network issues trigger retry prompts
Custom Error Messages
Section titled “Custom Error Messages”Configure custom error handling:
| Setting | Description |
|---|---|
| Error Message | Custom message to show on failure |
| Error Action | Action to run on failure (optional) |
Common Patterns
Section titled “Common Patterns”Quick Add
Section titled “Quick Add”Create a record with minimal input:
Action: Create RowTable: tasksField Values: - title: "New Task" - status: "draft" - created_by: {{$user.id}} - created_at: NOW()Status Update
Section titled “Status Update”Change a record’s status:
Action: Update RowTable: ordersRow: {{$row}}Field Values: - status: "shipped" - shipped_at: NOW()Navigate to Detail
Section titled “Navigate to Detail”Open a detail view for a row:
Action: NavigateTarget View: customer-detailsParameters: - id: {{$row.id}}Confirm Delete
Section titled “Confirm Delete”Delete with confirmation:
Action: Delete RowTable: itemsRow: {{$row}}
Button Settings: - Confirm Dialog: enabled - Confirm Message: "Delete {{$row.name}}?"Open External Link
Section titled “Open External Link”Open a URL based on row data:
Action: Open URLURL: {{$row.document_url}}Success Feedback
Section titled “Success Feedback”Show confirmation after save:
Action: Show MessageMessage: "Changes saved successfully"Type: successBest Practices
Section titled “Best Practices”Naming Conventions
Section titled “Naming Conventions”Use clear, descriptive names:
- “Create Order” instead of “Action 1”
- “Mark as Complete” instead of “Update”
- “Delete Customer” instead of “Remove”
Confirmation Dialogs
Section titled “Confirmation Dialogs”Always confirm destructive actions:
- Delete operations
- Bulk updates
- Irreversible changes
Error Messages
Section titled “Error Messages”Provide helpful error context:
"Unable to save order. Please check all required fields are filled."Data Validation
Section titled “Data Validation”Validate before CRUD operations:
- Check required fields aren’t empty
- Verify numeric values are in range
- Confirm relationships exist
User Feedback
Section titled “User Feedback”Always provide feedback:
- Success messages after saves
- Error messages with helpful context
- Loading states during operations
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”| Issue | Cause | Solution |
|---|---|---|
| Action not triggering | Button not configured | Check action is assigned to button |
| Wrong row affected | Incorrect row reference | Verify $row context is available |
| Field value errors | Invalid formula | Check formula syntax and field names |
| Navigation fails | Invalid view slug | Verify target view exists |
Debugging Tips
Section titled “Debugging Tips”- Test actions with simple static values first
- Check browser console for detailed errors
- Verify table and field names are correct
- Ensure required permissions are granted
Security Considerations
Section titled “Security Considerations”Access Control
Section titled “Access Control”- Actions respect user role permissions
- Users can only modify data they have access to
- Admin actions should have explicit role checks
Data Validation
Section titled “Data Validation”- Validate input on both client and server
- Sanitize user-provided values
- Check for SQL injection in dynamic queries
Audit Trail
Section titled “Audit Trail”- Consider logging important operations
- Track who performed destructive actions
- Maintain history for compliance needs
Next Steps
Section titled “Next Steps”Continue building your EmberBlocks app:
- Components - Add interactive UI elements
- Formulas - Create dynamic action parameters
- Settings - Configure app-wide settings