Module: Avo::TurboStreamActionsHelper

Defined in:
app/helpers/avo/turbo_stream_actions_helper.rb

Instance Method Summary collapse

Instance Method Details

#avo_close_modalObject



13
14
15
16
17
# File 'app/helpers/avo/turbo_stream_actions_helper.rb', line 13

def avo_close_modal
  turbo_stream_action_tag :replace,
    target: Avo::MODAL_FRAME_ID,
    template: @view_context.turbo_frame_tag(Avo::MODAL_FRAME_ID)
end

#avo_download(content:, filename:) ⇒ Object



3
4
5
# File 'app/helpers/avo/turbo_stream_actions_helper.rb', line 3

def avo_download(content:, filename:)
  turbo_stream_action_tag :download, content: content, filename: filename
end

#avo_flash_alertsObject



7
8
9
10
11
# File 'app/helpers/avo/turbo_stream_actions_helper.rb', line 7

def avo_flash_alerts
  turbo_stream_action_tag :append,
    target: "alerts",
    template: @view_context.render(Avo::FlashAlertsComponent.new(flashes: @view_context.flash.discard))
end

#avo_turbo_reloadObject



19
20
21
# File 'app/helpers/avo/turbo_stream_actions_helper.rb', line 19

def avo_turbo_reload
  turbo_stream_action_tag :turbo_reload
end

#avo_update_belongs_to(relation_name:, target_record_id:, target_resource_label:, target_resource_class:) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'app/helpers/avo/turbo_stream_actions_helper.rb', line 23

def avo_update_belongs_to(relation_name:, target_record_id:, target_resource_label:, target_resource_class:)
  turbo_stream_action_tag "update-belongs-to",
    data: {
      relation_name: relation_name,
      target_record_id: target_record_id,
      target_resource_label: target_resource_label,
      target_resource_class: target_resource_class
    }
end