netzke-basepack 0.7.7 → 0.8.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.
Files changed (192) hide show
  1. data/.travis.yml +15 -10
  2. data/{CHANGELOG.rdoc → CHANGELOG.md} +146 -110
  3. data/LICENSE +7 -1
  4. data/README.md +47 -56
  5. data/Rakefile +5 -5
  6. data/config/before-travis.sh +10 -0
  7. data/javascripts/basepack.js +0 -130
  8. data/javascripts/netzkeremotecombo.js +59 -0
  9. data/lib/netzke/basepack.rb +9 -14
  10. data/lib/netzke/basepack/accordion.rb +45 -0
  11. data/lib/netzke/basepack/active_record.rb +12 -0
  12. data/lib/netzke/basepack/active_record/relation_extensions.rb +27 -0
  13. data/lib/netzke/basepack/columns.rb +309 -0
  14. data/lib/netzke/basepack/data_accessor.rb +22 -12
  15. data/lib/netzke/basepack/data_adapters/abstract_adapter.rb +75 -11
  16. data/lib/netzke/basepack/data_adapters/active_record_adapter.rb +154 -49
  17. data/lib/netzke/basepack/fields.rb +162 -0
  18. data/lib/netzke/basepack/form.rb +136 -0
  19. data/lib/netzke/basepack/{form_panel → form}/javascripts/comma_list_cbg.js +0 -1
  20. data/lib/netzke/basepack/{form_panel/javascripts/form_panel.js → form/javascripts/form.js} +20 -26
  21. data/lib/netzke/basepack/{form_panel → form}/javascripts/n_radio_group.js +0 -1
  22. data/lib/netzke/basepack/{form_panel → form}/javascripts/readonly_mode.js +0 -0
  23. data/lib/netzke/basepack/form/services.rb +115 -0
  24. data/lib/netzke/basepack/{form_panel → form}/stylesheets/readonly_mode.css +0 -0
  25. data/lib/netzke/basepack/grid.rb +355 -0
  26. data/lib/netzke/basepack/{grid_panel → grid}/javascripts/advanced_search.js +1 -1
  27. data/lib/netzke/basepack/{grid_panel → grid}/javascripts/check_column_fix.js +0 -0
  28. data/lib/netzke/basepack/{grid_panel → grid}/javascripts/edit_in_form.js +3 -3
  29. data/lib/netzke/basepack/{grid_panel → grid}/javascripts/event_handling.js +5 -2
  30. data/lib/netzke/basepack/{grid_panel/javascripts/grid_panel.js → grid/javascripts/grid.js} +120 -132
  31. data/lib/netzke/basepack/{grid_panel → grid}/javascripts/misc.js +0 -0
  32. data/lib/netzke/basepack/grid/services.rb +216 -0
  33. data/lib/netzke/basepack/item_persistence.rb +44 -0
  34. data/lib/netzke/basepack/item_persistence/events_plugin.rb +47 -0
  35. data/lib/netzke/basepack/{paging_form_panel.rb → paging_form.rb} +24 -30
  36. data/lib/netzke/basepack/{paging_form_panel/javascripts/paging_form_panel.js → paging_form/javascripts/paging_form.js} +2 -4
  37. data/lib/netzke/basepack/query_builder.rb +44 -73
  38. data/lib/netzke/basepack/query_builder/javascripts/query_builder.js +16 -2
  39. data/lib/netzke/basepack/record_form_window.rb +67 -0
  40. data/lib/netzke/basepack/search_panel.rb +22 -24
  41. data/lib/netzke/basepack/search_panel/javascripts/condition_field.js +2 -2
  42. data/lib/netzke/basepack/search_window.rb +47 -53
  43. data/lib/netzke/basepack/simple_app.rb +10 -13
  44. data/lib/netzke/basepack/simple_app/javascripts/simple_app.js +2 -8
  45. data/lib/netzke/basepack/tab_panel.rb +5 -4
  46. data/lib/netzke/basepack/tab_panel/javascripts/tab_panel.js +5 -5
  47. data/lib/netzke/basepack/version.rb +2 -2
  48. data/lib/netzke/basepack/viewport.rb +16 -0
  49. data/lib/netzke/basepack/window.rb +27 -18
  50. data/lib/netzke/basepack/window/javascripts/window.js +7 -1
  51. data/lib/netzke/basepack/wrap_lazy_loaded.rb +18 -18
  52. data/locales/en.yml +40 -24
  53. data/netzke-basepack.gemspec +51 -82
  54. data/stylesheets/basepack.css +0 -41
  55. data/test/basepack_test_app/Gemfile +9 -46
  56. data/test/basepack_test_app/Gemfile.lock +61 -96
  57. data/test/basepack_test_app/app/components/author_form.rb +8 -5
  58. data/test/basepack_test_app/app/components/author_grid.rb +2 -2
  59. data/test/basepack_test_app/app/components/book_form.rb +34 -31
  60. data/test/basepack_test_app/app/components/book_form_with_defaults.rb +6 -7
  61. data/test/basepack_test_app/app/components/book_form_with_file_upload.rb +10 -0
  62. data/test/basepack_test_app/app/components/book_form_with_nested_attributes.rb +5 -6
  63. data/test/basepack_test_app/app/components/book_grid.rb +19 -8
  64. data/test/basepack_test_app/app/components/book_grid_filtering.rb +4 -7
  65. data/test/basepack_test_app/app/components/book_grid_loader.rb +28 -15
  66. data/test/basepack_test_app/app/components/book_grid_with_custom_columns.rb +45 -21
  67. data/test/basepack_test_app/app/components/book_grid_with_default_values.rb +26 -8
  68. data/test/basepack_test_app/app/components/book_grid_with_excluded_columns.rb +11 -0
  69. data/test/basepack_test_app/app/components/book_grid_with_extra_feedback.rb +2 -2
  70. data/test/basepack_test_app/app/components/book_grid_with_extra_filters.rb +7 -6
  71. data/test/basepack_test_app/app/components/book_grid_with_mass_assignment_security.rb +9 -0
  72. data/test/basepack_test_app/app/components/book_grid_with_nested_attributes.rb +9 -9
  73. data/test/basepack_test_app/app/components/book_grid_with_overridden_columns.rb +5 -3
  74. data/test/basepack_test_app/app/components/book_grid_with_paging.rb +6 -8
  75. data/test/basepack_test_app/app/components/book_grid_with_persistence.rb +6 -4
  76. data/test/basepack_test_app/app/components/book_grid_with_scope.rb +6 -0
  77. data/test/basepack_test_app/app/components/book_grid_with_scoped_authors.rb +10 -7
  78. data/test/basepack_test_app/app/components/book_grid_with_virtual_attributes.rb +21 -13
  79. data/test/basepack_test_app/app/components/book_paging_form.rb +21 -0
  80. data/test/basepack_test_app/app/components/book_query_builder.rb +7 -6
  81. data/test/basepack_test_app/app/components/book_with_custom_primary_key_grid.rb +6 -7
  82. data/test/basepack_test_app/app/components/books_bound_to_author.rb +9 -7
  83. data/test/basepack_test_app/app/components/border_layout_panel_with_persistence.rb +12 -0
  84. data/test/basepack_test_app/app/components/double_book_grid.rb +19 -14
  85. data/test/basepack_test_app/app/components/form_without_model.rb +15 -16
  86. data/test/basepack_test_app/app/components/grid_with_initial_sorting.rb +7 -0
  87. data/test/basepack_test_app/app/components/grid_with_inline_data.rb +7 -0
  88. data/test/basepack_test_app/app/components/paging_form_with_search.rb +2 -2
  89. data/test/basepack_test_app/app/components/panel_with_persistent_regions.rb +35 -0
  90. data/test/basepack_test_app/app/components/query_builder.rb +7 -0
  91. data/test/basepack_test_app/app/components/simple_panel.rb +16 -11
  92. data/test/basepack_test_app/app/components/simple_window.rb +7 -6
  93. data/test/basepack_test_app/app/components/some_accordion.rb +18 -0
  94. data/test/basepack_test_app/app/components/some_auth_app.rb +5 -5
  95. data/test/basepack_test_app/app/components/some_border_layout.rb +20 -20
  96. data/test/basepack_test_app/app/components/some_search_panel.rb +6 -0
  97. data/test/basepack_test_app/app/components/some_simple_app.rb +30 -16
  98. data/test/basepack_test_app/app/components/some_tab_panel.rb +18 -15
  99. data/test/basepack_test_app/app/components/user_form.rb +18 -16
  100. data/test/basepack_test_app/app/components/user_form_with_default_fields.rb +5 -6
  101. data/test/basepack_test_app/app/components/user_grid.rb +11 -6
  102. data/test/basepack_test_app/app/components/user_grid_with_customized_form_fields.rb +5 -3
  103. data/test/basepack_test_app/app/components/window_component_loader.rb +25 -21
  104. data/test/basepack_test_app/app/models/address.rb +0 -26
  105. data/test/basepack_test_app/app/models/author.rb +0 -31
  106. data/test/basepack_test_app/app/models/book.rb +1 -42
  107. data/test/basepack_test_app/app/models/book_with_custom_primary_key.rb +1 -23
  108. data/test/basepack_test_app/app/models/role.rb +0 -21
  109. data/test/basepack_test_app/app/models/user.rb +0 -24
  110. data/test/basepack_test_app/app/views/layouts/components.html.erb +1 -1
  111. data/test/basepack_test_app/config/application.rb +1 -1
  112. data/test/basepack_test_app/config/database.yml.travis +2 -6
  113. data/test/basepack_test_app/config/initializers/netzke.rb +1 -6
  114. data/test/basepack_test_app/db/schema.rb +14 -14
  115. data/test/basepack_test_app/features/accordion_panel.feature +2 -2
  116. data/test/basepack_test_app/features/form_panel.feature +7 -7
  117. data/test/basepack_test_app/features/grid_panel.feature +93 -39
  118. data/test/basepack_test_app/features/grid_panel_with_custom_primary_key.feature +2 -1
  119. data/test/basepack_test_app/features/grid_sorting.feature +30 -6
  120. data/test/basepack_test_app/features/paging_form_panel.feature +7 -7
  121. data/test/basepack_test_app/features/persistent_regions.feature +30 -0
  122. data/test/basepack_test_app/features/search_in_grid.feature +5 -5
  123. data/test/basepack_test_app/features/simple_app.feature +6 -7
  124. data/test/basepack_test_app/features/step_definitions/form_panel_steps.rb +1 -1
  125. data/test/basepack_test_app/features/step_definitions/generic_steps.rb +109 -4
  126. data/test/basepack_test_app/features/step_definitions/grid_panel_steps.rb +8 -10
  127. data/test/basepack_test_app/features/step_definitions/window_steps.rb +27 -0
  128. data/test/basepack_test_app/features/tab_panel.feature +1 -1
  129. data/test/basepack_test_app/features/window.feature +17 -0
  130. data/test/unit/accordion_panel_test.rb +2 -2
  131. data/test/unit/grid_panel_test.rb +4 -4
  132. metadata +57 -83
  133. data/TODO.rdoc +0 -8
  134. data/lib/generators/netzke/basepack_generator.rb +0 -10
  135. data/lib/generators/netzke/templates/assets/ts-checkbox.gif +0 -0
  136. data/lib/generators/netzke/templates/create_netzke_field_lists.rb +0 -18
  137. data/lib/netzke/active_record.rb +0 -20
  138. data/lib/netzke/active_record/attributes.rb +0 -259
  139. data/lib/netzke/active_record/combobox_options.rb +0 -16
  140. data/lib/netzke/active_record/relation_extensions.rb +0 -37
  141. data/lib/netzke/basepack/accordion_panel.rb +0 -39
  142. data/lib/netzke/basepack/action_column.rb +0 -68
  143. data/lib/netzke/basepack/action_column/javascripts/action_column.js +0 -61
  144. data/lib/netzke/basepack/auth_app.rb +0 -159
  145. data/lib/netzke/basepack/basic_app.rb +0 -7
  146. data/lib/netzke/basepack/border_layout_panel.rb +0 -53
  147. data/lib/netzke/basepack/border_layout_panel/javascripts/border_layout_panel.js +0 -40
  148. data/lib/netzke/basepack/data_adapters/data_mapper_adapter.rb +0 -264
  149. data/lib/netzke/basepack/data_adapters/sequel_adapter.rb +0 -260
  150. data/lib/netzke/basepack/form_panel.rb +0 -144
  151. data/lib/netzke/basepack/form_panel/fields.rb +0 -208
  152. data/lib/netzke/basepack/form_panel/javascripts/misc.js +0 -4
  153. data/lib/netzke/basepack/form_panel/services.rb +0 -142
  154. data/lib/netzke/basepack/grid_panel.rb +0 -441
  155. data/lib/netzke/basepack/grid_panel/columns.rb +0 -400
  156. data/lib/netzke/basepack/grid_panel/javascripts/rows-dd.js +0 -281
  157. data/lib/netzke/basepack/grid_panel/record_form_window.rb +0 -41
  158. data/lib/netzke/basepack/grid_panel/services.rb +0 -235
  159. data/lib/netzke/basepack/panel.rb +0 -11
  160. data/lib/netzke/basepack/wrapper.rb +0 -28
  161. data/lib/netzke/data_mapper.rb +0 -18
  162. data/lib/netzke/data_mapper/attributes.rb +0 -273
  163. data/lib/netzke/data_mapper/combobox_options.rb +0 -11
  164. data/lib/netzke/data_mapper/relation_extensions.rb +0 -38
  165. data/lib/netzke/sequel.rb +0 -18
  166. data/lib/netzke/sequel/attributes.rb +0 -274
  167. data/lib/netzke/sequel/combobox_options.rb +0 -10
  168. data/lib/netzke/sequel/relation_extensions.rb +0 -40
  169. data/locales/zh-cn.yml +0 -79
  170. data/test/basepack_test_app/app/components/book_form_with_custom_fields.rb +0 -21
  171. data/test/basepack_test_app/app/components/book_grid_with_column_actions.rb +0 -15
  172. data/test/basepack_test_app/app/components/book_grid_with_defaults.rb +0 -6
  173. data/test/basepack_test_app/app/components/book_paging_form_panel.rb +0 -22
  174. data/test/basepack_test_app/app/components/generic_user_form.rb +0 -12
  175. data/test/basepack_test_app/app/components/simple_accordion.rb +0 -11
  176. data/test/basepack_test_app/app/components/simple_tab_panel.rb +0 -11
  177. data/test/basepack_test_app/app/components/simple_wrapper.rb +0 -7
  178. data/test/basepack_test_app/app/components/some_accordion_panel.rb +0 -22
  179. data/test/basepack_test_app/app/presenters/forms/generic_user.rb +0 -6
  180. data/test/basepack_test_app/app/views/components/loadable_window.html.erb +0 -9
  181. data/test/basepack_test_app/app/views/components/simple_panel.html.erb +0 -1
  182. data/test/basepack_test_app/features/components_in_view.feature +0 -11
  183. data/test/basepack_test_app/features/simple_panel.feature +0 -11
  184. data/test/basepack_test_app/features/validations_in_grid.feature +0 -13
  185. data/test/basepack_test_app/features/virtual_attributes.feature +0 -16
  186. data/test/basepack_test_app/spec/components/form_panel_spec.rb +0 -53
  187. data/test/basepack_test_app/spec/components/grid_panel_spec.rb +0 -10
  188. data/test/basepack_test_app/spec/data_adapter/adapter_spec.rb +0 -68
  189. data/test/basepack_test_app/spec/data_adapter/attributes_spec.rb +0 -56
  190. data/test/basepack_test_app/spec/data_adapter/relation_extensions_spec.rb +0 -125
  191. data/test/basepack_test_app/spec/factories.rb +0 -28
  192. data/test/basepack_test_app/spec/spec_helper.rb +0 -39
@@ -6,47 +6,45 @@ module Netzke
6
6
 
7
7
  include Netzke::Basepack::DataAccessor
8
8
 
9
- js_base_class "Ext.form.FormPanel"
10
-
11
- js_properties(
12
- :padding => 5,
13
- :auto_scroll => true
14
- )
15
-
16
- js_include :condition_field
17
-
18
- js_mixin :search_panel
19
-
20
- js_property :attribute_operators_map, {
9
+ ATTRIBUTE_OPERATORS_MAP = {
21
10
  :integer => [
22
11
  ["eq", I18n.t('netzke.basepack.search_panel.equals')],
23
12
  ["gt", I18n.t('netzke.basepack.search_panel.greater_than')],
24
13
  ["lt", I18n.t('netzke.basepack.search_panel.less_than')]
25
14
  ],
26
- :text => [
27
- ["contains", I18n.t('netzke.basepack.search_panel.contains')] # same as matches => %string%
15
+ :text => [
16
+ ["contains", I18n.t('netzke.basepack.search_panel.contains')] # same as matches => %string%
28
17
  ],
29
18
  :string => [
30
19
  ["contains", I18n.t('netzke.basepack.search_panel.contains')], # same as matches => %string%
31
20
  ["matches", I18n.t('netzke.basepack.search_panel.matches')]
32
21
  ],
33
- :boolean => [
34
- ["is_any", I18n.t('netzke.basepack.search_panel.is_true')],
35
- ["is_true", I18n.t('netzke.basepack.search_panel.is_true')],
36
- ["is_false", I18n.t('netzke.basepack.search_panel.is_false')]
22
+ :boolean => [
23
+ ["is_any", I18n.t('netzke.basepack.search_panel.is_true')],
24
+ ["is_true", I18n.t('netzke.basepack.search_panel.is_true')],
25
+ ["is_false", I18n.t('netzke.basepack.search_panel.is_false')]
37
26
  ],
38
- :datetime => [
39
- ["eq", I18n.t('netzke.basepack.search_panel.date_equals')],
40
- ["gt", I18n.t('netzke.basepack.search_panel.after')],
41
- ["lt", I18n.t('netzke.basepack.search_panel.before')]
27
+ :datetime => [
28
+ ["eq", I18n.t('netzke.basepack.search_panel.date_equals')],
29
+ ["gt", I18n.t('netzke.basepack.search_panel.after')],
30
+ ["lt", I18n.t('netzke.basepack.search_panel.before')]
42
31
  ]
43
32
  }
44
33
 
34
+ js_configure do |c|
35
+ c.extend = "Ext.form.FormPanel"
36
+ c.padding = 5
37
+ c.auto_scroll = true
38
+ c.require :condition_field
39
+ c.mixin
40
+ c.attribute_operators_map = ATTRIBUTE_OPERATORS_MAP
41
+ end
42
+
45
43
  # Builds default query search panel, where each field is presented
46
44
  def default_query
47
45
  data_class.column_names.map do |c|
48
46
  column_type = data_class.columns_hash[c].type
49
- operator = (self.class.js_property(:attribute_operators_map)[column_type] || []).first.try(:fetch, 0) || "matches"
47
+ operator = (ATTRIBUTE_OPERATORS_MAP[column_type] || []).first.try(:fetch, 0) || "matches"
50
48
  {:attr => c, :attr_type => column_type, :operator => operator}
51
49
  end
52
50
  end
@@ -58,7 +56,7 @@ module Netzke
58
56
  def js_config
59
57
  super.merge(
60
58
  :attrs => attributes,
61
- :attrs_hash => data_class.column_names.inject({}){ |hsh,c|
59
+ :attrs_hash => data_class.column_names.inject({}){ |hsh,c|
62
60
  hsh.merge(c => data_adapter.get_property_type(data_class.columns_hash[c])) },
63
61
  :preset_query => (config[:load_last_preset] ? last_preset.try(:fetch, "query") : config[:query]) || []
64
62
  )
@@ -1,4 +1,4 @@
1
- Ext.define('Netzke.classes.Basepack.SearchPanel.ConditionField', {
1
+ Ext.define('Netzke.classes.Netzke.Basepack.SearchPanel.ConditionField', {
2
2
  extend: 'Ext.form.FieldContainer',
3
3
  alias: 'widget.netzkebasepacksearchpanelconditionfield',
4
4
 
@@ -101,7 +101,7 @@ Ext.define('Netzke.classes.Basepack.SearchPanel.ConditionField', {
101
101
 
102
102
  this.items = items;
103
103
 
104
- // Why on Earth is this not working? Netzke.classes.Basepack.SearchPanel.ConditionField undefined???
104
+ // Why on Earth is this not working? Netzke.classes.Netzke.Basepack.SearchPanel.ConditionField undefined???
105
105
  // Netzke.classes.Basepack.SearchPanel.ConditionField.superclass.initComponent.call(this);
106
106
  // Ext.form.CompositeField.prototype.initComponent.call(this); // workaround
107
107
  this.callParent();
@@ -2,65 +2,59 @@ module Netzke
2
2
  module Basepack
3
3
  class SearchWindow < Netzke::Basepack::Window
4
4
 
5
- action :search do
6
- { :text => I18n.t('netzke.basepack.search_window.action.search') }
5
+ action :search
6
+ action :cancel
7
+
8
+ js_configure do |c|
9
+ c.width = "50%"
10
+ c.auto_height = true
11
+ c.close_action = "hide"
12
+ c.modal = true
13
+ c.init_component = <<-JS
14
+ function(){
15
+ this.callParent();
16
+
17
+ this.on('show', function(){
18
+ this.closeRes = 'cancel';
19
+ });
20
+ }
21
+ JS
22
+
23
+ c.get_query = <<-JS
24
+ function(){
25
+ return this.items.first().getQuery();
26
+ }
27
+ JS
28
+
29
+ c.on_search = <<-JS
30
+ function(){
31
+ this.closeRes = 'search';
32
+ this.hide();
33
+ }
34
+ JS
35
+
36
+ c.on_cancel = <<-JS
37
+ function(){
38
+ this.hide();
39
+ }
40
+ JS
7
41
  end
8
42
 
9
- action :cancel do
10
- { :text => I18n.t('netzke.basepack.search_window.action.cancel') }
43
+ def configure(c)
44
+ super
45
+ c.items = [:search_panel]
46
+ c.title = I18n.t('netzke.basepack.search_window.title')
47
+ c.persistence = false
48
+ c.prevent_header = true
49
+ c.buttons = [:search, :cancel]
11
50
  end
12
51
 
13
- js_properties :width => "50%",
14
- :auto_height => true,
15
- :close_action => "hide",
16
- :buttons => [:search.action, :cancel.action],
17
- :modal => true
18
-
19
- def configuration
20
- super.tap do |s|
21
- s[:items] = [:search_panel.component(:prevent_header => true)]
22
- s[:title] = I18n.t('netzke.basepack.search_window.title')
23
- s[:persistence] = false
24
- end
25
- end
26
-
27
- component :search_panel do
28
- {
29
- :class_name => "Netzke::Basepack::QueryBuilder",
30
- :model => config[:model],
31
- :fields => config[:fields]
32
- }
52
+ component :search_panel do |c|
53
+ c.klass = QueryBuilder
54
+ c.model = config[:model]
55
+ c.fields = config[:fields]
33
56
  end
34
57
 
35
- js_method :init_component, <<-JS
36
- function(){
37
- this.callParent();
38
-
39
- this.on('show', function(){
40
- this.closeRes = 'cancel';
41
- });
42
- }
43
- JS
44
-
45
- js_method :get_query, <<-JS
46
- function(){
47
- return this.items.first().getQuery();
48
- }
49
- JS
50
-
51
- js_method :on_search, <<-JS
52
- function(){
53
- this.closeRes = 'search';
54
- this.hide();
55
- }
56
- JS
57
-
58
- js_method :on_cancel, <<-JS
59
- function(){
60
- this.hide();
61
- }
62
- JS
63
-
64
58
  end
65
59
  end
66
60
  end
@@ -31,26 +31,23 @@ module Netzke
31
31
  #
32
32
  # The JS side of the component will have those regions referenced as this.mainPanel, this.statusBar, and this.menuBar.
33
33
  class SimpleApp < Base
34
+ js_configure do |c|
35
+ c.extend = "Ext.container.Viewport"
36
+ c.layout = :border
37
+ c.require Netzke::Core.ext_path.join("examples", "ux/statusbar/StatusBar.js"), :statusbar_ext
38
+ c.mixin
39
+ end
34
40
 
35
- js_base_class "Ext.container.Viewport"
36
-
37
- js_property :layout, :border
38
- #js_include "#{File.dirname(__FILE__)}/../../../../../../public/extjs/examples/ux/statusbar/StatusBar.js"
39
- js_include Netzke::Core.ext_path.join("examples", "ux/statusbar/StatusBar.js"), :statusbar_ext
40
-
41
- js_mixin :simple_app
41
+ def configure(c)
42
+ super
43
+ c.items = [main_panel_config, menu_bar_config, status_bar_config]
44
+ end
42
45
 
43
46
  # In Ext 4.1 calling `render` on a viewport causes an error
44
47
  def js_component_render
45
48
  ""
46
49
  end
47
50
 
48
- def configuration
49
- super.merge(
50
- :items => [main_panel_config, menu_bar_config, status_bar_config]
51
- )
52
- end
53
-
54
51
  # Override for custom menu
55
52
  def menu
56
53
  []
@@ -33,7 +33,7 @@
33
33
  processHistory: function(token){
34
34
  if (token){
35
35
  this.mainPanel.removeAll();
36
- this.loadNetzkeComponent({name: token, container: this.mainPanel});
36
+ this.netzkeLoadComponent(token, {container: this.mainPanel});
37
37
  } else {
38
38
  this.mainPanel.removeAll();
39
39
  }
@@ -47,17 +47,11 @@
47
47
  Ext.util.History.add(name);
48
48
  },
49
49
 
50
- loadNetzkeComponentByAction: function(action){
50
+ netzkeLoadComponentByAction: function(action){
51
51
  var componentName = action.component || action.name;
52
52
  if (componentName) this.appLoadComponent(componentName);
53
53
  },
54
54
 
55
- // DEPRECATED
56
- loadComponentByAction: function(action) {
57
- Netzke.deprecationWarning("loadComponentByAction is deprecated in favor of loadNetzkeComponentByAction");
58
- this.loadNetzkeComponentByAction(action);
59
- },
60
-
61
55
  onToggleConfigMode: function(params){
62
56
  this.toggleConfigMode();
63
57
  }
@@ -5,7 +5,7 @@ module Netzke
5
5
  # Features:
6
6
  # * Dynamically loads components for the tabs that get activated for the first time
7
7
  # * (TODO) Provides the method markTabsOutdated to mark all inactive tabs as 'outdated', and calls "update" method on components in tabs when they get activated
8
- # * (TODO) Stores the last active tab in persistent_config
8
+ # * (TODO) Stores the last active tab in persistent config
9
9
  #
10
10
  # ToDo:
11
11
  # * Introduce a second or two delay before informing the server about a tab switched
@@ -13,9 +13,10 @@ module Netzke
13
13
 
14
14
  include WrapLazyLoaded
15
15
 
16
- js_base_class "Ext.TabPanel"
17
-
18
- js_mixin :tab_panel
16
+ js_configure do |c|
17
+ c.extend = "Ext.tab.Panel"
18
+ c.mixin
19
+ end
19
20
  end
20
21
  end
21
22
  end
@@ -1,10 +1,10 @@
1
1
  {
2
2
  initComponent: function(params){
3
- Netzke.classes.Basepack.TabPanel.superclass.initComponent.call(this);
4
- this.on('tabchange', function(self, i){
5
- if (i && i.wrappedComponent && !i.items.first() && !i.beingLoaded) {
6
- i.beingLoaded = true; // prevent more than one request per tab in case of fast clicking
7
- this.loadNetzkeComponent({name: i.wrappedComponent, container: i.id}, function(){i.beingLoaded = false});
3
+ this.callParent();
4
+ this.on('tabchange', function(self, tab){
5
+ if (tab && tab.wrappedComponent && !tab.items.first() && !tab.beingLoaded) {
6
+ tab.beingLoaded = true; // prevent more than one request per tab in case of fast clicking
7
+ this.netzkeLoadComponent(tab.wrappedComponent, {container: tab.id, callback: function(){tab.beingLoaded = false}});
8
8
  }
9
9
  }, this);
10
10
  }
@@ -2,8 +2,8 @@ module Netzke
2
2
  module Basepack
3
3
  module Version
4
4
  MAJOR = 0
5
- MINOR = 7
6
- PATCH = 7
5
+ MINOR = 8
6
+ PATCH = 0
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
9
9
  end
@@ -0,0 +1,16 @@
1
+ module Netzke
2
+ module Basepack
3
+ class Viewport < Netzke::Base
4
+ js_configure do |c|
5
+ c.extend = "Ext.container.Viewport"
6
+ end
7
+
8
+ # In Ext 4.1 calling `render` on a viewport causes an error:
9
+ #
10
+ # TypeError: protoEl is null
11
+ def js_component_render
12
+ ""
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,29 +1,38 @@
1
1
  module Netzke
2
2
  module Basepack
3
- # == Window
4
- # Ext.Window-based component able to nest other Netzke components
3
+ # Ext.window.Window-based component. With +persistence+ option set to +true+, it will remember it's size, position, and maximized state.
5
4
  #
6
- # == Features
7
- # * Persistent position and dimensions
5
+ # Example:
8
6
  #
9
- # == Instance configuration
10
- # <tt>:item</tt> - nested Netzke component, e.g.:
7
+ # class MyWindow < Netke::Basepack::Window
8
+ # def configure
9
+ # super
10
+ # c.width = 800
11
+ # c.height = 600
12
+ # c.items = [:users] # nesting the `users` component declared below
13
+ # end
11
14
  #
12
- # netzke :window, :item => {:class_name => "GridPanel", :model => "User"}
15
+ # component :users
16
+ # end
13
17
  class Window < Netzke::Base
14
- js_base_class "Ext.window.Window"
18
+ js_configure do |c|
19
+ c.extend = "Ext.window.Window"
20
+ c.mixin
21
+ end
22
+
23
+ def js_configure(c)
24
+ super
25
+ [:x, :y, :width, :height].each { |p| c[p] = state[p].to_i if state[p] }
26
+ c.maximized = state[:maximized] if state[:maximized]
27
+ end
15
28
 
16
- js_mixin
29
+ endpoint :set_size_and_position do |params, this|
30
+ [:x, :y, :width, :height].each {|p| state[p] = params[p].to_i}
31
+ end
17
32
 
18
- endpoint :set_size_and_position do |params|
19
- update_persistent_options(
20
- :x => params[:x].to_i,
21
- :y => params[:y].to_i,
22
- :width => params[:w].to_i,
23
- :height => params[:h].to_i
24
- )
25
- {}
33
+ endpoint :set_maximized do |maximized,this|
34
+ maximized ? state[:maximized] = true : state.delete(:maximized)
26
35
  end
27
36
  end
28
37
  end
29
- end
38
+ end
@@ -9,12 +9,18 @@
9
9
  this.on("show", function(){
10
10
  this.on("move", this.onMoveResize, this);
11
11
  this.on("resize", this.onMoveResize, this);
12
+ this.on("maximize", Ext.Function.pass(this.onMaximize, [true]), this);
13
+ this.on("restore", Ext.Function.pass(this.onMaximize, [false]), this);
12
14
  }, this);
13
15
  }
14
16
  },
15
17
 
16
18
  onMoveResize: function(){
17
19
  var x = this.getPosition()[0], y = this.getPosition()[1], w = this.getSize().width, h = this.getSize().height;
18
- this.setSizeAndPosition({x:x, y:y, w:w, h:h}); // API call
20
+ this.setSizeAndPosition({x: x, y: y, width: w, height: h}); // API call
21
+ },
22
+
23
+ onMaximize: function(maximized) {
24
+ this.setMaximized(maximized);
19
25
  }
20
26
  }
@@ -2,27 +2,27 @@ module Netzke
2
2
  module Basepack
3
3
  # Include this module into your component component class when you want lazy-loaded component in config to be auto-replaced with
4
4
  # a panel with the 'fit' layout, and a property wrappedComponent set to the name of the original component.
5
- # Used, for instance, in TabPanel and AccordionPanel to dynamically load components on expanding a panel or clicking
5
+ # Used, for instance, in TabPanel and Accordion to dynamically load components on expanding a panel or clicking
6
6
  # a tab.
7
7
  module WrapLazyLoaded
8
- def items
9
- orig = super.dup
10
- orig.each do |item|
11
- wrapped_component = components[item[:netzke_component]]
12
- # When a nested component with lazy loading is detected, it gets replaced with a 'fit' panel,
13
- # into which later the component itself is dynamically loaded on request.
14
- if wrapped_component && wrapped_component[:lazy_loading]
15
- item.replace({
16
- :layout => 'fit',
17
- :wrapped_component => wrapped_component[:name],
18
- :title => wrapped_component[:title] || wrapped_component[:name],
19
- :icon_cls => wrapped_component[:icon_cls],
20
- :disabled => wrapped_component[:disabled]
21
- })
22
- end
8
+ def extend_item(item)
9
+ item = super
10
+
11
+ c = components[item[:netzke_component]].try(:merge, item)
12
+
13
+ # when a nested component with lazy loading is detected, it gets replaced with a 'fit' panel,
14
+ # into which later the component itself is dynamically loaded on request.
15
+ if c && !c[:eager_loading]
16
+ { layout: :fit,
17
+ wrapped_component: c[:item_id],
18
+ title: c[:title] || c[:item_id].humanize,
19
+ icon_cls: c[:icon_cls],
20
+ disabled: c[:disabled]
21
+ }
22
+ else
23
+ item
23
24
  end
24
- orig
25
25
  end
26
26
  end
27
27
  end
28
- end
28
+ end