netzke-core 0.6.2 → 0.6.3
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/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/javascript.rb
CHANGED
@@ -3,7 +3,7 @@ module Netzke
|
|
3
3
|
# Here's a brief explanation on how a javascript class for a component gets built.
|
4
4
|
# Component gets defined as a constructor (a function) by +js_class+ class method (see "Inside component's contstructor").
|
5
5
|
# +Ext.extend+ provides inheritance from an Ext class specified in +js_base_class+ class method.
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# == Inside component's constructor
|
8
8
|
# * Component's constructor gets called with a parameter that is a configuration object provided by +config+ instance method. This configuration is specific for the instance of the component, and, for example, contains this component's unique id. As another example, by means of this configuration object, a grid receives the configuration array for its columns, a form - for its fields, etc.
|
9
9
|
module Javascript
|
@@ -13,14 +13,14 @@ module Netzke
|
|
13
13
|
class_attribute :js_included_files
|
14
14
|
self.js_included_files = []
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
module ClassMethods
|
18
18
|
|
19
19
|
# The JS (Ext) class that we inherit from on the JS level
|
20
20
|
def js_base_class(class_name = nil)
|
21
21
|
class_name.nil? ? (read_inheritable_attribute(:js_base_class) || "Ext.Panel") : write_inheritable_attribute(:js_base_class, class_name)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
# Definition of a public JS method, e.g.:
|
25
25
|
# js_method :on_call_server, <<-JS
|
26
26
|
# function(){
|
@@ -33,7 +33,7 @@ module Netzke
|
|
33
33
|
current_js_methods.merge!(name => definition.l)
|
34
34
|
write_inheritable_attribute(:js_methods, current_js_methods)
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
# Returns all JS method definitions in a hash
|
38
38
|
def js_methods
|
39
39
|
read_clean_inheritable_hash(:js_methods)
|
@@ -47,7 +47,7 @@ module Netzke
|
|
47
47
|
def js_include(*args)
|
48
48
|
self.js_included_files += args
|
49
49
|
end
|
50
|
-
|
50
|
+
|
51
51
|
# Definition of a public JS property, e.g.:
|
52
52
|
# js_property :title, "My Netzke Component"
|
53
53
|
def js_property(name, value = nil)
|
@@ -60,7 +60,7 @@ module Netzke
|
|
60
60
|
write_inheritable_attribute(:js_properties, current_js_properties)
|
61
61
|
end
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
# Assignment of multiple public JS properties in a bunch, e.g.:
|
65
65
|
# js_properties :title => "My Component", :border => true, :html => "Inner HTML"
|
66
66
|
def js_properties(hsh = nil)
|
@@ -72,7 +72,7 @@ module Netzke
|
|
72
72
|
write_inheritable_attribute(:js_properties, current_js_properties)
|
73
73
|
end
|
74
74
|
end
|
75
|
-
|
75
|
+
|
76
76
|
# JS properties and methods merged together
|
77
77
|
def js_extend_properties
|
78
78
|
@_js_extend_properties ||= js_properties.merge(js_methods)
|
@@ -82,13 +82,13 @@ module Netzke
|
|
82
82
|
# res
|
83
83
|
# end
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
# TODO: the code below needs refactoring and cleaning-up
|
87
|
-
|
87
|
+
|
88
88
|
# component's menus
|
89
89
|
# def js_menus; []; end
|
90
90
|
|
91
|
-
# Given class name, e.g. GridPanelLib::Components::RecordFormWindow,
|
91
|
+
# Given class name, e.g. GridPanelLib::Components::RecordFormWindow,
|
92
92
|
# returns its scope: "Components.RecordFormWindow"
|
93
93
|
def js_class_name_to_scope(name)
|
94
94
|
name.split("::")[0..-2].join(".")
|
@@ -129,7 +129,7 @@ module Netzke
|
|
129
129
|
superclass != Netzke::Base
|
130
130
|
end
|
131
131
|
|
132
|
-
# Declaration of component's class (stored in the cache storage (Ext.netzke.cache) at the client side
|
132
|
+
# Declaration of component's class (stored in the cache storage (Ext.netzke.cache) at the client side
|
133
133
|
# to be reused at the moment of component instantiation)
|
134
134
|
def js_class(cached = [])
|
135
135
|
res = []
|
@@ -142,29 +142,29 @@ module Netzke
|
|
142
142
|
|
143
143
|
res.join("\n")
|
144
144
|
end
|
145
|
-
|
146
|
-
|
145
|
+
|
146
|
+
|
147
147
|
def js_extra_code
|
148
148
|
""
|
149
149
|
end
|
150
|
-
|
150
|
+
|
151
151
|
# Generates declaration of the JS class as direct extension of a Ext component
|
152
152
|
def js_class_declaration_new_component
|
153
153
|
%(#{js_full_class_name} = Ext.extend(#{js_base_class}, Ext.apply(Netzke.componentMixin(#{js_base_class}),
|
154
154
|
#{js_extend_properties.to_nifty_json}));)
|
155
155
|
end
|
156
|
-
|
156
|
+
|
157
157
|
# Generates declaration of the JS class as extension of another Netzke component
|
158
158
|
def js_class_declaration_extending_component
|
159
159
|
base_class = superclass.js_full_class_name
|
160
160
|
|
161
|
-
# Do we specify our own extend properties?
|
161
|
+
# Do we specify our own extend properties?
|
162
162
|
# If so, include them, if not - don't re-include those from the parent.
|
163
163
|
js_extend_properties.empty? ? \
|
164
164
|
%{#{js_full_class_name} = #{base_class};} :
|
165
165
|
%{#{js_full_class_name} = Ext.extend(#{base_class}, #{js_extend_properties.to_nifty_json});}
|
166
166
|
end
|
167
|
-
|
167
|
+
|
168
168
|
# Returns all extra JavaScript-code (as string) required by this component's class
|
169
169
|
def js_included
|
170
170
|
res = ""
|
@@ -175,7 +175,7 @@ module Netzke
|
|
175
175
|
f = File.new(path)
|
176
176
|
res << f.read << "\n"
|
177
177
|
end
|
178
|
-
|
178
|
+
|
179
179
|
res
|
180
180
|
end
|
181
181
|
|
@@ -187,7 +187,7 @@ module Netzke
|
|
187
187
|
def js_code(cached = [])
|
188
188
|
[js_included, js_class(cached)].join("\n")
|
189
189
|
end
|
190
|
-
|
190
|
+
|
191
191
|
# Little helper
|
192
192
|
def this; "this".l; end
|
193
193
|
|
@@ -195,7 +195,7 @@ module Netzke
|
|
195
195
|
def null; "null".l; end
|
196
196
|
|
197
197
|
end
|
198
|
-
|
198
|
+
|
199
199
|
module InstanceMethods
|
200
200
|
# Config that is used for instantiating the component in javascript
|
201
201
|
def js_config
|
@@ -211,7 +211,7 @@ module Netzke
|
|
211
211
|
comp_instance.before_load
|
212
212
|
comp_hash[comp_name] = comp_instance.js_config
|
213
213
|
end
|
214
|
-
|
214
|
+
|
215
215
|
# All our non-lazy-loaded children are specified here, while in +items+ we barely reference them, because
|
216
216
|
# +items+, generally, only contain a subset of all non-lazy-loaded children.
|
217
217
|
res[:components] = comp_hash unless comp_hash.empty?
|
@@ -228,21 +228,32 @@ module Netzke
|
|
228
228
|
|
229
229
|
# Merge with the rest of config options, besides those that are only meant for the server side
|
230
230
|
res.merge!(config.reject{ |k,v| self.class.server_side_config_options.include?(k.to_sym) })
|
231
|
-
|
231
|
+
|
232
|
+
if config[:ext_config].present?
|
233
|
+
::ActiveSupport::Deprecation.warn("Using ext_config option is deprecated. All config options must be specified at the same level in the hash.", caller)
|
234
|
+
res.merge!(config[:ext_config])
|
235
|
+
end
|
236
|
+
|
232
237
|
res[:items] = items unless items.blank?
|
233
|
-
|
238
|
+
|
234
239
|
res
|
235
240
|
end
|
241
|
+
|
242
|
+
# Helper to access config[:ext_config] - DEPRECATED
|
243
|
+
def ext_config
|
244
|
+
::ActiveSupport::Deprecation.warn("Using ext_config is deprecated. All config options must be specified at the same level in the hash.", caller)
|
245
|
+
config[:ext_config] || {}
|
246
|
+
end
|
236
247
|
|
237
248
|
# All the JS-code required by this instance of the component to be instantiated in the browser.
|
238
249
|
# It includes JS-classes for the parents, non-lazy-loaded child components, and itself.
|
239
250
|
def js_missing_code(cached = [])
|
240
|
-
code = dependency_classes.inject("") do |r,k|
|
251
|
+
code = dependency_classes.inject("") do |r,k|
|
241
252
|
cached.include?(k.to_s) ? r : r + k.js_code(cached)#.strip_js_comments
|
242
253
|
end
|
243
254
|
code.blank? ? nil : code
|
244
255
|
end
|
245
|
-
|
256
|
+
|
246
257
|
end
|
247
258
|
end
|
248
259
|
end
|
data/lib/netzke/persistence.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
module Netzke
|
2
|
-
# TODO:
|
2
|
+
# TODO:
|
3
3
|
# rename persistence_ to persistence_
|
4
4
|
module Persistence
|
5
|
-
|
5
|
+
|
6
6
|
module ClassMethods
|
7
7
|
# Persistent config manager class
|
8
8
|
def persistence_manager_class
|
@@ -12,14 +12,14 @@ module Netzke
|
|
12
12
|
end
|
13
13
|
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
module InstanceMethods
|
17
|
-
|
17
|
+
|
18
18
|
# If the component has persistent config in its disposal
|
19
19
|
def persistence_enabled?
|
20
20
|
!persistence_manager_class.nil? && initial_config[:persistent_config]
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
# Access to own persistent config, e.g.:
|
24
24
|
# persistent_config["window.size"] = 100
|
25
25
|
# persistent_config["window.size"] => 100
|
@@ -30,7 +30,7 @@ module Netzke
|
|
30
30
|
# config_class.component_name = persistence_key.to_s # pass to the config class our unique name
|
31
31
|
# config_class
|
32
32
|
# else
|
33
|
-
# # if we can't use presistent config, all the calls to it will always return nil,
|
33
|
+
# # if we can't use presistent config, all the calls to it will always return nil,
|
34
34
|
# # and the "="-operation will be ignored
|
35
35
|
# logger.debug "==> NETZKE: no persistent config is set up for component '#{global_id}'"
|
36
36
|
# {}
|
@@ -44,7 +44,7 @@ module Netzke
|
|
44
44
|
config_class
|
45
45
|
end
|
46
46
|
|
47
|
-
# A string which will identify NetzkePreference records for this component.
|
47
|
+
# A string which will identify NetzkePreference records for this component.
|
48
48
|
# If <tt>persistence_key</tt> is passed, use it. Otherwise use global component's id.
|
49
49
|
def persistence_key #:nodoc:
|
50
50
|
# initial_config[:persistence_key] ? parent.try(:persistence_key) ? "#{parent.persistence_key}__#{initial_config[:persistence_key]}".to_sym : initial_config[:persistence_key] : global_id.to_sym
|
@@ -56,18 +56,18 @@ module Netzke
|
|
56
56
|
# current_config.deep_merge!(hsh.deep_convert_keys{ |k| k.to_s }) # first, recursively stringify the keys
|
57
57
|
# persistent_config[:ext_config] = current_config
|
58
58
|
# end
|
59
|
-
|
59
|
+
|
60
60
|
# Returns a hash built from all persistent config values for the current component, following the double underscore
|
61
61
|
# naming convention. E.g., if we have the following persistent config pairs:
|
62
62
|
# enabled => true
|
63
63
|
# layout__width => 100
|
64
64
|
# layout__header__height => 20
|
65
|
-
#
|
65
|
+
#
|
66
66
|
# this method will return the following hash:
|
67
67
|
# {:enabled => true, :layout => {:width => 100, :header => {:height => 20}}}
|
68
68
|
# def persistence_hash_OLD
|
69
69
|
# return {} if !persistence_enabled?
|
70
|
-
#
|
70
|
+
#
|
71
71
|
# @persistence_hash ||= begin
|
72
72
|
# prefs = NetzkePreference.find_all_for_component(persistence_key.to_s)
|
73
73
|
# res = {}
|
@@ -80,7 +80,7 @@ module Netzke
|
|
80
80
|
# anchor = tmp_res[level_prefix] if level_prefix == hsh_levels.first
|
81
81
|
# tmp_res = tmp_res[level_prefix]
|
82
82
|
# end
|
83
|
-
# # Now 'anchor' is a hash that represents the path to the single value,
|
83
|
+
# # Now 'anchor' is a hash that represents the path to the single value,
|
84
84
|
# # for example: {:ext_config => {:title => 100}} (which corresponds to ext_config__title)
|
85
85
|
# # So we need to recursively merge it into the final result
|
86
86
|
# res.deep_merge!(hsh_levels.first => anchor)
|
@@ -88,7 +88,7 @@ module Netzke
|
|
88
88
|
# res.deep_convert_keys{ |k| k.to_sym } # recursively symbolize the keys
|
89
89
|
# end
|
90
90
|
# end
|
91
|
-
|
91
|
+
|
92
92
|
def update_persistent_options(hash)
|
93
93
|
if persistence_enabled?
|
94
94
|
options = persistent_options
|
@@ -97,19 +97,19 @@ module Netzke
|
|
97
97
|
logger && logger.debug("Netzke warning: No persistence enabled for component '#{global_id}'")
|
98
98
|
end
|
99
99
|
end
|
100
|
-
|
100
|
+
|
101
101
|
def persistent_options
|
102
102
|
return {} if !persistence_enabled?
|
103
103
|
persistence_manager_class.pref_to_read(global_id).try(:value) || {}
|
104
104
|
end
|
105
|
-
|
105
|
+
|
106
106
|
# A convenience method for instances
|
107
107
|
def persistence_manager_class
|
108
108
|
self.class.persistence_manager_class
|
109
109
|
end
|
110
|
-
|
110
|
+
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
def self.included(receiver)
|
114
114
|
receiver.extend ClassMethods
|
115
115
|
receiver.send :include, InstanceMethods
|
@@ -3,10 +3,10 @@ module Netzke
|
|
3
3
|
# Include JavaScript
|
4
4
|
def netzke_js_include
|
5
5
|
res = []
|
6
|
-
|
6
|
+
|
7
7
|
# ExtJS
|
8
8
|
res << (ENV['RAILS_ENV'] == 'development' ? javascript_include_tag("/extjs/adapter/ext/ext-base-debug", "/extjs/ext-all-debug") : javascript_include_tag("/extjs/adapter/ext/ext-base", "/extjs/ext-all"))
|
9
|
-
|
9
|
+
|
10
10
|
# Netzke (dynamically generated)
|
11
11
|
res << javascript_include_tag("/netzke/netzke")
|
12
12
|
res.join("\n")
|
@@ -20,14 +20,14 @@ module Netzke
|
|
20
20
|
res << "\n" << stylesheet_link_tag("/extjs/resources/css/xtheme-#{theme_name}") unless theme_name.to_s == "default"
|
21
21
|
# Netzke (dynamically generated)
|
22
22
|
res << "\n" << stylesheet_link_tag("/netzke/netzke")
|
23
|
-
|
24
|
-
# External stylesheets (which cannot be loaded dynamically along with the rest of the component, e.g. due to that
|
23
|
+
|
24
|
+
# External stylesheets (which cannot be loaded dynamically along with the rest of the component, e.g. due to that
|
25
25
|
# relative paths are used in them)
|
26
26
|
res << "\n" << stylesheet_link_tag(Netzke::Core.external_css)
|
27
|
-
|
27
|
+
|
28
28
|
res
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
# JavaScript for all Netzke classes in this view, and Ext.onReady which renders all Netzke components in this view
|
32
32
|
def netzke_js
|
33
33
|
res = []
|
@@ -38,17 +38,17 @@ module Netzke
|
|
38
38
|
res << "Ext.onReady(function(){"
|
39
39
|
res << content_for(:netzke_on_ready)
|
40
40
|
res << "});"
|
41
|
-
|
41
|
+
|
42
42
|
javascript_tag res.join("\n")
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
def netzke_css
|
46
46
|
%{
|
47
47
|
<style type="text/css" media="screen">
|
48
48
|
#{content_for(:netzke_css)}
|
49
49
|
</style>}
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
# Wrapper for all the above. Use it in your layout.
|
53
53
|
# Params: <tt>:ext_theme</tt> - the name of ExtJS theme to apply (optional)
|
54
54
|
# E.g.:
|
@@ -57,42 +57,42 @@ module Netzke
|
|
57
57
|
theme = params[:ext_theme] || :default
|
58
58
|
raw([netzke_css_include(theme), netzke_css, netzke_js_include, netzke_js].join("\n"))
|
59
59
|
end
|
60
|
-
|
60
|
+
|
61
61
|
# Use this helper in your views to embed Netzke components. E.g.:
|
62
62
|
# netzke :my_grid, :class_name => "Basepack::GridPanel", :columns => [:id, :name, :created_at]
|
63
63
|
# On how to configure a component, see documentation for Netzke::Base or/and specific component
|
64
64
|
def netzke(name, config = {})
|
65
65
|
@rendered_classes ||= []
|
66
|
-
|
66
|
+
|
67
67
|
# if we are the first netzke call on the page, reset components hash in the session
|
68
68
|
if @rendered_classes.empty?
|
69
69
|
Netzke::Core.reset_components_in_session
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
class_name = config[:class_name] ||= name.to_s.camelcase
|
73
|
-
|
73
|
+
|
74
74
|
config[:name] = name
|
75
|
-
|
75
|
+
|
76
76
|
Netzke::Core.reg_component(config)
|
77
|
-
|
77
|
+
|
78
78
|
w = Netzke::Base.instance_by_config(config)
|
79
79
|
w.before_load # inform the component about initial load
|
80
|
-
|
80
|
+
|
81
81
|
if Netzke::Core.javascript_on_main_page
|
82
82
|
content_for :netzke_js_classes, raw(w.js_missing_code(@rendered_classes))
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
content_for :netzke_css, raw(w.css_missing_code(@rendered_classes))
|
86
|
-
|
86
|
+
|
87
87
|
content_for :netzke_on_ready, raw("#{w.js_component_instance}\n\n#{w.js_component_render}")
|
88
|
-
|
88
|
+
|
89
89
|
# Now mark this component's class as rendered, so that we only generate it once per view
|
90
90
|
@rendered_classes << class_name unless @rendered_classes.include?(class_name)
|
91
91
|
|
92
92
|
# Return the html for this component
|
93
93
|
raw(w.js_component_html)
|
94
94
|
end
|
95
|
-
|
95
|
+
|
96
96
|
def ext(name, config = {})
|
97
97
|
comp = Netzke::ExtComponent.new(name, config)
|
98
98
|
content_for :netzke_on_ready, raw("#{comp.js_component_render}")
|
data/lib/netzke/rails/routes.rb
CHANGED
data/lib/netzke/services.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
module Netzke
|
2
2
|
module Services
|
3
3
|
class BadEndpointReturnType < RuntimeError; end
|
4
|
-
|
4
|
+
|
5
5
|
module ClassMethods
|
6
6
|
# Declare connection points between client side of a component and its server side. For example:
|
7
7
|
#
|
8
8
|
# api :reset_data
|
9
|
-
#
|
10
|
-
# will provide JavaScript side with a method <tt>resetData</tt> that will result in a call to Ruby
|
9
|
+
#
|
10
|
+
# will provide JavaScript side with a method <tt>resetData</tt> that will result in a call to Ruby
|
11
11
|
# method <tt>reset_data</tt>, e.g.:
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# this.resetData({hard:true});
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# See netzke-basepack's GridPanel for an example.
|
16
|
-
#
|
16
|
+
#
|
17
17
|
def api(*api_points)
|
18
18
|
::ActiveSupport::Deprecation.warn("Using the 'api' call is deprecated. Use the 'endpoint' approach instead", caller)
|
19
|
-
|
19
|
+
|
20
20
|
api_points.each do |apip|
|
21
21
|
add_endpoint(apip)
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
# It may be needed later for security
|
25
25
|
api_points.each do |apip|
|
26
26
|
module_eval <<-END, __FILE__, __LINE__
|
@@ -36,14 +36,14 @@ module Netzke
|
|
36
36
|
def endpoint(name, options = {}, &block)
|
37
37
|
add_endpoint(name)
|
38
38
|
define_method name, &block if block # if no block is given, the method is supposed to be defined elsewhere
|
39
|
-
|
39
|
+
|
40
40
|
# define_method name, &block if block # if no block is given, the method is supposed to be defined elsewhere
|
41
41
|
define_method :"endpoint_#{name}" do |*args|
|
42
42
|
res = send(name, *args)
|
43
43
|
res.respond_to?(:to_nifty_json) && res.to_nifty_json || ""
|
44
44
|
end
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
# Register an endpoint
|
48
48
|
def add_endpoint(ep)
|
49
49
|
current_endpoints = read_inheritable_attribute(:endpoints) || []
|
@@ -56,10 +56,10 @@ module Netzke
|
|
56
56
|
read_inheritable_attribute(:endpoints)
|
57
57
|
end
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
module InstanceMethods
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
def self.included(receiver)
|
64
64
|
receiver.extend ClassMethods
|
65
65
|
receiver.send :include, InstanceMethods
|
data/lib/netzke/session.rb
CHANGED
@@ -6,17 +6,17 @@ module Netzke
|
|
6
6
|
def session
|
7
7
|
::Netzke::Core.session
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
# Component-specific session.
|
11
11
|
def component_session
|
12
12
|
session[global_id] ||= {}
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
# Returns this component's configuration options stored in the session. Those get merged into the component's configuration at instantiation.
|
16
16
|
def session_options
|
17
17
|
session_persistence_enabled? && component_session[:options] || {}
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
# Updates the session options
|
21
21
|
def update_session_options(hash)
|
22
22
|
if session_persistence_enabled?
|
@@ -26,7 +26,7 @@ module Netzke
|
|
26
26
|
logger.debug "Netzke warning: No session persistence enabled for component '#{global_id}'"
|
27
27
|
end
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
private
|
31
31
|
def session_persistence_enabled?
|
32
32
|
initial_config[:session_persistence]
|
data/lib/netzke/stylesheets.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
module Netzke
|
2
2
|
module Stylesheets
|
3
3
|
extend ActiveSupport::Concern
|
4
|
-
|
4
|
+
|
5
5
|
included do
|
6
6
|
class_attribute :css_included_files
|
7
7
|
self.css_included_files = []
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
module ClassMethods
|
11
11
|
# Returns all extra CSS code (as string) required by this component's class
|
12
12
|
def css_included
|
@@ -28,7 +28,7 @@ module Netzke
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# Definition of CSS files which will be dynamically loaded together with this component
|
31
|
-
# e.g.
|
31
|
+
# e.g.
|
32
32
|
# css_include "#{File.dirname(__FILE__)}/themis_navigation/static.css"
|
33
33
|
# or
|
34
34
|
# css_include "#{File.dirname(__FILE__)}/themis_navigation/one.css","#{File.dirname(__FILE__)}/themis_navigation/two.css"
|
@@ -36,17 +36,17 @@ module Netzke
|
|
36
36
|
def css_include(*args)
|
37
37
|
self.css_included_files += args
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
module InstanceMethods
|
43
43
|
def css_missing_code(cached = [])
|
44
|
-
code = dependency_classes.inject("") do |r,k|
|
44
|
+
code = dependency_classes.inject("") do |r,k|
|
45
45
|
cached.include?(k) ? r : r + constantize_class_name(k).css_code(cached)
|
46
46
|
end
|
47
47
|
code.blank? ? nil : code
|
48
48
|
end
|
49
|
-
|
50
|
-
end
|
49
|
+
|
50
|
+
end
|
51
51
|
end
|
52
52
|
end
|
data/lib/netzke-core.rb
CHANGED
@@ -8,7 +8,7 @@ require 'netzke/base'
|
|
8
8
|
module Netzke
|
9
9
|
autoload :Core, 'netzke/core'
|
10
10
|
autoload :ExtComponent, 'netzke/ext_component'
|
11
|
-
|
11
|
+
|
12
12
|
class Engine < ::Rails::Engine
|
13
13
|
config.after_initialize do
|
14
14
|
# Do some initialization which is only possible after Rails is initialized
|
@@ -31,7 +31,7 @@ if defined? Rails
|
|
31
31
|
require 'netzke/rails/action_view_ext'
|
32
32
|
include Netzke::ActionViewExt
|
33
33
|
end
|
34
|
-
|
34
|
+
|
35
35
|
# Make this plugin auto-reloadable for easier development
|
36
36
|
# ActiveSupport::Dependencies.autoload_once_paths.delete(File.join(File.dirname(__FILE__)))
|
37
37
|
end
|
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.
|
8
|
+
s.version = "0.6.3"
|
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{2010-
|
12
|
+
s.date = %q{2010-11-02}
|
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 = [
|
@@ -162,12 +162,12 @@ Gem::Specification.new do |s|
|
|
162
162
|
"test/unit/netzke_preference_test.rb",
|
163
163
|
"uninstall.rb"
|
164
164
|
]
|
165
|
-
s.homepage = %q{http://
|
165
|
+
s.homepage = %q{http://netzke.org}
|
166
166
|
s.post_install_message = %q{
|
167
167
|
========================================================================
|
168
168
|
|
169
169
|
Thanks for installing Netzke Core!
|
170
|
-
|
170
|
+
|
171
171
|
Netzke home page: http://netzke.org
|
172
172
|
Netzke Google Groups: http://groups.google.com/group/netzke
|
173
173
|
Netzke tutorials: http://blog.writelesscode.com
|
@@ -176,7 +176,6 @@ Gem::Specification.new do |s|
|
|
176
176
|
|
177
177
|
}
|
178
178
|
s.require_paths = ["lib"]
|
179
|
-
s.rubyforge_project = %q{netzke-core}
|
180
179
|
s.rubygems_version = %q{1.3.7}
|
181
180
|
s.summary = %q{Build ExtJS/Rails components with minimum effort}
|
182
181
|
s.test_files = [
|