rails-tables 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/rails-tables/datatable/column.rb +16 -0
- data/lib/rails-tables/model_additions.rb +6 -6
- data/lib/rails-tables/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -12,7 +12,7 @@ A clean jQuery datatables DSL
|
|
12
12
|
[jqd-railscast]: http://railscasts.com/episodes/340-datatables (Episode #340: Datatables)
|
13
13
|
[squeel]: https://github.com/ernie/squeel (Squeel: ActiveRecord 3, improved)
|
14
14
|
|
15
|
-
Version: 0.6.
|
15
|
+
Version: 0.6.6
|
16
16
|
|
17
17
|
Please refer to the [RailsTables Wiki][wiki] for:
|
18
18
|
|
@@ -50,6 +50,7 @@ private
|
|
50
50
|
property = object.try(:send, self.method)
|
51
51
|
property if not property.nil?
|
52
52
|
end
|
53
|
+
|
53
54
|
def self_referential_link(view, object)
|
54
55
|
property = object.try(:send, self.method)
|
55
56
|
view.link_to property, object if not property.nil?
|
@@ -61,6 +62,7 @@ private
|
|
61
62
|
def related_link_list(view, objects)
|
62
63
|
objects.reject(&:blank?).map{ |object| related_link(view, object).strip }.join(', ') if not objects.nil?
|
63
64
|
end
|
65
|
+
|
64
66
|
def time(view, object)
|
65
67
|
property = object.try(:send, self.method)
|
66
68
|
property.strftime("%I:%M%p") if not property.nil?
|
@@ -74,4 +76,18 @@ private
|
|
74
76
|
property.strftime("%m/%d/%Y at %I:%M%p") if not property.nil?
|
75
77
|
end
|
76
78
|
|
79
|
+
def currency(view, object)
|
80
|
+
property = object.try(:send, self.method)
|
81
|
+
view.number_to_currency(property.to_f) if not property.nil?
|
82
|
+
end
|
83
|
+
def phone(view, object)
|
84
|
+
property = object.try(:send, self.method)
|
85
|
+
view.number_to_phone(property.to_f) if not property.nil?
|
86
|
+
end
|
87
|
+
|
88
|
+
def truncate(view, object)
|
89
|
+
property = object.try(:send, self.method)
|
90
|
+
view.truncate(property, 50) if not property.nil?
|
91
|
+
end
|
92
|
+
|
77
93
|
end
|
@@ -24,11 +24,11 @@ module RailsTables::ModelAdditions
|
|
24
24
|
cattr_accessor :datatables unless self.respond_to? :datatables
|
25
25
|
self.datatables ||= {}
|
26
26
|
|
27
|
-
if self.has_datatable? name
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
else
|
27
|
+
# if self.has_datatable? name
|
28
|
+
# raise RailsTables::NameError,
|
29
|
+
# "#{self.name} already has a datatable with the name '#{name}'. "\
|
30
|
+
# "Please supply a :name parameter to has_datatable other than: #{self.datatables.keys.join(', ')}"
|
31
|
+
# else
|
32
32
|
self.datatables[name] = klass
|
33
33
|
cattr_writer name
|
34
34
|
self.send("#{name}=", klass.new(name, self))
|
@@ -37,7 +37,7 @@ module RailsTables::ModelAdditions
|
|
37
37
|
self.class_variable_get("@@#{name}").set_root(self)
|
38
38
|
end
|
39
39
|
end
|
40
|
-
end
|
40
|
+
# end
|
41
41
|
end
|
42
42
|
|
43
43
|
def has_datatable?(table_name=:datatable)
|
data/lib/rails-tables/version.rb
CHANGED