extjs-mvc 0.1.17 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/active_record/model.rb +12 -7
- metadata +1 -1
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.18
|
data/lib/active_record/model.rb
CHANGED
@@ -3,6 +3,10 @@ module ExtJS
|
|
3
3
|
def self.included(model)
|
4
4
|
model.send(:extend, ClassMethods)
|
5
5
|
model.send(:include, InstanceMethods)
|
6
|
+
model.class_eval do
|
7
|
+
cattr_accessor :extjs_record_fields
|
8
|
+
end
|
9
|
+
model.extjs_record_fields = []
|
6
10
|
end
|
7
11
|
|
8
12
|
##
|
@@ -21,7 +25,6 @@ module ExtJS
|
|
21
25
|
# ClassMethods
|
22
26
|
#
|
23
27
|
module ClassMethods
|
24
|
-
@@fields = []
|
25
28
|
##
|
26
29
|
# Defines the subset of AR columns used to create Ext.data.Record def'n.
|
27
30
|
# @param {Array/Hash} list-of-fields to include, :only, or :exclude
|
@@ -30,14 +33,14 @@ module ExtJS
|
|
30
33
|
options = params.extract_options!
|
31
34
|
if !options.keys.empty?
|
32
35
|
if options[:only]
|
33
|
-
|
36
|
+
self.extjs_record_fields = options[:only]
|
34
37
|
elsif options[:exclude]
|
35
|
-
|
38
|
+
self.extjs_record_fields = self.columns.reject {|c| options[:exclude].find {|ex| c.name.to_sym === ex}}.collect {|c| c.name.to_sym}
|
36
39
|
end
|
37
40
|
elsif !params.empty?
|
38
|
-
|
41
|
+
self.extjs_record_fields = params
|
39
42
|
else
|
40
|
-
|
43
|
+
self.extjs_record_fields
|
41
44
|
end
|
42
45
|
end
|
43
46
|
|
@@ -46,10 +49,12 @@ module ExtJS
|
|
46
49
|
# eg: {name:'foo', type: 'string'}
|
47
50
|
#
|
48
51
|
def extjs_record
|
49
|
-
|
52
|
+
self.extjs_record_fields = self.columns.collect {|c| c.name.to_sym } if self.extjs_record_fields.empty?
|
50
53
|
{
|
51
|
-
"fields" =>
|
54
|
+
"fields" => extjs_record_fields.collect {|f|
|
52
55
|
col = self.columns.find {|c| c.name.to_sym === f}
|
56
|
+
puts "COL: " + col.to_s
|
57
|
+
|
53
58
|
type = col.type
|
54
59
|
case col.type
|
55
60
|
when :datetime || :date || :time || :timestamp
|