class ActiveAdmin::Views::Column

Attributes

max_width[RW]
min_width[RW]
span_size[RW]

Public Instance Methods

build(options = {}) click to toggle source

@param [Hash] options An options hash for the column

@option options [Integer] :span The columns this column should span

Calls superclass method
# File lib/active_admin/views/components/columns.rb, line 123
def build(options = {})
  options = options.dup
  @span_size = options.delete(:span) || 1
  @max_width = options.delete(:max_width)
  @min_width = options.delete(:min_width)

  super(options)
end
set_column_styles(column_width, margin_width, is_last_column = false) click to toggle source
# File lib/active_admin/views/components/columns.rb, line 132
def set_column_styles(column_width, margin_width, is_last_column = false)
  column_with_span_width = (span_size * column_width) + ((span_size - 1) * margin_width)

  styles = []

  styles << "width: #{column_with_span_width}%;"

  if max_width
    styles << "max-width: #{safe_width(max_width)};"
  end

  if min_width
    styles << "min-width: #{safe_width(min_width)};"
  end

  styles << "margin-right: #{margin_width}%;" unless is_last_column

  set_attribute :style, styles.join(" ")
end

Private Instance Methods

safe_width(width) click to toggle source

Converts values without a '%' or 'px' suffix to a pixel value

# File lib/active_admin/views/components/columns.rb, line 155
def safe_width(width)
  width.to_s.gsub(/\A(\d+)\z/, '\1px')
end