refactor(turbo): use @coldwired/actions

This commit is contained in:
Paul Chavard 2023-01-13 11:13:09 +01:00
parent 0d2da7bac9
commit 7f9414012e
9 changed files with 100 additions and 115 deletions

View file

@ -54,8 +54,9 @@ module TurboStreamHelper
action_all :morph, targets, content, **rendering, &block
end
def dispatch(type, detail = {})
turbo_stream_simple_action_tag(:dispatch, 'event-type': type, 'event-detail': detail.to_json)
def dispatch(type, detail = nil)
content = detail.present? ? tag.script(cdata_section(detail.to_json), type: 'application/json') : nil
action_all :append, 'head', tag.dispatch_event(content, type:)
end
private