foodsoft/app/helpers/articles_helper.rb
wvengen 7841245795 migrate to Rails 4.0 (closes foodcoops#214)
Conflicts:
	Gemfile.lock
2014-02-24 12:46:28 +01:00

19 lines
615 B
Ruby

module ArticlesHelper
# useful for highlighting attributes, when synchronizing articles
def highlight_new(unequal_attributes, attribute)
unequal_attributes.detect {|a| a == attribute} ? "background-color: yellow" : ""
end
def row_classes(article)
classes = []
classes << "unavailable" if !article.availability
classes << "just-updated" if article.recently_updated && article.availability
classes.join(" ")
end
# Flatten search params, used in import from external database
def search_params
Hash[params[:q].map { |k,v| [k, (v.is_a?(Array) ? v.join(" ") : v)] }]
end
end