2009-01-06 11:49:19 +01:00
|
|
|
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
|
2009-01-16 16:19:26 +01:00
|
|
|
|
|
|
|
def row_classes(article)
|
2012-10-28 18:03:50 +01:00
|
|
|
classes = []
|
|
|
|
classes << "unavailable" if !article.availability
|
|
|
|
classes << "just-updated" if article.recently_updated && article.availability
|
|
|
|
classes.join(" ")
|
2009-01-16 16:19:26 +01:00
|
|
|
end
|
2012-10-19 01:12:47 +02:00
|
|
|
|
|
|
|
# Flatten search params, used in import from external database
|
|
|
|
def search_params
|
|
|
|
Hash[params[:search].map { |k,v| [k, (v.is_a?(Array) ? v.join(" ") : v)] }]
|
|
|
|
end
|
2009-01-06 11:49:19 +01:00
|
|
|
end
|