extjs-mvc 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/controller/controller.rb +0 -27
- data/lib/extjs/data/store.rb +42 -9
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.4
|
@@ -9,33 +9,6 @@ module ExtJS::Controller
|
|
9
9
|
#
|
10
10
|
module ClassMethods
|
11
11
|
|
12
|
-
def extjs_reader(model, fieldset)
|
13
|
-
{
|
14
|
-
"successProperty" => extjs_success_property,
|
15
|
-
"root" => extjs_root,
|
16
|
-
"messageProperty" => extjs_message_property
|
17
|
-
}.merge(model.extjs_record(fieldset))
|
18
|
-
end
|
19
|
-
|
20
|
-
def extjs_proxy(params)
|
21
|
-
proxy = {}
|
22
|
-
if params[:proxy] === 'direct'
|
23
|
-
actions = ['create', 'read', 'update', 'destroy']
|
24
|
-
proxy["api"] = {}
|
25
|
-
direct_actions.each_index do |n|
|
26
|
-
proxy["api"][actions[n]] = direct_actions[n][:name]
|
27
|
-
end
|
28
|
-
else
|
29
|
-
if params[:config]["api"]
|
30
|
-
proxy["api"] = {}
|
31
|
-
params[:config]["api"].each {|k,v| proxy["api"][k] = "/#{params[:controller]}/#{v}" }
|
32
|
-
else
|
33
|
-
proxy["url"] = "/#{params[:controller]}.#{params[:format].to_s}"
|
34
|
-
end
|
35
|
-
end
|
36
|
-
proxy
|
37
|
-
end
|
38
|
-
|
39
12
|
def extjs_root(value=nil)
|
40
13
|
ExtJS::MVC.root = value unless value.nil?
|
41
14
|
ExtJS::MVC.root
|
data/lib/extjs/data/store.rb
CHANGED
@@ -7,19 +7,21 @@ module ExtJS::Data
|
|
7
7
|
|
8
8
|
def initialize(*params)
|
9
9
|
options = params.extract_options!
|
10
|
-
options[:format] = 'json' if options[:format].nil?
|
11
10
|
|
12
|
-
@config = options[:config]
|
13
|
-
@format = options[:format]
|
11
|
+
@config = options[:config] || {}
|
12
|
+
@format = options[:format] || 'json'
|
13
|
+
@fieldset = options[:fieldset] || :default
|
14
|
+
@schema = options[:schema]
|
14
15
|
@proxy = options[:proxy] || 'http'
|
15
16
|
@writer = options[:writer]
|
16
17
|
@type = (options[:type].nil?) ? @proxy === 'direct' ? 'Ext.data.DirectStore' : "Ext.data.#{@format.capitalize}Store" : options[:type]
|
17
|
-
|
18
|
-
@
|
18
|
+
|
19
|
+
@controller = self.class.get_controller(options[:controller])
|
20
|
+
@model = self.class.get_model(options[:controller], options[:model])
|
19
21
|
|
20
22
|
# Merge Reader/Proxy config
|
21
|
-
@config.merge!(
|
22
|
-
@config.merge!(
|
23
|
+
@config.merge!(reader)
|
24
|
+
@config.merge!(proxy)
|
23
25
|
@config["format"] = @format
|
24
26
|
|
25
27
|
# Set storeId implicitly based upon Model name if not set explicitly
|
@@ -63,8 +65,10 @@ module ExtJS::Data
|
|
63
65
|
"<script>new #{@type}(#{@config.to_json});#{script}</script>"
|
64
66
|
end
|
65
67
|
end
|
68
|
+
|
69
|
+
private
|
66
70
|
|
67
|
-
def get_controller(name)
|
71
|
+
def self.get_controller(name)
|
68
72
|
if (defined?(Rails))
|
69
73
|
"#{name.to_s.camelize}Controller".constantize
|
70
74
|
else
|
@@ -72,12 +76,41 @@ module ExtJS::Data
|
|
72
76
|
end
|
73
77
|
end
|
74
78
|
|
75
|
-
def get_model(controller, model)
|
79
|
+
def self.get_model(controller, model)
|
76
80
|
if (defined?(Rails))
|
77
81
|
((model) ? model : controller.singularize).camelize.constantize
|
78
82
|
else
|
79
83
|
Extlib::Inflection.constantize(Extlib::Inflection.camelize(((model) ? model : Extlib::Inflection.singularize(controller))))
|
80
84
|
end
|
81
85
|
end
|
86
|
+
|
87
|
+
def proxy
|
88
|
+
proxy = {}
|
89
|
+
if @proxy === 'direct'
|
90
|
+
actions = ['create', 'read', 'update', 'destroy']
|
91
|
+
proxy["api"] = {}
|
92
|
+
@controller.direct_actions.each_index do |n|
|
93
|
+
proxy["api"][actions[n]] = @controller.direct_actions[n][:name]
|
94
|
+
end
|
95
|
+
else
|
96
|
+
if @config["api"]
|
97
|
+
proxy["api"] = {}
|
98
|
+
@config["api"].each {|k,v| proxy["api"][k] = "/#{@controller.controller_name}/#{v}" }
|
99
|
+
else
|
100
|
+
proxy["url"] = "/#{@controller.controller_name}.#{@format.to_s}"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
proxy
|
104
|
+
end
|
105
|
+
|
106
|
+
def reader
|
107
|
+
{
|
108
|
+
"successProperty" => @controller.extjs_success_property,
|
109
|
+
"root" => @controller.extjs_root,
|
110
|
+
"messageProperty" => @controller.extjs_message_property
|
111
|
+
}.merge(@schema || @model.extjs_record(@fieldset))
|
112
|
+
end
|
113
|
+
|
114
|
+
|
82
115
|
end
|
83
116
|
end
|
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.3.
|
4
|
+
version: 0.3.4
|
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: 2010-02-
|
12
|
+
date: 2010-02-20 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|