forked from fixin.me/fixin.me
Remove image_element_to helper
This commit is contained in:
parent
aa83f17a4c
commit
1b6bda4e70
@ -81,18 +81,23 @@ module ApplicationHelper
|
|||||||
end.join.html_safe
|
end.join.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
def image_button_to(name, image = nil, options = nil, html_options = {})
|
[:button_to, :link_to, :link_to_unless_current].each do |method_name|
|
||||||
html_options[:class] = class_names(html_options[:class], 'button')
|
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
|
||||||
image_element_to(:button, name, image, options, html_options)
|
def image_#{method_name}(name, image = nil, options = nil, html_options = {}, &block)
|
||||||
|
name = svg_tag("pictograms/\#{image}") + name if image
|
||||||
|
|
||||||
|
html_options[:class] = class_names(
|
||||||
|
html_options[:class],
|
||||||
|
'button',
|
||||||
|
dangerous: html_options[:method] == :delete
|
||||||
|
)
|
||||||
|
if html_options[:onclick]&.is_a? Hash
|
||||||
|
html_options[:onclick] = "return confirm('\#{html_options[:onclick][:confirm]}');"
|
||||||
end
|
end
|
||||||
|
|
||||||
def image_link_to(name, image = nil, options = nil, html_options = {})
|
send :#{method_name}, name, options, html_options, &block
|
||||||
html_options[:class] = class_names(html_options[:class], 'button')
|
|
||||||
image_element_to(:link, name, image, options, html_options)
|
|
||||||
end
|
end
|
||||||
|
RUBY_EVAL
|
||||||
def image_tab_to(name, image = nil, options = nil, html_options = {})
|
|
||||||
image_element_to(:link, name, image, options, html_options)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def render_errors(record)
|
def render_errors(record)
|
||||||
@ -120,24 +125,6 @@ module ApplicationHelper
|
|||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def image_element_to(type, name, image = nil, options = nil, html_options = {})
|
|
||||||
current = html_options.delete(:current)
|
|
||||||
current = nil unless url_for(options) == request.path
|
|
||||||
return '' if current == :hide
|
|
||||||
|
|
||||||
name = svg_tag("pictograms/#{image}") + name if image
|
|
||||||
html_options[:class] = class_names(
|
|
||||||
html_options[:class],
|
|
||||||
active: current == :active,
|
|
||||||
dangerous: html_options[:method] == :delete
|
|
||||||
)
|
|
||||||
if html_options[:onclick]&.is_a? Hash
|
|
||||||
html_options[:onclick] = "return confirm('#{html_options[:onclick][:confirm]}');"
|
|
||||||
end
|
|
||||||
|
|
||||||
send "#{type}_to", name, options, html_options
|
|
||||||
end
|
|
||||||
|
|
||||||
# Converts value to HTML formatted scientific notation
|
# Converts value to HTML formatted scientific notation
|
||||||
def scientifize(d)
|
def scientifize(d)
|
||||||
sign, coefficient, base, exponent = d.split
|
sign, coefficient, base, exponent = d.split
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
<body>
|
<body>
|
||||||
<header class="header">
|
<header class="header">
|
||||||
<% if user_signed_in? %>
|
<% if user_signed_in? %>
|
||||||
<%= image_link_to current_user.email, "account-wrench-outline",
|
<%= image_link_to_unless_current(current_user.email, "account-wrench-outline",
|
||||||
edit_user_registration_path, current: :hide %>
|
edit_user_registration_path) {} %>
|
||||||
<% if current_user_disguised? %>
|
<% if current_user_disguised? %>
|
||||||
<%= image_link_to t(".revert"), "incognito-off", revert_users_path %>
|
<%= image_link_to t(".revert"), "incognito-off", revert_users_path %>
|
||||||
<% else %>
|
<% else %>
|
||||||
@ -35,9 +35,9 @@
|
|||||||
method: :delete %>
|
method: :delete %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= image_link_to t(:sign_in), "login", new_user_session_path, current: :hide %>
|
<%= image_link_to_unless_current(t(:sign_in), "login", new_user_session_path) {} %>
|
||||||
<%= image_link_to t(:register), "account-plus-outline", new_user_registration_path,
|
<%= image_link_to_unless_current(t(:register), "account-plus-outline",
|
||||||
current: :hide %>
|
new_user_registration_path) {} %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user