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
@@ -1,14 +1,23 @@
|
|
1
1
|
# Loads a component with custom CSS, to make sure that also dynamically loaded components get the correct CSS applied
|
2
2
|
class LoaderOfComponentWithCustomCss < Netzke::Base
|
3
|
-
component :component_with_custom_css
|
3
|
+
component :component_with_custom_css do |c|
|
4
|
+
c.klass = ComponentWithCustomCss
|
5
|
+
end
|
4
6
|
|
5
7
|
action :load_component_with_custom_css
|
6
8
|
|
7
|
-
|
9
|
+
def configure(c)
|
10
|
+
super
|
11
|
+
c.title = "LoaderOfComponentWithCustomCss"
|
12
|
+
c.layout = :fit
|
13
|
+
c.bbar = [:load_component_with_custom_css]
|
14
|
+
end
|
8
15
|
|
9
|
-
|
16
|
+
js_configure do |c|
|
17
|
+
c.on_load_component_with_custom_css = <<-JS
|
10
18
|
function(params){
|
11
|
-
this.
|
19
|
+
this.netzkeLoadComponent({name: 'component_with_custom_css', container: this});
|
12
20
|
}
|
13
|
-
|
21
|
+
JS
|
22
|
+
end
|
14
23
|
end
|
@@ -1,37 +1,35 @@
|
|
1
1
|
class LocalizedPanel < Netzke::Base
|
2
|
-
# This action will be translated per-class basis if the translation is available,
|
2
|
+
# This action will be translated per-class basis if the translation is available, falling back to the default
|
3
3
|
action :action_one
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
{:text => I18n.t('localized_panel.action_two')}
|
5
|
+
action :action_two do |a|
|
6
|
+
a.text = I18n.t('localized_panel.action_two')
|
8
7
|
end
|
9
8
|
|
10
9
|
action :action_three
|
11
10
|
|
12
|
-
|
11
|
+
js_configure do |c|
|
12
|
+
c.translate :property_one, :property_two
|
13
13
|
|
14
|
-
|
14
|
+
c.on_render = <<-JS
|
15
|
+
function(ct){
|
16
|
+
Netzke.classes.LocalizedPanel.superclass.onRender.call(this, ct);
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
js_method :on_render, <<-JS
|
23
|
-
function(ct){
|
24
|
-
Netzke.classes.LocalizedPanel.superclass.onRender.call(this, ct);
|
25
|
-
|
26
|
-
this.body.update(this.i18n.propertyOne + ", " + this.i18n.propertyTwo);
|
27
|
-
}
|
28
|
-
JS
|
18
|
+
this.body.update(this.i18n.propertyOne + ", " + this.i18n.propertyTwo);
|
19
|
+
}
|
20
|
+
JS
|
29
21
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
22
|
+
c.on_action_three = <<-JS
|
23
|
+
function(){
|
24
|
+
var mask = new Ext.LoadMask(this.body);
|
25
|
+
mask.show();
|
26
|
+
}
|
27
|
+
JS
|
28
|
+
end
|
36
29
|
|
30
|
+
def configure(c)
|
31
|
+
super
|
32
|
+
c.title = I18n.t('localized_panel.title')
|
33
|
+
c.bbar = [:action_one, :action_two, :action_three]
|
34
|
+
end
|
37
35
|
end
|
@@ -5,24 +5,23 @@ class MultipaneComponentLoader < Netzke::Base
|
|
5
5
|
action :load_server_caller, :handler => :load_handler
|
6
6
|
action :load_component_loader, :handler => :load_handler
|
7
7
|
|
8
|
-
def
|
9
|
-
super
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
8
|
+
def configure(c)
|
9
|
+
super
|
10
|
+
c.items = [{
|
11
|
+
:title => "Container One",
|
12
|
+
:xtype => :panel,
|
13
|
+
:height => 200,
|
14
|
+
:flex => 1,
|
15
|
+
:border => true,
|
16
|
+
:bbar => [:load_server_caller, :load_component_loader],
|
17
|
+
:layout => :fit
|
18
|
+
},{
|
19
|
+
:title => "Container Two",
|
20
|
+
:xtype => :panel,
|
21
|
+
:height => 200,
|
22
|
+
:flex => 1,
|
23
|
+
:layout => :fit
|
24
|
+
}]
|
26
25
|
end
|
27
26
|
|
28
27
|
component :server_caller
|
@@ -30,7 +29,7 @@ class MultipaneComponentLoader < Netzke::Base
|
|
30
29
|
js_method :load_handler, <<-JS
|
31
30
|
function(button){
|
32
31
|
var container = button.ownerCt.ownerCt;
|
33
|
-
this.
|
32
|
+
this.netzkeLoadComponent({name: 'server_caller', container: container});
|
34
33
|
}
|
35
34
|
JS
|
36
35
|
|
@@ -39,4 +38,4 @@ class MultipaneComponentLoader < Netzke::Base
|
|
39
38
|
super
|
40
39
|
end
|
41
40
|
|
42
|
-
end
|
41
|
+
end
|
@@ -1,10 +1,9 @@
|
|
1
|
+
# FIXME
|
1
2
|
class NestedComponent < Netzke::Base
|
2
3
|
js_property :layout, :fit
|
3
4
|
|
4
|
-
def
|
5
|
-
|
6
|
-
c[:items] = [:child.component]
|
7
|
-
end
|
5
|
+
def configure(c)
|
6
|
+
c.items = [:child.component]
|
8
7
|
end
|
9
8
|
|
10
9
|
component :child,
|
@@ -15,4 +14,4 @@ class NestedComponent < Netzke::Base
|
|
15
14
|
:grand_child_one => {:class_name => "SimpleComponent", :title => "Grand Child One"},
|
16
15
|
:grand_child_two => {:class_name => "NestedComponent", :title => "Grand Child Two", :lazy_loading => true}
|
17
16
|
}
|
18
|
-
end
|
17
|
+
end
|
@@ -1,19 +1,20 @@
|
|
1
1
|
class PanelWithTools < Netzke::Base
|
2
|
-
def
|
3
|
-
super
|
4
|
-
|
5
|
-
end
|
2
|
+
def configure(c)
|
3
|
+
super
|
4
|
+
c.tools = [:refresh, :gear]
|
6
5
|
end
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
js_configure do |c|
|
8
|
+
c.on_refresh = <<-JS
|
9
|
+
function(){
|
10
|
+
this.setTitle("Refresh" + " clicked");
|
11
|
+
}
|
12
|
+
JS
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
c.on_gear = <<-JS
|
15
|
+
function(){
|
16
|
+
this.setTitle("Gear" + " clicked")
|
17
|
+
}
|
18
|
+
JS
|
19
|
+
end
|
19
20
|
end
|
@@ -1,14 +1,22 @@
|
|
1
1
|
class PluginWithComponents < Netzke::Plugin
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
js_configure do |c|
|
3
|
+
c.init = <<-JS
|
4
|
+
function(cmp){
|
5
|
+
this.cmp = cmp;
|
6
|
+
this.cmp.tools = this.cmp.tools || [];
|
7
|
+
this.cmp.tools.push({type: 'help', handler: function(){
|
8
|
+
// we can instantiate this because it was eagerly loaded
|
9
|
+
var w = this.netzkeInstantiateComponent('simple_window');
|
10
|
+
w.show();
|
11
|
+
}, scope: this});
|
12
|
+
}
|
13
|
+
JS
|
14
|
+
end
|
12
15
|
|
13
|
-
component :simple_window
|
14
|
-
|
16
|
+
component :simple_window do |c|
|
17
|
+
c.width = 300
|
18
|
+
c.height = 200
|
19
|
+
c.title = "Window created by PluginWithComponents"
|
20
|
+
c.eager_loading = true
|
21
|
+
end
|
22
|
+
end
|
@@ -1,7 +1,10 @@
|
|
1
1
|
module ScopedComponents
|
2
2
|
module DeepScopedComponents
|
3
3
|
class SomeDeepScopedComponent < ScopedComponents::SomeScopedComponent
|
4
|
-
|
4
|
+
js_configure do |c|
|
5
|
+
c.title = "Some Deep Scoped Component Title"
|
6
|
+
c.html = "Some Deep Scoped Component HTML"
|
7
|
+
end
|
5
8
|
end
|
6
9
|
end
|
7
|
-
end
|
10
|
+
end
|
@@ -1,5 +1,8 @@
|
|
1
1
|
module ScopedComponents
|
2
2
|
class ExtendedScopedComponent < SomeScopedComponent
|
3
|
-
|
3
|
+
js_configure do |c|
|
4
|
+
c.title = "Extended Scoped Component Title"
|
5
|
+
c.html = "Extended Scoped Component HTML"
|
6
|
+
end
|
4
7
|
end
|
5
|
-
end
|
8
|
+
end
|
@@ -1,5 +1,8 @@
|
|
1
1
|
module ScopedComponents
|
2
2
|
class SomeScopedComponent < Netzke::Base
|
3
|
-
|
3
|
+
js_configure do |c|
|
4
|
+
c.title = "Some Scoped Component Title"
|
5
|
+
c.html = "Some Scoped Component HTML"
|
6
|
+
end
|
4
7
|
end
|
5
|
-
end
|
8
|
+
end
|
@@ -1,23 +1,45 @@
|
|
1
1
|
class ServerCaller < Netzke::Base
|
2
|
-
title "Server Caller!"
|
3
|
-
|
4
2
|
action :bug_server # Actual action's text is set in en.yml
|
3
|
+
action :no_response
|
4
|
+
action :multiple_arguments
|
5
|
+
action :array_as_argument
|
6
|
+
|
7
|
+
# this action is using generic endpoint callback with scope
|
8
|
+
action :call_with_generic_callback_and_scope
|
9
|
+
|
10
|
+
js_configure do |c|
|
11
|
+
c.title = "Server Caller"
|
12
|
+
c.html = "Wow"
|
13
|
+
c.mixin
|
14
|
+
end
|
15
|
+
|
16
|
+
def configure(c)
|
17
|
+
super
|
18
|
+
c.bbar = [:bug_server, :no_response, :multiple_arguments, :array_as_argument, :call_with_generic_callback_and_scope]
|
19
|
+
|
20
|
+
# Alternative way of defining bbar:
|
21
|
+
# c.docked_items = [{
|
22
|
+
# xtype: :toolbar,
|
23
|
+
# dock: :right,
|
24
|
+
# items: [:bug_server, :no_response, :multiple_arguments, :array_as_argument]
|
25
|
+
# }]
|
26
|
+
end
|
5
27
|
|
6
|
-
|
7
|
-
|
8
|
-
:html => "Wow",
|
9
|
-
:tbar => [:bug_server.action] # NOTE: used to be bbar, but Ext >= 4.0.2 has problems with rendering it!
|
10
|
-
)
|
11
|
-
|
12
|
-
js_method :on_bug_server, <<-JS
|
13
|
-
function(){
|
14
|
-
this.whatsUp();
|
15
|
-
this.update('You should see the response from the server in the title bar the very next moment');
|
16
|
-
}
|
17
|
-
JS
|
18
|
-
|
19
|
-
endpoint :whats_up do |params|
|
20
|
-
{:set_title => "All quiet here on the server"}
|
28
|
+
endpoint :whats_up do |params, this|
|
29
|
+
this.set_title("All quiet here on the server")
|
21
30
|
end
|
22
31
|
|
32
|
+
endpoint :no_response do |params, this|
|
33
|
+
end
|
34
|
+
|
35
|
+
endpoint :multiple_arguments do |params, this|
|
36
|
+
this.take_two_arguments("First argument", "Second argument")
|
37
|
+
end
|
38
|
+
|
39
|
+
endpoint :array_as_argument do |params, this|
|
40
|
+
this.take_array_as_argument(['Element 1', 'Element 2'])
|
41
|
+
end
|
42
|
+
|
43
|
+
endpoint :do_nothing do |params,this|
|
44
|
+
end
|
23
45
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
{
|
2
|
+
onBugServer: function(){
|
3
|
+
this.whatsUp();
|
4
|
+
this.update('You should see the response from the server in the title bar the very next moment');
|
5
|
+
},
|
6
|
+
|
7
|
+
onNoResponse: function(){
|
8
|
+
this.noResponse({}, function(){
|
9
|
+
this.update('Successfully called endpoint with no response (this is a callback)');
|
10
|
+
}, this);
|
11
|
+
},
|
12
|
+
|
13
|
+
onMultipleArguments: function(){
|
14
|
+
this.multipleArguments();
|
15
|
+
},
|
16
|
+
|
17
|
+
takeTwoArguments: function(first, second){
|
18
|
+
this.update("Called a function with two arguments: " + first + ", " + second);
|
19
|
+
},
|
20
|
+
|
21
|
+
onArrayAsArgument: function() {
|
22
|
+
this.arrayAsArgument();
|
23
|
+
},
|
24
|
+
|
25
|
+
takeArrayAsArgument: function(arry) {
|
26
|
+
var arryAsString = "['"+ arry.join("', '") + "']";
|
27
|
+
this.update("Called a function with array as arguments: " + arryAsString);
|
28
|
+
},
|
29
|
+
|
30
|
+
onCallWithGenericCallbackAndScope: function(){
|
31
|
+
var that=this;
|
32
|
+
var fancyScope={
|
33
|
+
setFancyTitle: function () {
|
34
|
+
that.setTitle("Fancy title" + " set!");
|
35
|
+
}
|
36
|
+
};
|
37
|
+
this.doNothing({}, function () {
|
38
|
+
this.setFancyTitle();
|
39
|
+
}, fancyScope);
|
40
|
+
},
|
41
|
+
|
42
|
+
}
|
@@ -6,107 +6,43 @@ class ServerCounter < Netzke::Base
|
|
6
6
|
action :do_ordered # used for test if call order is preserved
|
7
7
|
action :fail_two_out_of_five # sends 5 requests, 2 will fail, but the request should be processed in order
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
)
|
13
|
-
|
14
|
-
js_method :on_count_one_time, <<-JS
|
15
|
-
function(){
|
16
|
-
this.count({how_many: 1});
|
17
|
-
}
|
18
|
-
JS
|
19
|
-
|
20
|
-
js_method :init_component, <<-JS
|
21
|
-
function () {
|
22
|
-
#{js_full_class_name}.superclass.initComponent.call(this);
|
23
|
-
Ext.Ajax.on('beforerequest',function (conn, options ) {
|
24
|
-
Netzke.connectionCount = Netzke.connectionCount || 0;
|
25
|
-
Netzke.connectionCount++;
|
26
|
-
Netzke.lastOptions=options;
|
27
|
-
});
|
28
|
-
}
|
29
|
-
JS
|
30
|
-
|
31
|
-
js_method :on_count_seven_times, <<-JS
|
32
|
-
function(){
|
33
|
-
for(var i=0; i<7; i++)
|
34
|
-
this.count({how_many: 1});
|
35
|
-
}
|
36
|
-
JS
|
37
|
-
|
38
|
-
js_method :on_count_eight_times_special, <<-JS
|
39
|
-
function(){
|
40
|
-
for(var i=0;i<8;i++)
|
41
|
-
this.count({how_many: 1, special: true});
|
42
|
-
}
|
43
|
-
JS
|
44
|
-
|
45
|
-
# TODO: is it actually meant to succeed and display "Something succeeded"?..
|
46
|
-
js_method :on_fail_in_the_middle, <<-JS
|
47
|
-
function() {
|
48
|
-
this.successingEndpoint();
|
49
|
-
this.failingEndpoint();
|
50
|
-
this.successingEndpoint();
|
51
|
-
}
|
52
|
-
JS
|
53
|
-
|
54
|
-
js_method :on_do_ordered, <<-JS
|
55
|
-
function () {
|
56
|
-
this.firstEp();
|
57
|
-
this.secondEp();
|
58
|
-
}
|
59
|
-
JS
|
60
|
-
|
61
|
-
js_method :update_appending, <<-JS
|
62
|
-
function(html){
|
63
|
-
if (!this.panelText) { this.panelText = ""; }
|
64
|
-
this.panelText += html + ",";
|
65
|
-
this.body.update(this.panelText);
|
66
|
-
}
|
67
|
-
JS
|
68
|
-
|
69
|
-
js_method :on_fail_two_out_of_five, <<-JS
|
70
|
-
function(){
|
71
|
-
for(var i=1; i<=5; i++) {
|
72
|
-
this.failTwoOutOfFive(i);
|
73
|
-
}
|
74
|
-
}
|
75
|
-
JS
|
9
|
+
js_configure do |c|
|
10
|
+
c.mixin
|
11
|
+
end
|
76
12
|
|
77
|
-
def
|
78
|
-
|
79
|
-
|
13
|
+
def configure(c)
|
14
|
+
super
|
15
|
+
c.bbar = [:count_one_time, :count_seven_times, :count_eight_times_special, :fail_in_the_middle, :do_ordered, :fail_two_out_of_five]
|
16
|
+
c.title "Server Counter"
|
80
17
|
end
|
81
18
|
|
82
|
-
endpoint :count do |params|
|
19
|
+
endpoint :count do |params, this|
|
83
20
|
component_session[:count] ||= 0
|
84
21
|
component_session[:count] += params[:how_many]
|
85
|
-
|
22
|
+
this.update_content("I am at " + component_session[:count].to_s + (params[:special] ? ' and i was invoked specially' : ''))
|
86
23
|
end
|
87
24
|
|
88
|
-
endpoint :successing_endpoint do |params|
|
89
|
-
|
25
|
+
endpoint :successing_endpoint do |params, this|
|
26
|
+
this.update_content("Something successed ")
|
90
27
|
end
|
91
28
|
|
92
|
-
endpoint :failing_endpoint do |params|
|
29
|
+
endpoint :failing_endpoint do |params, this|
|
93
30
|
throw "something happened"
|
94
|
-
{:update => "This will never get returned"}
|
95
31
|
end
|
96
32
|
|
97
|
-
endpoint :first_ep do |params|
|
33
|
+
endpoint :first_ep do |params, this|
|
98
34
|
component_session[:count]||=0
|
99
35
|
component_session[:count]+=1
|
100
|
-
|
36
|
+
this.update_content("First. "+ component_session[:count].to_s)
|
101
37
|
end
|
102
38
|
|
103
|
-
endpoint :second_ep do |params|
|
39
|
+
endpoint :second_ep do |params, this|
|
104
40
|
component_session[:count]||=0
|
105
41
|
component_session[:count]+=1
|
106
|
-
|
42
|
+
this.update_content("Second. "+ component_session[:count].to_s)
|
107
43
|
end
|
108
44
|
|
109
|
-
endpoint :fail_two_out_of_five do |count|
|
45
|
+
endpoint :fail_two_out_of_five do |count, this|
|
110
46
|
component_session[:count] ||= 0
|
111
47
|
component_session[:count] += 1
|
112
48
|
|
@@ -117,7 +53,7 @@ class ServerCounter < Netzke::Base
|
|
117
53
|
end
|
118
54
|
|
119
55
|
component_session[:is_retry] = false
|
120
|
-
|
56
|
+
this.update_appending(count)
|
121
57
|
end
|
122
58
|
|
123
59
|
end
|