extjs-mvc 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -127,6 +127,7 @@ Now render a store in an erb template:
127
127
 
128
128
  @store = extjs_store(
129
129
  :controller => "users",
130
+ :fieldset => :grid, # <-- Specify a particular fieldset as defined in the Model (used to render DataReader)
130
131
  :proxy => "http" # <-- default
131
132
  :format => "json" # <-- default
132
133
  :model => "user", # <-- default: controller_name.singularize
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -9,12 +9,12 @@ module ExtJS::Controller
9
9
  #
10
10
  module ClassMethods
11
11
 
12
- def extjs_reader(model)
12
+ def extjs_reader(model, fieldset = nil)
13
13
  {
14
14
  "successProperty" => extjs_success_property,
15
15
  "root" => extjs_root,
16
16
  "messageProperty" => extjs_message_property
17
- }.merge(model.extjs_record)
17
+ }.merge(model.extjs_record(fieldset))
18
18
  end
19
19
 
20
20
  def extjs_proxy(params)
@@ -8,8 +8,8 @@ module ExtJS::Data
8
8
  def initialize(*params)
9
9
  options = params.extract_options!
10
10
  options[:format] = 'json' if options[:format].nil?
11
-
12
- @config = options[:config]
11
+
12
+ @config = options[:config]
13
13
  @format = options[:format]
14
14
  @proxy = options[:proxy] || 'http'
15
15
  @writer = options[:writer]
@@ -18,7 +18,7 @@ module ExtJS::Data
18
18
  @model = self.get_model(options[:controller], options[:model])
19
19
 
20
20
  # Merge Reader/Proxy config
21
- @config.merge!(@controller.extjs_reader(@model))
21
+ @config.merge!(@controller.extjs_reader(@model, options[:fieldset]))
22
22
  @config.merge!(@controller.extjs_proxy(options))
23
23
  @config["format"] = @format
24
24
 
data/lib/model/base.rb CHANGED
@@ -37,7 +37,7 @@ module ExtJS
37
37
  pk = self.class.extjs_primary_key
38
38
 
39
39
  # build the initial field data-hash
40
- data = {pk => self.send(pk)}
40
+ data = extjs_prepare_data(pk)
41
41
 
42
42
  fields.each do |field|
43
43
  next if data.has_key? field[:name] # already processed (e.g. explicit mentioning of :id)
@@ -76,6 +76,15 @@ module ExtJS
76
76
  end
77
77
  data
78
78
  end
79
+
80
+ ##
81
+ # prepares the initial data-hash. Had to implement this to fix a MongoMapper issue where pk
82
+ # is an Object. Messed things up when converting to JSON. Perhaps a better way is possible.
83
+ # Any adapter can override this but typical relational dbs with Integer pks won't need to.
84
+ #
85
+ def extjs_prepare_data(pk)
86
+ {pk => self.send(pk)}
87
+ end
79
88
  end
80
89
 
81
90
  ##
@@ -276,7 +285,6 @@ module ExtJS
276
285
  end
277
286
  field
278
287
  end
279
-
280
288
 
281
289
  # ##
282
290
  # # Returns an array of symbolized association names that will be referenced by a call to to_record
@@ -1,6 +1,7 @@
1
1
  ##
2
2
  # DataMapper adapter for ExtJS::Model mixin
3
3
  #
4
+
4
5
  module ExtJS
5
6
  module Model
6
7
  module ClassMethods
@@ -1,8 +1,15 @@
1
1
  ##
2
2
  # MongoMapper adapter to ExtJS::Model mixin
3
3
  #
4
+
4
5
  module ExtJS
5
6
  module Model
7
+ module InstanceMethods
8
+ def extjs_prepare_data(pk)
9
+ {pk => self.send(pk).to_s}
10
+ end
11
+ end
12
+
6
13
  ##
7
14
  # ClassMethods
8
15
  #
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.1
4
+ version: 0.3.2
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-17 00:00:00 -05:00
12
+ date: 2010-02-18 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency