lib/tabulatr/renderer/column.rb in tabulatr2-0.9.2 vs lib/tabulatr/renderer/column.rb in tabulatr2-0.9.3
- old
+ new
@@ -23,11 +23,11 @@
class Tabulatr::Renderer::Column
include ActiveModel::Model
attr_accessor *%i{name header width align valign wrap type th_html filter_html
- filter checkbox_value checkbox_label filter_width range_filter_symbol
+ filter filter_width range_filter_symbol
sortable table_name block klass format map classes cell_style header_style}
def self.from(
name: nil,
table_name: nil,
@@ -38,12 +38,10 @@
valign: false,
wrap: nil,
th_html: false,
filter_html: false,
filter: true,
- checkbox_value: '1',
- checkbox_label: '',
sortable: true,
format: nil,
map: true,
klass: nil,
cell_style: {},
@@ -60,12 +58,10 @@
valign: valign,
wrap: wrap,
th_html: th_html,
filter_html: filter_html,
filter: filter,
- checkbox_value: checkbox_value,
- checkbox_label: checkbox_label,
sortable: sortable,
format: format,
map: map,
klass: klass,
block: b,
@@ -132,8 +128,21 @@
end
end
def principal_value(record)
record.send name
+ end
+
+ def determine_appropriate_filter!
+ case self.klass.columns_hash[self.name.to_s].try(:type)
+ when :integer, :float, :decimal
+ self.filter = :exact
+ when :string, :text
+ self.filter = :like
+ when :date, :time, :datetime, :timestamp
+ self.filter = :date
+ when :boolean
+ self.filter = :checkbox
+ end
end
end