netzke-core 0.6.5 → 0.6.6

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.
Files changed (54) hide show
  1. data/CHANGELOG.rdoc +7 -0
  2. data/TODO +2 -0
  3. data/app/controllers/netzke_controller.rb +72 -20
  4. data/features/actions.feature +1 -1
  5. data/features/component_loader.feature +13 -1
  6. data/features/ext.direct.feature +32 -0
  7. data/features/i18n.feature +32 -0
  8. data/features/inheritance.feature +2 -2
  9. data/features/step_definitions/generic_steps.rb +21 -5
  10. data/features/step_definitions/touch_steps.rb +3 -0
  11. data/features/support/env.rb +4 -0
  12. data/features/support/paths.rb +6 -0
  13. data/features/touch.feature +10 -0
  14. data/javascripts/core.js +10 -15
  15. data/javascripts/ext.js +92 -1
  16. data/javascripts/touch.js +11 -0
  17. data/lib/netzke/actions.rb +13 -8
  18. data/lib/netzke/base.rb +32 -45
  19. data/lib/netzke/configuration.rb +53 -0
  20. data/lib/netzke/core/options_hash.rb +27 -0
  21. data/lib/netzke/core/version.rb +1 -1
  22. data/lib/netzke/core.rb +15 -5
  23. data/lib/netzke/core_ext/hash.rb +10 -8
  24. data/lib/netzke/inheritance.rb +31 -0
  25. data/lib/netzke/javascript.rb +45 -2
  26. data/lib/netzke/railz/action_view_ext.rb +8 -0
  27. data/lib/netzke/railz/controller_extensions.rb +1 -1
  28. data/lib/netzke/railz/engine.rb +27 -0
  29. data/lib/netzke/railz.rb +1 -0
  30. data/lib/netzke/session.rb +4 -0
  31. data/lib/netzke/state.rb +6 -6
  32. data/lib/netzke-core.rb +0 -23
  33. data/netzke-core.gemspec +27 -4
  34. data/spec/component/actions_spec.rb +2 -2
  35. data/spec/component/configuration_spec.rb +61 -0
  36. data/test/rails_app/Gemfile +1 -1
  37. data/test/rails_app/Gemfile.lock +48 -46
  38. data/test/rails_app/app/components/component_loader.rb +34 -1
  39. data/test/rails_app/app/components/ext_direct/composite.rb +48 -0
  40. data/test/rails_app/app/components/ext_direct/details.rb +13 -0
  41. data/test/rails_app/app/components/ext_direct/selector.rb +31 -0
  42. data/test/rails_app/app/components/ext_direct/statistics.rb +13 -0
  43. data/test/rails_app/app/components/extended_localized_panel.rb +2 -0
  44. data/test/rails_app/app/components/extended_server_caller.rb +0 -1
  45. data/test/rails_app/app/components/localized_panel.rb +28 -0
  46. data/test/rails_app/app/components/server_caller.rb +1 -0
  47. data/test/rails_app/app/components/server_counter.rb +123 -0
  48. data/test/rails_app/app/controllers/application_controller.rb +7 -0
  49. data/test/rails_app/config/initializers/backtrace_silencers.rb +1 -1
  50. data/test/rails_app/config/initializers/netzke.rb +1 -1
  51. data/test/rails_app/config/locales/en.yml +9 -2
  52. data/test/rails_app/config/locales/es.yml +11 -0
  53. data/test/rails_app/config/routes.rb +2 -2
  54. metadata +28 -16
@@ -33,6 +33,59 @@ module Netzke
33
33
  end
34
34
  end
35
35
 
36
+ # Used to define class-level configuration options for a component, e.g.:
37
+ #
38
+ # class Netzke::Basepack::GridPanel < Netzke::Base
39
+ # class_config_option :rows_reordering_available, true
40
+ # ...
41
+ # end
42
+ #
43
+ # This can later be set in the application configuration:
44
+ #
45
+ # module RailsApp
46
+ # class Application < Rails::Application
47
+ # config.netzke.basepack.grid_panel.rows_reordering_available = false
48
+ # ...
49
+ # end
50
+ # end
51
+ #
52
+ # Configuration options can be accessed as class attributes:
53
+ #
54
+ # Netzke::Basepack::GridPanel.rows_reordering_available # => false
55
+ def class_config_option(name, default_value)
56
+ value = if app_level_config.has_key?(name.to_sym)
57
+ if app_level_config[name.to_sym].is_a?(Hash) && default_value.is_a?(Hash)
58
+ default_value.deep_merge(app_level_config[name.to_sym])
59
+ else
60
+ app_level_config[name.to_sym]
61
+ end
62
+ else
63
+ default_value
64
+ end
65
+
66
+ class_attribute(name.to_sym)
67
+ self.send("#{name}=", value)
68
+ end
69
+
70
+ protected
71
+
72
+ def app_level_config
73
+ @app_level_config ||= class_ancestors.inject({}) do |r,klass|
74
+ r.deep_merge(klass.app_level_config_excluding_parents)
75
+ end
76
+ end
77
+
78
+ def app_level_config_excluding_parents
79
+ path_parts = name.split("::").map(&:underscore)[1..-1]
80
+ if path_parts.present?
81
+ path_parts.inject(Netzke::Core.config) do |r,part|
82
+ r.send(part)
83
+ end
84
+ else
85
+ {}
86
+ end
87
+ end
88
+
36
89
  end
37
90
 
38
91
  module InstanceMethods
@@ -0,0 +1,27 @@
1
+ module Netzke
2
+ module Core
3
+ # Allows deep-nested configuration without previously defining the hash tree:
4
+ #
5
+ # config = Netzke::Core::OptionsHash.new
6
+ # config.basepack.grid_panel.add_form.with_tools = true
7
+ # config
8
+ # => {:basepack=>{:grid_panel=>{:add_form=>{:with_tools=>true}}}}
9
+ class OptionsHash < ::Hash
10
+ def []=(key, value)
11
+ super(key.to_sym, value)
12
+ end
13
+
14
+ def [](key)
15
+ super(key.to_sym)
16
+ end
17
+
18
+ def method_missing(name, *args)
19
+ if name.to_s =~ /(.*)=$/
20
+ self[$1.to_sym] = args.first
21
+ else
22
+ self.has_key?(name) ? self[name] : self[name] = OptionsHash.new
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -3,7 +3,7 @@ module Netzke
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 6
6
- PATCH = 5
6
+ PATCH = 6
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
9
9
  end
data/lib/netzke/core.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'active_support/core_ext'
2
+ require 'netzke/core/options_hash'
2
3
  require 'netzke/core/version'
3
4
  require 'netzke/core/session'
4
5
  require 'netzke/core/masquerading'
@@ -19,6 +20,10 @@ module Netzke
19
20
  extend Session
20
21
  extend Masquerading
21
22
 
23
+ # Configuration specified at the initialization times (set in the Engine in case of Rails)
24
+ mattr_accessor :config
25
+ @@config = {}
26
+
22
27
  # Ext or Touch
23
28
  mattr_accessor :platform
24
29
  @@platform = :ext
@@ -46,18 +51,23 @@ module Netzke
46
51
  mattr_accessor :external_ext_css
47
52
  @@external_ext_css = []
48
53
 
49
- # Set in the Engine after_initialize callback
50
- mattr_accessor :ext_location # TODO: rename to ext_path
51
- mattr_accessor :touch_location # TODO: rename to touch_path
52
- mattr_accessor :with_icons
53
-
54
54
  mattr_accessor :icons_uri
55
55
  @@icons_uri = "/images/icons"
56
56
 
57
57
  mattr_accessor :persistence_manager
58
58
  @@persistence_manager = "NetzkeComponentState"
59
59
 
60
+ # The amount of retries that the direct remoting provider will attempt in case of failure
61
+ mattr_accessor :js_direct_max_retries
62
+ @@js_direct_max_retries = 0
63
+
60
64
  # Set in the Engine after_initialize callback
65
+ mattr_accessor :ext_location # TODO: rename to ext_path
66
+
67
+ mattr_accessor :touch_location # TODO: rename to touch_path
68
+
69
+ mattr_accessor :with_icons
70
+
61
71
  mattr_accessor :persistence_manager_class
62
72
 
63
73
  def self.setup
@@ -69,16 +69,18 @@ class Hash
69
69
  freeze
70
70
  end
71
71
 
72
- # Javascrit-like access to Hash values
73
- def method_missing(method, *args)
74
- if method.to_s =~ /=$/
75
- method_base = method.to_s.sub(/=$/,'').to_sym
76
- key = self[method_base.to_s].nil? ? method_base : method_base.to_s
77
- self[key] = args.first
72
+ # From http://rubyworks.github.com/facets
73
+ def update_keys #:yield:
74
+ if block_given?
75
+ keys.each { |old_key| store(yield(old_key), delete(old_key)) }
78
76
  else
79
- key = self[method.to_s].nil? ? method : method.to_s
80
- self[key]
77
+ to_enum(:update_keys)
81
78
  end
82
79
  end
83
80
 
81
+ def literalize_keys
82
+ update_keys{ |k| k.to_s.l }
83
+ self
84
+ end
85
+
84
86
  end
@@ -0,0 +1,31 @@
1
+ module Netzke
2
+ module Inheritance
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ # All ancestor classes in the Netzke class hierarchy (i.e. up to Netzke::Base)
7
+ def class_ancestors
8
+ if self == Netzke::Base
9
+ []
10
+ else
11
+ superclass.class_ancestors + [self]
12
+ end
13
+ end
14
+
15
+ # Same as +read_inheritable_attribute+ returning a hash, but returns empty hash when it's equal to superclass's
16
+ def read_clean_inheritable_hash(attr_name)
17
+ res = read_inheritable_attribute(attr_name) || {}
18
+ # We don't want here any values from the superclass (which is the consequence of using inheritable attributes).
19
+ res == self.superclass.read_inheritable_attribute(attr_name) ? {} : res
20
+ end
21
+
22
+ # Same as +read_inheritable_attribute+ returning a hash, but returns empty hash when it's equal to superclass's
23
+ def read_clean_inheritable_array(attr_name)
24
+ res = read_inheritable_attribute(attr_name) || []
25
+ # We don't want here any values from the superclass (which is the consequence of using inheritable attributes).
26
+ res == self.superclass.read_inheritable_attribute(attr_name) ? [] : res
27
+ end
28
+
29
+ end
30
+ end
31
+ end
@@ -103,6 +103,35 @@ module Netzke
103
103
  end
104
104
  end
105
105
 
106
+ # Defines the "i18n" config property, that is a translation object for this component, such as:
107
+ # i18n: {
108
+ # overwriteConfirm: "Are you sure you want to overwrite preset '{0}'?",
109
+ # overwriteConfirmTitle: "Overwriting preset",
110
+ # deleteConfirm: "Are you sure you want to delete preset '{0}'?",
111
+ # deleteConfirmTitle: "Deleting preset"
112
+ # }
113
+ #
114
+ # E.g.:
115
+ # js_translate :overwrite_confirm, :overwrite_confirm_title, :delete_confirm, :delete_confirm_title
116
+ #
117
+ # TODO: make the name of the root property configurable
118
+ def js_translate(*properties)
119
+ if properties.empty?
120
+ read_clean_inheritable_hash(:js_translated_properties)
121
+ else
122
+ current_translated_properties = read_clean_inheritable_hash(:js_translated_properties)
123
+ properties.each do |p|
124
+ if p.is_a?(Hash)
125
+ # TODO: make it possible to nest translated objects
126
+ else
127
+ current_translated_properties[p] = p
128
+ end
129
+ end
130
+
131
+ write_inheritable_attribute(:js_translated_properties, current_translated_properties)
132
+ end
133
+ end
134
+
106
135
  # Use it to "mixin" JavaScript objects defined in a separate file.
107
136
  #
108
137
  # You do not _have_ to use +js_method+ or +js_properties+ if those methods or properties are not supposed to be changed _dynamically_ (by means of configuring the component on the class level). Instead, you may "mixin" a JavaScript object defined in the JavaScript file named following a certain convention. This way static JavaScript code will rest in a corresponding .js file, not in the Ruby class. E.g.:
@@ -136,7 +165,7 @@ module Netzke
136
165
  end
137
166
 
138
167
  # Builds this component's xtype
139
- # E.g.: netzkewindow, netzkegridpanel
168
+ # E.g.: netzkebasepackwindow, netzkebasepackgridpanel
140
169
  def js_xtype
141
170
  name.gsub("::", "").downcase
142
171
  end
@@ -227,7 +256,9 @@ module Netzke
227
256
  end
228
257
 
229
258
  module InstanceMethods
230
- # Config that, after being converted to JSON, is used for instantiating the component in JavaScript.
259
+ # The result of this method (a hash) is converted to a JSON object and passed as the configuration parameter
260
+ # to the constructor of our JavaScript class. Override it when you want to pass any extra configuration
261
+ # to the JavaScript side.
231
262
  def js_config
232
263
  res = {}
233
264
 
@@ -267,6 +298,8 @@ module Netzke
267
298
  # Items (nested Ext/Netzke components)
268
299
  res[:items] = items unless items.blank?
269
300
 
301
+ res[:i18n] = js_translate_properties if js_translate_properties.present?
302
+
270
303
  res
271
304
  end
272
305
 
@@ -285,6 +318,16 @@ module Netzke
285
318
  config[:ext_config] || {}
286
319
  end
287
320
 
321
+ private
322
+
323
+ # Merges all the translations in the class hierarchy
324
+ def js_translate_properties
325
+ @js_translate_properties ||= self.class.class_ancestors.inject({}) do |r,klass|
326
+ hsh = klass.js_translate.keys.inject({}) { |h,t| h.merge(t => I18n.t("#{klass.i18n_id}.#{t}")) }
327
+ r.merge(hsh)
328
+ end
329
+ end
330
+
288
331
  end
289
332
  end
290
333
  end
@@ -82,5 +82,13 @@ module Netzke
82
82
  end
83
83
 
84
84
  end
85
+
86
+ def netzke_call(global_id,fun,*params)
87
+ fun=fun.to_s.camelize(:lower)
88
+ p=params.inject([]) do |r,p|
89
+ r << p.to_json
90
+ end.join(', ')
91
+ "Ext.getCmp('#{global_id}').#{fun}(#{p});"
92
+ end
85
93
  end
86
94
  end
@@ -26,7 +26,7 @@ module Netzke
26
26
  end
27
27
 
28
28
  def set_controller
29
- ::Netzke::Core.controller = self
29
+ ::Netzke::Core.controller = self
30
30
  end
31
31
  end
32
32
  end
@@ -0,0 +1,27 @@
1
+ module Netzke
2
+ module Railz
3
+ class Engine < Rails::Engine
4
+ config.netzke = Netzke::Core::OptionsHash.new
5
+
6
+ # before loading initializers and classes (in app/**)
7
+ config.before_initialize do
8
+ Netzke::Core.config = config.netzke
9
+ Netzke::Core.ext_location = Rails.root.join("public", "extjs")
10
+ Netzke::Core.touch_location = Rails.root.join("public", "sencha-touch")
11
+ Netzke::Core.persistence_manager_class = Netzke::Core.persistence_manager.constantize rescue nil
12
+ end
13
+
14
+ # after loading initializers and classes
15
+ config.after_initialize do
16
+ Netzke::Core.with_icons = File.exists?("#{::Rails.root}/public#{Netzke::Core.icons_uri}") if Netzke::Core.with_icons.nil?
17
+
18
+ # If need to cache classes, memoize Netzke::Base.constantize_class_name for performance
19
+ if Rails.configuration.cache_classes
20
+ class << Netzke::Base
21
+ memoize :constantize_class_name
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
data/lib/netzke/railz.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'netzke/railz/engine'
1
2
  require 'netzke/railz/routes'
2
3
  require 'netzke/railz/action_view_ext'
3
4
  require 'netzke/railz/controller_extensions'
@@ -16,6 +16,10 @@ module Netzke
16
16
  (Netzke::Core.session[@component_id] ||= {})[key] = value
17
17
  # super
18
18
  end
19
+
20
+ def clear
21
+ Netzke::Core.session[@component_id].clear if Netzke::Core.session[@component_id]
22
+ end
19
23
  end
20
24
 
21
25
  # Top-level session (straight from the controller).
data/lib/netzke/state.rb CHANGED
@@ -28,7 +28,7 @@ module Netzke
28
28
 
29
29
  # Component's persistent state.
30
30
  def state
31
- @state ||= (state_manager.state || {}).symbolize_keys
31
+ @state ||= (state_manager.try(:state) || {}).symbolize_keys
32
32
  end
33
33
 
34
34
  # Merges passed hash into component's state.
@@ -40,18 +40,18 @@ module Netzke
40
40
  #
41
41
  # update_state(:peoples_most_feared_number => 13)
42
42
  def update_state(*args)
43
- state_manager.update_state!(args.first.is_a?(Hash) ? args.first : {args.first => args.last})
43
+ state_manager.try(:update_state!, args.first.is_a?(Hash) ? args.first : {args.first => args.last})
44
44
  @state = nil # reset cache
45
45
  end
46
46
 
47
47
  # Component's persistent state.
48
48
  def global_state
49
- @global_state ||= (global_state_manager.state || {}).symbolize_keys
49
+ @global_state ||= (global_state_manager.try(:state) || {}).symbolize_keys
50
50
  end
51
51
 
52
52
  # Merges passed hash into component's state.
53
53
  def update_global_state(hsh)
54
- global_state_manager.update_state!(hsh)
54
+ global_state_manager.try(:update_state!, hsh)
55
55
  @global_state = nil # reset cache
56
56
  end
57
57
 
@@ -71,7 +71,7 @@ module Netzke
71
71
 
72
72
  # Initialized state manager class. At this moment this class has current_user, component, and session set.
73
73
  def state_manager
74
- @state_manager ||= Netzke::Core.persistence_manager_class.init({
74
+ @state_manager ||= Netzke::Core.persistence_manager_class && Netzke::Core.persistence_manager_class.init({
75
75
  :component => persistence_key,
76
76
  :current_user => Netzke::Core.controller.respond_to?(:current_user) && Netzke::Core.controller.current_user,
77
77
  :session => Netzke::Core.session
@@ -80,7 +80,7 @@ module Netzke
80
80
 
81
81
  # Initialized state manager class, configured for managing global (not component specific) settings. At this moment this class has current_user and session set.
82
82
  def global_state_manager
83
- @global_state_manager ||= Netzke::Core.persistence_manager_class.init({
83
+ @global_state_manager ||= Netzke::Core.persistence_manager_class && Netzke::Core.persistence_manager_class.init({
84
84
  :current_user => Netzke::Core.controller.respond_to?(:current_user) && Netzke::Core.controller.current_user,
85
85
  :session => Netzke::Core.session
86
86
  })
data/lib/netzke-core.rb CHANGED
@@ -6,29 +6,6 @@ require 'netzke/base'
6
6
  module Netzke
7
7
  autoload :Core, 'netzke/core'
8
8
  autoload :ExtComponent, 'netzke/ext_component'
9
-
10
- module Core
11
- class Engine < ::Rails::Engine
12
- # before loading initializers and classes (in app/**)
13
- config.before_initialize do
14
- Netzke::Core.ext_location = Rails.root.join("public", "extjs")
15
- Netzke::Core.touch_location = Rails.root.join("public", "sencha-touch")
16
- Netzke::Core.persistence_manager_class = Netzke::Core.persistence_manager.constantize rescue nil
17
- end
18
-
19
- # after loading initializers and classes
20
- config.after_initialize do
21
- Netzke::Core.with_icons = File.exists?("#{::Rails.root}/public#{Netzke::Core.icons_uri}") if Netzke::Core.with_icons.nil?
22
-
23
- # If need to cache classes, memoize Netzke::Base.constantize_class_name for performance
24
- if Rails.configuration.cache_classes
25
- class << Netzke::Base
26
- memoize :constantize_class_name
27
- end
28
- end
29
- end
30
- end
31
- end
32
9
  end
33
10
 
34
11
  # Rails specific
data/netzke-core.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{netzke-core}
8
- s.version = "0.6.5"
8
+ s.version = "0.6.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sergei Kozlov"]
12
- s.date = %q{2011-01-14}
12
+ s.date = %q{2011-02-26}
13
13
  s.description = %q{Allows building ExtJS/Rails reusable code in a DRY way}
14
14
  s.email = %q{sergei@playcode.nl}
15
15
  s.extra_rdoc_files = [
@@ -37,7 +37,9 @@ Gem::Specification.new do |s|
37
37
  "features/component_loader.feature",
38
38
  "features/composition.feature",
39
39
  "features/custom_css.feature",
40
+ "features/ext.direct.feature",
40
41
  "features/file_inclusion.feature",
42
+ "features/i18n.feature",
41
43
  "features/inheritance.feature",
42
44
  "features/js_include.feature",
43
45
  "features/nested_views.feature",
@@ -45,9 +47,11 @@ Gem::Specification.new do |s|
45
47
  "features/scopes.feature",
46
48
  "features/step_definitions/custom_css_steps.rb",
47
49
  "features/step_definitions/generic_steps.rb",
50
+ "features/step_definitions/touch_steps.rb",
48
51
  "features/step_definitions/web_steps.rb",
49
52
  "features/support/env.rb",
50
53
  "features/support/paths.rb",
54
+ "features/touch.feature",
51
55
  "init.rb",
52
56
  "install.rb",
53
57
  "javascripts/core.js",
@@ -60,6 +64,7 @@ Gem::Specification.new do |s|
60
64
  "lib/netzke/configuration.rb",
61
65
  "lib/netzke/core.rb",
62
66
  "lib/netzke/core/masquerading.rb",
67
+ "lib/netzke/core/options_hash.rb",
63
68
  "lib/netzke/core/session.rb",
64
69
  "lib/netzke/core/version.rb",
65
70
  "lib/netzke/core_ext.rb",
@@ -70,6 +75,7 @@ Gem::Specification.new do |s|
70
75
  "lib/netzke/core_ext/time_with_zone.rb",
71
76
  "lib/netzke/embedding.rb",
72
77
  "lib/netzke/ext_component.rb",
78
+ "lib/netzke/inheritance.rb",
73
79
  "lib/netzke/javascript.rb",
74
80
  "lib/netzke/javascript/scopes.rb",
75
81
  "lib/netzke/railz.rb",
@@ -77,6 +83,7 @@ Gem::Specification.new do |s|
77
83
  "lib/netzke/railz/action_view_ext/ext.rb",
78
84
  "lib/netzke/railz/action_view_ext/touch.rb",
79
85
  "lib/netzke/railz/controller_extensions.rb",
86
+ "lib/netzke/railz/engine.rb",
80
87
  "lib/netzke/railz/routes.rb",
81
88
  "lib/netzke/services.rb",
82
89
  "lib/netzke/session.rb",
@@ -87,6 +94,7 @@ Gem::Specification.new do |s|
87
94
  "spec/component/actions_spec.rb",
88
95
  "spec/component/base_spec.rb",
89
96
  "spec/component/composition_spec.rb",
97
+ "spec/component/configuration_spec.rb",
90
98
  "spec/component/javascript_spec.rb",
91
99
  "spec/component/state_spec.rb",
92
100
  "spec/core_ext_spec.rb",
@@ -113,9 +121,14 @@ Gem::Specification.new do |s|
113
121
  "test/rails_app/app/components/component_with_js_mixin/javascripts/method_set_two.js",
114
122
  "test/rails_app/app/components/component_with_session_persistence.rb",
115
123
  "test/rails_app/app/components/deprecated/server_caller.rb",
124
+ "test/rails_app/app/components/ext_direct/composite.rb",
125
+ "test/rails_app/app/components/ext_direct/details.rb",
126
+ "test/rails_app/app/components/ext_direct/selector.rb",
127
+ "test/rails_app/app/components/ext_direct/statistics.rb",
116
128
  "test/rails_app/app/components/extended_component_with_actions.rb",
117
129
  "test/rails_app/app/components/extended_component_with_js_mixin.rb",
118
130
  "test/rails_app/app/components/extended_component_with_js_mixin/javascripts/some_method_set.js",
131
+ "test/rails_app/app/components/extended_localized_panel.rb",
119
132
  "test/rails_app/app/components/extended_server_caller.rb",
120
133
  "test/rails_app/app/components/hello_world_component.rb",
121
134
  "test/rails_app/app/components/included.js",
@@ -123,10 +136,12 @@ Gem::Specification.new do |s|
123
136
  "test/rails_app/app/components/kinda_complex_component/basic_stuff.rb",
124
137
  "test/rails_app/app/components/kinda_complex_component/extra_stuff.rb",
125
138
  "test/rails_app/app/components/loader_of_component_with_custom_css.rb",
139
+ "test/rails_app/app/components/localized_panel.rb",
126
140
  "test/rails_app/app/components/scoped_components/deep_scoped_components/some_deep_scoped_component.rb",
127
141
  "test/rails_app/app/components/scoped_components/extended_scoped_component.rb",
128
142
  "test/rails_app/app/components/scoped_components/some_scoped_component.rb",
129
143
  "test/rails_app/app/components/server_caller.rb",
144
+ "test/rails_app/app/components/server_counter.rb",
130
145
  "test/rails_app/app/components/simple_component.rb",
131
146
  "test/rails_app/app/components/simple_panel.rb",
132
147
  "test/rails_app/app/components/simple_tab_panel.rb",
@@ -164,6 +179,7 @@ Gem::Specification.new do |s|
164
179
  "test/rails_app/config/initializers/secret_token.rb",
165
180
  "test/rails_app/config/initializers/session_store.rb",
166
181
  "test/rails_app/config/locales/en.yml",
182
+ "test/rails_app/config/locales/es.yml",
167
183
  "test/rails_app/config/routes.rb",
168
184
  "test/rails_app/db/development_structure.sql",
169
185
  "test/rails_app/db/migrate/20110110132720_create_netzke_component_states.rb",
@@ -200,12 +216,13 @@ Gem::Specification.new do |s|
200
216
 
201
217
  }
202
218
  s.require_paths = ["lib"]
203
- s.rubygems_version = %q{1.3.7}
219
+ s.rubygems_version = %q{1.5.2}
204
220
  s.summary = %q{Build ExtJS/Rails components with minimum effort}
205
221
  s.test_files = [
206
222
  "spec/component/actions_spec.rb",
207
223
  "spec/component/base_spec.rb",
208
224
  "spec/component/composition_spec.rb",
225
+ "spec/component/configuration_spec.rb",
209
226
  "spec/component/javascript_spec.rb",
210
227
  "spec/component/state_spec.rb",
211
228
  "spec/core_ext_spec.rb",
@@ -218,18 +235,25 @@ Gem::Specification.new do |s|
218
235
  "test/rails_app/app/components/component_with_js_mixin.rb",
219
236
  "test/rails_app/app/components/component_with_session_persistence.rb",
220
237
  "test/rails_app/app/components/deprecated/server_caller.rb",
238
+ "test/rails_app/app/components/ext_direct/composite.rb",
239
+ "test/rails_app/app/components/ext_direct/details.rb",
240
+ "test/rails_app/app/components/ext_direct/selector.rb",
241
+ "test/rails_app/app/components/ext_direct/statistics.rb",
221
242
  "test/rails_app/app/components/extended_component_with_actions.rb",
222
243
  "test/rails_app/app/components/extended_component_with_js_mixin.rb",
244
+ "test/rails_app/app/components/extended_localized_panel.rb",
223
245
  "test/rails_app/app/components/extended_server_caller.rb",
224
246
  "test/rails_app/app/components/hello_world_component.rb",
225
247
  "test/rails_app/app/components/kinda_complex_component.rb",
226
248
  "test/rails_app/app/components/kinda_complex_component/basic_stuff.rb",
227
249
  "test/rails_app/app/components/kinda_complex_component/extra_stuff.rb",
228
250
  "test/rails_app/app/components/loader_of_component_with_custom_css.rb",
251
+ "test/rails_app/app/components/localized_panel.rb",
229
252
  "test/rails_app/app/components/scoped_components/deep_scoped_components/some_deep_scoped_component.rb",
230
253
  "test/rails_app/app/components/scoped_components/extended_scoped_component.rb",
231
254
  "test/rails_app/app/components/scoped_components/some_scoped_component.rb",
232
255
  "test/rails_app/app/components/server_caller.rb",
256
+ "test/rails_app/app/components/server_counter.rb",
233
257
  "test/rails_app/app/components/simple_component.rb",
234
258
  "test/rails_app/app/components/simple_panel.rb",
235
259
  "test/rails_app/app/components/simple_tab_panel.rb",
@@ -271,7 +295,6 @@ Gem::Specification.new do |s|
271
295
  ]
272
296
 
273
297
  if s.respond_to? :specification_version then
274
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
275
298
  s.specification_version = 3
276
299
 
277
300
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
@@ -40,8 +40,8 @@ module Netzke
40
40
  action :action_one, :text => "Action 1"
41
41
  action :action_five, :text => "Action Five"
42
42
 
43
- action :action_two do
44
- super().merge :disabled => true, :text => super()[:text] + ", extended"
43
+ def action_two_action
44
+ super.merge(:disabled => true, :text => normalize_action_config(super)[:text] + ", extended")
45
45
  end
46
46
 
47
47
  action :action_three do
@@ -0,0 +1,61 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'netzke-core'
3
+
4
+ describe Netzke::Configuration do
5
+ it "should be able to configure components on the class level" do
6
+
7
+ Netzke::Core.config = Netzke::Core::OptionsHash.new
8
+ Netzke::Core.config.my_components.component_one.to_override = 2
9
+ Netzke::Core.config.my_components.component_one.another_to_override = 20
10
+
11
+ Netzke::Core.config.my_components.component_one.options_set.option_three = "three"
12
+ Netzke::Core.config.my_components.component_one.options_set.option_four = 4
13
+
14
+ Netzke::Core.config.my_components.child_component_one.to_override = 4
15
+
16
+ module Netzke
17
+ module MyComponents
18
+ class ComponentOne < Netzke::Base
19
+ class_config_option :amount_cool_things, 100
20
+ class_config_option :with_cool_feature, true
21
+ class_config_option :to_override, 1
22
+ class_config_option :another_to_override, 10
23
+
24
+ class_config_option :options_set, {
25
+ :option_one => 1,
26
+ :option_two => 2,
27
+ :option_three => 3
28
+ }
29
+ end
30
+
31
+ class ChildComponentOne < ComponentOne
32
+ class_config_option :with_cool_feature, false
33
+ class_config_option :with_another_cool_feature, true
34
+ class_config_option :to_override, 3 # in order to make this configurable, we need to declare it again (not enough to have declaration in the parent class)
35
+ self.another_to_override = 30 # freeze this config option for this class - it'll not be configurable
36
+ end
37
+
38
+ end
39
+ end
40
+
41
+ Netzke::MyComponents::ComponentOne.amount_cool_things.should == 100
42
+ Netzke::MyComponents::ComponentOne.with_cool_feature.should be_true
43
+ Netzke::MyComponents::ComponentOne.to_override.should == 2
44
+ Netzke::MyComponents::ComponentOne.another_to_override.should == 20
45
+
46
+ Netzke::MyComponents::ComponentOne.options_set.should == {
47
+ :option_one => 1,
48
+ :option_two => 2,
49
+ :option_three => "three",
50
+ :option_four => 4
51
+ }
52
+
53
+ Netzke::MyComponents::ChildComponentOne.amount_cool_things.should == 100
54
+ Netzke::MyComponents::ChildComponentOne.to_override.should == 4
55
+ Netzke::MyComponents::ChildComponentOne.with_cool_feature.should be_false
56
+ Netzke::MyComponents::ChildComponentOne.with_another_cool_feature.should be_true
57
+ Netzke::MyComponents::ChildComponentOne.another_to_override.should == 30
58
+
59
+ end
60
+
61
+ end
@@ -1,6 +1,6 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'rails', '3.0.3'
3
+ gem 'rails', '3.0.4'
4
4
 
5
5
  # Bundle edge Rails instead:
6
6
  # gem 'rails', :git => 'git://github.com/rails/rails.git'