rails-tables 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/app/tables/column.rb CHANGED
@@ -7,7 +7,7 @@ class Column
7
7
 
8
8
  attributes = args.pop || {}
9
9
  self.method = attributes.fetch(:method, name)
10
- self.column_source = attributes.fetch(:column_source, '')
10
+ self.column_source = attributes.fetch(:column_source, '').to_s
11
11
  self.render_with = attributes.fetch(:render_with, :default_render)
12
12
  self.sortable = attributes.fetch(:sortable, true)
13
13
  self.searchable = attributes.fetch(:searchable, true)
@@ -39,7 +39,7 @@ class Column
39
39
  view.link_to property, property if not property.nil?
40
40
  end
41
41
  def related_link_list(view, objects)
42
- objects.map{ |object| related_link(view, object) }.reject(&:nil?).join(', ') if not objects.nil?
42
+ objects.map{ |object| related_link(view, object).strip }.reject(&:blank?).join(', ') if not objects.nil?
43
43
  end
44
44
  def time(view, object)
45
45
  property = object.try(:send, self.method)
@@ -62,15 +62,9 @@ class_attribute :columns, :column_factory
62
62
  @columns ||= self.column_factory.map{ |new_column| Column.new(self.model, new_column[:name], new_column[:args]) }
63
63
  end
64
64
 
65
- class_attribute :match_any
66
- self.match_any = true
67
- def self.match_all_columns
68
- self.match_any = false
69
- end
70
-
71
65
  attr_accessor :joins
72
66
  def joins
73
- @joins ||= self.columns.map(&:column_source).uniq.reject(&:blank?)
67
+ @joins ||= self.columns.map(&:column_source).reject(&:blank?).uniq
74
68
  end
75
69
  attr_accessor :searches
76
70
  def searches
@@ -80,13 +74,13 @@ attr_accessor :searches
80
74
  private
81
75
 
82
76
  def objects
83
- query = self.model
77
+ query = self.model.uniq
84
78
  self.joins.each do |join|
85
- query = query.uniq.includes{ join.split('.').inject((strs.present? ? self : nil), :__send__).outer }
79
+ query = query.joins{ join.split('.').inject(self, :__send__).outer }.includes{ join.split('.').inject(self, :__send__).outer }
86
80
  end
87
81
  if sortable
88
82
  sort_expression = sort
89
- query = query.reorder{ my{sort_expression} }#("#{sort_column} #{sort_direction}")
83
+ query = query.reorder{ my{sort_expression} }
90
84
  end
91
85
  self.scopes.each do |scope|
92
86
  query = scope.call(query)
@@ -1,3 +1,3 @@
1
1
  module RailsTables
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-tables
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: