Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ import 'controllers'
* `turbo_stream.dispatch_event(target, name, detail: {}, **attributes)`


### Form Actions

* `turbo_stream.reset_form(target, **attributes)`


### Storage Actions

* `turbo_stream.clear_storage(type, **attributes)`
Expand All @@ -145,6 +150,7 @@ import 'controllers'
* `turbo_stream.set_focus(target, **attributes)`
* `turbo_stream.set_title(title, **attributes)`


### Browser History Actions

* `turbo_stream.history_go(delta, **attributes)`
Expand All @@ -157,20 +163,24 @@ import 'controllers'
* `turbo_stream.console_log(message, level = 'log', **attributes)`
* `turbo_stream.console_table(data, columns, **attributes)`


### Notification Actions

* `turbo_stream.notification(title, options, **attributes)`


### Turbo Frame Actions

* `turbo_stream.turbo_frame_reload(frame_id, **attributes)`
* `turbo_stream.turbo_frame_set_src(frame_id, src, **attributes)`


### Turbo Actions

* `turbo_stream.redirect_to(url, turbo_action = "advance", **attributes)`
* `turbo_stream.turbo_clear_cache()`


## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
Expand Down
6 changes: 6 additions & 0 deletions lib/turbo_power/stream_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ def dispatch_event(target, name, detail: {}, **attributes)
custom_action_all :dispatch_event, targets: target, attributes: attributes.merge(name: name), content: detail.to_json
end

# Form Actions

def reset_form(target, **attributes)
custom_action_all :reset_form, targets: target, attributes: attributes
end

# Storage Actions

def clear_storage(type, **attributes)
Expand Down
6 changes: 6 additions & 0 deletions test/turbo_power/stream_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,11 @@ class StreamHelperTest < ActionView::TestCase

assert_dom_equal stream, turbo_stream.dispatch_event("#element", "custom-event", detail: { count: 1, type: "custom", enabled: true, ids: [1, 2, 3] })
end

test "reset_form" do
stream = %(<turbo-stream action="reset_form" targets="#form"><template></template></turbo-stream>)

assert_dom_equal stream, turbo_stream.reset_form("#form")
end
end
end