netzke-core 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +9 -6
- data/README.rdoc +14 -15
- data/Rakefile +20 -15
- data/TODO +1 -1
- data/app/controllers/netzke_controller.rb +9 -9
- data/app/models/netzke_preference.rb +27 -27
- data/features/actions.feature +1 -1
- data/features/basic.feature +1 -1
- data/features/client-server.feature +1 -1
- data/features/component_loader.feature +6 -7
- data/features/composition.feature +5 -6
- data/features/custom_css.feature +1 -1
- data/features/inheritance.feature +0 -1
- data/features/persistence.feature +3 -3
- data/features/scopes.feature +3 -3
- data/features/step_definitions/web_steps.rb +5 -5
- data/features/support/env.rb +6 -6
- data/generators/netzke_core/netzke_core_generator.rb +2 -2
- data/javascripts/core.js +43 -43
- data/lib/generators/migration_helper.rb +6 -6
- data/lib/generators/netzke/USAGE +2 -3
- data/lib/generators/netzke/core_generator.rb +7 -7
- data/lib/netzke/actions.rb +18 -18
- data/lib/netzke/base.rb +72 -85
- data/lib/netzke/composition.rb +30 -30
- data/lib/netzke/configuration.rb +15 -15
- data/lib/netzke/core/masquerading.rb +3 -3
- data/lib/netzke/core/session.rb +1 -1
- data/lib/netzke/core/version.rb +1 -1
- data/lib/netzke/core.rb +9 -9
- data/lib/netzke/core_ext/array.rb +5 -5
- data/lib/netzke/core_ext/hash.rb +7 -7
- data/lib/netzke/core_ext/string.rb +4 -4
- data/lib/netzke/core_ext/symbol.rb +3 -3
- data/lib/netzke/embedding.rb +2 -2
- data/lib/netzke/ext_component.rb +4 -4
- data/lib/netzke/javascript.rb +36 -25
- data/lib/netzke/persistence.rb +16 -16
- data/lib/netzke/rails/action_view_ext.rb +20 -20
- data/lib/netzke/rails/controller_extensions.rb +1 -1
- data/lib/netzke/rails/routes.rb +1 -1
- data/lib/netzke/services.rb +12 -12
- data/lib/netzke/session.rb +4 -4
- data/lib/netzke/stylesheets.rb +8 -8
- data/lib/netzke-core.rb +2 -2
- data/netzke-core.gemspec +4 -5
- data/spec/component/actions_spec.rb +18 -18
- data/spec/component/base_spec.rb +6 -6
- data/spec/component/composition_spec.rb +12 -12
- data/spec/component/javascript_spec.rb +2 -2
- data/spec/core_ext_spec.rb +3 -3
- data/templates/core/create_netzke_preferences.rb +1 -1
- data/test/rails_app/app/components/component_loader.rb +8 -8
- data/test/rails_app/app/components/component_with_actions.rb +9 -9
- data/test/rails_app/app/components/component_with_custom_css.rb +2 -2
- data/test/rails_app/app/components/component_with_included_js.rb +5 -5
- data/test/rails_app/app/components/component_with_session_persistence.rb +3 -3
- data/test/rails_app/app/components/deprecated/server_caller.rb +2 -2
- data/test/rails_app/app/components/extended_component_with_actions.rb +1 -1
- data/test/rails_app/app/components/extended_server_caller.rb +3 -3
- data/test/rails_app/app/components/kinda_complex_component/basic_stuff.rb +8 -8
- data/test/rails_app/app/components/kinda_complex_component/extra_stuff.rb +2 -2
- data/test/rails_app/app/components/loader_of_component_with_custom_css.rb +2 -2
- data/test/rails_app/app/components/server_caller.rb +3 -3
- data/test/rails_app/app/components/simple_component.rb +1 -1
- data/test/rails_app/app/components/simple_tab_panel.rb +2 -2
- data/test/rails_app/app/components/some_composite.rb +16 -16
- data/test/rails_app/config/routes.rb +2 -2
- data/test/test_helper.rb +1 -1
- data/test/unit/core_ext_test.rb +13 -13
- data/test/unit/netzke_core_test.rb +20 -20
- data/test/unit/netzke_preference_test.rb +12 -12
- metadata +6 -6
data/lib/netzke/composition.rb
CHANGED
@@ -3,11 +3,11 @@
|
|
3
3
|
module Netzke
|
4
4
|
module Composition
|
5
5
|
extend ActiveSupport::Concern
|
6
|
-
|
6
|
+
|
7
7
|
included do
|
8
|
-
|
8
|
+
|
9
9
|
# Loads a component on browser's request. Every Nettzke component gets this endpoint.
|
10
|
-
# <tt>params</tt> should contain:
|
10
|
+
# <tt>params</tt> should contain:
|
11
11
|
# * <tt>:cache</tt> - an array of component classes cached at the browser
|
12
12
|
# * <tt>:id</tt> - reference to the component
|
13
13
|
# * <tt>:container</tt> - Ext id of the container where in which the component will be rendered
|
@@ -21,7 +21,7 @@ module Netzke
|
|
21
21
|
component.before_load
|
22
22
|
|
23
23
|
[{
|
24
|
-
:eval_js => component.js_missing_code(cache),
|
24
|
+
:eval_js => component.js_missing_code(cache),
|
25
25
|
:eval_css => component.css_missing_code(cache)
|
26
26
|
}, {
|
27
27
|
:component_delivered => component.js_config
|
@@ -30,18 +30,18 @@ module Netzke
|
|
30
30
|
{:feedback => "Couldn't load component '#{component_name}'"}
|
31
31
|
end
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
end # included
|
35
|
-
|
35
|
+
|
36
36
|
module ClassMethods
|
37
|
-
|
37
|
+
|
38
38
|
# Defines a nested component.
|
39
39
|
# For example:
|
40
|
-
#
|
40
|
+
#
|
41
41
|
# component :users, :data_class => "GridPanel", :model => "User"
|
42
|
-
#
|
42
|
+
#
|
43
43
|
# It can also accept a block (receiving as parameter the eventual definition from super class):
|
44
|
-
#
|
44
|
+
#
|
45
45
|
# component :books do |orig|
|
46
46
|
# {:data_class => "Book", :title => orig[:title] + ", extended"}
|
47
47
|
# end
|
@@ -50,7 +50,7 @@ module Netzke
|
|
50
50
|
config[:class_name] ||= name.to_s.camelize
|
51
51
|
config[:name] = name.to_s
|
52
52
|
method_name = "_#{name}_component"
|
53
|
-
|
53
|
+
|
54
54
|
if block_given?
|
55
55
|
define_method(method_name, &block)
|
56
56
|
else
|
@@ -59,31 +59,31 @@ module Netzke
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
62
|
-
|
63
|
-
# Component's js config used when embedding components as Container's items
|
62
|
+
|
63
|
+
# Component's js config used when embedding components as Container's items
|
64
64
|
# (see some_composite.rb for an example)
|
65
65
|
def js_component(name, config = {})
|
66
66
|
::ActiveSupport::Deprecation.warn("Using js_component is deprecated. Use Symbol#component instead", caller)
|
67
67
|
config.merge(:component => name)
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
module InstanceMethods
|
73
|
-
|
73
|
+
|
74
74
|
def items
|
75
75
|
@items_with_normalized_components
|
76
76
|
end
|
77
|
-
|
77
|
+
|
78
78
|
def initial_components
|
79
79
|
{}
|
80
80
|
end
|
81
|
-
|
81
|
+
|
82
82
|
# All components for this instance, which includes components defined on class level, and components detected in :items
|
83
83
|
def components
|
84
84
|
# items if @components.nil? # simply trigger collecting @components from items
|
85
85
|
# self.class.components.merge(@components || {})
|
86
|
-
|
86
|
+
|
87
87
|
@components ||= begin
|
88
88
|
method_regexp = /^_(.+)_component$/
|
89
89
|
self.class.instance_methods.grep(method_regexp).inject({}) do |r, m|
|
@@ -148,16 +148,16 @@ module Netzke
|
|
148
148
|
composite
|
149
149
|
end
|
150
150
|
end
|
151
|
-
|
151
|
+
|
152
152
|
def dependency_classes
|
153
153
|
res = []
|
154
|
-
|
154
|
+
|
155
155
|
non_late_components.keys.each do |aggr|
|
156
156
|
res += component_instance(aggr).dependency_classes
|
157
157
|
end
|
158
|
-
|
158
|
+
|
159
159
|
res += self.class.class_ancestors
|
160
|
-
|
160
|
+
|
161
161
|
res << self.class
|
162
162
|
res.uniq
|
163
163
|
end
|
@@ -180,7 +180,7 @@ module Netzke
|
|
180
180
|
end
|
181
181
|
|
182
182
|
# Returns global id of a component in the hierarchy, based on passed reference that follows
|
183
|
-
# the double-underscore notation. Referring to "parent" is allowed. If going to far up the hierarchy will
|
183
|
+
# the double-underscore notation. Referring to "parent" is allowed. If going to far up the hierarchy will
|
184
184
|
# result in <tt>nil</tt>, while referring to a non-existent component will simply provide an erroneous ID.
|
185
185
|
# Example:
|
186
186
|
# <tt>parent__parent__child__subchild</tt> will traverse the hierarchy 2 levels up, then going down to "child",
|
@@ -198,7 +198,7 @@ module Netzke
|
|
198
198
|
end
|
199
199
|
|
200
200
|
# Method dispatcher - instantiates an component and calls the method on it
|
201
|
-
# E.g.:
|
201
|
+
# E.g.:
|
202
202
|
# users__center__get_data
|
203
203
|
# instantiates component "users", and calls "center__get_data" on it
|
204
204
|
# books__move_column
|
@@ -220,9 +220,9 @@ module Netzke
|
|
220
220
|
super
|
221
221
|
end
|
222
222
|
end
|
223
|
-
|
223
|
+
|
224
224
|
private
|
225
|
-
|
225
|
+
|
226
226
|
def normalize_components(items)
|
227
227
|
@component_index ||= 0
|
228
228
|
@items_with_normalized_components = items.each_with_index.map do |item, i|
|
@@ -238,15 +238,15 @@ module Netzke
|
|
238
238
|
end
|
239
239
|
end
|
240
240
|
end
|
241
|
-
|
241
|
+
|
242
242
|
def normalize_components_in_items
|
243
243
|
normalize_components(config[:items]) if config[:items]
|
244
244
|
end
|
245
|
-
|
245
|
+
|
246
246
|
def is_component_config?(c)
|
247
247
|
!!(c.is_a?(Hash) && c[:class_name])
|
248
248
|
end
|
249
249
|
end
|
250
|
-
|
250
|
+
|
251
251
|
end
|
252
252
|
end
|
data/lib/netzke/configuration.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
module Netzke
|
2
2
|
module Configuration
|
3
3
|
extend ActiveSupport::Concern
|
4
|
-
|
4
|
+
|
5
5
|
CONFIGURATION_LEVELS = [:default, :initial, :independent, :session, :final]
|
6
|
-
|
6
|
+
|
7
7
|
included do
|
8
8
|
CONFIGURATION_LEVELS.each do |level|
|
9
9
|
define_method("weak_#{level}_options"){ {} }
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
module ClassMethods
|
14
14
|
def setup
|
15
15
|
yield self
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
# Config options that should not go to the client side
|
19
19
|
def server_side_config_options
|
20
20
|
[:lazy_loading, :class_name]
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def config(*args, &block)
|
24
24
|
level = args.first.is_a?(Symbol) ? args.first : :final
|
25
25
|
config_hash = args.last.is_a?(Hash) && args.last
|
@@ -27,14 +27,14 @@ module Netzke
|
|
27
27
|
if block_given?
|
28
28
|
define_method(:"weak_#{level}_options", &block)
|
29
29
|
else
|
30
|
-
define_method(:"weak_#{level}_options") do
|
30
|
+
define_method(:"weak_#{level}_options") do
|
31
31
|
config_hash
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
35
|
-
|
35
|
+
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
module InstanceMethods
|
39
39
|
# Default config - before applying any passed configuration
|
40
40
|
def default_config
|
@@ -55,20 +55,20 @@ module Netzke
|
|
55
55
|
@session_config ||= independent_config.merge(weak_session_options).merge(session_options)
|
56
56
|
end
|
57
57
|
|
58
|
-
# Last level config, overridden only by ineritance
|
58
|
+
# Last level config, overridden only by ineritance
|
59
59
|
def final_config
|
60
60
|
@strong_config ||= session_config.merge(weak_final_options).merge(strong_parent_config)
|
61
61
|
end
|
62
62
|
|
63
63
|
# Resulting config that takes into account all possible ways to configure a component. *Read only*.
|
64
64
|
# Translates into something like this:
|
65
|
-
#
|
65
|
+
#
|
66
66
|
# default_config.
|
67
67
|
# deep_merge(@passed_config).
|
68
68
|
# deep_merge(persistent_options).
|
69
69
|
# deep_merge(strong_parent_config).
|
70
70
|
# deep_merge(strong_session_config)
|
71
|
-
#
|
71
|
+
#
|
72
72
|
# Moved out to a separate method in order to provide for easy caching.
|
73
73
|
# *Do not override this method*, use +Base.config+ instead.
|
74
74
|
def config
|
@@ -98,17 +98,17 @@ module Netzke
|
|
98
98
|
fc = initial_config.flatten_with_type
|
99
99
|
key.nil? ? fc : fc.select{ |c| c[:name] == key.to_sym }.first.try(:value)
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
# Like normal config, but stored in session
|
103
103
|
# def weak_session_config
|
104
104
|
# component_session[:weak_session_config] ||= {}
|
105
105
|
# end
|
106
|
-
#
|
106
|
+
#
|
107
107
|
# def strong_session_config
|
108
108
|
# component_session[:strong_session_config] ||= {}
|
109
109
|
# end
|
110
|
-
|
111
|
-
|
110
|
+
|
111
|
+
|
112
112
|
|
113
113
|
# configuration of all children will get deep_merge'd with strong_children_config
|
114
114
|
# def strong_children_config= (c)
|
@@ -9,11 +9,11 @@ module Netzke
|
|
9
9
|
reset_masquerading
|
10
10
|
session.merge!(:"masq_#{authority_level}" => authority_id)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def reset_masquerading
|
14
14
|
session[:masq_world] = session[:masq_role] = session[:masq_user] = nil
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
# Who are we acting as?
|
18
18
|
def authority_level
|
19
19
|
if session[:masq_world]
|
@@ -28,7 +28,7 @@ module Netzke
|
|
28
28
|
:none # or nil ?
|
29
29
|
end
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
data/lib/netzke/core/session.rb
CHANGED
data/lib/netzke/core/version.rb
CHANGED
data/lib/netzke/core.rb
CHANGED
@@ -5,13 +5,13 @@ require 'netzke/core/masquerading'
|
|
5
5
|
|
6
6
|
module Netzke
|
7
7
|
# You can configure Netzke::Core like this:
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# Netzke::Core.setup do |config|
|
10
10
|
# config.ext_location = "/home/netzke/ext-3.3.0"
|
11
11
|
# config.icons_uri = "/images/famfamfam/icons"
|
12
12
|
# # ...
|
13
13
|
# end
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# The following configuration options are available:
|
16
16
|
# * ext_location - absolute path to your Ext code root
|
17
17
|
# * icons_uri - relative URI to the icons
|
@@ -20,7 +20,7 @@ module Netzke
|
|
20
20
|
module Core
|
21
21
|
extend Session
|
22
22
|
extend Masquerading
|
23
|
-
|
23
|
+
|
24
24
|
mattr_accessor :controller
|
25
25
|
|
26
26
|
mattr_accessor :javascripts
|
@@ -28,24 +28,24 @@ module Netzke
|
|
28
28
|
|
29
29
|
mattr_accessor :stylesheets
|
30
30
|
@@stylesheets = ["#{File.dirname(__FILE__)}/../../stylesheets/core.css"]
|
31
|
-
|
31
|
+
|
32
32
|
mattr_accessor :external_css
|
33
33
|
@@external_css = []
|
34
34
|
|
35
35
|
mattr_accessor :ext_location
|
36
|
-
|
36
|
+
|
37
37
|
mattr_accessor :with_icons
|
38
|
-
|
38
|
+
|
39
39
|
mattr_accessor :icons_uri
|
40
40
|
@@icons_uri = "/images/icons"
|
41
|
-
|
41
|
+
|
42
42
|
mattr_accessor :javascript_on_main_page
|
43
43
|
@@javascript_on_main_page = true
|
44
|
-
|
44
|
+
|
45
45
|
def self.setup
|
46
46
|
yield self
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
def self.reset_components_in_session
|
50
50
|
Netzke::Core.session[:netzke_components].try(:clear)
|
51
51
|
end
|
@@ -2,27 +2,27 @@ class Array
|
|
2
2
|
def jsonify
|
3
3
|
self.map{ |el| el.instance_of?(Array) || el.instance_of?(Hash) ? el.jsonify : el }
|
4
4
|
end
|
5
|
-
|
5
|
+
|
6
6
|
# Camelizes the keys of hashes and converts them to JSON
|
7
7
|
def to_nifty_json
|
8
8
|
self.recursive_delete_if_nil.jsonify.to_json
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
# Applies deep_convert_keys to each element which responds to deep_convert_keys
|
12
12
|
def deep_convert_keys(&block)
|
13
13
|
block_given? ? self.map do |i|
|
14
14
|
i.respond_to?('deep_convert_keys') ? i.deep_convert_keys(&block) : i
|
15
15
|
end : self
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def deep_each_pair(&block)
|
19
19
|
self.each{ |el| el.respond_to?('deep_each_pair') && el.deep_each_pair(&block) }
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
def recursive_delete_if_nil
|
23
23
|
self.map{|el| el.respond_to?('recursive_delete_if_nil') ? el.recursive_delete_if_nil : el}
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def deep_freeze
|
27
27
|
each { |j| j.deep_freeze if j.respond_to? :deep_freeze }
|
28
28
|
freeze
|
data/lib/netzke/core_ext/hash.rb
CHANGED
@@ -6,7 +6,7 @@ class Hash
|
|
6
6
|
end
|
7
7
|
|
8
8
|
# Recursively convert the keys. Example:
|
9
|
-
# {:bla_bla => 1, "wow_now" => {:look_ma => true}}.deep_convert_keys{|k| k.to_s.camelize.to_sym}
|
9
|
+
# {:bla_bla => 1, "wow_now" => {:look_ma => true}}.deep_convert_keys{|k| k.to_s.camelize.to_sym}
|
10
10
|
# => {:BlaBla => 1, "WowNow" => {:LookMa => true}}
|
11
11
|
def deep_convert_keys(&block)
|
12
12
|
block_given? ? self.inject({}) do |h,(k,v)|
|
@@ -22,12 +22,12 @@ class Hash
|
|
22
22
|
h.merge(new_key => new_value)
|
23
23
|
end
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
# First camelizes the keys, then convert the whole hash to JSON
|
27
27
|
def to_nifty_json
|
28
28
|
self.recursive_delete_if_nil.jsonify.to_json
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
# Converts values of a Hash in such a way that they can be easily stored in the database: hashes and arrays are jsonified, symbols - stringified
|
32
32
|
def deebeefy_values
|
33
33
|
inject({}) do |options, (k, v)|
|
@@ -45,7 +45,7 @@ class Hash
|
|
45
45
|
h
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
# add flatten_with_type method to Hash
|
50
50
|
def flatten_with_type(preffix = "")
|
51
51
|
res = []
|
@@ -55,7 +55,7 @@ class Hash
|
|
55
55
|
res += v.flatten_with_type(name)
|
56
56
|
else
|
57
57
|
res << {
|
58
|
-
:name => name,
|
58
|
+
:name => name,
|
59
59
|
:value => v,
|
60
60
|
:type => (["TrueClass", "FalseClass"].include?(v.class.name) ? 'Boolean' : v.class.name).to_sym
|
61
61
|
}
|
@@ -71,7 +71,7 @@ class Hash
|
|
71
71
|
|
72
72
|
# Javascrit-like access to Hash values
|
73
73
|
def method_missing(method, *args)
|
74
|
-
if method.to_s =~ /=$/
|
74
|
+
if method.to_s =~ /=$/
|
75
75
|
method_base = method.to_s.sub(/=$/,'').to_sym
|
76
76
|
key = self[method_base.to_s].nil? ? method_base : method_base.to_s
|
77
77
|
self[key] = args.first
|
@@ -80,5 +80,5 @@ class Hash
|
|
80
80
|
self[key]
|
81
81
|
end
|
82
82
|
end
|
83
|
-
|
83
|
+
|
84
84
|
end
|
@@ -2,12 +2,12 @@ class String
|
|
2
2
|
def jsonify
|
3
3
|
self.camelize(:lower)
|
4
4
|
end
|
5
|
-
|
5
|
+
|
6
6
|
# Converts self to "literal JSON"-string - one that doesn't get quotes appended when being sent "to_json" method
|
7
7
|
def l
|
8
8
|
ActiveSupport::JSON::Variable.new(self)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
# removes JS-comments (both single- and multi-line) from the string
|
12
12
|
def strip_js_comments
|
13
13
|
regexp = /\/\/.*$|(?m:\/\*.*?\*\/)/
|
@@ -17,10 +17,10 @@ class String
|
|
17
17
|
regexp = /^\s*\n/
|
18
18
|
self.gsub!(regexp, '')
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
# "false" => false, "whatever_else" => true
|
22
22
|
def to_b
|
23
23
|
self != "false"
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
end
|
@@ -2,15 +2,15 @@ class Symbol
|
|
2
2
|
def jsonify
|
3
3
|
self.to_s.camelize(:lower).to_sym
|
4
4
|
end
|
5
|
-
|
5
|
+
|
6
6
|
def l
|
7
7
|
ActiveSupport::JSON::Variable.new(self.to_s)
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def action(config = {})
|
11
11
|
config.merge(:action => self.to_s)
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
def component(config = {})
|
15
15
|
config.merge(:component => self.to_s)
|
16
16
|
end
|
data/lib/netzke/embedding.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Netzke
|
2
2
|
# The following methods are used when a component is generated stand-alone (as a part of a HTML page)
|
3
3
|
module Embedding
|
4
|
-
|
4
|
+
|
5
5
|
# Instantiating
|
6
6
|
def js_component_instance
|
7
7
|
%Q{Netzke.page.#{name.jsonify} = Ext.create(#{js_config.to_nifty_json});}
|
@@ -16,6 +16,6 @@ module Netzke
|
|
16
16
|
def js_component_html
|
17
17
|
%Q{<div id="#{name.to_s.split('_').join('-')}-netzke" class="netzke-component"></div>}
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
end
|
21
21
|
end
|
data/lib/netzke/ext_component.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
module Netzke
|
2
2
|
class ExtComponent
|
3
3
|
attr_accessor :name
|
4
|
-
|
4
|
+
|
5
5
|
def initialize(name, config = {})
|
6
6
|
@name = name
|
7
7
|
@config = config
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def config
|
11
11
|
@config ||= {}
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
# Rendering
|
15
15
|
def js_component_render
|
16
16
|
%Q{Ext.ComponentMgr.create(#{config.to_nifty_json}).render("ext-#{name.to_s.split('_').join('-')}");}
|
@@ -20,6 +20,6 @@ module Netzke
|
|
20
20
|
def js_component_html
|
21
21
|
%Q{<div id="ext-#{name.to_s.split('_').join('-')}" class="ext-component"></div>}
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
end
|
25
25
|
end
|