netzke-core 0.7.7 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -2
- data/CHANGELOG.md +572 -0
- data/LICENSE +7 -1
- data/README.md +345 -29
- data/Rakefile +3 -3
- data/app/controllers/netzke_controller.rb +37 -48
- data/config/ci/before-travis.sh +3 -4
- data/javascripts/base.js +86 -150
- data/javascripts/ext.js +180 -210
- data/javascripts/{core_extensions.js → js_extensions.js} +0 -0
- data/lib/netzke-core.rb +16 -6
- data/lib/netzke/base.rb +84 -107
- data/lib/netzke/core.rb +7 -41
- data/lib/netzke/core/action_config.rb +37 -0
- data/lib/netzke/core/actions.rb +123 -0
- data/lib/netzke/core/client_class.rb +252 -0
- data/lib/netzke/core/component_config.rb +12 -0
- data/lib/netzke/core/composition.rb +274 -0
- data/lib/netzke/core/config_to_dsl_delegator.rb +69 -0
- data/lib/netzke/core/configuration.rb +63 -0
- data/lib/netzke/core/css_config.rb +51 -0
- data/lib/netzke/core/dynamic_assets.rb +19 -49
- data/lib/netzke/{embedding.rb → core/embedding.rb} +4 -6
- data/lib/netzke/core/endpoint_response.rb +15 -0
- data/lib/netzke/core/javascript.rb +111 -0
- data/lib/netzke/core/panel.rb +11 -0
- data/lib/netzke/{plugins.rb → core/plugins.rb} +10 -5
- data/lib/netzke/core/railz.rb +4 -0
- data/lib/netzke/{railz → core/railz}/action_view_ext.rb +22 -18
- data/lib/netzke/core/railz/action_view_ext/ext.rb +49 -0
- data/lib/netzke/core/railz/controller_extensions.rb +17 -0
- data/lib/netzke/core/railz/engine.rb +16 -0
- data/lib/netzke/core/railz/routes.rb +10 -0
- data/lib/netzke/core/ruby_ext.rb +5 -0
- data/lib/netzke/core/ruby_ext/array.rb +23 -0
- data/lib/netzke/core/ruby_ext/hash.rb +47 -0
- data/lib/netzke/{core_ext → core/ruby_ext}/string.rb +2 -7
- data/lib/netzke/core/ruby_ext/symbol.rb +13 -0
- data/lib/netzke/{core_ext → core/ruby_ext}/time_with_zone.rb +0 -0
- data/lib/netzke/core/services.rb +130 -0
- data/lib/netzke/core/session.rb +15 -19
- data/lib/netzke/core/state.rb +40 -0
- data/lib/netzke/core/stylesheets.rb +48 -0
- data/lib/netzke/core/version.rb +2 -2
- data/lib/netzke/plugin.rb +8 -11
- data/netzke-core.gemspec +69 -59
- data/test/core_test_app/Gemfile +2 -20
- data/test/core_test_app/Gemfile.lock +65 -74
- data/test/core_test_app/app/components/card_component_loader.rb +4 -4
- data/test/core_test_app/app/components/component_loader.rb +40 -120
- data/test/core_test_app/app/components/component_loader/javascripts/component_loader.js +49 -0
- data/test/core_test_app/app/components/component_with_actions.rb +61 -47
- data/test/core_test_app/app/components/component_with_custom_css.rb +8 -5
- data/test/core_test_app/app/components/component_with_js_mixin.rb +11 -5
- data/test/core_test_app/app/components/component_with_js_mixin/javascripts/extra_one.js +1 -1
- data/test/core_test_app/app/components/component_with_js_mixin/javascripts/extra_two.js +1 -1
- data/test/core_test_app/app/components/component_with_js_mixin/javascripts/method_set_one.js +1 -1
- data/test/core_test_app/app/components/component_with_nested_through.rb +2 -2
- data/test/core_test_app/app/components/component_with_prebuilt_toolbar_control.rb +12 -0
- data/test/core_test_app/app/components/component_with_prebuilt_toolbar_control/javascripts/component_with_prebuilt_toolbar_control.js +12 -0
- data/test/core_test_app/app/components/component_with_required_js.rb +24 -0
- data/test/core_test_app/app/components/configurable_on_class_level.rb +8 -0
- data/test/core_test_app/app/components/dsl_delegated_properties.rb +4 -0
- data/test/core_test_app/app/components/dsl_delegated_properties_base.rb +5 -0
- data/test/core_test_app/app/components/dynamic_tab_panel/javascripts/dynamic_tab_panel.js +2 -2
- data/test/core_test_app/app/components/ext_direct/composite.rb +32 -33
- data/test/core_test_app/app/components/ext_direct/details.rb +2 -4
- data/test/core_test_app/app/components/ext_direct/selector.rb +20 -22
- data/test/core_test_app/app/components/ext_direct/statistics.rb +2 -4
- data/test/core_test_app/app/components/extended_component_with_actions.rb +7 -3
- data/test/core_test_app/app/components/extended_component_with_js_mixin.rb +7 -4
- data/test/core_test_app/app/components/extended_component_with_js_mixin/javascripts/some_method_set.js +1 -1
- data/test/core_test_app/app/components/extended_server_caller.rb +20 -14
- data/test/core_test_app/app/components/hello_world.rb +23 -0
- data/test/core_test_app/app/components/hello_world/javascripts/hello_world.js +12 -0
- data/test/core_test_app/app/components/included.js +2 -2
- data/test/core_test_app/app/components/kinda_complex_component.rb +1 -3
- data/test/core_test_app/app/components/kinda_complex_component/basic_stuff.rb +15 -17
- data/test/core_test_app/app/components/kinda_complex_component/extra_stuff.rb +4 -5
- data/test/core_test_app/app/components/loader_of_component_with_custom_css.rb +14 -5
- data/test/core_test_app/app/components/localized_panel.rb +23 -25
- data/test/core_test_app/app/components/multipane_component_loader.rb +19 -20
- data/test/core_test_app/app/components/nested_component.rb +4 -5
- data/test/core_test_app/app/components/panel_with_plugin.rb +8 -3
- data/test/core_test_app/app/components/panel_with_tools.rb +15 -14
- data/test/core_test_app/app/components/plugin_with_components.rb +20 -12
- data/test/core_test_app/app/components/scoped_components/deep_scoped_components/some_deep_scoped_component.rb +5 -2
- data/test/core_test_app/app/components/scoped_components/extended_scoped_component.rb +5 -2
- data/test/core_test_app/app/components/scoped_components/some_scoped_component.rb +5 -2
- data/test/core_test_app/app/components/server_caller.rb +39 -17
- data/test/core_test_app/app/components/server_caller/javascripts/server_caller.js +42 -0
- data/test/core_test_app/app/components/server_counter.rb +18 -82
- data/test/core_test_app/app/components/server_counter/javascripts/server_counter.js +53 -0
- data/test/core_test_app/app/components/simple_authentication_component.rb +46 -0
- data/test/core_test_app/app/components/simple_component.rb +8 -3
- data/test/core_test_app/app/components/simple_composite.rb +12 -0
- data/test/core_test_app/app/components/simple_form_with_file_upload.rb +49 -0
- data/test/core_test_app/app/components/simple_panel.rb +2 -2
- data/test/core_test_app/app/components/simple_tab_panel.rb +24 -3
- data/test/core_test_app/app/components/simple_window.rb +4 -2
- data/test/core_test_app/app/components/some_composite.rb +77 -48
- data/test/core_test_app/app/components/some_plugin.rb +31 -30
- data/test/core_test_app/app/components/stateful_component.rb +46 -0
- data/test/core_test_app/app/components/stateful_component_with_shared_state.rb +11 -0
- data/test/core_test_app/app/components/window_with_simple_component.rb +14 -0
- data/test/core_test_app/app/views/layouts/application.html.erb +1 -1
- data/test/core_test_app/app/views/simple_rails/multiple_nested.html.erb +7 -19
- data/test/core_test_app/app/views/simple_rails/panel.html.erb +1 -0
- data/test/core_test_app/config/database.yml.travis +3 -5
- data/test/core_test_app/config/environments/production.rb +1 -1
- data/test/core_test_app/config/initializers/netzke.rb +3 -1
- data/test/core_test_app/config/locales/en.yml +9 -4
- data/test/core_test_app/config/locales/es.yml +4 -2
- data/test/core_test_app/config/routes.rb +2 -8
- data/test/core_test_app/db/schema.rb +3 -11
- data/test/core_test_app/features/actions_and_tools.feature +1 -0
- data/test/core_test_app/features/client-server.feature +7 -0
- data/test/core_test_app/features/component_loader.feature +13 -13
- data/test/core_test_app/features/composition.feature +14 -0
- data/test/core_test_app/features/config_to_dsl_delegation.feature +10 -0
- data/test/core_test_app/features/file_inclusion.feature +1 -1
- data/test/core_test_app/features/i18n.feature +4 -4
- data/test/core_test_app/features/js_include.feature +1 -1
- data/test/core_test_app/features/persistence.feature +21 -5
- data/test/core_test_app/features/step_definitions/generic_steps.rb +14 -0
- data/test/core_test_app/features/support/paths.rb +0 -3
- data/test/core_test_app/public/images/icons/accept.png +0 -0
- data/test/core_test_app/public/images/icons/anchor.png +0 -0
- data/test/core_test_app/public/images/icons/tick.png +0 -0
- data/test/core_test_app/spec/action_config_spec.rb +15 -0
- data/test/core_test_app/spec/{component/actions_spec.rb → actions_spec.rb} +38 -36
- data/test/core_test_app/spec/base_spec.rb +35 -0
- data/test/core_test_app/spec/client_class_spec.rb +17 -0
- data/test/core_test_app/spec/component +0 -0
- data/test/core_test_app/spec/composition_spec.rb +118 -0
- data/test/core_test_app/spec/core_ext_spec.rb +3 -14
- data/test/core_test_app/spec/endpoint_response_spec.rb +17 -0
- data/test/core_test_app/spec/javascript_spec.rb +33 -0
- data/test/core_test_app/spec/js_class_config_scope.rb +37 -0
- data/test/core_test_app/spec/panel_spec.rb +11 -0
- data/test/core_test_app/spec/services_spec.rb +16 -0
- data/test/core_test_app/spec/state_spec.rb +20 -0
- data/test/unit/core_ext_test.rb +0 -53
- data/test/unit/netzke_core_test.rb +11 -11
- metadata +76 -62
- data/CHANGELOG.rdoc +0 -325
- data/javascripts/touch.js +0 -58
- data/lib/netzke/actions.rb +0 -107
- data/lib/netzke/composition.rb +0 -224
- data/lib/netzke/config_to_dsl_delegator.rb +0 -43
- data/lib/netzke/configuration.rb +0 -195
- data/lib/netzke/core/masquerading.rb +0 -34
- data/lib/netzke/core_ext.rb +0 -6
- data/lib/netzke/core_ext/array.rb +0 -30
- data/lib/netzke/core_ext/hash.rb +0 -86
- data/lib/netzke/core_ext/symbol.rb +0 -21
- data/lib/netzke/ext_component.rb +0 -25
- data/lib/netzke/inheritance.rb +0 -31
- data/lib/netzke/javascript.rb +0 -382
- data/lib/netzke/javascript/scopes.rb +0 -39
- data/lib/netzke/railz.rb +0 -4
- data/lib/netzke/railz/action_view_ext/ext.rb +0 -64
- data/lib/netzke/railz/action_view_ext/touch.rb +0 -52
- data/lib/netzke/railz/controller_extensions.rb +0 -33
- data/lib/netzke/railz/engine.rb +0 -48
- data/lib/netzke/railz/routes.rb +0 -7
- data/lib/netzke/services.rb +0 -101
- data/lib/netzke/session.rb +0 -54
- data/lib/netzke/state.rb +0 -91
- data/lib/netzke/stylesheets.rb +0 -65
- data/test/core_test_app/app/components/component_with_included_js.rb +0 -16
- data/test/core_test_app/app/components/component_with_session_persistence.rb +0 -35
- data/test/core_test_app/app/components/deprecated/server_caller.rb +0 -20
- data/test/core_test_app/app/components/dynamic_tab_panel.rb +0 -19
- data/test/core_test_app/app/components/hello_world_component.rb +0 -31
- data/test/core_test_app/app/components/touch/hello_world_component.rb +0 -25
- data/test/core_test_app/app/components/touch/server_caller.rb +0 -28
- data/test/core_test_app/app/components/touch/simple_carousel.rb +0 -17
- data/test/core_test_app/app/controllers/touch_controller.rb +0 -6
- data/test/core_test_app/app/helpers/touch_helper.rb +0 -2
- data/test/core_test_app/app/views/layouts/touch.html.erb +0 -13
- data/test/core_test_app/db/migrate/20110110132720_create_netzke_component_states.rb +0 -20
- data/test/core_test_app/features/step_definitions/touch_steps.rb +0 -3
- data/test/core_test_app/features/touch.feature +0 -10
- data/test/core_test_app/gemfiles/rails3_1.gemfile +0 -16
- data/test/core_test_app/gemfiles/rails3_2.gemfile +0 -16
- data/test/core_test_app/spec/component/base_spec.rb +0 -36
- data/test/core_test_app/spec/component/component_spec.rb +0 -20
- data/test/core_test_app/spec/component/composition_spec.rb +0 -132
- data/test/core_test_app/spec/component/configuration_spec.rb +0 -61
- data/test/core_test_app/spec/component/javascript_spec.rb +0 -16
- data/test/core_test_app/spec/component/state_spec.rb +0 -18
data/config/ci/before-travis.sh
CHANGED
@@ -2,10 +2,9 @@
|
|
2
2
|
sh -e /etc/init.d/xvfb start
|
3
3
|
|
4
4
|
# fetch extjs
|
5
|
-
wget http://cdn.sencha.io/ext-4.
|
6
|
-
unzip -q -d test/core_test_app/public/ -n ext-4.
|
7
|
-
mv test/core_test_app/public/ext-4.
|
5
|
+
wget http://cdn.sencha.io/ext-4.1.1a-gpl.zip
|
6
|
+
unzip -q -d test/core_test_app/public/ -n ext-4.1.1a-gpl.zip
|
7
|
+
mv test/core_test_app/public/ext-4.1.1a test/core_test_app/public/extjs
|
8
8
|
|
9
9
|
# cp db configuration
|
10
10
|
cp test/core_test_app/config/database.yml.travis test/core_test_app/config/database.yml
|
11
|
-
|
data/javascripts/base.js
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
/**
|
2
|
-
This file gets loaded along with the rest of Ext library at the initial load
|
2
|
+
This file gets loaded along with the rest of Ext library at the initial load. It is common for both Ext JS and Touch; Ext JS-specific stuff is in ext.js.
|
3
|
+
|
3
4
|
At this time the following constants have been set by Rails:
|
4
5
|
|
5
6
|
Netzke.RelativeUrlRoot - set to ActionController::Base.config.relative_url_root
|
6
7
|
Netzke.RelativeExtUrl - URL to ext files
|
8
|
+
Netzke.ControllerUrl - NetzkeController URL
|
7
9
|
*/
|
8
10
|
|
9
11
|
// Initial stuff
|
12
|
+
Netzke.classNamespace = 'Netzke.classes'; // TODO: pass from Ruby
|
10
13
|
Ext.ns('Ext.netzke'); // namespace for extensions that depend on Ext
|
11
14
|
Ext.ns('Netzke.page'); // namespace for all component instances on the page
|
12
|
-
Ext.ns(
|
15
|
+
Ext.ns(Netzke.classNamespace); // namespace for all component classes
|
13
16
|
Ext.ns('Netzke.classes.Core'); // namespace for Core mixins
|
14
17
|
|
15
18
|
Netzke.deprecationWarning = function(msg){
|
@@ -41,28 +44,6 @@ Netzke.isLoading=function () {
|
|
41
44
|
return Netzke.runningRequests != 0;
|
42
45
|
}
|
43
46
|
|
44
|
-
// Similar to Ext.apply, but can accept any number of parameters, e.g.
|
45
|
-
//
|
46
|
-
// Netzke.chainApply(targetObject, {...}, {...}, {...});
|
47
|
-
Netzke.chainApply = function(){
|
48
|
-
var res = {};
|
49
|
-
Ext.each(arguments, function(o){
|
50
|
-
Ext.apply(res, o);
|
51
|
-
});
|
52
|
-
return res;
|
53
|
-
};
|
54
|
-
|
55
|
-
/* Similar to Rails' alias_method_chain. Usefull when using mixins. E.g.:
|
56
|
-
|
57
|
-
Netzke.aliasMethodChain(this, "initComponent", "netzke")
|
58
|
-
|
59
|
-
will result in 2 new methods on this.initComponentWithNetzke and this.initComponentWithoutNetzke
|
60
|
-
*/
|
61
|
-
Netzke.aliasMethodChain = function(klass, method, feature) {
|
62
|
-
klass[method + "Without" + feature.capitalize()] = klass[method];
|
63
|
-
klass[method] = klass[method + "With" + feature.capitalize()];
|
64
|
-
};
|
65
|
-
|
66
47
|
// xtypes of cached Netzke classes
|
67
48
|
Netzke.cache = [];
|
68
49
|
|
@@ -70,38 +51,14 @@ Netzke.componentNotInSessionHandler = function() {
|
|
70
51
|
throw "Netzke: component not in Rails session. Define Netzke.componentNotInSessionHandler to handle this.";
|
71
52
|
};
|
72
53
|
|
73
|
-
Netzke.classes.Core.Mixin
|
74
|
-
|
75
|
-
// Properties/methods common to all Netzke component classes
|
76
|
-
Netzke.componentMixin = Ext.applyIf(Netzke.classes.Core.Mixin, {
|
54
|
+
Ext.define("Netzke.classes.Core.Mixin", {
|
77
55
|
isNetzke: true, // to distinguish Netzke components from regular Ext components
|
78
56
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
This way it becomes ready to be instantiated properly by Ext.
|
83
|
-
*/
|
84
|
-
detectComponents: function(o){
|
85
|
-
if (Ext.isObject(o)) {
|
86
|
-
if (o.items) this.detectComponents(o.items);
|
87
|
-
} else if (Ext.isArray(o)) {
|
88
|
-
var a = o;
|
89
|
-
Ext.each(a, function(c, i){
|
90
|
-
if (c.netzkeComponent) {
|
91
|
-
var cmpName = c.netzkeComponent,
|
92
|
-
cmpCfg = this.netzkeComponents[cmpName.camelize(true)];
|
93
|
-
if (!cmpCfg) throw "Netzke: unknown component reference " + cmpName;
|
94
|
-
a[i] = Ext.apply(cmpCfg, c);
|
95
|
-
delete a[i].netzkeComponent; // not needed any longer
|
96
|
-
} else if (c.items) this.detectComponents(c.items);
|
97
|
-
}, this);
|
98
|
-
}
|
99
|
-
},
|
100
|
-
|
101
|
-
/*
|
102
|
-
Evaluates CSS
|
57
|
+
/**
|
58
|
+
* Evaluates CSS
|
59
|
+
* @private
|
103
60
|
*/
|
104
|
-
|
61
|
+
netzkeEvalCss : function(code){
|
105
62
|
var head = Ext.fly(document.getElementsByTagName('head')[0]);
|
106
63
|
Ext.core.DomHelper.append(head, {
|
107
64
|
tag: 'style',
|
@@ -110,24 +67,24 @@ Netzke.componentMixin = Ext.applyIf(Netzke.classes.Core.Mixin, {
|
|
110
67
|
});
|
111
68
|
},
|
112
69
|
|
113
|
-
|
114
|
-
Evaluates JS
|
70
|
+
/**
|
71
|
+
* Evaluates JS
|
72
|
+
* @private
|
115
73
|
*/
|
116
|
-
|
74
|
+
netzkeEvalJs : function(code){
|
117
75
|
eval(code);
|
118
76
|
},
|
119
77
|
|
120
|
-
|
121
|
-
Gets id in the context of provided parent.
|
122
|
-
For example, the components "properties", being a child of "books" has global id "books__properties",
|
123
|
-
|
124
|
-
returns "properties".
|
78
|
+
/**
|
79
|
+
* Gets id in the context of provided parent.
|
80
|
+
* For example, the components "properties", being a child of "books" has global id "books__properties", which *is* its component's real id. This methods, with the instance of "books" passed as parameter, returns "properties".
|
81
|
+
* @private
|
125
82
|
*/
|
126
|
-
|
83
|
+
netzkeLocalId : function(parent){
|
127
84
|
return this.id.replace(parent.id + "__", "");
|
128
85
|
},
|
129
86
|
|
130
|
-
|
87
|
+
/**
|
131
88
|
Executes a bunch of methods. This method is called almost every time a communication to the server takes place.
|
132
89
|
Thus the server side of a component can provide any set of commands to its client side.
|
133
90
|
Args:
|
@@ -135,7 +92,7 @@ Netzke.componentMixin = Ext.applyIf(Netzke.classes.Core.Mixin, {
|
|
135
92
|
1) a hash of instructions, where the key is the method name, and value - the argument that method will be called with (thus, these methods are expected to *only* receive 1 argument). In this case, the methods will be executed in no particular order.
|
136
93
|
2) an array of hashes of instructions. They will be executed in order.
|
137
94
|
Arrays and hashes may be nested at will.
|
138
|
-
If the key in the instructions hash refers to a child Netzke component,
|
95
|
+
If the key in the instructions hash refers to a child Netzke component, netzkeBulkExecute will be called on that component with the value passed as the argument.
|
139
96
|
|
140
97
|
Examples of the arguments:
|
141
98
|
// same as this.feedback("Your order is accepted");
|
@@ -144,22 +101,25 @@ Netzke.componentMixin = Ext.applyIf(Netzke.classes.Core.Mixin, {
|
|
144
101
|
// same as: this.setTitle('Suprise!'); this.setDisabled(true);
|
145
102
|
[{setTitle:'Suprise!'}, {setDisabled:true}]
|
146
103
|
|
147
|
-
// the same as this.
|
104
|
+
// the same as this.netzkeGetComponent('users').netzkeBulkExecute([{setTitle:'Suprise!'}, {setDisabled:true}]);
|
148
105
|
{users: [{setTitle:'Suprise!'}, {setDisabled:true}] }
|
106
|
+
@private
|
149
107
|
*/
|
150
|
-
|
108
|
+
netzkeBulkExecute : function(instructions){
|
151
109
|
if (Ext.isArray(instructions)) {
|
152
|
-
Ext.each(instructions, function(instruction){ this.
|
110
|
+
Ext.each(instructions, function(instruction){ this.netzkeBulkExecute(instruction)}, this);
|
153
111
|
} else {
|
154
112
|
for (var instr in instructions) {
|
113
|
+
var args = instructions[instr];
|
114
|
+
|
155
115
|
if (Ext.isFunction(this[instr])) {
|
156
116
|
// Executing the method.
|
157
|
-
this[instr].apply(this,
|
117
|
+
this[instr].apply(this, args);
|
158
118
|
} else {
|
159
|
-
var childComponent = this.
|
119
|
+
var childComponent = this.netzkeGetComponent(instr);
|
160
120
|
if (childComponent) {
|
161
|
-
childComponent.
|
162
|
-
} else {
|
121
|
+
childComponent.netzkeBulkExecute(args);
|
122
|
+
} else if (Ext.isArray(args)) { // only consider those calls that have arguments wrapped in an array; the only (probably) case when they are not, is with 'success' property set to true in a non-ajax form submit - silently ignore that
|
163
123
|
throw "Netzke: Unknown method or child component '" + instr +"' in component '" + this.id + "'"
|
164
124
|
}
|
165
125
|
}
|
@@ -167,96 +127,72 @@ Netzke.componentMixin = Ext.applyIf(Netzke.classes.Core.Mixin, {
|
|
167
127
|
}
|
168
128
|
},
|
169
129
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
// Does the call to the server and processes the response
|
176
|
-
callServer : function(intp, params, callback, scope){
|
177
|
-
Netzke.runningRequests++;
|
178
|
-
if (!params) params = {};
|
179
|
-
Ext.Ajax.request({
|
180
|
-
params: params,
|
181
|
-
url: this.endpointUrl(intp),
|
182
|
-
callback: function(options, success, response){
|
183
|
-
if (success && response.responseText) {
|
184
|
-
// execute commands from server
|
185
|
-
this.bulkExecute(Ext.decode(response.responseText));
|
186
|
-
|
187
|
-
// provide callback if needed
|
188
|
-
if (typeof callback == 'function') {
|
189
|
-
if (!scope) scope = this;
|
190
|
-
callback.apply(scope, [this.latestResult]);
|
191
|
-
}
|
192
|
-
}
|
193
|
-
Netzke.runningRequests--;
|
194
|
-
},
|
195
|
-
scope : this
|
196
|
-
});
|
197
|
-
},
|
198
|
-
|
199
|
-
setResult: function(result) {
|
130
|
+
/**
|
131
|
+
* @private
|
132
|
+
*/
|
133
|
+
netzkeSetResult: function(result) {
|
200
134
|
this.latestResult = result;
|
201
135
|
},
|
202
136
|
|
203
|
-
|
204
|
-
|
137
|
+
/**
|
138
|
+
* When an endpoint call is issued while the session has expired, this method is called. Override it to do whatever is appropriate.
|
139
|
+
* @private
|
140
|
+
*/
|
141
|
+
netzkeComponentNotInSession: function() {
|
205
142
|
Netzke.componentNotInSessionHandler();
|
206
|
-
}
|
207
|
-
});
|
208
|
-
|
209
|
-
|
210
|
-
// DEPRECATED as whole. Netzke extensions for Ext.Container.
|
211
|
-
Ext.override(Ext.Container, {
|
212
|
-
// Instantiates an component by its config. If it appears to be a window, shows it instead of adding as item.
|
213
|
-
instantiateChild: function(config){
|
214
|
-
Netzke.deprecationWarning("instantiateChild is deprecated");
|
215
|
-
var instance = Ext.createByAlias( config.alias, config );
|
216
|
-
this.insertNetzkeComponent(instance);
|
217
|
-
return instance;
|
218
143
|
},
|
219
144
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
this.doLayout();
|
227
|
-
} else {
|
228
|
-
this.on('show', function(cmp){cmp.doLayout();}, {single: true});
|
229
|
-
}
|
145
|
+
/**
|
146
|
+
* Returns a URL for old-fashion requests (used at multi-part form non-AJAX submissions)
|
147
|
+
* @private
|
148
|
+
*/
|
149
|
+
netzkeEndpointUrl: function(endpoint){
|
150
|
+
return Netzke.ControllerUrl + "dispatcher?address=" + this.id + "__" + endpoint;
|
230
151
|
},
|
231
152
|
|
232
153
|
/**
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
if (
|
243
|
-
|
244
|
-
|
245
|
-
|
154
|
+
* @private
|
155
|
+
*/
|
156
|
+
netzkeNormalizeConfigArray: function(items){
|
157
|
+
var cfg, ref, cmpName, cmpCfg, actName, actCfg;
|
158
|
+
|
159
|
+
Ext.each(items, function(item, i){
|
160
|
+
cfg = item;
|
161
|
+
|
162
|
+
// potentially, referencing a component or action with a string
|
163
|
+
if (Ext.isString(item)) {
|
164
|
+
ref = item.camelize(true);
|
165
|
+
if ((this.netzkeComponents || {})[ref]) cfg = {netzkeComponent: ref};
|
166
|
+
else if ((this.actions || {})[ref]) cfg = {netzkeAction: ref};
|
246
167
|
}
|
247
|
-
}
|
248
|
-
},
|
249
168
|
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
169
|
+
if (cfg.netzkeAction) {
|
170
|
+
// replace with action instance
|
171
|
+
actName = cfg.netzkeAction.camelize(true);
|
172
|
+
if (!this.actions[actName]) throw "Netzke: unknown action " + cfg.netzkeAction;
|
173
|
+
items[i] = this.actions[actName];
|
174
|
+
delete(item);
|
175
|
+
|
176
|
+
} else if (cfg.netzkeComponent) {
|
177
|
+
// replace with component config
|
178
|
+
cmpName = cfg.netzkeComponent;
|
179
|
+
cmpCfg = this.netzkeComponents[cmpName.camelize(true)];
|
180
|
+
if (!cmpCfg) throw "Netzke: unknown component " + cmpName;
|
181
|
+
items[i] = Ext.apply(cmpCfg, cfg);
|
182
|
+
delete(item);
|
183
|
+
|
184
|
+
} else if (Ext.isString(cfg) && Ext.isFunction(this[cfg.camelize(true)+"Config"])) { // replace with config referred to on the Ruby side as a symbol
|
185
|
+
// pre-built config
|
186
|
+
items[i] = Ext.apply(this[cfg.camelize(true)+"Config"](this.passedConfig), {netzkeParent: this});
|
255
187
|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
188
|
+
} else {
|
189
|
+
// recursion
|
190
|
+
for (key in cfg) {
|
191
|
+
if (Ext.isArray(cfg[key])) {
|
192
|
+
this.netzkeNormalizeConfigArray(cfg[key]);
|
193
|
+
}
|
194
|
+
}
|
195
|
+
}
|
196
|
+
}, this);
|
261
197
|
}
|
262
198
|
});
|
data/javascripts/ext.js
CHANGED
@@ -1,14 +1,11 @@
|
|
1
|
-
//
|
2
|
-
if (Ext.Compat) Ext.Compat.showErrors = true;
|
1
|
+
// This file has stuff related to Ext JS (as apposed to Touch)
|
3
2
|
|
4
3
|
// Because of Netzke's double-underscore notation, Ext.TabPanel should have a different id-delimiter (yes, this should be in netzke-core)
|
5
4
|
Ext.TabPanel.prototype.idDelimiter = "___";
|
6
5
|
|
6
|
+
// Enable quick tips
|
7
7
|
Ext.QuickTips.init();
|
8
8
|
|
9
|
-
// We don't want no state managment by default, thank you!
|
10
|
-
Ext.state.Provider.prototype.set = Ext.emptyFn;
|
11
|
-
|
12
9
|
// Checking Ext JS version: both major and minor versions must be the same
|
13
10
|
(function(){
|
14
11
|
var requiredVersionMajor = 4,
|
@@ -55,9 +52,6 @@ Ext.define('Netzke.FeedbackGhost', {
|
|
55
52
|
}
|
56
53
|
});
|
57
54
|
|
58
|
-
// Mix it into every Netzke component as feedbackGhost
|
59
|
-
Netzke.componentMixin.feedbackGhost = Ext.create("Netzke.FeedbackGhost");
|
60
|
-
|
61
55
|
Ext.define('Netzke.classes.NetzkeRemotingProvider', {
|
62
56
|
extend: 'Ext.direct.RemotingProvider',
|
63
57
|
|
@@ -89,9 +83,41 @@ Ext.define('Netzke.classes.NetzkeRemotingProvider', {
|
|
89
83
|
}
|
90
84
|
});
|
91
85
|
|
86
|
+
// Override Ext.Component's constructor to enable Netzke features
|
87
|
+
Ext.define(null, {
|
88
|
+
override: 'Ext.Component',
|
89
|
+
constructor: function(config) {
|
90
|
+
if (this.isNetzke) {
|
91
|
+
|
92
|
+
this.netzkeComponents = config.netzkeComponents;
|
93
|
+
this.passedConfig = config;
|
94
|
+
|
95
|
+
// process and get rid of endpoints config
|
96
|
+
this.netzkeProcessEndpoints(config);
|
97
|
+
|
98
|
+
// process and get rid of plugins config
|
99
|
+
this.netzkeProcessPlugins(config);
|
100
|
+
|
101
|
+
this.netzkeNormalizeActions(config);
|
102
|
+
|
103
|
+
this.netzkeNormalizeConfig(config);
|
104
|
+
|
105
|
+
this.netzkeNormalizeTools(config);
|
106
|
+
|
107
|
+
// This is where the references to different callback functions will be stored
|
108
|
+
this.callbackHash = {};
|
109
|
+
|
110
|
+
// This is where we store the information about components that are currently being loaded with this.loadComponent()
|
111
|
+
this.componentsBeingLoaded = {};
|
112
|
+
}
|
113
|
+
|
114
|
+
this.callOverridden([config]);
|
115
|
+
}
|
116
|
+
});
|
117
|
+
|
92
118
|
Netzke.directProvider = new Netzke.classes.NetzkeRemotingProvider({
|
93
119
|
type: "remoting", // create a Ext.direct.RemotingProvider
|
94
|
-
url: Netzke.
|
120
|
+
url: Netzke.ControllerUrl + "direct/", // url to connect to the Ext.Direct server-side router.
|
95
121
|
namespace: "Netzke.providers", // namespace to create the Remoting Provider in
|
96
122
|
actions: {},
|
97
123
|
maxRetries: Netzke.core.directMaxRetries,
|
@@ -102,58 +128,35 @@ Netzke.directProvider = new Netzke.classes.NetzkeRemotingProvider({
|
|
102
128
|
Ext.Direct.addProvider(Netzke.directProvider);
|
103
129
|
|
104
130
|
// Methods/properties that each and every Netzke component will have
|
105
|
-
Ext.
|
131
|
+
Ext.define(null, {
|
132
|
+
override: 'Netzke.classes.Core.Mixin',
|
133
|
+
feedbackGhost: Ext.create("Netzke.FeedbackGhost"),
|
134
|
+
|
106
135
|
/*
|
107
136
|
Mask shown during loading of a component. Set to false to not mask. Pass config for Ext.LoadMask for configuring msg/cls, etc.
|
108
137
|
Set msg to null if mask without any msg is desirable.
|
109
138
|
*/
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
this.normalizeTools();
|
124
|
-
|
125
|
-
this.processEndpoints();
|
126
|
-
|
127
|
-
this.processPlugins();
|
128
|
-
|
129
|
-
// This is where the references to different callback functions will be stored
|
130
|
-
this.callbackHash = {};
|
131
|
-
|
132
|
-
// This is where we store the information about components that are currently being loaded with this.loadComponent()
|
133
|
-
this.componentsBeingLoaded = {};
|
134
|
-
|
135
|
-
// Set title
|
136
|
-
if (this.mode === "config"){
|
137
|
-
if (!this.title) {
|
138
|
-
this.title = '[' + this.id + ']';
|
139
|
-
} else {
|
140
|
-
this.title = this.title + ' [' + this.id + ']';
|
141
|
-
}
|
142
|
-
} else {
|
143
|
-
if (!this.title) {
|
144
|
-
this.title = this.id.humanize();
|
145
|
-
}
|
139
|
+
netzkeLoadMask: true,
|
140
|
+
|
141
|
+
/**
|
142
|
+
* Runs through initial config options and does the following:
|
143
|
+
*
|
144
|
+
* * detects component placeholders and replaces them with full component config found in netzkeComponents
|
145
|
+
* * detects action placeholders and replaces them with instances of Ext actions found in this.actions
|
146
|
+
* @private
|
147
|
+
*/
|
148
|
+
netzkeNormalizeConfig: function(config) {
|
149
|
+
for (key in config) {
|
150
|
+
if (Ext.isArray(config[key])) this.netzkeNormalizeConfigArray(config[key]);
|
146
151
|
}
|
147
|
-
|
148
|
-
// Call the original initComponent
|
149
|
-
this.initComponentWithoutNetzke();
|
150
152
|
},
|
151
153
|
|
152
|
-
|
153
|
-
Dynamically creates methods for endpoints, so that we could later call them like: this.myEndpointMethod()
|
154
|
+
/**
|
155
|
+
* Dynamically creates methods for endpoints, so that we could later call them like: this.myEndpointMethod()
|
156
|
+
* @private
|
154
157
|
*/
|
155
|
-
|
156
|
-
var endpoints =
|
158
|
+
netzkeProcessEndpoints: function(config){
|
159
|
+
var endpoints = config.endpoints || [];
|
157
160
|
endpoints.push('deliver_component'); // all Netzke components get this endpoint
|
158
161
|
var directActions = [];
|
159
162
|
var that = this;
|
@@ -164,12 +167,12 @@ Ext.apply(Netzke.classes.Core.Mixin, {
|
|
164
167
|
Netzke.runningRequests++;
|
165
168
|
|
166
169
|
scope = scope || that;
|
167
|
-
Netzke.providers[
|
170
|
+
Netzke.providers[config.id][intp.camelize(true)].call(scope, arg, function(result, remotingEvent) {
|
168
171
|
if(remotingEvent.message) {
|
169
172
|
console.error("RPC event indicates an error: ", remotingEvent);
|
170
173
|
throw new Error(remotingEvent.message);
|
171
174
|
}
|
172
|
-
that.
|
175
|
+
that.netzkeBulkExecute(result); // invoke the endpoint result on the calling component
|
173
176
|
if(typeof callback == "function") {
|
174
177
|
callback.call(scope, that.latestResult); // invoke the callback on the provided scope, or on the calling component if no scope set. Pass latestResult to callback
|
175
178
|
}
|
@@ -178,92 +181,86 @@ Ext.apply(Netzke.classes.Core.Mixin, {
|
|
178
181
|
}
|
179
182
|
}, this);
|
180
183
|
|
181
|
-
Netzke.directProvider.addAction(
|
184
|
+
Netzke.directProvider.addAction(config.id, directActions);
|
185
|
+
|
186
|
+
delete config.endpoints;
|
182
187
|
},
|
183
188
|
|
184
|
-
|
185
|
-
|
189
|
+
/**
|
190
|
+
* @private
|
191
|
+
*/
|
192
|
+
netzkeNormalizeTools: function(config) {
|
193
|
+
if (config.tools) {
|
186
194
|
var normTools = [];
|
187
|
-
Ext.each(
|
195
|
+
Ext.each(config.tools, function(tool){
|
188
196
|
// Create an event for each action (so that higher-level components could interfere)
|
189
197
|
this.addEvents(tool.id+'click');
|
190
198
|
|
191
|
-
var handler = Ext.Function.bind(this.
|
199
|
+
var handler = Ext.Function.bind(this.netzkeToolHandler, this, [tool]);
|
192
200
|
normTools.push({type : tool, handler : handler, scope : this});
|
193
201
|
}, this);
|
194
202
|
this.tools = normTools;
|
203
|
+
delete config.tools;
|
195
204
|
}
|
196
205
|
},
|
197
206
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
207
|
+
/**
|
208
|
+
* Replaces actions configs with Ext.Action instances, assigning default handler to them
|
209
|
+
* @private
|
210
|
+
*/
|
211
|
+
netzkeNormalizeActions : function(config){
|
202
212
|
var normActions = {};
|
203
|
-
for (var name in
|
213
|
+
for (var name in config.actions) {
|
204
214
|
// Create an event for each action (so that higher-level components could interfere)
|
205
215
|
this.addEvents(name+'click');
|
206
216
|
|
207
217
|
// Configure the action
|
208
|
-
var actionConfig = Ext.apply({},
|
218
|
+
var actionConfig = Ext.apply({}, config.actions[name]); // do not modify original this.actions
|
209
219
|
actionConfig.customHandler = actionConfig.handler;
|
210
|
-
actionConfig.handler = Ext.Function.bind(this.
|
220
|
+
actionConfig.handler = Ext.Function.bind(this.netzkeActionHandler, this); // handler common for all actions
|
211
221
|
actionConfig.name = name;
|
212
222
|
normActions[name] = new Ext.Action(actionConfig);
|
213
223
|
}
|
214
|
-
delete(this.actions);
|
215
224
|
this.actions = normActions;
|
225
|
+
delete(config.actions);
|
216
226
|
},
|
217
227
|
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
},
|
252
|
-
|
253
|
-
/*
|
254
|
-
Dynamically loads a Netzke component.
|
255
|
-
Config options:
|
256
|
-
'name' (required) - the name of the child component to load
|
257
|
-
'container' - if specified, the id (or instance) of a panel with the 'fit' layout where the loaded component will be added to; the previously existing component will be destroyed
|
258
|
-
'callback' - function that gets called after the component is loaded; it receives the component's instance as parameter
|
259
|
-
'scope' - scope for the callback
|
260
|
-
*/
|
261
|
-
loadNetzkeComponent: function(params){
|
262
|
-
if (params.id) {
|
263
|
-
params.name = params.id;
|
264
|
-
Netzke.deprecationWarning("Using 'id' in loadComponent is deprecated. Use 'name' instead.");
|
228
|
+
/**
|
229
|
+
* Dynamically loads a Netzke component.
|
230
|
+
* @param {String} name
|
231
|
+
* @param {Object} config Can contain the following keys:
|
232
|
+
* 'container' - if specified, the instance (or id) of a panel with the 'fit' layout where the loaded component will be added to; the previously existing component will be destroyed
|
233
|
+
* 'append' - if set to +true+, do not clear the container before adding the loaded component
|
234
|
+
* 'callback' - function that gets called after the component is loaded; it receives the component's instance as parameter
|
235
|
+
* 'configOnly' - if set to +true+, do not instantiate the component, instead pass its config to the callback function
|
236
|
+
* 'params' - object passed to the endpoint, may be useful for extra configuration
|
237
|
+
* 'scope' - scope for the callback
|
238
|
+
*
|
239
|
+
* Examples:
|
240
|
+
*
|
241
|
+
* this.netzkeLoadComponent('info');
|
242
|
+
*
|
243
|
+
* loads 'info' and adds it to +this+ container, removing anything from it first.
|
244
|
+
*
|
245
|
+
* this.netzkeLoadComponent('info', {container: win, callback: function(instance){}, scope: this});
|
246
|
+
*
|
247
|
+
* loads 'info' and adds it to +win+ container, envoking a callback in +this+ scope, passing it an instance of 'info'.
|
248
|
+
*
|
249
|
+
* this.netzkeLoadComponent('info', {configOnly: true, callback: function(config){}, scope: this});
|
250
|
+
*
|
251
|
+
* loads configuration for the 'info' component, envoking a callback in +this+ scope, passing it the loaded config for 'info'.
|
252
|
+
*/
|
253
|
+
netzkeLoadComponent: function(){
|
254
|
+
var params;
|
255
|
+
|
256
|
+
if (Ext.isString(arguments[0])) {
|
257
|
+
params = arguments[1] || {};
|
258
|
+
params.name = arguments[0];
|
259
|
+
} else {
|
260
|
+
params = arguments[0];
|
265
261
|
}
|
266
262
|
|
263
|
+
if (params.container == undefined) params.container = this;
|
267
264
|
params.name = params.name.underscore();
|
268
265
|
|
269
266
|
// params that will be provided for the server API call (deliver_component); all what's passed in params.params is merged in. This way we exclude from sending along such things as :scope, :callback, etc.
|
@@ -281,8 +278,8 @@ Ext.apply(Netzke.classes.Core.Mixin, {
|
|
281
278
|
|
282
279
|
// Show loading mask if possible
|
283
280
|
var containerEl = (containerCmp || this).getEl();
|
284
|
-
if (this.
|
285
|
-
storedConfig.loadMaskCmp = new Ext.LoadMask(containerEl, this.
|
281
|
+
if (this.netzkeLoadMask && containerEl){
|
282
|
+
storedConfig.loadMaskCmp = new Ext.LoadMask(containerEl, this.netzkeLoadMask);
|
286
283
|
storedConfig.loadMaskCmp.show();
|
287
284
|
}
|
288
285
|
|
@@ -290,19 +287,14 @@ Ext.apply(Netzke.classes.Core.Mixin, {
|
|
290
287
|
this.deliverComponent(serverParams);
|
291
288
|
},
|
292
289
|
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
params.container = params.container || this.getId(); // for backward compatibility
|
297
|
-
this.loadNetzkeComponent(params);
|
298
|
-
},
|
299
|
-
|
300
|
-
/*
|
301
|
-
Called by the server after we ask him to load a component
|
290
|
+
/**
|
291
|
+
* Called by the server after we ask him to load a component
|
292
|
+
* @private
|
302
293
|
*/
|
303
|
-
|
294
|
+
netzkeComponentDelivered: function(config){
|
304
295
|
// retrieve the loading config for this component
|
305
296
|
var storedConfig = this.componentsBeingLoaded[config.name] || {};
|
297
|
+
var callbackParam;
|
306
298
|
delete this.componentsBeingLoaded[config.name];
|
307
299
|
|
308
300
|
if (storedConfig.loadMaskCmp) {
|
@@ -310,29 +302,36 @@ Ext.apply(Netzke.classes.Core.Mixin, {
|
|
310
302
|
storedConfig.loadMaskCmp.destroy();
|
311
303
|
}
|
312
304
|
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
var
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
containerCmp.
|
322
|
-
|
323
|
-
|
324
|
-
|
305
|
+
if (storedConfig.configOnly) {
|
306
|
+
callbackParam = config;
|
307
|
+
} else {
|
308
|
+
var componentInstance = Ext.ComponentManager.create(config);
|
309
|
+
|
310
|
+
// there's no sense in adding a window-type components
|
311
|
+
if (storedConfig.container && !componentInstance.isFloating()) {
|
312
|
+
var containerCmp = storedConfig.container;
|
313
|
+
if (!storedConfig.append) containerCmp.removeAll();
|
314
|
+
containerCmp.add(componentInstance);
|
315
|
+
|
316
|
+
if (containerCmp.isVisible()) {
|
317
|
+
containerCmp.doLayout();
|
318
|
+
} else {
|
319
|
+
// if loaded into a hidden container, we need a little trick
|
320
|
+
containerCmp.on('show', function(cmp){ cmp.doLayout(); }, {single: true});
|
321
|
+
}
|
325
322
|
}
|
323
|
+
callbackParam = componentInstance;
|
326
324
|
}
|
327
325
|
|
328
326
|
if (storedConfig.callback) {
|
329
|
-
storedConfig.callback.call(storedConfig.scope || this,
|
327
|
+
storedConfig.callback.call(storedConfig.scope || this, callbackParam);
|
330
328
|
}
|
331
|
-
|
332
|
-
this.fireEvent('componentload', componentInstance);
|
333
329
|
},
|
334
330
|
|
335
|
-
|
331
|
+
/**
|
332
|
+
* @private
|
333
|
+
*/
|
334
|
+
netzkeComponentDeliveryFailed: function(params) {
|
336
335
|
var storedConfig = this.componentsBeingLoaded[params.componentName] || {};
|
337
336
|
delete this.componentsBeingLoaded[params.componentName];
|
338
337
|
|
@@ -344,24 +343,10 @@ Ext.apply(Netzke.classes.Core.Mixin, {
|
|
344
343
|
this.netzkeFeedback({msg: params.msg, level: "Error"});
|
345
344
|
},
|
346
345
|
|
347
|
-
|
348
|
-
|
346
|
+
/**
|
347
|
+
* Returns parent Netzke component
|
349
348
|
*/
|
350
|
-
|
351
|
-
var componentInstance;
|
352
|
-
if (containerId) {
|
353
|
-
var container = Ext.getCmp(containerId);
|
354
|
-
componentInstance = container.instantiateChild(config);
|
355
|
-
} else {
|
356
|
-
componentInstance = this.instantiateChild(config);
|
357
|
-
}
|
358
|
-
return componentInstance;
|
359
|
-
},
|
360
|
-
|
361
|
-
/*
|
362
|
-
Returns parent Netzke component
|
363
|
-
*/
|
364
|
-
getParentNetzkeComponent: function(){
|
349
|
+
netzkeGetParentComponent: function(){
|
365
350
|
// simply cutting the last part of the id: some_parent__a_kid__a_great_kid => some_parent__a_kid
|
366
351
|
var idSplit = this.id.split("__");
|
367
352
|
idSplit.pop();
|
@@ -370,63 +355,46 @@ Ext.apply(Netzke.classes.Core.Mixin, {
|
|
370
355
|
return parentId === "" ? null : Ext.getCmp(parentId);
|
371
356
|
},
|
372
357
|
|
373
|
-
|
374
|
-
|
375
|
-
Netzke.deprecationWarning("getParent is deprecated in favor of getParentNetzkeComponent");
|
376
|
-
return this.getParentNetzkeComponent();
|
377
|
-
},
|
378
|
-
|
379
|
-
/*
|
380
|
-
Reloads current component (calls the parent to reload us as its component)
|
358
|
+
/**
|
359
|
+
* Reloads current component (calls the parent to reload us as its component)
|
381
360
|
*/
|
382
|
-
|
383
|
-
var parent = this.
|
361
|
+
netzkeReload: function(){
|
362
|
+
var parent = this.netzkeGetParentComponent();
|
384
363
|
if (parent) {
|
385
|
-
parent.
|
364
|
+
parent.netzkeLoadComponent({id:this.netzkeLocalId(parent), container:this.ownerCt.id});
|
386
365
|
} else {
|
387
366
|
window.location.reload();
|
388
367
|
}
|
389
368
|
},
|
390
369
|
|
391
|
-
|
392
|
-
|
370
|
+
/**
|
371
|
+
* Instantiates and returns a Netzke component by its name.
|
372
|
+
* @private
|
393
373
|
*/
|
394
|
-
|
395
|
-
this.ownerCt.instantiateChild(config)
|
396
|
-
},
|
397
|
-
|
398
|
-
/*
|
399
|
-
Instantiates and returns a Netzke component by its name.
|
400
|
-
*/
|
401
|
-
instantiateChildNetzkeComponent: function(name) {
|
374
|
+
netzkeInstantiateComponent: function(name) {
|
402
375
|
name = name.camelize(true);
|
403
376
|
return Ext.createByAlias(this.netzkeComponents[name].alias, this.netzkeComponents[name])
|
404
377
|
},
|
405
378
|
|
406
|
-
|
407
|
-
Returns *instantiated* child component by its relative id, which may contain the 'parent' part to walk _up_ the hierarchy
|
379
|
+
/**
|
380
|
+
* Returns *instantiated* child component by its relative id, which may contain the 'parent' part to walk _up_ the hierarchy
|
381
|
+
* @private
|
408
382
|
*/
|
409
|
-
|
383
|
+
netzkeGetComponent: function(id){
|
410
384
|
if (id === "") {return this};
|
411
385
|
id = id.underscore();
|
412
386
|
var split = id.split("__");
|
413
387
|
if (split[0] === 'parent') {
|
414
388
|
split.shift();
|
415
389
|
var childInParentScope = split.join("__");
|
416
|
-
return this.
|
390
|
+
return this.netzkeGetParentComponent().netzkeGetComponent(childInParentScope);
|
417
391
|
} else {
|
418
392
|
return Ext.getCmp(this.id+"__"+id);
|
419
393
|
}
|
420
394
|
},
|
421
395
|
|
422
|
-
|
423
|
-
|
424
|
-
Netzke.deprecationWarning("getChildComponent is deprecated in favor of getChildNetzkeComponent");
|
425
|
-
return this.getChildNetzkeComponent(id);
|
426
|
-
},
|
427
|
-
|
428
|
-
/*
|
429
|
-
Provides a visual feedback. TODO: refactor
|
396
|
+
/**
|
397
|
+
* Provides a visual feedback. TODO: refactor
|
430
398
|
*/
|
431
399
|
netzkeFeedback: function(msg){
|
432
400
|
if (this.initialConfig && this.initialConfig.quiet) {
|
@@ -451,31 +419,29 @@ Ext.apply(Netzke.classes.Core.Mixin, {
|
|
451
419
|
}
|
452
420
|
},
|
453
421
|
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
this.netzkeFeedback(msg);
|
458
|
-
},
|
459
|
-
|
460
|
-
/*
|
461
|
-
Common handler for all netzke's actions. <tt>comp</tt> is the Component that triggered the action (e.g. button or menu item)
|
422
|
+
/**
|
423
|
+
* Common handler for all netzke's actions. <tt>comp</tt> is the Component that triggered the action (e.g. button or menu item)
|
424
|
+
* @private
|
462
425
|
*/
|
463
|
-
|
426
|
+
netzkeActionHandler: function(comp){
|
464
427
|
var actionName = comp.name;
|
465
428
|
// If firing corresponding event doesn't return false, call the handler
|
466
429
|
if (this.fireEvent(actionName+'click', comp)) {
|
467
430
|
var action = this.actions[actionName];
|
468
431
|
var customHandler = action.initialConfig.customHandler;
|
469
432
|
var methodName = (customHandler && customHandler.camelize(true)) || "on" + actionName.camelize();
|
470
|
-
if (!this[methodName]) {throw "Netzke:
|
433
|
+
if (!this[methodName]) {throw "Netzke: handler '" + methodName + "' is undefined in '" + this.id + "'";}
|
471
434
|
|
472
435
|
// call the handler passing it the triggering component
|
473
436
|
this[methodName](comp);
|
474
437
|
}
|
475
438
|
},
|
476
439
|
|
477
|
-
|
478
|
-
|
440
|
+
/**
|
441
|
+
* Common handler for tools
|
442
|
+
* @private
|
443
|
+
*/
|
444
|
+
netzkeToolHandler: function(tool){
|
479
445
|
// If firing corresponding event doesn't return false, call the handler
|
480
446
|
if (this.fireEvent(tool.id+'click')) {
|
481
447
|
var methodName = "on"+tool.camelize();
|
@@ -484,14 +450,18 @@ Ext.apply(Netzke.classes.Core.Mixin, {
|
|
484
450
|
}
|
485
451
|
},
|
486
452
|
|
487
|
-
|
488
|
-
|
453
|
+
/**
|
454
|
+
* @private
|
455
|
+
*/
|
456
|
+
netzkeProcessPlugins: function(config) {
|
457
|
+
if (config.netzkePlugins) {
|
489
458
|
if (!this.plugins) this.plugins = [];
|
490
|
-
Ext.each(
|
491
|
-
this.plugins.push(this.
|
459
|
+
Ext.each(config.netzkePlugins, function(p){
|
460
|
+
this.plugins.push(this.netzkeInstantiateComponent(p));
|
492
461
|
}, this);
|
462
|
+
delete config.netzkePlugins;
|
493
463
|
}
|
494
464
|
},
|
495
465
|
|
496
|
-
|
466
|
+
// netzkeOnComponentLoad: Ext.emptyFn // gets overridden
|
497
467
|
});
|