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

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

Calls superclass method
# File lib/active_admin/views/components/columns.rb, line 119
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 128
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: #{max_width};"
  end

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

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

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