Use boolean comparators where it makes sense
This commit is contained in:
parent
dbdc7ae4aa
commit
118886344a
28 changed files with 60 additions and 60 deletions
|
|
@ -17,10 +17,10 @@ module Admin::ConfigsHelper
|
|||
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) and 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] or options[:as] == :select
|
||||
elsif options[:collection] || options[:as] == :select
|
||||
options[:selected] = options[:input_html].delete(:value)
|
||||
return form.input key, options, &block
|
||||
elsif options[:as] == :time_zone
|
||||
|
|
@ -53,7 +53,7 @@ module Admin::ConfigsHelper
|
|||
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) and v!='false'
|
||||
options[:checked] = 'checked' if v=options.delete(:value) && v!='false'
|
||||
form.hidden_field(key, value: unchecked_value, as: :hidden) + form.check_box(key, options, checked_value, false)
|
||||
elsif options[:as] == :select_recurring
|
||||
options[:value] = FoodsoftDateUtil.rule_from(options[:value])
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ module ApplicationHelper
|
|||
end
|
||||
|
||||
def format_datetime_timespec(time, format)
|
||||
I18n.l(time, :format => format) unless (time.nil? or format.nil?)
|
||||
I18n.l(time, :format => format) unless (time.nil? || format.nil?)
|
||||
end
|
||||
|
||||
# Creates ajax-controlled-links for pagination
|
||||
|
|
@ -92,7 +92,7 @@ module ApplicationHelper
|
|||
if options[:short]
|
||||
desc = options[:desc]
|
||||
desc ||= model.human_attribute_name("#{attribute}_desc".to_sym, options.merge({fallback: true, default: '', count: 2}))
|
||||
desc.blank? and desc = s
|
||||
desc.blank? && desc = s
|
||||
sshort = model.human_attribute_name("#{attribute}_short".to_sym, options.merge({fallback: true, default: '', count: 2}))
|
||||
s = raw "<abbr title='#{desc}'>#{sshort}</abbr>" unless sshort.blank?
|
||||
end
|
||||
|
|
@ -187,7 +187,7 @@ module ApplicationHelper
|
|||
# render base errors in a form after failed validation
|
||||
# http://railsapps.github.io/twitter-bootstrap-rails.html
|
||||
def base_errors resource
|
||||
return '' if (resource.errors.empty?) or (resource.errors[:base].empty?)
|
||||
return '' if resource.errors.empty? || resource.errors[:base].empty?
|
||||
messages = resource.errors[:base].map { |msg| content_tag(:li, msg) }.join
|
||||
render :partial => 'shared/base_errors', :locals => {:error_messages => messages}
|
||||
end
|
||||
|
|
@ -197,7 +197,7 @@ module ApplicationHelper
|
|||
if user.nil?
|
||||
"?"
|
||||
elsif FoodsoftConfig[:use_nick]
|
||||
if options[:full] and options[:markup]
|
||||
if options[:full] && options[:markup]
|
||||
raw "<b>#{h user.nick}</b> (#{h user.first_name} #{h user.last_name})"
|
||||
elsif options[:full]
|
||||
"#{user.nick} (#{user.first_name} #{user.last_name})"
|
||||
|
|
@ -217,7 +217,7 @@ module ApplicationHelper
|
|||
|
||||
# allow truncate to add title when tooltip option is given
|
||||
def truncate(text, options={}, &block)
|
||||
return text if not text or text.length <= (options[:length] or 30)
|
||||
return text if !text || text.length <= (options[:length] || 30)
|
||||
text_truncated = super(text, options, &block)
|
||||
if options[:tooltip]
|
||||
content_tag :span, text_truncated, title: text
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ module GroupOrderArticlesHelper
|
|||
|
||||
# return an edit field for a GroupOrderArticle result
|
||||
def group_order_article_edit_result(goa)
|
||||
unless goa.group_order.order.finished? and current_user.role_finance?
|
||||
unless goa.group_order.order.finished? && current_user.role_finance?
|
||||
goa.result
|
||||
else
|
||||
simple_form_for goa, remote: true, html: {'data-submit-onchange' => 'changed', class: 'delta-input'} do |f|
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ module GroupOrdersHelper
|
|||
# If the option :show is true, the link is for showing the group_order.
|
||||
def link_to_ordering(order, options = {}, &block)
|
||||
group_order = order.group_order(current_user.ordergroup)
|
||||
path = if options[:show] and group_order
|
||||
path = if options[:show] && group_order
|
||||
group_order_path(group_order)
|
||||
elsif group_order
|
||||
edit_group_order_path(group_order, :order_id => order.id)
|
||||
|
|
|
|||
|
|
@ -48,12 +48,12 @@ module OrdersHelper
|
|||
# Sensible in tables with multiple columns.
|
||||
# @return [String] Text showing unit and unit quantity when applicable.
|
||||
def pkg_helper(article, options={})
|
||||
return '' if not article or article.unit_quantity == 1
|
||||
return '' if !article || article.unit_quantity == 1
|
||||
uq_text = "× #{article.unit_quantity}"
|
||||
uq_text = content_tag(:span, uq_text, class: 'hidden-phone') if options[:soft_uq]
|
||||
if options[:plain]
|
||||
uq_text
|
||||
elsif options[:icon].nil? or options[:icon]
|
||||
elsif options[:icon].nil? || options[:icon]
|
||||
pkg_helper_icon(uq_text)
|
||||
else
|
||||
pkg_helper_icon(uq_text, tag: :span)
|
||||
|
|
@ -80,7 +80,7 @@ module OrdersHelper
|
|||
|
||||
def receive_input_field(form)
|
||||
order_article = form.object
|
||||
units_expected = (order_article.units_billed or order_article.units_to_order) *
|
||||
units_expected = (order_article.units_billed || order_article.units_to_order) *
|
||||
1.0 * order_article.article.unit_quantity / order_article.article_price.unit_quantity
|
||||
|
||||
input_classes = 'input input-nano units_received'
|
||||
|
|
@ -117,7 +117,7 @@ module OrdersHelper
|
|||
# @param order_or_supplier [Order, Supplier] Order or supplier to link to
|
||||
# @return [String] Link to order or supplier, showing its name.
|
||||
def supplier_link(order_or_supplier)
|
||||
if order_or_supplier.kind_of?(Order) and order_or_supplier.stockit?
|
||||
if order_or_supplier.kind_of?(Order) && order_or_supplier.stockit?
|
||||
link_to(order_or_supplier.name, stock_articles_path).html_safe
|
||||
else
|
||||
link_to(@order.supplier.name, supplier_path(@order.supplier)).html_safe
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue