netzke-basepack 0.1.4.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/CHANGELOG +10 -0
  2. data/Manifest +13 -8
  3. data/README.mdown +10 -10
  4. data/Rakefile +1 -1
  5. data/css/basepack.css +4 -0
  6. data/generators/netzke_basepack/netzke_grid_panel_generator.rb +7 -0
  7. data/generators/netzke_basepack/templates/{create_netzke_grid_columns.rb → create_netzke_grid_panel_columns.rb} +4 -4
  8. data/javascripts/basepack.js +1 -1
  9. data/lib/app/models/{netzke_grid_column.rb → netzke_grid_panel_column.rb} +1 -1
  10. data/lib/netzke-basepack.rb +18 -6
  11. data/lib/netzke/accordion_panel.rb +73 -0
  12. data/lib/netzke/ar_ext.rb +51 -25
  13. data/lib/netzke/border_layout_panel.rb +119 -0
  14. data/lib/netzke/container.rb +5 -5
  15. data/lib/netzke/{grid.rb → grid_panel.rb} +30 -25
  16. data/lib/netzke/{grid_interface.rb → grid_panel_interface.rb} +11 -7
  17. data/lib/netzke/grid_panel_js_builder.rb +282 -0
  18. data/lib/netzke/panel.rb +4 -0
  19. data/lib/netzke/preference_grid.rb +4 -4
  20. data/lib/netzke/properties_tool.rb +51 -40
  21. data/lib/netzke/property_grid.rb +3 -3
  22. data/lib/netzke/wrapper.rb +20 -0
  23. data/netzke-basepack.gemspec +8 -8
  24. data/test/app_root/db/migrate/20081222033440_create_genres.rb +1 -0
  25. data/test/app_root/db/migrate/20081222035855_create_netzke_preferences.rb +1 -1
  26. data/test/ar_ext_test.rb +10 -2
  27. data/test/border_layout_panel_test.rb +28 -0
  28. data/test/{grid_test.rb → grid_panel_test.rb} +5 -4
  29. data/test/netzke_basepack_test.rb +0 -4
  30. metadata +26 -17
  31. data/generators/netzke_basepack/netzke_grid_generator.rb +0 -7
  32. data/lib/netzke/accordion.rb +0 -11
  33. data/lib/netzke/grid_js_builder.rb +0 -276
data/CHANGELOG CHANGED
@@ -1,3 +1,13 @@
1
+ v0.2.0
2
+ Some re-factoring and redesign along with netzke-core
3
+ Panel widget added
4
+ BorderLayoutPanel added
5
+ AccordionPanel added
6
+ Bug fix: column operations configuration misbehaving
7
+ Renamed Grid into GridPanel
8
+ Bug fix: exception was thrown at a column operation when no layout_manager was present
9
+ Reworked permission handling in GridPanel.
10
+
1
11
  v0.1.4.1
2
12
  Meta: updated netzke-core version (dependency)
3
13
 
data/Manifest CHANGED
@@ -1,23 +1,27 @@
1
1
  CHANGELOG
2
+ css/basepack.css
2
3
  generators/netzke_basepack/netzke_basepack_generator.rb
3
- generators/netzke_basepack/netzke_grid_generator.rb
4
- generators/netzke_basepack/templates/create_netzke_grid_columns.rb
4
+ generators/netzke_basepack/netzke_grid_panel_generator.rb
5
+ generators/netzke_basepack/templates/create_netzke_grid_panel_columns.rb
5
6
  generators/netzke_basepack/USAGE
6
7
  init.rb
7
8
  install.rb
8
9
  javascripts/basepack.js
9
10
  javascripts/filters.js
10
- lib/app/models/netzke_grid_column.rb
11
- lib/netzke/accordion.rb
11
+ lib/app/models/netzke_grid_panel_column.rb
12
+ lib/netzke/accordion_panel.rb
12
13
  lib/netzke/ar_ext.rb
14
+ lib/netzke/border_layout_panel.rb
13
15
  lib/netzke/column.rb
14
16
  lib/netzke/container.rb
15
- lib/netzke/grid.rb
16
- lib/netzke/grid_interface.rb
17
- lib/netzke/grid_js_builder.rb
17
+ lib/netzke/grid_panel.rb
18
+ lib/netzke/grid_panel_interface.rb
19
+ lib/netzke/grid_panel_js_builder.rb
20
+ lib/netzke/panel.rb
18
21
  lib/netzke/preference_grid.rb
19
22
  lib/netzke/properties_tool.rb
20
23
  lib/netzke/property_grid.rb
24
+ lib/netzke/wrapper.rb
21
25
  lib/netzke-basepack.rb
22
26
  LICENSE
23
27
  Manifest
@@ -49,6 +53,7 @@ test/app_root/db/migrate/20081223025653_create_continents.rb
49
53
  test/app_root/db/migrate/20081223025732_create_cities.rb
50
54
  test/app_root/script/console
51
55
  test/ar_ext_test.rb
56
+ test/border_layout_panel_test.rb
52
57
  test/column_test.rb
53
58
  test/console_with_fixtures.rb
54
59
  test/fixtures/books.yml
@@ -57,7 +62,7 @@ test/fixtures/cities.yml
57
62
  test/fixtures/continents.yml
58
63
  test/fixtures/countries.yml
59
64
  test/fixtures/genres.yml
60
- test/grid_test.rb
65
+ test/grid_panel_test.rb
61
66
  test/netzke_basepack_test.rb
62
67
  test/schema.rb
63
68
  test/test_helper.rb
data/README.mdown CHANGED
@@ -1,9 +1,9 @@
1
1
  # netzke-basepack
2
- A pack of basic Rails/ExtJS widgets, as a part of Netzke framework.
2
+ A pack of basic Rails/Ext JS widgets, as a part of Netzke framework.
3
3
 
4
4
  # Prerequisites
5
5
  1. Rails >= 2.2
6
- 2. ExtJS >= 2.0: its root *must* be accessible as RAILS_ROOT/public/extjs. You may symlink your ExtJS library to here, like this (from your app folder): `cd public && ln -s ~/Developer/extjs/ext-2.2 extjs`
6
+ 2. Ext JS >= 2.0: its root *must* be accessible as `RAILS_ROOT/public/extjs`. You may symlink your Ext JS library here like this (from your app folder): `cd public && ln -s ~/Developer/extjs/ext-2.2 extjs`
7
7
  3. `acts_as_list` plugin must be installed: `./script/plugin install git://github.com/rails/acts_as_list.git`
8
8
 
9
9
  # Installation
@@ -14,7 +14,7 @@ Include it into environment.rb:
14
14
  `config.gem "netzke-basepack"`
15
15
 
16
16
  # Usage
17
- First, run the generators to have the necessary migrations (if not done so already):
17
+ First, run the generators to have the necessary migrations:
18
18
 
19
19
  `./script/generate netzke_core`
20
20
 
@@ -24,27 +24,27 @@ Do the migrations:
24
24
 
25
25
  `rake db:migrate`
26
26
 
27
- This example will provide you with a grid-based scaffold for ActiveRecord-model called `Book`. If you don't have it already, you may generate it like this:
27
+ The following example will provide you with a grid-based scaffold for ActiveRecord-model called `Book`. You may generate it like this:
28
28
 
29
29
  `./script/generate model Book title:string amount:integer`
30
- (don't forget to do the migrations after this)
30
+ (don't forget to run the migrations after it)
31
31
 
32
32
  In the controller declare the widget:
33
33
 
34
34
  `class WelcomeController < ApplicationController
35
- netzke_widget :books, :widget_class_name => 'Grid', :data_class_name => 'Book'
35
+ netzke :books, :widget_class_name => 'GridPanel', :data_class_name => 'Book'
36
36
  end`
37
37
 
38
38
  After a widget is declared in the controller, it can be accessed in 3 different ways: 1) loaded by means of an automatically created controller action which will produce a basic HTML-page with the widget (handy for testing), 2) embedded directly into a view (by means of helpers), 3) dynamically loaded by other widgets (usually by the widget of class 'Application', if you want a desktop-like, AJAX-driven web-app).
39
39
 
40
40
  ## Using automatically created controller action
41
- Without writing any more code, you can access the widget by `http://yourhost/welcome/books_test`. That is to say, you simply append `_test` to your widget's name (as declared in the controller) and use it as the action of the controller.
41
+ Without writing any more code, you can access the widget by `http://yourhost/welcome/books_test`. That is to say, you simply append `_test` to your widget's name (as declared in the controller) to get the action name.
42
42
 
43
43
  ## Embedding a widget into a view
44
- netzke-core plugin provides the following 2 helpers to put inside your head-tag (use it in your layout)
44
+ netzke-core plugin provides the following 2 helpers to put inside your head-tag (use it in your layout):
45
45
 
46
46
  1. `netzke_js_include` - to include extjs and netzke javascript files
47
- 2. `netzke_css_include` - to include the css. This one can take a parameter to specify a color schema you wish for ExtJS, e.g.: `netzke_css_include(:gray)`
47
+ 2. `netzke_css_include` - to include the css. This one can take a parameter to specify a color schema you wish for Ext JS, e.g.: `netzke_css_include(:gray)`
48
48
 
49
49
  Declaring a widget in the controller provides you with a couple of helpers that can be used in the view:
50
50
 
@@ -71,7 +71,7 @@ Ext.onReady(function(){
71
71
  books.render("books");
72
72
  })
73
73
  <% end %>
74
- <!-- some HTML... -->
74
+ <p>... your page content here ...</p>
75
75
  <div id="books">the widget will be rendered in this div</div>`
76
76
 
77
77
  ## Dynamic loading of widgets
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ Echoe.new("netzke-basepack") do |p|
5
5
  p.email = "sergei@writelesscode.com"
6
6
  p.summary = "Base Netzke widgets - grid, form, tree, and more"
7
7
  p.url = "http://writelesscode.com"
8
- p.runtime_dependencies = ["searchlogic >=1.6.2", "netzke-core >= 0.1.4"]
8
+ p.runtime_dependencies = ["searchlogic >=1.6.2", "netzke-core >= 0.2.0"]
9
9
  p.development_dependencies = []
10
10
  p.test_pattern = 'test/**/*_test.rb'
11
11
 
data/css/basepack.css ADDED
@@ -0,0 +1,4 @@
1
+ /* write accordion header in bold */
2
+ .x-accordion-hd {
3
+ font-weight:bold;
4
+ }
@@ -0,0 +1,7 @@
1
+ class NetzkeGridPanelGenerator < Rails::Generator::Base
2
+ def manifest
3
+ record do |m|
4
+ m.migration_template 'create_netzke_grid_panel_columns.rb', "db/migrate", {:migration_file_name => "create_netzke_grid_panel_columns"}
5
+ end
6
+ end
7
+ end
@@ -1,13 +1,13 @@
1
- class CreateNetzkeGridColumns < ActiveRecord::Migration
1
+ class CreateNetzkeGridPanelColumns < ActiveRecord::Migration
2
2
  def self.up
3
- create_table :netzke_grid_columns do |t|
3
+ create_table :netzke_grid_panel_columns do |t|
4
4
  t.string :name
5
5
  t.string :label
6
6
  t.boolean :read_only
7
7
  t.integer :position
8
8
  t.boolean :hidden
9
9
  t.integer :width
10
- t.string :shows_as, :limit => 32
10
+ t.string :editor, :limit => 32
11
11
 
12
12
  t.integer :layout_id
13
13
 
@@ -16,6 +16,6 @@ class CreateNetzkeGridColumns < ActiveRecord::Migration
16
16
  end
17
17
 
18
18
  def self.down
19
- drop_table :netzke_grid_columns
19
+ drop_table :netzke_grid_panel_columns
20
20
  end
21
21
  end
@@ -41,7 +41,7 @@ Ext.netzke.editors = {
41
41
  }
42
42
  };
43
43
 
44
- // Mapping of showsAs field to grid filters
44
+ // Mapping of editor field to grid filters
45
45
  Ext.netzke.filterMap = {
46
46
  number_field:'Numeric',
47
47
  text_field:'String',
@@ -1,4 +1,4 @@
1
- class NetzkeGridColumn < ActiveRecord::Base
1
+ class NetzkeGridPanelColumn < ActiveRecord::Base
2
2
  belongs_to :layout, :class_name => "NetzkeLayout"
3
3
 
4
4
  acts_as_list :scope => :layout
@@ -4,6 +4,11 @@ require 'searchlogic'
4
4
 
5
5
  require 'netzke/ar_ext'
6
6
 
7
+ # Default boot config
8
+ Netzke::Base.config.merge!({
9
+ :grid_panel => {:filters => true}
10
+ }.recursive_merge(Object.const_defined?(:NETZKE_BOOT_CONFIG) ? Object.const_get(:NETZKE_BOOT_CONFIG) : {}))
11
+
7
12
  %w{ models }.each do |dir|
8
13
  path = File.join(File.dirname(__FILE__), 'app', dir)
9
14
  $LOAD_PATH << path
@@ -16,13 +21,20 @@ Netzke::Base.config[:javascripts] << "#{File.dirname(__FILE__)}/../javascripts/b
16
21
 
17
22
  # TODO: implement configurable loading of JS, to spare the traffic at the initial loading
18
23
  extjs_dir = "#{RAILS_ROOT}/public/extjs"
19
- Netzke::Base.config[:javascripts] << "#{extjs_dir}/examples/grid-filtering/menu/EditableItem.js"
20
- Netzke::Base.config[:javascripts] << "#{extjs_dir}/examples/grid-filtering/menu/RangeMenu.js"
21
- Netzke::Base.config[:javascripts] << "#{extjs_dir}/examples/grid-filtering/grid/GridFilters.js"
22
- %w{Boolean Date List Numeric String}.unshift("").each do |f|
23
- Netzke::Base.config[:javascripts] << "#{extjs_dir}/examples/grid-filtering/grid/filter/#{f}Filter.js"
24
+
25
+ # Filters in GridPanel
26
+ if Netzke::Base.config[:grid_panel][:filters]
27
+ Netzke::Base.config[:javascripts] << "#{extjs_dir}/examples/grid-filtering/menu/EditableItem.js"
28
+ Netzke::Base.config[:javascripts] << "#{extjs_dir}/examples/grid-filtering/menu/RangeMenu.js"
29
+ Netzke::Base.config[:javascripts] << "#{extjs_dir}/examples/grid-filtering/grid/GridFilters.js"
30
+ %w{Boolean Date List Numeric String}.unshift("").each do |f|
31
+ Netzke::Base.config[:javascripts] << "#{extjs_dir}/examples/grid-filtering/grid/filter/#{f}Filter.js"
32
+ end
33
+ Netzke::Base.config[:javascripts] << "#{File.dirname(__FILE__)}/../javascripts/filters.js"
24
34
  end
25
- Netzke::Base.config[:javascripts] << "#{File.dirname(__FILE__)}/../javascripts/filters.js"
26
35
 
27
36
  # Make this plugin reloadable for easier development
28
37
  ActiveSupport::Dependencies.load_once_paths.delete(File.join(File.dirname(__FILE__)))
38
+
39
+ # Include CSS
40
+ Netzke::Base.config[:css] << "#{File.dirname(__FILE__)}/../css/basepack.css"
@@ -0,0 +1,73 @@
1
+ module Netzke
2
+ class AccordionPanel < Base
3
+ #
4
+ # JS-class generation
5
+ #
6
+ class << self
7
+
8
+ def js_default_config
9
+ super.merge({
10
+ :layout => 'accordion',
11
+ :listeners => {
12
+ # every item gets an expand event activeted, which dynamically loads a widget into this item
13
+ :add => {
14
+ :fn => <<-JS.l
15
+ function(self, comp){
16
+ comp.on('expand', this.loadItemWidget, self)
17
+ }
18
+ JS
19
+ }
20
+ }
21
+ })
22
+ end
23
+
24
+ def js_extend_properties
25
+ {
26
+ # loads widget into the panel if it wasn't loaded yet
27
+ :load_item_widget => <<-JS.l,
28
+ function(panel) {
29
+ if (!panel.getWidget()) panel.loadWidget(this.id + "__" + panel.id + "__get_widget");
30
+ }
31
+ JS
32
+ }
33
+ end
34
+
35
+ end
36
+
37
+ def js_config
38
+ super.merge(:items => items)
39
+ end
40
+
41
+ # the items are late aggregatees (besides the ones that are marked "active")
42
+ def initial_aggregatees
43
+ res = {}
44
+ config[:items].each_with_index do |item, i|
45
+ item[:late_aggregation] = !item[:active]
46
+ res.merge!(item[:name].to_sym => item)
47
+ end
48
+ res
49
+ end
50
+
51
+ def items
52
+ res = []
53
+ config[:items].each_with_index do |item, i|
54
+ item_config = {
55
+ :id => item[:name] || "item_#{i}",
56
+ :title => item[:title] || (item[:name] && item[:name].humanize) || "Item #{i}",
57
+ :layout => 'fit',
58
+ :collapsed => !(item[:active] || false)
59
+ }
60
+
61
+ # directly embed the widget in the active panel
62
+ if item[:active]
63
+ item_instance = Netzke::Base.instance_by_config(item.merge(:name => "#{id_name}__#{item[:name]}"))
64
+ item_config[:items] = ["new Ext.componentCache['#{item[:widget_class_name]}'](#{item_instance.js_config.to_js})".l]
65
+ end
66
+
67
+ res << item_config
68
+ end
69
+ res
70
+ end
71
+
72
+ end
73
+ end
data/lib/netzke/ar_ext.rb CHANGED
@@ -5,11 +5,11 @@ module Netzke
5
5
  end
6
6
 
7
7
  #
8
- # Allow nested association acces (assocs separated by "." or "__"), e.g.: proxy_service.send('asset__gui_folder__name')
8
+ # Allow nested association access (assocs separated by "." or "__"), e.g.: proxy_service.asset__gui_folder__name
9
9
  # Example:
10
10
  # b = Book.first
11
11
  # b.genre__name = 'Fantasy' => b.genre = Genre.find_by_name('Fantasy')
12
- # NOT IMPLEMENTED: ANY USE? b.genre__catalog__name = 'Best sellers' => b.genre_id = b.genre.find_by_catalog_id(Catalog.find_by_name('Best sellers')).id
12
+ # NOT IMPLEMENTED (any real use?): b.genre__catalog__name = 'Best sellers' => b.genre_id = b.genre.find_by_catalog_id(Catalog.find_by_name('Best sellers')).id
13
13
  #
14
14
 
15
15
  def method_missing(method, *args, &block)
@@ -49,8 +49,8 @@ module Netzke
49
49
  end
50
50
  end
51
51
 
52
-
53
52
  module ActiveRecordClassMethods
53
+ # Returns all unique values for a column, filtered by the query
54
54
  def choices_for(column, query = nil)
55
55
  if respond_to?("#{column}_choices", query)
56
56
  # AR class provides the choices itself
@@ -77,11 +77,11 @@ module Netzke
77
77
  end
78
78
 
79
79
  # which columns are to be picked up by grids and forms
80
- def expose_columns(columns, *args)
81
- if columns == :all
80
+ def expose_columns(*column_configs)
81
+ if column_configs.first == :all
82
82
  write_inheritable_attribute(:exposed_columns, self.column_names.map(&:to_sym))
83
83
  else
84
- write_inheritable_attribute(:exposed_columns, columns)
84
+ write_inheritable_attribute(:exposed_columns, column_configs)
85
85
  end
86
86
  end
87
87
 
@@ -108,40 +108,52 @@ module Netzke
108
108
  end
109
109
 
110
110
  #
111
- # Used by Netzke::Grid
111
+ # Used by Netzke::GridPanel
112
112
  #
113
113
 
114
114
  DEFAULT_COLUMN_WIDTH = 100
115
115
 
116
+ # Returns default column config understood by Netzke::GridPanel
117
+ # Argument: column name (as Symbol) or column config
116
118
  def default_column_config(config)
117
- config = {:name => config} if config.is_a?(Symbol) # optionally we may get only a column name (as Symbol)
119
+ config = config.dup
120
+ # config = config.dup # to not touch the original config
121
+ config = {:name => config} if config.is_a?(Symbol) # if got a column name
122
+
123
+ # detect ActiveRecord column type (if the column is "real") or fall back to :virtual
118
124
  type = (columns_hash[config[:name].to_s] && columns_hash[config[:name].to_s].type) || :virtual
119
125
 
120
- # general config
121
126
  res = {
122
127
  :name => config[:name].to_s || "unnamed",
123
- :label => config[:label] || config[:name].to_s.humanize,
128
+ :label => config[:label] || config[:name].to_s.gsub('__', '_').humanize,
124
129
  :read_only => config[:name] == :id, # make "id" column read-only by default
125
130
  :hidden => config[:name] == :id, # hide "id" column by default
126
131
  :width => DEFAULT_COLUMN_WIDTH,
127
- :shows_as => :text_field
132
+ :editor => ext_editor(type)
128
133
  }
129
134
 
130
- case type
131
- when :integer
132
- res[:shows_as] = :number_field
133
- when :boolean
134
- res[:shows_as] = :checkbox
135
- res[:width] = 50
136
- when :date
137
- res[:shows_as] = :date_field
138
- when :datetime
139
- res[:shows_as] = :datetime
140
- when :string
141
- res[:shows_as] = :text_field
135
+ # detect :assoc__method
136
+ if config[:name].to_s.index('__')
137
+ assoc_name, method = config[:name].to_s.split('__').map(&:to_sym)
138
+ if assoc = reflect_on_association(assoc_name)
139
+ assoc_column = assoc.klass.columns_hash[method.to_s]
140
+ assoc_method_type = assoc_column && assoc_column.type
141
+ if assoc_method_type
142
+ res[:editor] = ext_editor(assoc_method_type) == :checkbox ? :checkbox : :combo_box
143
+ end
144
+ end
142
145
  end
143
-
144
- res.merge(config) # merge with custom confg (it has the priority)
146
+
147
+ # detect association column (e.g. :category_id)
148
+ if assoc = reflect_on_all_associations.detect{|a| a.primary_key_name.to_sym == config[:name]}
149
+ res[:editor] = :combo_box
150
+ assoc_method = %w{name title label}.detect{|m| (assoc.klass.instance_methods + assoc.klass.column_names).include?(m) } || assoc.klass.primary_key
151
+ res[:name] = "#{assoc.name}__#{assoc_method}"
152
+ end
153
+
154
+ # merge with the given confg, which has the priority
155
+ config.delete(:name) # because we might have changed the name
156
+ res.merge(config)
145
157
  end
146
158
 
147
159
  #
@@ -154,6 +166,20 @@ module Netzke
154
166
  # TODO
155
167
  end
156
168
 
169
+ private
170
+ # identify Ext editor for the data type
171
+ TYPE_EDITOR_MAP = {
172
+ :integer => :number_field,
173
+ :boolean => :checkbox,
174
+ :date => :date_field,
175
+ :datetime => :datetime,
176
+ :string => :text_field
177
+ }
178
+
179
+ def ext_editor(type)
180
+ TYPE_EDITOR_MAP[type] || :text_field # fall back to :text_field
181
+ end
182
+
157
183
  end
158
184
  end
159
185
  end
@@ -0,0 +1,119 @@
1
+ module Netzke
2
+ class BorderLayoutPanel < Base
3
+ interface :resize_region
4
+
5
+ REGIONS = %w(center west east south north).map(&:to_sym)
6
+
7
+ #
8
+ # JS-class generation
9
+ #
10
+ class << self
11
+ def js_listeners
12
+ {
13
+ :afterlayout => {:fn => "this.setResizeEvents".l, :scope => this}
14
+ }
15
+ end
16
+
17
+ def js_before_constructor
18
+ <<-JS.l
19
+ var items = [];
20
+ Ext.each(['center', 'west', 'east', 'south', 'north'], function(r){
21
+ var configName = r+'Config';
22
+ if (config[configName]){
23
+ var regionConfig = config[configName].regionConfig || {};
24
+ regionConfig.layout = 'fit';
25
+ regionConfig.region = r;
26
+ regionConfig.items = [new Ext.componentCache[config[configName].widgetClassName](config[configName])]
27
+ items.push(regionConfig);
28
+ };
29
+ }, this)
30
+ JS
31
+ end
32
+
33
+ def js_default_config
34
+ super.merge({
35
+ :layout => 'border',
36
+ :items => "items".l
37
+ })
38
+ end
39
+
40
+ def js_extend_properties
41
+ {:set_resize_events => <<-JS.l,
42
+ function(){
43
+ this.items.each(function(item, index, length){
44
+ if (!item.oldSize) item.oldSize = item.getSize();
45
+ if (item.region == 'east' || item.region == 'west') item.on('resize', function(panel, w, h){
46
+ if (panel.oldSize.width != w) {
47
+ Ext.Ajax.request({
48
+ url:this.initialConfig.interface.resizeRegion,
49
+ params: {region_name: panel.region, new_width:w}
50
+ });
51
+ panel.oldSize.width = w;
52
+ }
53
+ return true;
54
+ }, this);
55
+ else if (item.region == 'south' || item.region == 'north') item.on('resize', function(panel, w, h){
56
+ if (panel.oldSize.height != h) {
57
+ Ext.Ajax.request({
58
+ url:this.initialConfig.interface.resizeRegion,
59
+ params: {region_name: panel.region, new_height:h}
60
+ });
61
+ panel.oldSize.height = h;
62
+ }
63
+ return true;
64
+ }, this);
65
+ }, this);
66
+ this.un('afterlayout', this.setResizeEvents, this); // to avoid redefinition of resize events
67
+ }
68
+ JS
69
+ }
70
+ end
71
+
72
+ end
73
+
74
+ def initial_aggregatees
75
+ config[:regions] || {}
76
+ end
77
+
78
+ # def items
79
+ # res = []
80
+ # config[:regions].each_pair do |k,v|
81
+ # width = v.delete(:width)
82
+ # height = v.delete(:height)
83
+ # split = v[:split].nil? ? true : v.delete(:split) # split is by default true
84
+ # region_config = {
85
+ # :region => k,
86
+ # :width => @pref["#{k}_width"] || width || 100,
87
+ # :height => @pref["#{k}_height"] || height || 100,
88
+ # :split => split,
89
+ # :layout => v.delete(:layout) || 'fit',
90
+ # :id => @id_name + "_#{k}_region"
91
+ # }
92
+ # region_widget_instance = "Netzke::#{v[:widget_class_name]}".constantize.new(v.merge(:name => "#{id_name}__#{k}"))
93
+ # region_config.merge!(v)
94
+ # region_config[:items] = ["new Ext.componentCache['#{v[:widget_class_name]}'](#{region_widget_instance.js_config.to_js})".l]
95
+ # res << region_config
96
+ # end
97
+ # res
98
+ # end
99
+
100
+ def region_aggregatees
101
+ aggregatees.reject{ |k,v| !REGIONS.include?(k) }
102
+ end
103
+
104
+ # def js_config
105
+ # super.merge(:regional_config => items)
106
+ # end
107
+
108
+ def interface_resize_region(params)
109
+ @pref["#{params[:region_name]}_width"] = params[:new_width].to_i if params[:new_width]
110
+ @pref["#{params[:region_name]}_height"] = params[:new_height].to_i if params[:new_height]
111
+ end
112
+
113
+ protected
114
+
115
+ def extend_functions; ""; end
116
+ def js_extra_events; ""; end
117
+
118
+ end
119
+ end