Run rubocop --fix-layout and remove encoding comments

This commit is contained in:
Patrick Gansterer 2021-03-01 15:27:26 +01:00
parent fa63e6e81d
commit ea2862fdef
283 changed files with 1164 additions and 1969 deletions

View file

@ -11,13 +11,14 @@ module Admin::ConfigsHelper
# @todo find way to pass current value to time_zone input without using default
def config_input(form, key, options = {}, &block)
return unless @cfg.allowed_key? key
options[:label] ||= config_input_label(form, key)
options[:required] ||= false
options[:input_html] ||= {}
config_input_field_options form, key, options[:input_html]
config_input_tooltip_options form, key, options[:input_html]
if options[:as] == :boolean
options[:input_html][:checked] = 'checked' if v=options[:input_html].delete(:value) && v!='false'
options[:input_html][:checked] = 'checked' if v = options[:input_html].delete(:value) && v != 'false'
options[:checked_value] = 'true' if options[:checked_value].nil?
options[:unchecked_value] = 'false' if options[:unchecked_value].nil?
elsif options[:collection] || options[:as] == :select
@ -47,13 +48,14 @@ module Admin::ConfigsHelper
# @todo find out how to pass +checked_value+ and +unchecked_value+ to +input_field+
def config_input_field(form, key, options = {})
return unless @cfg.allowed_key? :key
options[:required] ||= false
config_input_field_options form, key, options
config_input_tooltip_options form, key, options
if options[:as] == :boolean
checked_value = options.delete(:checked_value) || 'true'
unchecked_value = options.delete(:unchecked_value) || 'false'
options[:checked] = 'checked' if v=options.delete(:value) && v!='false'
options[:checked] = 'checked' if v = options.delete(:value) && v != 'false'
# different key for hidden field so that allow clocking on label focuses the control
form.hidden_field(key, id: "#{key}_", value: unchecked_value, as: :hidden) + form.check_box(key, options, checked_value, false)
elsif options[:as] == :select_recurring
@ -73,13 +75,13 @@ module Admin::ConfigsHelper
# @option options [String] :label Label to show
def config_use_heading(form, key, options = {})
head = content_tag :label do
lbl = options[:label] || config_input_label(form, key)
field = config_input_field(form, key, as: :boolean, boolean_style: :inline,
data: {toggle: 'collapse', target: "##{key}-fields"})
content_tag :h4 do
# put in span to keep space for tooltip at right
content_tag :span, (lbl + field).html_safe, config_input_tooltip_options(form, key, {})
end
lbl = options[:label] || config_input_label(form, key)
field = config_input_field(form, key, as: :boolean, boolean_style: :inline,
data: { toggle: 'collapse', target: "##{key}-fields" })
content_tag :h4 do
# put in span to keep space for tooltip at right
content_tag :span, (lbl + field).html_safe, config_input_tooltip_options(form, key, {})
end
end
fields = content_tag(:fieldset, id: "#{key}-fields", class: "collapse#{' in' if @cfg[key]}") do
yield
@ -99,12 +101,12 @@ module Admin::ConfigsHelper
'(protected)'
elsif value.is_a? Hash
content_tag :ul do
value.map do |k,v|
value.map do |k, v|
content_tag :li, content_tag(:tt, "#{k}: ") + show_config_value(k, v).to_s
end.join.html_safe
end
elsif value.is_a? Enumerable
content_tag :ul, value.map {|v| content_tag :li, h(v)}.join.html_safe
content_tag :ul, value.map { |v| content_tag :li, h(v) }.join.html_safe
elsif key =~ /url|website|www|homepage/
link_to(value, value.to_s).html_safe
else
@ -115,7 +117,7 @@ module Admin::ConfigsHelper
# @return [String] Tooltip element (span)
# @param form [ActionView::Helpers::FormBuilder] Form object.
# @param key [Symbol, String] Configuration key of a boolean (e.g. +use_messages+).
def config_tooltip(form, key, options={}, &block)
def config_tooltip(form, key, options = {}, &block)
content_tag :span, config_input_tooltip_options(form, key, options), &block
end
@ -139,7 +141,7 @@ module Admin::ConfigsHelper
# set current value
unless options.has_key?(:value)
value = @cfg
cfg_path.each {|n| value = value[n] if value.respond_to? :[] }
cfg_path.each { |n| value = value[n] if value.respond_to? :[] }
options[:value] = value
end
options