netzke-core 0.6.7 → 0.7.0
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 +36 -1
- data/{README.markdown → README.md} +17 -15
- data/Rakefile +1 -1
- data/TODO +4 -4
- data/app/controllers/netzke_controller.rb +8 -3
- data/javascripts/base.js +71 -68
- data/javascripts/ext.js +182 -111
- data/lib/netzke/actions.rb +2 -1
- data/lib/netzke/base.rb +5 -1
- data/lib/netzke/composition.rb +2 -2
- data/lib/netzke/configuration.rb +1 -1
- data/lib/netzke/core/dynamic_assets.rb +7 -7
- data/lib/netzke/core/session.rb +4 -0
- data/lib/netzke/core/version.rb +2 -2
- data/lib/netzke/core.rb +23 -30
- data/lib/netzke/core_ext/symbol.rb +1 -1
- data/lib/netzke/embedding.rb +1 -1
- data/lib/netzke/ext_component.rb +2 -2
- data/lib/netzke/javascript.rb +70 -39
- data/lib/netzke/plugin.rb +15 -0
- data/lib/netzke/plugins.rb +29 -0
- data/lib/netzke/railz/action_view_ext/ext.rb +13 -16
- data/lib/netzke/railz/action_view_ext/touch.rb +3 -3
- data/lib/netzke/railz/action_view_ext.rb +0 -3
- data/lib/netzke/railz/engine.rb +34 -29
- data/lib/netzke/services.rb +1 -1
- data/lib/netzke/state.rb +2 -2
- data/lib/netzke-core.rb +1 -0
- data/netzke-core.gemspec +108 -9
- data/stylesheets/core.css +25 -5
- data/test/rails_app/Gemfile +1 -1
- data/test/rails_app/Gemfile.lock +37 -36
- data/test/rails_app/app/components/component_loader.rb +36 -24
- data/test/rails_app/app/components/component_with_js_mixin/javascripts/component_with_js_mixin.js +5 -0
- data/test/rails_app/app/components/component_with_js_mixin.rb +3 -1
- data/test/rails_app/app/components/component_with_nested_through.rb +28 -0
- data/test/rails_app/app/components/component_with_session_persistence.rb +7 -5
- data/test/rails_app/app/components/dynamic_tab_panel/javascripts/dynamic_tab_panel.js +9 -0
- data/test/rails_app/app/components/dynamic_tab_panel.rb +19 -0
- data/test/rails_app/app/components/extended_server_caller.rb +6 -5
- data/test/rails_app/app/components/loader_of_component_with_custom_css.rb +7 -8
- data/test/rails_app/app/components/localized_panel.rb +10 -1
- data/test/rails_app/app/components/nested_component.rb +18 -0
- data/test/rails_app/app/components/panel_with_plugin.rb +4 -0
- data/test/rails_app/app/components/panel_with_tools.rb +19 -0
- data/test/rails_app/app/components/plugin_with_components.rb +14 -0
- data/test/rails_app/app/components/server_caller.rb +1 -1
- data/test/rails_app/app/components/server_counter.rb +1 -1
- data/test/rails_app/app/components/simple_component.rb +2 -0
- data/test/rails_app/app/components/simple_tab_panel.rb +21 -21
- data/test/rails_app/app/components/simple_window.rb +1 -1
- data/test/rails_app/app/components/some_composite.rb +3 -2
- data/test/rails_app/app/components/some_plugin.rb +39 -0
- data/test/rails_app/app/controllers/application_controller.rb +1 -1
- data/test/rails_app/app/controllers/components_controller.rb +1 -1
- data/test/rails_app/app/views/layouts/touch.html.erb +1 -1
- data/test/rails_app/config/application.rb +0 -2
- data/test/rails_app/config/initializers/netzke.rb +2 -1
- data/test/rails_app/config/locales/es.yml +1 -0
- data/test/rails_app/features/{actions.feature → actions_and_tools.feature} +8 -0
- data/test/rails_app/features/client-server.feature +0 -1
- data/test/rails_app/features/complex_component.feature +1 -1
- data/test/rails_app/features/component_loader.feature +7 -0
- data/test/rails_app/features/composition.feature +2 -2
- data/test/rails_app/features/custom_css.feature +1 -1
- data/test/rails_app/features/i18n.feature +3 -0
- data/test/rails_app/features/js_include.feature +2 -0
- data/test/rails_app/features/nested_views.feature +5 -4
- data/test/rails_app/features/plugin.feature +16 -0
- data/test/rails_app/features/step_definitions/generic_steps.rb +21 -2
- data/test/rails_app/features/touch.feature +10 -10
- data/test/rails_app/spec/component/component_spec.rb +20 -0
- metadata +106 -10
- data/app/models/netzke_preference.rb +0 -170
@@ -2,14 +2,13 @@
|
|
2
2
|
class LoaderOfComponentWithCustomCss < Netzke::Base
|
3
3
|
component :component_with_custom_css, :class_name => "ComponentWithCustomCss", :lazy_loading => true
|
4
4
|
|
5
|
-
|
5
|
+
action :load_component_with_custom_css
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
}, this);
|
7
|
+
js_properties :title => "LoaderOfComponentWithCustomCss", :layout => 'fit', :bbar => [:load_component_with_custom_css.action]
|
8
|
+
|
9
|
+
js_method :on_load_component_with_custom_css, <<-JS
|
10
|
+
function(params){
|
11
|
+
this.loadComponent({name: 'component_with_custom_css'});
|
13
12
|
}
|
14
13
|
JS
|
15
|
-
end
|
14
|
+
end
|
@@ -7,9 +7,11 @@ class LocalizedPanel < Netzke::Base
|
|
7
7
|
{:text => I18n.t('localized_panel.action_two')}
|
8
8
|
end
|
9
9
|
|
10
|
+
action :action_three
|
11
|
+
|
10
12
|
js_translate :property_one, :property_two
|
11
13
|
|
12
|
-
js_property :bbar, [:action_one.action, :action_two.action]
|
14
|
+
js_property :bbar, [:action_one.action, :action_two.action, :action_three.action]
|
13
15
|
|
14
16
|
def configuration
|
15
17
|
super.tap do |c|
|
@@ -25,4 +27,11 @@ class LocalizedPanel < Netzke::Base
|
|
25
27
|
}
|
26
28
|
JS
|
27
29
|
|
30
|
+
js_method :on_action_three, <<-JS
|
31
|
+
function(){
|
32
|
+
var mask = new Ext.LoadMask(this.body);
|
33
|
+
mask.show();
|
34
|
+
}
|
35
|
+
JS
|
36
|
+
|
28
37
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class NestedComponent < Netzke::Base
|
2
|
+
js_property :layout, :fit
|
3
|
+
|
4
|
+
def configuration
|
5
|
+
super.tap do |c|
|
6
|
+
c[:items] = [:child.component]
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
component :child,
|
11
|
+
:class_name => "SimpleComponent",
|
12
|
+
:layout => 'accordion',
|
13
|
+
:items => [:grand_child_one.component, :grand_child_two.component],
|
14
|
+
:components => {
|
15
|
+
:grand_child_one => {:class_name => "SimpleComponent", :title => "Grand Child One"},
|
16
|
+
:grand_child_two => {:class_name => "NestedComponent", :title => "Grand Child Two", :lazy_loading => true}
|
17
|
+
}
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class PanelWithTools < Netzke::Base
|
2
|
+
def configuration
|
3
|
+
super.tap do |c|
|
4
|
+
c[:tools] = [:refresh, :gear]
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
js_method :on_refresh, <<-JS
|
9
|
+
function(){
|
10
|
+
this.setTitle("Refresh" + " clicked");
|
11
|
+
}
|
12
|
+
JS
|
13
|
+
|
14
|
+
js_method :on_gear, <<-JS
|
15
|
+
function(){
|
16
|
+
this.setTitle("Gear" + " clicked")
|
17
|
+
}
|
18
|
+
JS
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class PluginWithComponents < Netzke::Plugin
|
2
|
+
js_method :init, <<-JS
|
3
|
+
function(cmp){
|
4
|
+
this.cmp = cmp;
|
5
|
+
this.cmp.tools = this.cmp.tools || [];
|
6
|
+
this.cmp.tools.push({type: 'help', handler: function(){
|
7
|
+
var w = this.instantiateChildNetzkeComponent('simple_window');
|
8
|
+
w.show();
|
9
|
+
}, scope: this});
|
10
|
+
}
|
11
|
+
JS
|
12
|
+
|
13
|
+
component :simple_window, :width => 300, :height => 200, :title => "Window created by PluginWithComponents"
|
14
|
+
end
|
@@ -4,7 +4,7 @@ class ServerCaller < Netzke::Base
|
|
4
4
|
js_properties(
|
5
5
|
:title => "Server Caller",
|
6
6
|
:html => "Wow",
|
7
|
-
:
|
7
|
+
:tbar => [:bug_server.action] # TODO: used to be bbar, but Ext 4.0.2 has problems with rendering it!
|
8
8
|
)
|
9
9
|
|
10
10
|
js_method :on_bug_server, <<-JS
|
@@ -25,7 +25,6 @@ class ServerCounter < Netzke::Base
|
|
25
25
|
Netzke.connectionCount++;
|
26
26
|
Netzke.lastOptions=options;
|
27
27
|
});
|
28
|
-
|
29
28
|
}
|
30
29
|
JS
|
31
30
|
|
@@ -43,6 +42,7 @@ class ServerCounter < Netzke::Base
|
|
43
42
|
}
|
44
43
|
JS
|
45
44
|
|
45
|
+
# TODO: is it actually meant to succeed and display "Something succeeded"?..
|
46
46
|
js_method :on_fail_in_the_middle, <<-JS
|
47
47
|
function() {
|
48
48
|
this.successingEndpoint();
|
@@ -3,25 +3,25 @@ class SimpleTabPanel < Netzke::Base
|
|
3
3
|
|
4
4
|
js_property :active_tab, 0
|
5
5
|
|
6
|
-
config :items => [{
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
6
|
+
# config :items => [{
|
7
|
+
# # Loading a primitive BorderLayoutPanel here
|
8
|
+
# :class_name => "BorderLayoutPanel",
|
9
|
+
# :title => "A border layout panel",
|
10
|
+
# :items => [{
|
11
|
+
# :region => :north,
|
12
|
+
# :height => 100,
|
13
|
+
# :title => "I'm NOT a Netzke component",
|
14
|
+
# :html => "I'm a simple panel"
|
15
|
+
# },{
|
16
|
+
# :region => :center,
|
17
|
+
# :class_name => "ServerCaller"
|
18
|
+
# },{
|
19
|
+
# :region => :west,
|
20
|
+
# :width => 300,
|
21
|
+
# :split => true,
|
22
|
+
# :class_name => "ExtendedServerCaller"
|
23
|
+
# }]
|
24
|
+
# },{
|
25
|
+
# :class_name => "ExtendedServerCaller"
|
26
|
+
# }]
|
27
27
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
class SomeComposite < Netzke::Base
|
2
2
|
js_properties :title => "Static Composite",
|
3
|
+
:height => 400,
|
3
4
|
:layout => 'border',
|
4
5
|
:bbar => [
|
5
6
|
:update_west_panel.action,
|
@@ -26,9 +27,9 @@ class SomeComposite < Netzke::Base
|
|
26
27
|
|
27
28
|
component :center_panel, :class_name => "ServerCaller"
|
28
29
|
|
29
|
-
component :east_center_panel, :class_name => "SimpleComponent", :title => "A panel"
|
30
|
+
component :east_center_panel, :class_name => "SimpleComponent", :title => "A panel", :border => false
|
30
31
|
|
31
|
-
component :east_south_panel, :class_name => "SimpleComponent", :title => "Another panel"
|
32
|
+
component :east_south_panel, :class_name => "SimpleComponent", :title => "Another panel", :border => false
|
32
33
|
|
33
34
|
endpoint :update_east_south do |params|
|
34
35
|
{:east_south_panel => {:set_title => "Here's an update for south panel in east panel"}}
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class SomePlugin < Netzke::Plugin
|
2
|
+
action :action_one
|
3
|
+
|
4
|
+
js_method :init, <<-JS
|
5
|
+
function(){
|
6
|
+
this.callParent(arguments);
|
7
|
+
this.cmp.tools = [{id: 'gear', handler: this.onGear, scope: this}];
|
8
|
+
|
9
|
+
this.cmp.addDocked({
|
10
|
+
dock: 'bottom',
|
11
|
+
xtype: 'toolbar',
|
12
|
+
items: [this.actions.actionOne]
|
13
|
+
});
|
14
|
+
}
|
15
|
+
JS
|
16
|
+
|
17
|
+
js_method :on_action_one, <<-JS
|
18
|
+
function(){
|
19
|
+
this.cmp.setTitle('Action one ' + 'triggered');
|
20
|
+
}
|
21
|
+
JS
|
22
|
+
|
23
|
+
js_method :on_gear, <<-JS
|
24
|
+
function(){
|
25
|
+
this.processGear();
|
26
|
+
}
|
27
|
+
JS
|
28
|
+
|
29
|
+
js_method :process_gear_callback, <<-JS
|
30
|
+
function(newTitle){
|
31
|
+
this.cmp.setTitle(newTitle);
|
32
|
+
}
|
33
|
+
JS
|
34
|
+
|
35
|
+
endpoint :process_gear do |params|
|
36
|
+
{:process_gear_callback => "Server response"}
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class ComponentsController < ApplicationController
|
2
2
|
def index
|
3
3
|
component_name = params[:component].gsub("::", "_").underscore
|
4
|
-
render :inline => "<%= netzke :#{component_name}, :class_name => '#{params[:component]}' %>", :layout => true
|
4
|
+
render :inline => "<%= netzke :#{component_name}, :class_name => '#{params[:component]}', :height => 400 %>", :layout => true
|
5
5
|
end
|
6
6
|
|
7
7
|
# For panel_with_autoload
|
@@ -11,3 +11,11 @@ Scenario: Pressing button should result in corresponding actions
|
|
11
11
|
|
12
12
|
When I press "Some Cool Action"
|
13
13
|
Then I should see "Some action was triggered"
|
14
|
+
|
15
|
+
@javascript
|
16
|
+
Scenario: Pressing a tool should result in corresponding action
|
17
|
+
Given I am on the PanelWithTools test page
|
18
|
+
When I press tool "gear"
|
19
|
+
Then I should see "Gear clicked"
|
20
|
+
When I press tool "refresh"
|
21
|
+
Then I should see "Refresh clicked"
|
@@ -8,6 +8,5 @@ Scenario: Ask server to set our title
|
|
8
8
|
Given I am on the ServerCaller test page
|
9
9
|
Then I should see "Server Caller"
|
10
10
|
|
11
|
-
# When I execute "Ext.getCmp('server_caller').buttons.first().fireEvent('click');"
|
12
11
|
When I press "Call server"
|
13
12
|
Then I should see "All quiet here on the server"
|
@@ -13,6 +13,6 @@ Feature: Complex component
|
|
13
13
|
@javascript
|
14
14
|
Scenario: The last tab of the complex component is a Netzke component that just works
|
15
15
|
Given I am on the KindaComplexComponent test page
|
16
|
-
When I
|
16
|
+
When I press "Server Caller"
|
17
17
|
And I press "Call server"
|
18
18
|
Then I should see "All quiet here on the server"
|
@@ -43,3 +43,10 @@ Feature: Component loader
|
|
43
43
|
Given I am on the ComponentLoader test page
|
44
44
|
When I press "Load with params"
|
45
45
|
Then I should see "Simple Component with changed HTML"
|
46
|
+
|
47
|
+
@javascript
|
48
|
+
Scenario: Component loader should report that it can't load a component
|
49
|
+
Given I am on the ComponentLoader test page
|
50
|
+
When I press "Non-existing component"
|
51
|
+
Then I should see "Couldn't load component 'non_existing_component'"
|
52
|
+
And I should not see "Loading"
|
@@ -23,9 +23,9 @@ Feature: Composition
|
|
23
23
|
Scenario: Server should be able to address (deeply) nested components
|
24
24
|
Given I am on the SomeComposite test page
|
25
25
|
When I press "Update west from server"
|
26
|
-
And I
|
26
|
+
And I wait for response from server
|
27
27
|
Then I should see "Here's an update for west panel"
|
28
28
|
|
29
29
|
When I press "Update east south from server"
|
30
|
-
And I
|
30
|
+
And I wait for response from server
|
31
31
|
Then I should see "Here's an update for south panel in east panel"
|
@@ -12,6 +12,6 @@ Feature: Custom css
|
|
12
12
|
@javascript
|
13
13
|
Scenario: A dynamically loaded component with a hidden body should not display its body
|
14
14
|
When I go to the LoaderOfComponentWithCustomCss test page
|
15
|
-
And I press "Load
|
15
|
+
And I press "Load component with custom css"
|
16
16
|
Then I should see "ComponentWithCustomCss"
|
17
17
|
But the body of LoaderOfComponentWithCustomCss/ComponentWithCustomCss component should not be invisible
|
@@ -17,6 +17,9 @@ Scenario: LocalizedPanel should be available in 2 languages
|
|
17
17
|
And I should see "Primera acción"
|
18
18
|
And I should see "Segunda acción"
|
19
19
|
|
20
|
+
When I press "Tercera acción"
|
21
|
+
Then I should see "Cargando..."
|
22
|
+
|
20
23
|
When I go to the "es" version of the ExtendedLocalizedPanel page
|
21
24
|
Then I should see "Panel Localizada"
|
22
25
|
And I should see "Primera propriedad, Segunda propriedad"
|
@@ -10,6 +10,8 @@ Feature: JsMixins
|
|
10
10
|
Then I should see "Action One triggered!"
|
11
11
|
When I press "Action two"
|
12
12
|
Then I should see "Action Two triggered!"
|
13
|
+
When I press "Action three"
|
14
|
+
Then I should see "Action Three triggered!"
|
13
15
|
|
14
16
|
@javascript
|
15
17
|
Scenario: ExtendedComponentWithJsMixin should behave, too
|
@@ -3,7 +3,8 @@ Feature: Nested views
|
|
3
3
|
As a role
|
4
4
|
I want feature
|
5
5
|
|
6
|
-
@javascript
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
# @javascript
|
7
|
+
# WIP: This scenario may never be needed
|
8
|
+
# Scenario: A component with auto loaded content should render properly
|
9
|
+
# When I go to the "panel with autoload" view
|
10
|
+
# Then I should see "Autoloaded Panel"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Feature: Plugin
|
2
|
+
In order to value
|
3
|
+
As a role
|
4
|
+
I want feature
|
5
|
+
|
6
|
+
@javascript
|
7
|
+
Scenario: Plugin calling its server part
|
8
|
+
Given I am on the PanelWithPlugin test page
|
9
|
+
When I press tool "gear"
|
10
|
+
Then I should see "Server response"
|
11
|
+
|
12
|
+
@javascript
|
13
|
+
Scenario: Plugin inserting its action into component
|
14
|
+
Given I am on the PanelWithPlugin test page
|
15
|
+
When I press "Action one"
|
16
|
+
Then I should see "Action one triggered"
|
@@ -8,14 +8,14 @@ end
|
|
8
8
|
|
9
9
|
Then /^button "([^"]*)" should be enabled$/ do |arg1|
|
10
10
|
page.driver.browser.execute_script(<<-JS).should == true
|
11
|
-
var btn = Ext.
|
11
|
+
var btn = Array.filter( Ext.ComponentManager.all.getValues(), function(o){ return o.text == '#{arg1}' })[0];
|
12
12
|
return typeof(btn)!='undefined' ? !btn.disabled : false
|
13
13
|
JS
|
14
14
|
end
|
15
15
|
|
16
16
|
Then /^button "([^"]*)" should be disabled$/ do |arg1|
|
17
17
|
page.driver.browser.execute_script(<<-JS).should == true
|
18
|
-
var btn = Ext.
|
18
|
+
var btn = Array.filter( Ext.ComponentManager.all.getValues(), function(o){ return o.text == '#{arg1}' })[0];
|
19
19
|
return typeof(btn)!='undefined' ? btn.disabled : false
|
20
20
|
JS
|
21
21
|
end
|
@@ -26,6 +26,25 @@ When /^total requests made should be (\d+)$/ do |count|
|
|
26
26
|
JS
|
27
27
|
end
|
28
28
|
|
29
|
+
When /^I press tool "([^"]*)"$/ do |tool|
|
30
|
+
id = page.driver.browser.execute_script(<<-JS)
|
31
|
+
var toolCmp;
|
32
|
+
Ext.ComponentManager.all.each(function(k,v){
|
33
|
+
if (v.type == '#{tool}') {
|
34
|
+
toolCmp = v;
|
35
|
+
return false;
|
36
|
+
}
|
37
|
+
});
|
38
|
+
return toolCmp.getId();
|
39
|
+
JS
|
40
|
+
|
41
|
+
find("##{id} img").click
|
42
|
+
end
|
43
|
+
|
44
|
+
When /^I wait for response from server$/ do
|
45
|
+
page.wait_until{ page.driver.browser.execute_script("return !Netzke.ajaxIsLoading()") }
|
46
|
+
end
|
47
|
+
|
29
48
|
When /I sleep (\d+) seconds?/ do |arg1|
|
30
49
|
sleep arg1.to_i
|
31
50
|
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
Feature: Touch - to be run in Chrome only
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
@javascript
|
7
|
-
Scenario: Client-server communication
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
# Feature: Touch - to be run in Chrome only
|
2
|
+
# In order to value
|
3
|
+
# As a role
|
4
|
+
# I want feature
|
5
|
+
#
|
6
|
+
# @javascript
|
7
|
+
# Scenario: Client-server communication
|
8
|
+
# Given I am on the ServerCaller page for touch
|
9
|
+
# When I press button "Bug server"
|
10
|
+
# Then I should see "Hello from the server!"
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
require "netzke-core"
|
3
|
+
|
4
|
+
describe "Any component" do
|
5
|
+
|
6
|
+
class TestComponent < Netzke::Base
|
7
|
+
|
8
|
+
endpoint :some_action do
|
9
|
+
{}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should be able to register endpoints" do
|
14
|
+
TestComponent.endpoints.should include :some_action
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should have deliver_component endpoint by default" do
|
18
|
+
TestComponent.endpoints.should include :deliver_component
|
19
|
+
end
|
20
|
+
end
|