rails-tables 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/app/tables/column.rb CHANGED
@@ -31,11 +31,11 @@ class Column
31
31
  end
32
32
  def related_link(view, object)
33
33
  property = object.send(self.column_name)
34
- view.link_to self.name, property if not property.nil?
34
+ view.link_to property, property if not property.nil?
35
35
  end
36
36
  def related_link_list(view, object)
37
37
  property = object.send(self.referring_column_name)
38
- property.collect { |related_object| self_referential_link(view, related_object) }.join(', ') if not property.nil?
38
+ property.collect { |related_object| related_link(view, related_object) }.join(', ') if not property.nil?
39
39
  end
40
40
  def time(view, object)
41
41
  property = object.send(self.column_name)
@@ -24,7 +24,7 @@ attr_accessor :view, :filters
24
24
  }
25
25
  end
26
26
 
27
- class_attribute :columns, :searches, :match_any
27
+ class_attribute :columns, :searches, :scopes, :match_any
28
28
  def self.column(name, *args)
29
29
  arguments = args.pop || {}
30
30
  self.columns = [] if self.columns.nil?
@@ -35,8 +35,12 @@ class_attribute :columns, :searches, :match_any
35
35
  self.searches = [] if self.searches.nil?
36
36
  self.searches << Search.new(name, self, arguments)
37
37
  end
38
- self.match_any = true
38
+ def self.available_scopes(*args)
39
+ self.scopes = [] if self.scopes.nil?
40
+ self.scopes += args
41
+ end
39
42
  def self.match_any_column(match_any=true)
43
+ self.match_any = true if self.match_any.nil?
40
44
  self.match_any = match_any
41
45
  end
42
46
 
@@ -48,12 +52,11 @@ private
48
52
  else
49
53
  objects = self.model
50
54
  end
51
- @filters.each do |method, arguments|
52
- objects = objects.send(method, arguments)
55
+ self.filters.each do |method, arguments|
56
+ objects = objects.send(method, *arguments) if self.scopes.include?(method.to_sym)
53
57
  end
54
58
  if params[:sSearch].present?
55
59
  objects = objects.send("#{self.name}_search", params[:sSearch])
56
- #objects = objects.where("name like :search or category like :search", search: "%#{params[:sSearch]}%")
57
60
  end
58
61
  objects = objects.paginate(page: page, per_page: per_page)
59
62
  objects
@@ -1,3 +1,3 @@
1
1
  module RailsTables
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
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.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-10 00:00:00.000000000 Z
12
+ date: 2012-09-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -28,21 +28,53 @@ dependencies:
28
28
  - !ruby/object:Gem::Version
29
29
  version: 3.2.7
30
30
  - !ruby/object:Gem::Dependency
31
- name: sqlite3
31
+ name: jquery-datatables-rails
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ! '>='
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.11.0
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
36
44
  - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :development
45
+ version: 1.11.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: will_paginate
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 3.0.3
54
+ type: :runtime
39
55
  prerelease: false
40
56
  version_requirements: !ruby/object:Gem::Requirement
41
57
  none: false
42
58
  requirements:
43
- - - ! '>='
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 3.0.3
62
+ - !ruby/object:Gem::Dependency
63
+ name: squeel
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.0.11
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
44
76
  - !ruby/object:Gem::Version
45
- version: '0'
77
+ version: 1.0.11
46
78
  description: A clean jQuery datatables DSL that follows the structure of Ryan Bate's
47
79
  jQuery datatables railscast.
48
80
  email: