Class: ActiveAdmin::Views::Column

Inherits:
Component
  • Object
show all
Defined in:
lib/active_admin/views/components/columns.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#max_widthObject

Returns the value of attribute max_width.



119
120
121
# File 'lib/active_admin/views/components/columns.rb', line 119

def max_width
  @max_width
end

#min_widthObject

Returns the value of attribute min_width.



119
120
121
# File 'lib/active_admin/views/components/columns.rb', line 119

def min_width
  @min_width
end

#span_sizeObject

Returns the value of attribute span_size.



119
120
121
# File 'lib/active_admin/views/components/columns.rb', line 119

def span_size
  @span_size
end

Instance Method Details

#build(options = {}) ⇒ Object

Parameters:

  • options (Hash) (defaults to: {})

    An options hash for the column

Options Hash (options):

  • :span (Integer)

    The columns this column should span



124
125
126
127
128
129
130
131
# File 'lib/active_admin/views/components/columns.rb', line 124

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) ⇒ Object



133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/active_admin/views/components/columns.rb', line 133

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