netzke-basepack 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,4 +1,9 @@
1
- = v0.5.6
1
+ = v0.5.7 - 2010-02-26
2
+ * Regression: column config for GridPanel again accepts a renderer along with its parameters (as array, where the first element is the renderers name, the second - the parameters passed to the renderer, e.g.: :renderer => ["date", "y-m-d"])
3
+ * Fix: Window resize/move now works correctly
4
+ * Code: taking care of deprecated methods
5
+
6
+ = v0.5.6 - 2010-01-10
2
7
  * Compatibility with latest netzke-core
3
8
  * Compatibility with Ext JS v3.1
4
9
  * Impr: Code reorganization
data/README.rdoc CHANGED
@@ -3,9 +3,9 @@ A pack of basic Rails/ExtJS widgets as a part of the Netzke framework. Live demo
3
3
 
4
4
  = Prerequisites
5
5
  1. Rails >= 2.2
6
- 2. ExtJS = 3.0.3. Its root by default must be accessible as RAILS_ROOT/public/extjs. You may symlink your Ext JS library here like this (from your app folder):
6
+ 2. Netzke assumes that your ExtJS library is in public/extjs, which may be a symbolic link, e.g:
7
7
 
8
- cd public && ln -s ~/Developer/extjs/ext-3.0.3 extjs
8
+ cd public && ln -s ~/Developer/extjs/ext-3.1.1 extjs
9
9
 
10
10
  3. acts_as_list plugin:
11
11
 
@@ -24,11 +24,7 @@ For the "edge" stuff, install as plugin (recommended):
24
24
 
25
25
  ./script/plugin install git://github.com/skozlov/netzke-basepack.git
26
26
 
27
- Otherwise install as gem. The gem is hosted on gemcutter. If you haven't yet enabled gemcutter, run the following:
28
-
29
- sudo gem install gemcutter && gem tumble
30
-
31
- Install the gem:
27
+ Or install as gem:
32
28
 
33
29
  gem install netzke-basepack
34
30
 
@@ -66,10 +62,19 @@ Now embed a widget into a view like this:
66
62
 
67
63
  <%= netzke :books, :class_name => 'GridPanel', :model => 'Book' %>
68
64
 
69
- == Dynamic loading of widgets
70
- TODO: this part will be covered later
65
+ For more examples, see http://netzke-demo.writelesscode.com
66
+
67
+ == More info
68
+ Introduction to Netzke framework and wiki: http://github.com/skozlov/netzke
69
+
70
+ Twitter: http://twitter.com/skozlov
71
+
72
+ Tutorials: http://blog.writelesscode.com
73
+
74
+ Live-demo with sample code: http://netzke-demo.writelesscode.com
71
75
 
72
76
  = Credentials
73
77
  Testing done with the help of http://github.com/pluginaweek/plugin_test_helper
74
78
 
75
- Copyright (c) 2008-2009 Sergei Kozlov, released under the MIT license
79
+ ---
80
+ Copyright (c) 2008-2010 Sergei Kozlov, released under the MIT license
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  begin
2
2
  require 'jeweler'
3
3
  Jeweler::Tasks.new do |gemspec|
4
- gemspec.version = "0.5.6"
4
+ gemspec.version = "0.5.7"
5
5
  gemspec.name = "netzke-basepack"
6
6
  gemspec.summary = "Pre-built Rails + ExtJS widgets for your RIA"
7
7
  gemspec.description = "A set of full-featured extendible Netzke widgets (such as FormPanel, GridPanel, Window, BorderLayoutPanel, etc) which can be used as building block for your RIA"
@@ -9,7 +9,7 @@ begin
9
9
  gemspec.homepage = "http://github.com/skozlov/netzke-basepack"
10
10
  gemspec.rubyforge_project = "netzke-basepack"
11
11
  gemspec.authors = ["Sergei Kozlov"]
12
- gemspec.add_dependency("netzke-core", ">=0.5.0")
12
+ gemspec.add_dependency("netzke-core", ">=0.5.1")
13
13
  gemspec.add_dependency("searchlogic", ">=2.0.0")
14
14
  gemspec.add_dependency("will_paginate", ">=2.0.0")
15
15
  end
@@ -104,7 +104,7 @@ module Netzke
104
104
  def initial_aggregatees
105
105
  res = {}
106
106
  config[:items].each_with_index do |item, i|
107
- item[:late_aggregation] = !item[:active]
107
+ item[:late_aggregation] = !item[:active] && !item[:preloaded]
108
108
  res.merge!(item[:name].to_sym => item)
109
109
  end
110
110
  res
@@ -22,10 +22,10 @@ module Netzke
22
22
  # == Example configuration:
23
23
  #
24
24
  # :regions => {
25
- # :center => {:widget_class_name => "Panel", :ext_config => {:html => "A panel"}},
25
+ # :center => {:class_name => "Panel", :ext_config => {:html => "A panel"}},
26
26
  # :west => {
27
- # :widget_class_name => "GridPanel",
28
- # :data_class_name => "User",
27
+ # :class_name => "GridPanel",
28
+ # :model => "User",
29
29
  # :region_config => {
30
30
  # :width => 100,
31
31
  # :split => true
@@ -25,7 +25,7 @@ module Netzke
25
25
  def default_config
26
26
  super.deep_merge({
27
27
  :name => 'columns',
28
- :data_class_name => is_for_grid? ? "NetzkeAutoColumn" : "NetzkeAutoField",
28
+ :model => is_for_grid? ? "NetzkeAutoColumn" : "NetzkeAutoField",
29
29
  :ext_config => {
30
30
  :header => false,
31
31
  :enable_extended_search => false,
@@ -76,7 +76,7 @@ module Netzke
76
76
 
77
77
  res << {
78
78
  :name => 'fields',
79
- :widget_class_name => "FieldsConfigurator",
79
+ :class_name => "FieldsConfigurator",
80
80
  :active => true,
81
81
  :widget => self,
82
82
  :persistent_config => true
@@ -84,7 +84,7 @@ module Netzke
84
84
 
85
85
  res << {
86
86
  :name => 'general',
87
- :widget_class_name => "PropertyEditor",
87
+ :class_name => "PropertyEditor",
88
88
  :widget => self,
89
89
  :ext_config => {:title => false}
90
90
  }
@@ -106,7 +106,7 @@ module Netzke
106
106
  def js_config
107
107
  res = super
108
108
  res.merge!(:clmns => columns)
109
- res.merge!(:data_class_name => data_class.name) if data_class
109
+ res.merge!(:model => data_class.name) if data_class
110
110
  res.merge!(:pri => data_class.primary_key) if data_class
111
111
  res
112
112
  end
@@ -42,7 +42,7 @@ module Netzke
42
42
 
43
43
  # API handling form load
44
44
  # def load(params)
45
- # klass = config[:data_class_name].constantize
45
+ # klass = config[:model].constantize
46
46
  # case params[:neighbour]
47
47
  # when "previous" then @record = klass.previous(params[:id])
48
48
  # when "next" then @record = klass.next(params[:id])
@@ -237,13 +237,13 @@ module Netzke
237
237
  res << {
238
238
  :persistent_config => true,
239
239
  :name => 'columns',
240
- :widget_class_name => "FieldsConfigurator",
240
+ :class_name => "FieldsConfigurator",
241
241
  :active => true,
242
242
  :widget => self
243
243
  }
244
244
  res << {
245
245
  :name => 'general',
246
- :widget_class_name => "PropertyEditor",
246
+ :class_name => "PropertyEditor",
247
247
  :widget => self,
248
248
  :ext_config => {:title => false}
249
249
  }
@@ -269,14 +269,14 @@ module Netzke
269
269
  # Edit in form
270
270
  res.merge!({
271
271
  :add_form => {
272
- :widget_class_name => "GridPanel::RecordFormWindow",
272
+ :class_name => "GridPanel::RecordFormWindow",
273
273
  :ext_config => {
274
274
  :title => "Add #{data_class.name.humanize}",
275
275
  :button_align => "right"
276
276
  },
277
277
  :item => {
278
- :widget_class_name => "FormPanel",
279
- :data_class_name => data_class.name,
278
+ :class_name => "FormPanel",
279
+ :model => data_class.name,
280
280
  :persistent_config => config[:persistent_config],
281
281
  :strong_default_attrs => config[:strong_default_attrs],
282
282
  :ext_config => {
@@ -290,8 +290,8 @@ module Netzke
290
290
  },
291
291
 
292
292
  :edit_form => {
293
- :widget_class_name => "FormPanel",
294
- :data_class_name => data_class.name,
293
+ :class_name => "FormPanel",
294
+ :model => data_class.name,
295
295
  :persistent_config => config[:persistent_config],
296
296
  :ext_config => {
297
297
  :bbar => false,
@@ -301,8 +301,8 @@ module Netzke
301
301
  },
302
302
 
303
303
  :multi_edit_form => {
304
- :widget_class_name => "FormPanel",
305
- :data_class_name => data_class.name,
304
+ :class_name => "FormPanel",
305
+ :model => data_class.name,
306
306
  :persistent_config => config[:persistent_config],
307
307
  :ext_config => {
308
308
  :bbar => false,
@@ -312,8 +312,8 @@ module Netzke
312
312
  },
313
313
 
314
314
  :new_record_form => {
315
- :widget_class_name => "FormPanel",
316
- :data_class_name => data_class.name,
315
+ :class_name => "FormPanel",
316
+ :model => data_class.name,
317
317
  :persistent_config => config[:persistent_config],
318
318
  :strong_default_attrs => config[:strong_default_attrs],
319
319
  :ext_config => {
@@ -328,7 +328,7 @@ module Netzke
328
328
  # Extended search
329
329
  res.merge!({
330
330
  :search_panel => {
331
- :widget_class_name => "SearchPanel",
331
+ :class_name => "SearchPanel",
332
332
  :search_class_name => data_class.name,
333
333
  :persistent_config => config[:persistent_config],
334
334
  :ext_config => {
@@ -8,7 +8,7 @@ module Netzke
8
8
  def js_config
9
9
  res = super
10
10
  res.merge!(:clmns => columns)
11
- res.merge!(:data_class_name => config[:data_class_name])
11
+ res.merge!(:model => config[:model])
12
12
  res.merge!(:inline_data => get_data) if ext_config[:load_inline_data]
13
13
  res.merge!(:pri => data_class.primary_key)
14
14
  res
@@ -106,7 +106,7 @@ module Netzke
106
106
  }
107
107
 
108
108
  // set the renderer
109
- if (c.renderer && c.renderer.match(/^\\s*function\\s*\\(/)) {
109
+ if (c.renderer && !Ext.isArray(c.renderer) && c.renderer.match(/^\\s*function\\s*\\(/)) {
110
110
  // if the renderer is an inline function - eval it (double escaping because we are inside of the Ruby string here...)
111
111
  eval("c.renderer = " + c.renderer + ";");
112
112
  } else {
@@ -5,8 +5,8 @@ module Netzke
5
5
  @items ||= [{
6
6
  :name => "roles",
7
7
  :active => true,
8
- :widget_class_name => "GridPanel",
9
- :data_class_name => 'Role',
8
+ :class_name => "GridPanel",
9
+ :model => 'Role',
10
10
  :columns => [:id, :name],
11
11
  :ext_config => {
12
12
  :header => false,
@@ -15,8 +15,8 @@ module Netzke
15
15
  },{
16
16
  :name => "users",
17
17
  :preloaded => true,
18
- :widget_class_name => "GridPanel",
19
- :data_class_name => 'User',
18
+ :class_name => "GridPanel",
19
+ :model => 'User',
20
20
  :ext_config => {
21
21
  :header => false,
22
22
  :rows_per_page => 10,
@@ -31,7 +31,7 @@ module Netzke::Plugins
31
31
  :on_gear => <<-END_OF_JAVASCRIPT.l
32
32
  function(){
33
33
  var w = new Ext.Window({
34
- title:'Config - '+ this.dataClassName,
34
+ title:'Config - '+ this.model,
35
35
  layout:'fit',
36
36
  modal:true,
37
37
  width: Ext.lib.Dom.getViewWidth() *0.9,
@@ -93,7 +93,7 @@ module Netzke::Plugins
93
93
  # Add the ConfigurationPanel as aggregatee, which in its turn aggregates widgets from the
94
94
  # configuration_widgets method
95
95
  res.merge!(:configuration_panel => {
96
- :widget_class_name => 'ConfigurationPanel',
96
+ :class_name => 'ConfigurationPanel',
97
97
  :items => configuration_widgets,
98
98
  :late_aggregation => true
99
99
  }) if config_tool_needed?
@@ -9,7 +9,7 @@ module Netzke
9
9
 
10
10
  def default_config
11
11
  super.merge({
12
- :data_class_name => @passed_config[:search_class_name]
12
+ :model => @passed_config[:search_class_name]
13
13
  })
14
14
  end
15
15
 
@@ -88,16 +88,16 @@ module Netzke
88
88
  split_size = config[:split_size] || 200
89
89
  {
90
90
  :center => {
91
- :widget_class_name => "GridPanel",
92
- :data_class_name => config[:data_class_name],
91
+ :class_name => "GridPanel",
92
+ :model => config[:model],
93
93
  :ext_config => {
94
- :title => config[:grid_title] || config[:data_class_name].pluralize
94
+ :title => config[:grid_title] || config[:model].pluralize
95
95
  }
96
96
  }.deep_merge(config[:grid_config] || {}),
97
97
 
98
98
  split_region => {
99
- :widget_class_name => "FormPanel",
100
- :data_class_name => config[:data_class_name],
99
+ :class_name => "FormPanel",
100
+ :model => config[:model],
101
101
  :region_config => {
102
102
  :width => split_size,
103
103
  :height => split_size,
@@ -105,7 +105,7 @@ module Netzke
105
105
  :collapsible => true
106
106
  },
107
107
  :ext_config => {
108
- :title => config[:form_title] || "#{config[:data_class_name]} details",
108
+ :title => config[:form_title] || "#{config[:model]} details",
109
109
  :listeners => {:actioncomplete => {
110
110
  :fn => "function(f, a){this.ownerCt.ownerCt.onFormActioncomplete(f,a)}".l
111
111
  }}
@@ -18,7 +18,7 @@ class Netzke::TreePanel < Netzke::Base
18
18
  end
19
19
 
20
20
  def get_children(params)
21
- klass = config[:data_class_name].constantize
21
+ klass = config[:model].constantize
22
22
  node = params[:node] == 'source' ? klass.find_by_parent_id(nil) : klass.find(params[:node].to_i)
23
23
  node.children.map{|n| {:text => n.name, :id => n.id, :leaf => n.children.empty?}}
24
24
  end
data/lib/netzke/window.rb CHANGED
@@ -1,15 +1,14 @@
1
1
  module Netzke
2
2
  # == Window
3
- # Ext.Window-based widget
3
+ # Ext.Window-based widget able to nest other Netzke widgets
4
4
  #
5
5
  # == Features
6
- # * Persistent position
7
- # * Persistent dimensions
6
+ # * Persistent position and dimensions
8
7
  #
9
8
  # == Instance configuration
10
- # <tt>:height</tt> and <tt>:width</tt> - besides accepting a number (which would be just standard ExtJS),
11
- # can accept a string specifying relative sizes, calculated from current browser window dimensions.
12
- # E.g.: :height => "90%", :width => "60%"
9
+ # <tt>:item</tt> - nested Netzke widget, e.g.:
10
+ #
11
+ # netzke :window, :item => {:class_name => "GridPanel", :model => "User"}
13
12
  class Window < Base
14
13
  # Based on Ext.Window, naturally
15
14
  def self.js_base_class
@@ -26,57 +25,57 @@ module Netzke
26
25
  # Extends the JavaScript class
27
26
  def self.js_extend_properties
28
27
  {
28
+ # we nest widget inside the "fit" layout
29
29
  :layout => "fit",
30
30
 
31
+ # default width and height
32
+ :width => 300,
33
+ :height => 200,
34
+
31
35
  :init_component => <<-END_OF_JAVASCRIPT.l,
32
36
  function(){
33
- // Width and height may be specified as percentage of available space, e.g. "60%".
34
- // Convert them into actual pixels.
35
- Ext.each(["width", "length"], function(k){
36
- if (Ext.isString(this[k])) {
37
- this[k] = Ext.lib.Dom.getViewHeight() * parseFloat("." + this[k].substr(0, this[k].length - 1)); // "66%" => ".66"
38
- }
39
- });
40
-
41
- // Superclass' initComponent
37
+ // superclass' initComponent
42
38
  #{js_full_class_name}.superclass.initComponent.call(this);
43
39
 
44
- // Set the move and resize events after window is shown, so that they don't fire at initial rendering
40
+ // set the move and resize events after window is shown, so that they don't fire at initial rendering
45
41
  this.on("show", function(){
46
- this.on("move", this.onMove, this);
47
- this.on("resize", this.onSelfResize, this); // Work around firing "resize" event twice (currently a bug in ExtJS)
42
+ this.on("move", this.onMoveResize, this);
43
+ this.on("resize", this.onMoveResize, this);
48
44
  }, this);
49
45
 
46
+ // instantiate the aggregatee
50
47
  if (this.itemConfig){
51
48
  this.instantiateChild(this.itemConfig);
52
49
  }
53
50
  }
54
51
  END_OF_JAVASCRIPT
55
52
 
56
- :on_move => <<-END_OF_JAVASCRIPT.l,
57
- function(w,x,y){
58
- this.moveToPosition({x:x, y:y});
59
- }
60
- END_OF_JAVASCRIPT
53
+ :on_move_resize => <<-END_OF_JAVASCRIPT.l,
54
+ function(){
55
+ var x = this.getPosition()[0], y = this.getPosition()[1], w = this.getSize().width, h = this.getSize().height;
61
56
 
62
- :on_self_resize => <<-END_OF_JAVASCRIPT.l,
63
- function(w, width, height){
64
- this.selfResize({w:width, h:height});
57
+ // Don't bother the server twice when both move and resize events are fired at the same time
58
+ // (which happens when the left or upper window border is dragged)
59
+ if (this.moveResizeTimer) {clearTimeout(this.moveResizeTimer)};
60
+
61
+ this.moveResizeTimer = (function(sizeAndPosition){
62
+ this.setSizeAndPosition(sizeAndPosition); // API call
63
+ }).defer(10, this, [{x:x, y:y, w:w, h:h}]); // 10ms should be enough
65
64
  }
66
65
  END_OF_JAVASCRIPT
66
+
67
67
  }
68
68
  end
69
69
 
70
70
  # Processing API calls from client
71
- api :move_to_position
72
- def move_to_position(params)
73
- update_persistent_ext_config(:x => params[:x].to_i, :y => params[:y].to_i)
74
- {}
75
- end
76
-
77
- api :self_resize
78
- def self_resize(params)
79
- update_persistent_ext_config(:width => params[:w].to_i, :height => params[:h].to_i)
71
+ api :set_size_and_position
72
+ def set_size_and_position(params)
73
+ update_persistent_ext_config(
74
+ :x => params[:x].to_i,
75
+ :y => params[:y].to_i,
76
+ :width => params[:w].to_i,
77
+ :height => params[:h].to_i
78
+ )
80
79
  {}
81
80
  end
82
81
  end
@@ -11,8 +11,8 @@ module Netzke
11
11
  # Example:
12
12
  #
13
13
  # netzke :wrapper, :item => {
14
- # :widget_class_name => "FormPanel",
15
- # :data_class_name => "User"
14
+ # :class_name => "FormPanel",
15
+ # :model => "User"
16
16
  # }
17
17
  class Wrapper < Base
18
18
  def self.js_extend_properties
@@ -6,9 +6,9 @@ class AccordionPanelTest < ActiveSupport::TestCase
6
6
 
7
7
  test "specifying items" do
8
8
  accordion = Netzke::AccordionPanel.new(:items => [{
9
- :widget_class_name => "Panel"
9
+ :class_name => "Panel"
10
10
  },{
11
- :widget_class_name => "Panel", :name => "second_panel", :active => true
11
+ :class_name => "Panel", :name => "second_panel", :active => true
12
12
  }])
13
13
 
14
14
  assert_equal(2, accordion.initial_aggregatees.keys.size)
@@ -4,8 +4,8 @@ require 'netzke-core'
4
4
  require 'netzke/plugins/configuration_tool'
5
5
  require 'netzke/accordion_panel'
6
6
 
7
- require 'netzke/grid_panel_api'
8
- require 'netzke/grid_panel_js'
7
+ require 'netzke/grid_panel/grid_panel_api'
8
+ require 'netzke/grid_panel/grid_panel_js'
9
9
  require 'netzke/grid_panel'
10
10
 
11
11
  require 'netzke/active_record/basepack'
@@ -13,7 +13,7 @@ require 'netzke/active_record/basepack'
13
13
  class GridPanelTest < ActiveSupport::TestCase
14
14
 
15
15
  test "api" do
16
- grid = Netzke::GridPanel.new(:name => 'grid', :data_class_name => 'Book', :columns => [:id, :title, :recent])
16
+ grid = Netzke::GridPanel.new(:name => 'grid', :model => 'Book', :columns => [:id, :title, :recent])
17
17
 
18
18
  # post
19
19
  res = grid.post_data("created_records" => [{:title => 'Lord of the Rings'}].to_nifty_json)
@@ -36,7 +36,7 @@ class GridPanelTest < ActiveSupport::TestCase
36
36
  end
37
37
 
38
38
  test "normalize index" do
39
- grid = Netzke::GridPanel.new(:name => 'grid', :data_class_name => 'Book', :columns => [:id, :col0, {:name => :col1, :excluded => true}, :col2, {:name => :col3, :excluded => true}, :col4, :col5])
39
+ grid = Netzke::GridPanel.new(:name => 'grid', :model => 'Book', :columns => [:id, :col0, {:name => :col1, :excluded => true}, :col2, {:name => :col3, :excluded => true}, :col4, :col5])
40
40
 
41
41
  assert_equal(0, grid.normalize_index(0))
42
42
  assert_equal(1, grid.normalize_index(1))
@@ -11,7 +11,7 @@ class HelperModelTest < ActiveSupport::TestCase
11
11
  :enable_config_tool => true
12
12
  },
13
13
  })
14
- form = Netzke::FormPanel.new(:data_class_name => "Book")
14
+ form = Netzke::FormPanel.new(:model => "Book")
15
15
  Netzke::PropertyEditor::HelperModel.widget = form
16
16
  helper_model = Netzke::PropertyEditor::HelperModel.new
17
17
 
@@ -23,7 +23,7 @@ class HelperModelTest < ActiveSupport::TestCase
23
23
 
24
24
  # now try to change the configuration
25
25
  helper_model.ext_config__config_tool = "false"
26
- # form = Netzke::FormPanel.new(:data_class_name => "Book")
26
+ # form = Netzke::FormPanel.new(:model => "Book")
27
27
  # assert(false, form.ext_config[:enable_config_tool]) # FIXME: make it work
28
28
  end
29
29
 
@@ -6,9 +6,9 @@ class TabPanelTest < ActiveSupport::TestCase
6
6
 
7
7
  test "active item" do
8
8
  tab_panel = Netzke::TabPanel.new(:items => [{
9
- :widget_class_name => "Panel"
9
+ :class_name => "Panel"
10
10
  },{
11
- :widget_class_name => "Panel", :name => "second_panel", :active => true
11
+ :class_name => "Panel", :name => "second_panel", :active => true
12
12
  }])
13
13
 
14
14
  assert_equal(2, tab_panel.initial_aggregatees.keys.size)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netzke-basepack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.6
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergei Kozlov
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-21 00:00:00 -03:00
12
+ date: 2010-02-26 00:00:00 -03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.5.0
23
+ version: 0.5.1
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: searchlogic