Module: NitroRails::PanelHelper
- Defined in:
- app/helpers/nitro_rails/panel_helper.rb
Defined Under Namespace
Classes: PanelLinkComponent
Instance Method Summary
collapse
Instance Method Details
#in_panel? ⇒ Boolean
16
17
18
|
# File 'app/helpers/nitro_rails/panel_helper.rb', line 16
def in_panel?
request.['Turbo-Panel-Request'].present?
end
|
#panel_frame_tag ⇒ Object
4
5
6
|
# File 'app/helpers/nitro_rails/panel_helper.rb', line 4
def panel_frame_tag
render partial: "nitro_rails/panel_frame_tag", locals: { component_id: "nie" } end
|
#panel_link(*args, **opts, &block) ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'app/helpers/nitro_rails/panel_helper.rb', line 20
def panel_link(*args, **opts, &block)
if in_panel?
return link_to(*args, **opts, &block)
end
opts[:data] ||= {}
opts[:data][:action] = "click->panel-manager#toggle"
if opts[:panel].is_a?(Hash)
opts[:panel].each do |key, value|
opts[:data]["panel-#{key.to_s.dasherize}"] = value.to_s.dasherize
end
else
opts[:data][:panel] = "default"
end
opts[:data][:panel_id] = "#{opts.to_s}#{args[-1].to_s}".hash
if opts[:panel] && opts[:panel][:presentation]
args[-1] = args[1] + "?presentation=#{opts[:panel][:presentation]}"
end
presentation = opts[:panel] && opts[:panel][:presentation] ? opts[:panel][:presentation] : "card"
container_opts = opts.delete(:container) || {}
container_opts[:class] ? container_opts[:class] += " panel-container #{presentation}" : container_opts[:class] = "panel-container #{presentation}"
content_tag(:div, **container_opts) do
link_to(*args, **opts, &block)
end
end
|
#panel_template ⇒ Object
8
9
10
|
# File 'app/helpers/nitro_rails/panel_helper.rb', line 8
def panel_template
render partial: "nitro_rails/panel_template"
end
|
12
13
14
|
# File 'app/helpers/nitro_rails/panel_helper.rb', line 12
def (*args, **opts, &block)
end
|