2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'app/helpers/overlastic/navigation_helper.rb', line 2
def link_to_overlay(name = nil, options = nil, html_options = nil, &block)
method_type = __callee__.to_s.delete_prefix("link_to_")
method_type = nil if method_type == "overlay"
if block_given?
options ||= {}
options = options.stringify_keys
options["data"] ||= {}
type = options.delete("overlay_type") || method_type
options["data"][:overlay_type] = type if type.present?
action = options.delete("overlay_action") || Overlastic.configuration.default_action
options["data"][:turbo_frame] = turbo_frame_from_overlastic_action(action)
target = options.delete("overlay_target")
options["data"][:overlay_target] = target if target.present?
args = options.delete("overlay_args")
options["data"][:overlay_args] = args.to_json if args.present?
link_to(name, options, &block)
else
html_options ||= {}
html_options = html_options.stringify_keys
html_options["data"] ||= {}
type = html_options.delete("overlay_type") || method_type
html_options["data"][:overlay_type] = type if type.present?
action = html_options.delete("overlay_action") || Overlastic.configuration.default_action
html_options["data"][:turbo_frame] = turbo_frame_from_overlastic_action(action)
target = html_options.delete("overlay_target")
html_options["data"][:overlay_target] = target if target.present?
args = html_options.delete("overlay_args")
html_options["data"][:overlay_args] = args.to_json if args.present?
link_to(name, options, html_options, &block)
end
end
|