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

- (Object) max_width

Returns the value of attribute max_width



114
115
116
# File 'lib/active_admin/views/components/columns.rb', line 114

def max_width
  @max_width
end

- (Object) min_width

Returns the value of attribute min_width



114
115
116
# File 'lib/active_admin/views/components/columns.rb', line 114

def min_width
  @min_width
end

- (Object) span_size

Returns the value of attribute span_size



114
115
116
# File 'lib/active_admin/views/components/columns.rb', line 114

def span_size
  @span_size
end

Instance Method Details

- (Object) build(options = {})

Parameters:

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

    An options hash for the column



119
120
121
122
123
124
125
126
# 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

- (Object) set_column_styles(column_width, margin_width, is_last_column = false)



128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# 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: #{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