Sha256: c5309163d71cfd511f62cee048839e095d62e1a080e174d98fcd5d23da0fe582

Contents?: true

Size: 901 Bytes

Versions: 22

Compression:

Stored size: 901 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

22 entries across 22 versions & 2 rubygems

Version Path
rails_admin-1.4.3 lib/rails_admin/config/fields/types/color.rb
rails_admin-2.0.0.beta lib/rails_admin/config/fields/types/color.rb
rails_admin-1.4.2 lib/rails_admin/config/fields/types/color.rb
rails_admin-1.4.1 lib/rails_admin/config/fields/types/color.rb
rails_admin-1.4.0 lib/rails_admin/config/fields/types/color.rb
rails_admin-1.3.0 lib/rails_admin/config/fields/types/color.rb
rails_admin-1.2.0 lib/rails_admin/config/fields/types/color.rb
rails_admin-1.1.1 lib/rails_admin/config/fields/types/color.rb
rails_admin-1.1.0 lib/rails_admin/config/fields/types/color.rb
rails_admin-1.0.0 lib/rails_admin/config/fields/types/color.rb
rails_admin-1.0.0.rc lib/rails_admin/config/fields/types/color.rb
rails_admin-0.8.1 lib/rails_admin/config/fields/types/color.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/rails_admin-0.7.0/lib/rails_admin/config/fields/types/color.rb
rails_admin-0.7.0 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.6.8 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.6.7 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.6.6 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.6.5 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.6.4 lib/rails_admin/config/fields/types/color.rb
rails_admin-0.6.3 lib/rails_admin/config/fields/types/color.rb