extjs-mvc 0.1.19 → 0.1.20
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/active_record/model.rb +2 -4
- data/lib/extjs/component.rb +21 -7
- data/lib/extjs/data/store.rb +1 -1
- data/lib/helpers/component.rb +4 -2
- data/lib/helpers/store.rb +1 -1
- metadata +4 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.20
|
data/lib/active_record/model.rb
CHANGED
@@ -15,7 +15,7 @@ module ExtJS
|
|
15
15
|
module InstanceMethods
|
16
16
|
def to_record
|
17
17
|
data = {self.class.primary_key => self.send(self.class.primary_key)}
|
18
|
-
self.class.
|
18
|
+
self.class.extjs_record_fields.each do |f|
|
19
19
|
data[f] = self.send(f)
|
20
20
|
end
|
21
21
|
data
|
@@ -51,10 +51,8 @@ module ExtJS
|
|
51
51
|
def extjs_record
|
52
52
|
self.extjs_record_fields = self.columns.collect {|c| c.name.to_sym } if self.extjs_record_fields.empty?
|
53
53
|
{
|
54
|
-
"fields" => extjs_record_fields.collect {|f|
|
54
|
+
"fields" => self.extjs_record_fields.collect {|f|
|
55
55
|
col = self.columns.find {|c| c.name.to_sym === f}
|
56
|
-
puts "COL: " + col.to_s
|
57
|
-
|
58
56
|
type = col.type
|
59
57
|
case col.type
|
60
58
|
when :datetime || :date || :time || :timestamp
|
data/lib/extjs/component.rb
CHANGED
@@ -3,9 +3,9 @@
|
|
3
3
|
#
|
4
4
|
class ExtJS::Component
|
5
5
|
attr_accessor :config
|
6
|
-
def initialize(
|
7
|
-
@config = params.extract_options!
|
8
|
-
@controller = controller
|
6
|
+
def initialize(params)
|
7
|
+
@config = params#params.extract_options!
|
8
|
+
@controller = @config.delete(:controller) unless @config[:controller].nil?
|
9
9
|
|
10
10
|
@config[:items] = [] if config[:items].nil?
|
11
11
|
|
@@ -19,6 +19,11 @@ class ExtJS::Component
|
|
19
19
|
@config.merge!(params)
|
20
20
|
end
|
21
21
|
|
22
|
+
##
|
23
|
+
# Adds a config {} or ExtJS::Component instance to this component's items collection.
|
24
|
+
# NOTE: When :partial option is used a String will of course be returned. Otherwise an ExtJS::Component
|
25
|
+
# instance will be returned.
|
26
|
+
# @return {String/ExtJS::Component}
|
22
27
|
def add(*config)
|
23
28
|
options = config.extract_options!
|
24
29
|
if !options.keys.empty?
|
@@ -28,21 +33,30 @@ class ExtJS::Component
|
|
28
33
|
return @controller.render(:partial => url, :locals => {:container => self})
|
29
34
|
else
|
30
35
|
options.merge!(@partial_config) unless @partial_config.nil?
|
31
|
-
|
36
|
+
options[:controller] = @controller unless @controller.nil?
|
37
|
+
cmp = ExtJS::Component.new(options)
|
38
|
+
@partial_config = nil
|
39
|
+
@config[:items] << cmp
|
40
|
+
return cmp
|
32
41
|
end
|
33
42
|
elsif !config.empty? && config.first.kind_of?(ExtJS::Component)
|
34
43
|
cmp = config.first
|
35
44
|
cmp.apply(@partial_config) unless @partial_config.nil?
|
45
|
+
@partial_config = nil
|
36
46
|
@config[:items] << cmp.config
|
47
|
+
return cmp
|
37
48
|
end
|
38
|
-
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_json
|
52
|
+
config.to_json
|
39
53
|
end
|
40
54
|
|
41
55
|
def render
|
42
56
|
# If there are any listeners attached in json, we have to get rid of double-quotes in order to expose
|
43
57
|
# the javascript object.
|
44
58
|
# eg: "listeners":"SomeController.listeners.grid" -> {"listeners":SomeController.listeners.grid, ...}
|
45
|
-
json = @config.to_json.gsub(/\"listeners\":\s?\"([a-zA-Z\.\[\]\(\)]+)\"/, '"
|
59
|
+
json = @config.to_json.gsub(/\"(listeners|handler|scope)\":\s?\"([a-zA-Z\.\[\]\(\)]+)\"/, '"\1":\2')
|
46
60
|
"Ext.ComponentMgr.create(#{json});"
|
47
61
|
end
|
48
|
-
end
|
62
|
+
end
|
data/lib/extjs/data/store.rb
CHANGED
data/lib/helpers/component.rb
CHANGED
@@ -12,7 +12,9 @@ module ExtJS::Helpers
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def extjs_component(*params)
|
15
|
-
|
15
|
+
options = params.extract_options!
|
16
|
+
options[:controller] = self
|
17
|
+
ExtJS::Component.new(options)
|
16
18
|
end
|
17
19
|
|
18
20
|
##
|
@@ -32,4 +34,4 @@ module ExtJS::Helpers
|
|
32
34
|
"<script>\nExt.onReady(function() {\n\t#{@@onready_queue.collect {|cmp| (cmp.kind_of?(ExtJS::Component)) ? cmp.render : cmp}.join("\n\t")}\n });\n</script>"
|
33
35
|
end
|
34
36
|
end
|
35
|
-
end
|
37
|
+
end
|
data/lib/helpers/store.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extjs-mvc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Scott
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-06 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- test/test_helper.rb
|
52
52
|
has_rdoc: true
|
53
53
|
homepage: http://github.com/extjs/mvc
|
54
|
+
licenses:
|
54
55
|
post_install_message:
|
55
56
|
rdoc_options:
|
56
57
|
- --charset=UTF-8
|
@@ -71,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
72
|
requirements: []
|
72
73
|
|
73
74
|
rubyforge_project:
|
74
|
-
rubygems_version: 1.
|
75
|
+
rubygems_version: 1.3.5
|
75
76
|
signing_key:
|
76
77
|
specification_version: 2
|
77
78
|
summary: Ruby tools for ExtJS development
|