Sha256: 4d3604e21cb4563489bad2279e50ae703810dc09dc5edd11371f0287eaa8b40e

Contents?: true

Size: 1.34 KB

Versions: 8

Compression:

Stored size: 1.34 KB

Contents

module Admin::CustomFieldsHelper

  def options_for_field_kind
    options = %w{string text category boolean date file}.map do |kind|
      [t("admin.custom_fields.kind.#{kind}"), kind]
    end
  end

  def options_for_order_by(content_type, collection_name)
    options = %w{created_at updated_at _position_in_list}.map do |type|
      [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' || f.kind == 'file' }
    collection.map { |field| [field.label, field._name] }
  end

  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

  def options_for_text_formatting
    options = %w{none html}.map do |option|
      [t("admin.custom_fields.text_formatting.#{option}"), option]
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
locomotive_cms-1.0.0.beta.2 app/helpers/admin/custom_fields_helper.rb
locomotive_cms-1.0.0.beta app/helpers/admin/custom_fields_helper.rb
locomotive_cms-0.0.4.beta12 app/helpers/admin/custom_fields_helper.rb
locomotive_cms-0.0.4.beta11 app/helpers/admin/custom_fields_helper.rb
locomotive_cms-0.0.4.beta10 app/helpers/admin/custom_fields_helper.rb
locomotive_cms-0.0.4.beta9 app/helpers/admin/custom_fields_helper.rb
locomotive_cms-0.0.4.beta8 app/helpers/admin/custom_fields_helper.rb
locomotive_cms-0.0.4.beta7 app/helpers/admin/custom_fields_helper.rb