Sha256: b1f342dc274c6f4995e4f4f65260a263c554ee6bdf464a6d252999b33cd45c82

Contents?: true

Size: 905 Bytes

Versions: 29

Compression:

Stored size: 905 Bytes

Contents

require 'rails_admin/config/fields/base'

module RailsAdmin
  module Config
    module Fields
      module Types
        class Color < RailsAdmin::Config::Fields::Base
          RailsAdmin::Config::Fields::Types::register(self)

          register_instance_option :pretty_value do
            bindings[:view].content_tag :strong, (value.presence || ' - '), :style => "color: #{color}"
          end

          register_instance_option :partial do
            :form_colorpicker
          end

          register_instance_option :color do
            if value.present?
              if value =~ /^[0-9a-fA-F]{3,6}$/
                '#' + value
              else
                value
              end
            else
              'white'
            end
          end

          register_instance_option :export_value do
            formatted_value
          end
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 5 rubygems

Version Path
rails_admin-0.6.0 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.5.0 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.4.9 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.4.8 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.4.7 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.4.6 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.4.5 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.4.4 lib/rails_admin/config/fields/types/color.rb
rails_admin-lbgraham-0.4.2 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.4.3 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.4.2 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.4.1 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.4.0 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.3.0 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.2.0 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.1.2 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.1.1 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.1.0 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.0.5 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.0.4 lib/rails_admin/config/fields/types/color.rb