extjs-mvc 0.1.24 → 0.1.25

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 CHANGED
@@ -1 +1 @@
1
- 0.1.24
1
+ 0.1.25
@@ -3,7 +3,7 @@ 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
6
+ model.class_eval do
7
7
  cattr_accessor :extjs_record_fields
8
8
  end
9
9
  model.extjs_record_fields = []
@@ -32,9 +32,7 @@ module ExtJS
32
32
  def extjs_fields(*params)
33
33
  options = params.extract_options!
34
34
  if !options.keys.empty?
35
- if options[:only]
36
- self.extjs_record_fields = options[:only]
37
- elsif options[:exclude]
35
+ if options[:exclude]
38
36
  self.extjs_record_fields = self.columns.reject {|c| options[:exclude].find {|ex| c.name.to_sym === ex}}.collect {|c| c.name.to_sym}
39
37
  end
40
38
  elsif !params.empty?
@@ -49,22 +47,30 @@ module ExtJS
49
47
  # eg: {name:'foo', type: 'string'}
50
48
  #
51
49
  def extjs_record
52
- self.extjs_record_fields = self.columns.collect {|c| c.name.to_sym } if self.extjs_record_fields.empty?
53
- {
50
+ if self.extjs_record_fields.empty?
51
+ self.extjs_record_fields = self.columns.collect {|c| c.name.to_sym }
52
+ self.extjs_record_fields.concat(self.reflect_on_all_associations.collect {|assn| assn.name})
53
+ end
54
+
55
+ return {
54
56
  "fields" => self.extjs_record_fields.collect {|f|
55
- col = self.columns.find {|c| c.name.to_sym === f}
56
- type = col.type
57
- case col.type
58
- when :datetime || :date || :time || :timestamp
59
- type = :date
60
- when :text
61
- type = :string
62
- when :integer
63
- type = :int
57
+ if col = self.columns_hash[f.to_s]
58
+ type = col.type
59
+ case col.type
60
+ when :datetime || :date || :time || :timestamp
61
+ type = :date
62
+ when :text
63
+ type = :string
64
+ when :integer
65
+ type = :int
66
+ end
67
+ field = {:name => col.name, :allowBlank => (col.primary) ? true : col.null, :type => type}
68
+ field[:dateFormat] = "c" if col.type === :datetime || col.type === :date # <-- ugly hack for date
69
+ field
70
+ elsif self.reflections[f]
71
+ assn = self.reflections[f]
72
+ field = {:name => assn.name, :allowBlank => true, :type => 'auto'}
64
73
  end
65
- field = {:name => col.name, :allowBlank => (col.primary) ? true : col.null, :type => type}
66
- field[:dateFormat] = "c" if col.type === :datetime || col.type === :date # <-- ugly hack for date
67
- field
68
74
  },
69
75
  "idProperty" => self.primary_key
70
76
  }
@@ -15,7 +15,7 @@ module ExtJS::Data
15
15
  @proxy = options[:proxy] || 'http'
16
16
  @writer = options[:writer]
17
17
  @type = (@proxy === 'direct' ? @proxy : @format).capitalize
18
- @controller = "#{options[:controller].to_s.capitalize}Controller".constantize
18
+ @controller = "#{options[:controller].to_s.camelize}Controller".constantize
19
19
  @model = ((options[:model]) ? options[:model] : @controller.controller_name.singularize).camelize.constantize
20
20
 
21
21
  # Merge Reader/Proxy config
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.24
4
+ version: 0.1.25
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-08 00:00:00 -07:00
12
+ date: 2009-09-13 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -51,7 +51,6 @@ files:
51
51
  - test/test_helper.rb
52
52
  has_rdoc: true
53
53
  homepage: http://github.com/extjs/mvc
54
- licenses:
55
54
  post_install_message:
56
55
  rdoc_options:
57
56
  - --charset=UTF-8
@@ -72,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
71
  requirements: []
73
72
 
74
73
  rubyforge_project:
75
- rubygems_version: 1.3.5
74
+ rubygems_version: 1.2.0
76
75
  signing_key:
77
76
  specification_version: 2
78
77
  summary: Ruby tools for ExtJS development