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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
# File 'app/helpers/bmc/button_helper.rb', line 22
def bs_button(
url,
icon:, method: :get,
confirm: nil,
text: nil,
action: nil,
title: text,
btn_size: BMC::ButtonHelper.default_size,
btn_style: BMC::ButtonHelper.default_style,
add_class: [],
helper: :link_to,
**options
)
text = ta(action) if text.nil? && action
content = fa_s(icon).concat(" ").concat(tag.span(text, class: "text"))
if method != :get
if helper == :link_to
options[BMC::ButtonHelper.method_attribute] = method
options[:rel] = "nofollow"
elsif helper == :button_to
options[:method] = method
end
confirm = true if confirm.nil?
end
unless options[:class]
options[:class] = [
"btn",
"btn-#{btn_size}",
"btn-#{btn_style.to_s.tr('_', '-')}",
("link-#{action}" if action),
*add_class,
]
end
options[:title] = title
unless confirm.nil?
confirm = ta(:confirm) if confirm == true
options[BMC::ButtonHelper.confirm_attribute] = confirm
end
public_send(helper, content, url, options.sort.to_h)
end
|