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
44
45
46
47
48
49
50
51
|
# 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"] ||= {}
options["data"][:turbo_stream] = true
overlay_name = options.delete("overlay")
options["data"][:overlay_name] = overlay_name_from(overlay_name || overlay_name_from_overlastic_action(Overlastic.configuration.default_action))
type = options.delete("overlay_type") || method_type
options["data"][:overlay_type] = type if type.present?
target = options.delete("overlay_target")
options["data"][:overlay_target] = target if target.present?
args = options.delete("overlay_args")
options["data"][:overlay_args] = Base64.urlsafe_encode64(args.to_json) if args.present?
options["target"] = :_blank
link_to(name, options, &block)
else
html_options ||= {}
html_options = html_options.stringify_keys
html_options["data"] ||= {}
html_options["data"][:turbo_stream] = true
overlay_name = html_options.delete("overlay")
html_options["data"][:overlay_name] = overlay_name_from(overlay_name || overlay_name_from_overlastic_action(Overlastic.configuration.default_action))
type = html_options.delete("overlay_type") || method_type
html_options["data"][:overlay_type] = type if type.present?
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] = Base64.urlsafe_encode64(args.to_json) if args.present?
html_options["target"] = :_blank
link_to(name, options, html_options, &block)
end
end
|