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
|
||||
|
||||
def image_button_to(name, image = nil, options = nil, html_options = {})
|
||||
html_options[:class] = class_names(html_options[:class], 'button')
|
||||
image_element_to(:button, name, image, options, html_options)
|
||||
end
|
||||
[:button_to, :link_to, :link_to_unless_current].each do |method_name|
|
||||
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
|
||||
def image_#{method_name}(name, image = nil, options = nil, html_options = {}, &block)
|
||||
name = svg_tag("pictograms/\#{image}") + name if image
|
||||
|
||||
def image_link_to(name, image = nil, options = nil, html_options = {})
|
||||
html_options[:class] = class_names(html_options[:class], 'button')
|
||||
image_element_to(:link, name, image, options, html_options)
|
||||
end
|
||||
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
|
||||
|
||||
def image_tab_to(name, image = nil, options = nil, html_options = {})
|
||||
image_element_to(:link, name, image, options, html_options)
|
||||
send :#{method_name}, name, options, html_options, &block
|
||||
end
|
||||
RUBY_EVAL
|
||||
end
|
||||
|
||||
def render_errors(record)
|
||||
@ -120,24 +125,6 @@ module ApplicationHelper
|
||||
|
||||
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
|
||||
def scientifize(d)
|
||||
sign, coefficient, base, exponent = d.split
|
||||
|
@ -26,8 +26,8 @@
|
||||
<body>
|
||||
<header class="header">
|
||||
<% if user_signed_in? %>
|
||||
<%= image_link_to current_user.email, "account-wrench-outline",
|
||||
edit_user_registration_path, current: :hide %>
|
||||
<%= image_link_to_unless_current(current_user.email, "account-wrench-outline",
|
||||
edit_user_registration_path) {} %>
|
||||
<% if current_user_disguised? %>
|
||||
<%= image_link_to t(".revert"), "incognito-off", revert_users_path %>
|
||||
<% else %>
|
||||
@ -35,9 +35,9 @@
|
||||
method: :delete %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= image_link_to t(:sign_in), "login", new_user_session_path, current: :hide %>
|
||||
<%= image_link_to t(:register), "account-plus-outline", new_user_registration_path,
|
||||
current: :hide %>
|
||||
<%= image_link_to_unless_current(t(:sign_in), "login", new_user_session_path) {} %>
|
||||
<%= image_link_to_unless_current(t(:register), "account-plus-outline",
|
||||
new_user_registration_path) {} %>
|
||||
<% end %>
|
||||
</header>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user