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.
Files changed (192) hide show
  1. data/.travis.yml +1 -2
  2. data/CHANGELOG.md +572 -0
  3. data/LICENSE +7 -1
  4. data/README.md +345 -29
  5. data/Rakefile +3 -3
  6. data/app/controllers/netzke_controller.rb +37 -48
  7. data/config/ci/before-travis.sh +3 -4
  8. data/javascripts/base.js +86 -150
  9. data/javascripts/ext.js +180 -210
  10. data/javascripts/{core_extensions.js → js_extensions.js} +0 -0
  11. data/lib/netzke-core.rb +16 -6
  12. data/lib/netzke/base.rb +84 -107
  13. data/lib/netzke/core.rb +7 -41
  14. data/lib/netzke/core/action_config.rb +37 -0
  15. data/lib/netzke/core/actions.rb +123 -0
  16. data/lib/netzke/core/client_class.rb +252 -0
  17. data/lib/netzke/core/component_config.rb +12 -0
  18. data/lib/netzke/core/composition.rb +274 -0
  19. data/lib/netzke/core/config_to_dsl_delegator.rb +69 -0
  20. data/lib/netzke/core/configuration.rb +63 -0
  21. data/lib/netzke/core/css_config.rb +51 -0
  22. data/lib/netzke/core/dynamic_assets.rb +19 -49
  23. data/lib/netzke/{embedding.rb → core/embedding.rb} +4 -6
  24. data/lib/netzke/core/endpoint_response.rb +15 -0
  25. data/lib/netzke/core/javascript.rb +111 -0
  26. data/lib/netzke/core/panel.rb +11 -0
  27. data/lib/netzke/{plugins.rb → core/plugins.rb} +10 -5
  28. data/lib/netzke/core/railz.rb +4 -0
  29. data/lib/netzke/{railz → core/railz}/action_view_ext.rb +22 -18
  30. data/lib/netzke/core/railz/action_view_ext/ext.rb +49 -0
  31. data/lib/netzke/core/railz/controller_extensions.rb +17 -0
  32. data/lib/netzke/core/railz/engine.rb +16 -0
  33. data/lib/netzke/core/railz/routes.rb +10 -0
  34. data/lib/netzke/core/ruby_ext.rb +5 -0
  35. data/lib/netzke/core/ruby_ext/array.rb +23 -0
  36. data/lib/netzke/core/ruby_ext/hash.rb +47 -0
  37. data/lib/netzke/{core_ext → core/ruby_ext}/string.rb +2 -7
  38. data/lib/netzke/core/ruby_ext/symbol.rb +13 -0
  39. data/lib/netzke/{core_ext → core/ruby_ext}/time_with_zone.rb +0 -0
  40. data/lib/netzke/core/services.rb +130 -0
  41. data/lib/netzke/core/session.rb +15 -19
  42. data/lib/netzke/core/state.rb +40 -0
  43. data/lib/netzke/core/stylesheets.rb +48 -0
  44. data/lib/netzke/core/version.rb +2 -2
  45. data/lib/netzke/plugin.rb +8 -11
  46. data/netzke-core.gemspec +69 -59
  47. data/test/core_test_app/Gemfile +2 -20
  48. data/test/core_test_app/Gemfile.lock +65 -74
  49. data/test/core_test_app/app/components/card_component_loader.rb +4 -4
  50. data/test/core_test_app/app/components/component_loader.rb +40 -120
  51. data/test/core_test_app/app/components/component_loader/javascripts/component_loader.js +49 -0
  52. data/test/core_test_app/app/components/component_with_actions.rb +61 -47
  53. data/test/core_test_app/app/components/component_with_custom_css.rb +8 -5
  54. data/test/core_test_app/app/components/component_with_js_mixin.rb +11 -5
  55. data/test/core_test_app/app/components/component_with_js_mixin/javascripts/extra_one.js +1 -1
  56. data/test/core_test_app/app/components/component_with_js_mixin/javascripts/extra_two.js +1 -1
  57. data/test/core_test_app/app/components/component_with_js_mixin/javascripts/method_set_one.js +1 -1
  58. data/test/core_test_app/app/components/component_with_nested_through.rb +2 -2
  59. data/test/core_test_app/app/components/component_with_prebuilt_toolbar_control.rb +12 -0
  60. data/test/core_test_app/app/components/component_with_prebuilt_toolbar_control/javascripts/component_with_prebuilt_toolbar_control.js +12 -0
  61. data/test/core_test_app/app/components/component_with_required_js.rb +24 -0
  62. data/test/core_test_app/app/components/configurable_on_class_level.rb +8 -0
  63. data/test/core_test_app/app/components/dsl_delegated_properties.rb +4 -0
  64. data/test/core_test_app/app/components/dsl_delegated_properties_base.rb +5 -0
  65. data/test/core_test_app/app/components/dynamic_tab_panel/javascripts/dynamic_tab_panel.js +2 -2
  66. data/test/core_test_app/app/components/ext_direct/composite.rb +32 -33
  67. data/test/core_test_app/app/components/ext_direct/details.rb +2 -4
  68. data/test/core_test_app/app/components/ext_direct/selector.rb +20 -22
  69. data/test/core_test_app/app/components/ext_direct/statistics.rb +2 -4
  70. data/test/core_test_app/app/components/extended_component_with_actions.rb +7 -3
  71. data/test/core_test_app/app/components/extended_component_with_js_mixin.rb +7 -4
  72. data/test/core_test_app/app/components/extended_component_with_js_mixin/javascripts/some_method_set.js +1 -1
  73. data/test/core_test_app/app/components/extended_server_caller.rb +20 -14
  74. data/test/core_test_app/app/components/hello_world.rb +23 -0
  75. data/test/core_test_app/app/components/hello_world/javascripts/hello_world.js +12 -0
  76. data/test/core_test_app/app/components/included.js +2 -2
  77. data/test/core_test_app/app/components/kinda_complex_component.rb +1 -3
  78. data/test/core_test_app/app/components/kinda_complex_component/basic_stuff.rb +15 -17
  79. data/test/core_test_app/app/components/kinda_complex_component/extra_stuff.rb +4 -5
  80. data/test/core_test_app/app/components/loader_of_component_with_custom_css.rb +14 -5
  81. data/test/core_test_app/app/components/localized_panel.rb +23 -25
  82. data/test/core_test_app/app/components/multipane_component_loader.rb +19 -20
  83. data/test/core_test_app/app/components/nested_component.rb +4 -5
  84. data/test/core_test_app/app/components/panel_with_plugin.rb +8 -3
  85. data/test/core_test_app/app/components/panel_with_tools.rb +15 -14
  86. data/test/core_test_app/app/components/plugin_with_components.rb +20 -12
  87. data/test/core_test_app/app/components/scoped_components/deep_scoped_components/some_deep_scoped_component.rb +5 -2
  88. data/test/core_test_app/app/components/scoped_components/extended_scoped_component.rb +5 -2
  89. data/test/core_test_app/app/components/scoped_components/some_scoped_component.rb +5 -2
  90. data/test/core_test_app/app/components/server_caller.rb +39 -17
  91. data/test/core_test_app/app/components/server_caller/javascripts/server_caller.js +42 -0
  92. data/test/core_test_app/app/components/server_counter.rb +18 -82
  93. data/test/core_test_app/app/components/server_counter/javascripts/server_counter.js +53 -0
  94. data/test/core_test_app/app/components/simple_authentication_component.rb +46 -0
  95. data/test/core_test_app/app/components/simple_component.rb +8 -3
  96. data/test/core_test_app/app/components/simple_composite.rb +12 -0
  97. data/test/core_test_app/app/components/simple_form_with_file_upload.rb +49 -0
  98. data/test/core_test_app/app/components/simple_panel.rb +2 -2
  99. data/test/core_test_app/app/components/simple_tab_panel.rb +24 -3
  100. data/test/core_test_app/app/components/simple_window.rb +4 -2
  101. data/test/core_test_app/app/components/some_composite.rb +77 -48
  102. data/test/core_test_app/app/components/some_plugin.rb +31 -30
  103. data/test/core_test_app/app/components/stateful_component.rb +46 -0
  104. data/test/core_test_app/app/components/stateful_component_with_shared_state.rb +11 -0
  105. data/test/core_test_app/app/components/window_with_simple_component.rb +14 -0
  106. data/test/core_test_app/app/views/layouts/application.html.erb +1 -1
  107. data/test/core_test_app/app/views/simple_rails/multiple_nested.html.erb +7 -19
  108. data/test/core_test_app/app/views/simple_rails/panel.html.erb +1 -0
  109. data/test/core_test_app/config/database.yml.travis +3 -5
  110. data/test/core_test_app/config/environments/production.rb +1 -1
  111. data/test/core_test_app/config/initializers/netzke.rb +3 -1
  112. data/test/core_test_app/config/locales/en.yml +9 -4
  113. data/test/core_test_app/config/locales/es.yml +4 -2
  114. data/test/core_test_app/config/routes.rb +2 -8
  115. data/test/core_test_app/db/schema.rb +3 -11
  116. data/test/core_test_app/features/actions_and_tools.feature +1 -0
  117. data/test/core_test_app/features/client-server.feature +7 -0
  118. data/test/core_test_app/features/component_loader.feature +13 -13
  119. data/test/core_test_app/features/composition.feature +14 -0
  120. data/test/core_test_app/features/config_to_dsl_delegation.feature +10 -0
  121. data/test/core_test_app/features/file_inclusion.feature +1 -1
  122. data/test/core_test_app/features/i18n.feature +4 -4
  123. data/test/core_test_app/features/js_include.feature +1 -1
  124. data/test/core_test_app/features/persistence.feature +21 -5
  125. data/test/core_test_app/features/step_definitions/generic_steps.rb +14 -0
  126. data/test/core_test_app/features/support/paths.rb +0 -3
  127. data/test/core_test_app/public/images/icons/accept.png +0 -0
  128. data/test/core_test_app/public/images/icons/anchor.png +0 -0
  129. data/test/core_test_app/public/images/icons/tick.png +0 -0
  130. data/test/core_test_app/spec/action_config_spec.rb +15 -0
  131. data/test/core_test_app/spec/{component/actions_spec.rb → actions_spec.rb} +38 -36
  132. data/test/core_test_app/spec/base_spec.rb +35 -0
  133. data/test/core_test_app/spec/client_class_spec.rb +17 -0
  134. data/test/core_test_app/spec/component +0 -0
  135. data/test/core_test_app/spec/composition_spec.rb +118 -0
  136. data/test/core_test_app/spec/core_ext_spec.rb +3 -14
  137. data/test/core_test_app/spec/endpoint_response_spec.rb +17 -0
  138. data/test/core_test_app/spec/javascript_spec.rb +33 -0
  139. data/test/core_test_app/spec/js_class_config_scope.rb +37 -0
  140. data/test/core_test_app/spec/panel_spec.rb +11 -0
  141. data/test/core_test_app/spec/services_spec.rb +16 -0
  142. data/test/core_test_app/spec/state_spec.rb +20 -0
  143. data/test/unit/core_ext_test.rb +0 -53
  144. data/test/unit/netzke_core_test.rb +11 -11
  145. metadata +76 -62
  146. data/CHANGELOG.rdoc +0 -325
  147. data/javascripts/touch.js +0 -58
  148. data/lib/netzke/actions.rb +0 -107
  149. data/lib/netzke/composition.rb +0 -224
  150. data/lib/netzke/config_to_dsl_delegator.rb +0 -43
  151. data/lib/netzke/configuration.rb +0 -195
  152. data/lib/netzke/core/masquerading.rb +0 -34
  153. data/lib/netzke/core_ext.rb +0 -6
  154. data/lib/netzke/core_ext/array.rb +0 -30
  155. data/lib/netzke/core_ext/hash.rb +0 -86
  156. data/lib/netzke/core_ext/symbol.rb +0 -21
  157. data/lib/netzke/ext_component.rb +0 -25
  158. data/lib/netzke/inheritance.rb +0 -31
  159. data/lib/netzke/javascript.rb +0 -382
  160. data/lib/netzke/javascript/scopes.rb +0 -39
  161. data/lib/netzke/railz.rb +0 -4
  162. data/lib/netzke/railz/action_view_ext/ext.rb +0 -64
  163. data/lib/netzke/railz/action_view_ext/touch.rb +0 -52
  164. data/lib/netzke/railz/controller_extensions.rb +0 -33
  165. data/lib/netzke/railz/engine.rb +0 -48
  166. data/lib/netzke/railz/routes.rb +0 -7
  167. data/lib/netzke/services.rb +0 -101
  168. data/lib/netzke/session.rb +0 -54
  169. data/lib/netzke/state.rb +0 -91
  170. data/lib/netzke/stylesheets.rb +0 -65
  171. data/test/core_test_app/app/components/component_with_included_js.rb +0 -16
  172. data/test/core_test_app/app/components/component_with_session_persistence.rb +0 -35
  173. data/test/core_test_app/app/components/deprecated/server_caller.rb +0 -20
  174. data/test/core_test_app/app/components/dynamic_tab_panel.rb +0 -19
  175. data/test/core_test_app/app/components/hello_world_component.rb +0 -31
  176. data/test/core_test_app/app/components/touch/hello_world_component.rb +0 -25
  177. data/test/core_test_app/app/components/touch/server_caller.rb +0 -28
  178. data/test/core_test_app/app/components/touch/simple_carousel.rb +0 -17
  179. data/test/core_test_app/app/controllers/touch_controller.rb +0 -6
  180. data/test/core_test_app/app/helpers/touch_helper.rb +0 -2
  181. data/test/core_test_app/app/views/layouts/touch.html.erb +0 -13
  182. data/test/core_test_app/db/migrate/20110110132720_create_netzke_component_states.rb +0 -20
  183. data/test/core_test_app/features/step_definitions/touch_steps.rb +0 -3
  184. data/test/core_test_app/features/touch.feature +0 -10
  185. data/test/core_test_app/gemfiles/rails3_1.gemfile +0 -16
  186. data/test/core_test_app/gemfiles/rails3_2.gemfile +0 -16
  187. data/test/core_test_app/spec/component/base_spec.rb +0 -36
  188. data/test/core_test_app/spec/component/component_spec.rb +0 -20
  189. data/test/core_test_app/spec/component/composition_spec.rb +0 -132
  190. data/test/core_test_app/spec/component/configuration_spec.rb +0 -61
  191. data/test/core_test_app/spec/component/javascript_spec.rb +0 -16
  192. data/test/core_test_app/spec/component/state_spec.rb +0 -18
@@ -0,0 +1,53 @@
1
+ {
2
+ onCountOneTime: function(){
3
+ this.count({how_many: 1});
4
+ },
5
+
6
+ initComponent: function () {
7
+ this.callParent();
8
+ Ext.Ajax.on('beforerequest',function (conn, options ) {
9
+ Netzke.connectionCount = Netzke.connectionCount || 0;
10
+ Netzke.connectionCount++;
11
+ Netzke.lastOptions=options;
12
+ });
13
+ },
14
+
15
+ onCountSevenTimes: function(){
16
+ for(var i=0; i<7; i++) {
17
+ this.count({how_many: 1});
18
+ }
19
+ },
20
+
21
+ onCountEightTimesSpecial: function(){
22
+ for(var i=0;i<8;i++) {
23
+ this.count({how_many: 1, special: true});
24
+ }
25
+ },
26
+
27
+ onFailInTheMiddle: function() {
28
+ this.successingEndpoint();
29
+ this.failingEndpoint();
30
+ this.successingEndpoint();
31
+ },
32
+
33
+ onDoOrdered: function () {
34
+ this.firstEp();
35
+ this.secondEp();
36
+ },
37
+
38
+ updateContent: function(html){
39
+ this.update(html);
40
+ },
41
+
42
+ updateAppending: function(html){
43
+ if (!this.panelText) { this.panelText = ""; }
44
+ this.panelText += html + ",";
45
+ this.body.update(this.panelText);
46
+ },
47
+
48
+ onFailTwoOutOfFive: function(){
49
+ for(var i=1; i<=5; i++) {
50
+ this.failTwoOutOfFive(i);
51
+ }
52
+ }
53
+ }
@@ -0,0 +1,46 @@
1
+ class SimpleAuthenticationComponent < Netzke::Base
2
+ action :sign_in
3
+
4
+ action :sign_out
5
+
6
+ def configure(c)
7
+ super
8
+ c.tbar = signed_in? ? [current_user_info, "->", :sign_out] : ["->", :sign_in]
9
+ end
10
+
11
+ js_configure do |c|
12
+ c.on_sign_in = <<-JS
13
+ function(){
14
+ this.signIn();
15
+ }
16
+ JS
17
+
18
+ c.on_sign_out = <<-JS
19
+ function(){
20
+ this.signOut();
21
+ }
22
+ JS
23
+
24
+ c.reload_page = <<-JS
25
+ function(){window.location = window.location;}
26
+ JS
27
+ end
28
+
29
+ endpoint :sign_in do |params,this|
30
+ session[:user_id] = 1
31
+ this.reload_page
32
+ end
33
+
34
+ endpoint :sign_out do |params,this|
35
+ session.delete(:user_id)
36
+ this.reload_page
37
+ end
38
+
39
+ def current_user_info
40
+ session[:user_id] && "Signed in as user#: #{session[:user_id]}" || ""
41
+ end
42
+
43
+ def signed_in?
44
+ !!session[:user_id]
45
+ end
46
+ end
@@ -1,6 +1,11 @@
1
1
  class SimpleComponent < Netzke::Base
2
- js_properties :title => "SimpleComponent",
3
- :html => "Inner text"
2
+ js_configure do |c|
3
+ c.html = "Inner text"
4
+ end
4
5
 
5
- # component :one, :class_name => "SimplePanel", :title => "One"
6
+ def configure(c)
7
+ c.bbar = ["Hello"]
8
+ c.title = "SimpleComponent"
9
+ super
10
+ end
6
11
  end
@@ -0,0 +1,12 @@
1
+ # Not used in tests
2
+ class SimpleComposite < Netzke::Base
3
+ def configure(c)
4
+ c.layout = :fit
5
+ c.items = [:child]
6
+ super
7
+ end
8
+
9
+ component :child do |c|
10
+ c.klass = SimpleComponent
11
+ end
12
+ end
@@ -0,0 +1,49 @@
1
+ # Not used in automatic tests
2
+ class SimpleFormWithFileUpload < Netzke::Base
3
+ js_configure do |c|
4
+ c.extend = "Ext.form.Panel"
5
+ c.body_padding = 10
6
+ c.on_submit = <<-JS
7
+ function(){
8
+
9
+ var msg = function(title, msg) {
10
+ Ext.Msg.show({
11
+ title: title,
12
+ msg: msg,
13
+ minWidth: 200,
14
+ modal: true,
15
+ icon: Ext.Msg.INFO,
16
+ buttons: Ext.Msg.OK
17
+ });
18
+ };
19
+
20
+ var me = this;
21
+
22
+ this.getForm().submit({
23
+ url: this.netzkeEndpointUrl('server_submit'),
24
+ success: function(fp, o){
25
+ msg("Success", 'Your file is uploaded!');
26
+ },
27
+ failure: function(){msg("Failure", 'Server did not inform us about success');}
28
+ });
29
+ }
30
+ JS
31
+ end
32
+
33
+ action :submit
34
+
35
+ def configure(c)
36
+ super
37
+ c.items = [{ xtype: :filefield, emptyText: 'Select an image', fieldLabel: 'Photo', buttonText: '...' }]
38
+
39
+ c.bbar = [:submit]
40
+ end
41
+
42
+ endpoint :server_submit do |params, this|
43
+ # because this endpoint wasn't called in the normal way, we cannot do anything like this (it won't have any effect):
44
+ # this.set_title('File uploaded')
45
+
46
+ # But this will define whether the client is informed about success or not:
47
+ this.success = true
48
+ end
49
+ end
@@ -1,2 +1,2 @@
1
- class SimplePanel < Netzke::Base
2
- end
1
+ class SimplePanel < Netzke::Core::Panel
2
+ end
@@ -1,4 +1,25 @@
1
1
  class SimpleTabPanel < Netzke::Base
2
- js_base_class "Ext.TabPanel"
3
- js_property :active_tab, 0
4
- end
2
+ js_configure do |c|
3
+ c.extend = "Ext.tab.Panel"
4
+ c.active_tab = 0
5
+ end
6
+
7
+ component :server_caller
8
+ component :hello_world do |c|
9
+ c.excluded = true
10
+ end
11
+ component :extended_server_caller
12
+
13
+ component :simple_panel_one do |c|
14
+ c.klass = SimplePanel
15
+ end
16
+
17
+ component :simple_panel_two do |c|
18
+ c.klass = SimplePanel
19
+ end
20
+
21
+ def configure(c)
22
+ c.items = [:server_caller, :hello_world, :extended_server_caller, :simple_panel_one, :simple_panel_two]
23
+ super
24
+ end
25
+ end
@@ -1,3 +1,5 @@
1
1
  class SimpleWindow < Netzke::Base
2
- js_base_class "Ext.window.Window"
3
- end
2
+ js_configure do |c|
3
+ c.extend = "Ext.window.Window"
4
+ end
5
+ end
@@ -1,65 +1,94 @@
1
1
  class SomeComposite < Netzke::Base
2
- js_properties :height => 400,
3
- :layout => 'border',
4
- :bbar => [
5
- :update_west_panel.action,
6
- :update_center_panel.action,
7
- :update_west_from_server.action,
8
- :update_east_south_from_server.action
9
- ]
2
+ js_configure do |c|
3
+ c.height = 400
4
+ c.layout = :border
10
5
 
11
- action :update_center_panel
12
- action :update_west_panel
13
- action :update_west_from_server
14
- action :update_east_south_from_server
6
+ c.on_update_west_panel = <<-JS
7
+ function(){
8
+ this.getComponent('west_panel').body.update('West Panel Body Updated');
9
+ }
10
+ JS
15
11
 
16
- config :items => [
17
- :center_panel.component(:region => 'center'),
18
- :west_panel.component(:region => 'west', :width => 300, :split => true),
19
- {:layout => 'border', :region => :east, :width => 500, :split => true, :items => [
20
- :east_center_panel.component(:region => :center),
21
- :east_south_panel.component(:region => :south, :height => 200, :split => true)
22
- ]},
23
- ]
12
+ c.on_update_center_panel = <<-JS
13
+ function(){
14
+ this.getComponent('center_panel').body.update('Center Panel Body Updated');
15
+ }
16
+ JS
24
17
 
25
- component :west_panel, :class_name => "ExtendedServerCaller"
18
+ c.on_update_east_south_from_server = <<-JS
19
+ function(){
20
+ this.updateEastSouth();
21
+ }
22
+ JS
26
23
 
27
- component :center_panel, :class_name => "ServerCaller"
24
+ c.on_update_west_from_server = <<-JS
25
+ function(){
26
+ this.updateWest();
27
+ }
28
+ JS
28
29
 
29
- component :east_center_panel, :class_name => "SimpleComponent", :title => "A panel", :border => false
30
+ c.on_show_hidden_window = <<-JS
31
+ function(){
32
+ this.netzkeInstantiateComponent('hidden_window').show();
33
+ }
34
+ JS
35
+ end
36
+
37
+ action :update_center_panel
38
+ action :update_west_panel
39
+ action :update_west_from_server
40
+ action :update_east_south_from_server
41
+ action :show_hidden_window
30
42
 
31
- component :east_south_panel, :class_name => "SimpleComponent", :title => "Another panel", :border => false
43
+ def configure(c)
44
+ super
45
+ c.bbar = [ :update_west_panel, :update_center_panel, :update_west_from_server, :update_east_south_from_server, :show_hidden_window ]
46
+ c.items = [
47
+ :center_panel,
48
+ { region: :west, width: 300, split: true, component: :west_panel },
49
+ { layout: :border, region: :east, width: 500, split: true, items: [
50
+ { region: :center, component: :east_center_panel },
51
+ { region: :south, height: 200, split: true, component: :east_south_panel }
52
+ ] }
53
+ ]
54
+ end
32
55
 
33
- endpoint :update_east_south do |params|
34
- {:east_south_panel => {:set_title => "Here's an update for south panel in east panel"}}
56
+ component :center_panel do |c|
57
+ c.klass = ServerCaller
58
+ c.region = :center
35
59
  end
36
60
 
37
- endpoint :update_west do |params|
38
- {:west_panel => {:set_title => "Here's an update for west panel"}}
61
+ component :west_panel do |c|
62
+ c.klass = ExtendedServerCaller
39
63
  end
40
64
 
41
- js_method :on_update_west_panel, <<-JS
42
- function(){
43
- this.items.filter('name', 'west_panel').first().body.update('West Panel Body Updated');
44
- }
45
- JS
65
+ component :east_center_panel do |c|
66
+ c.klass = SimpleComponent
67
+ c.title = "A panel"
68
+ c.border = false
69
+ end
46
70
 
47
- js_method :on_update_center_panel, <<-JS
48
- function(){
49
- this.items.filter('name', 'center_panel').first().body.update('Center Panel Body Updated');
50
- }
51
- JS
71
+ component :east_south_panel do |c|
72
+ c.klass = SimpleComponent
73
+ c.title = "Another panel"
74
+ c.border = false
75
+ end
52
76
 
53
- js_method :on_update_east_south_from_server, <<-JS
54
- function(){
55
- this.updateEastSouth();
56
- }
57
- JS
77
+ # Eagerly loaded Netzke component that only requires instantiating at client
78
+ component :hidden_window do |c|
79
+ c.klass = SimpleWindow
80
+ c.eager_loading = true # !
81
+ c.title = "Hidden window gone visible!"
82
+ c.width = 300
83
+ c.height = 200
84
+ c.modal = true
85
+ end
58
86
 
59
- js_method :on_update_west_from_server, <<-JS
60
- function(){
61
- this.updateWest();
62
- }
63
- JS
87
+ endpoint :update_east_south do |params, this|
88
+ this.east_south_panel.set_title("Here's an update for south panel in east panel")
89
+ end
64
90
 
91
+ endpoint :update_west do |params, this|
92
+ this.west_panel.set_title("Here's an update for west panel")
93
+ end
65
94
  end
@@ -1,39 +1,40 @@
1
1
  class SomePlugin < Netzke::Plugin
2
2
  action :action_one
3
3
 
4
- js_method :init, <<-JS
5
- function(){
6
- this.callParent(arguments);
7
- this.cmp.tools = [{id: 'gear', handler: this.onGear, scope: this}];
4
+ js_configure do |c|
5
+ c.init = <<-JS
6
+ function(){
7
+ this.callParent(arguments);
8
+ this.cmp.tools = [{id: 'gear', handler: this.onGear, scope: this}];
8
9
 
9
- this.cmp.addDocked({
10
- dock: 'bottom',
11
- xtype: 'toolbar',
12
- items: [this.actions.actionOne]
13
- });
14
- }
15
- JS
10
+ this.cmp.addDocked({
11
+ dock: 'bottom',
12
+ xtype: 'toolbar',
13
+ items: [this.actions.actionOne]
14
+ });
15
+ }
16
+ JS
16
17
 
17
- js_method :on_action_one, <<-JS
18
- function(){
19
- this.cmp.setTitle('Action one ' + 'triggered');
20
- }
21
- JS
18
+ c.on_action_one = <<-JS
19
+ function(){
20
+ this.cmp.setTitle('Action one ' + 'triggered');
21
+ }
22
+ JS
22
23
 
23
- js_method :on_gear, <<-JS
24
- function(){
25
- this.processGear();
26
- }
27
- JS
24
+ c.on_gear = <<-JS
25
+ function(){
26
+ this.processGear();
27
+ }
28
+ JS
28
29
 
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"}
30
+ c.process_gear_callback = <<-JS
31
+ function(newTitle){
32
+ this.cmp.setTitle(newTitle);
33
+ }
34
+ JS
37
35
  end
38
36
 
39
- end
37
+ endpoint :process_gear do |params, this|
38
+ this.process_gear_callback("Server response")
39
+ end
40
+ end
@@ -0,0 +1,46 @@
1
+ # Shows how component session and state can be used for persistence
2
+ class StatefulComponent < Netzke::Base
3
+ action :set_session_data do |a|
4
+ a.text = "Set session and state"
5
+ end
6
+
7
+ action :reset_session_data do |a|
8
+ a.text = "Reset session and state"
9
+ end
10
+
11
+ def configure(c)
12
+ super
13
+ c.persistence = true
14
+ c.bbar = [:set_session_data, :reset_session_data]
15
+
16
+ # title will be gotten from component's state
17
+ c.title = state[:title] || "Default Title"
18
+
19
+ # body content will be stored directly in component's session
20
+ c.html = component_session[:html_content] || "Default HTML"
21
+ end
22
+
23
+ js_configure do |c|
24
+ c.on_set_session_data = <<-JS
25
+ function(){
26
+ this.serverSetSessionData();
27
+ }
28
+ JS
29
+
30
+ c.on_reset_session_data = <<-JS
31
+ function(){
32
+ this.serverResetSessionData();
33
+ }
34
+ JS
35
+ end
36
+
37
+ endpoint :server_set_session_data do |params, this|
38
+ component_session[:html_content] = "HTML from session"
39
+ state[:title] = "Title From State"
40
+ end
41
+
42
+ endpoint :server_reset_session_data do |params,this|
43
+ component_session.clear
44
+ state.clear
45
+ end
46
+ end