2010-05-19 16:17:45 +00:00
|
|
|
module Admin::CustomFieldsHelper
|
2010-05-25 00:32:12 +00:00
|
|
|
|
2010-05-19 16:17:45 +00:00
|
|
|
def options_for_field_kind(selected = nil)
|
2010-06-30 13:18:17 +00:00
|
|
|
options = %w{String Text Category Boolean Date File}.map do |kind|
|
2010-05-19 16:17:45 +00:00
|
|
|
[t("admin.custom_fields.kind.#{kind.downcase}"), kind]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-05-25 00:32:12 +00:00
|
|
|
def options_for_order_by(content_type, collection_name)
|
2010-05-26 00:41:10 +00:00
|
|
|
options = %w{updated_at _position_in_list}.map do |type|
|
2010-05-25 00:32:12 +00:00
|
|
|
[t("admin.content_types.form.order_by.#{type.gsub(/^_/, '')}"), type]
|
|
|
|
end
|
|
|
|
options + options_for_highlighted_field(content_type, collection_name)
|
|
|
|
end
|
|
|
|
|
|
|
|
def options_for_highlighted_field(content_type, collection_name)
|
|
|
|
custom_fields_collection_name = "ordered_#{collection_name.singularize}_custom_fields".to_sym
|
|
|
|
collection = content_type.send(custom_fields_collection_name)
|
|
|
|
collection.delete_if { |f| f.label == 'field name' }
|
|
|
|
collection.map { |field| [field.label, field._name] }
|
|
|
|
end
|
|
|
|
|
2010-06-16 14:43:29 +00:00
|
|
|
def options_for_group_by_field(content_type, collection_name)
|
|
|
|
custom_fields_collection_name = "ordered_#{collection_name.singularize}_custom_fields".to_sym
|
|
|
|
collection = content_type.send(custom_fields_collection_name)
|
|
|
|
collection.delete_if { |f| not f.category? }
|
|
|
|
collection.map { |field| [field.label, field._name] }
|
|
|
|
end
|
|
|
|
|
2010-06-22 13:04:40 +00:00
|
|
|
def options_for_text_formatting
|
|
|
|
options = %w{none html}.map do |option|
|
|
|
|
[t("admin.custom_fields.text_formatting.#{option}"), option]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-05-19 16:17:45 +00:00
|
|
|
end
|