netzke-basepack 0.5.4 → 0.5.5

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.
@@ -0,0 +1,46 @@
1
+ module Netzke::GridPanelExtras
2
+ class RecordFormWindow < Window
3
+ def actions
4
+ {:ok => {:text => "OK"}, :cancel => {:text => "Cancel"}}
5
+ end
6
+
7
+ def initial_config
8
+ super.deep_merge({
9
+ :ext_config => {
10
+ :modal => true,
11
+ :width => "60%",
12
+ :height => "90%",
13
+ :fbar => [:ok, :cancel]
14
+ }
15
+ })
16
+ end
17
+
18
+ def self.js_extend_properties
19
+ {
20
+ :button_align => "right",
21
+
22
+ :init_component => <<-END_OF_JAVASCRIPT.l,
23
+ function(){
24
+ #{js_full_class_name}.superclass.initComponent.call(this);
25
+ this.getWidget().on("submitsuccess", function(){this.closeRes = "ok"; this.close();}, this);
26
+ }
27
+ END_OF_JAVASCRIPT
28
+
29
+ :on_ok => <<-END_OF_JAVASCRIPT.l,
30
+ function(){
31
+ this.getWidget().onApply();
32
+ // this.closeRes = "ok",
33
+ // this.close();
34
+ }
35
+ END_OF_JAVASCRIPT
36
+
37
+ :on_cancel => <<-END_OF_JAVASCRIPT.l,
38
+ function(){
39
+ this.close();
40
+ }
41
+ END_OF_JAVASCRIPT
42
+
43
+ }
44
+ end
45
+ end
46
+ end
@@ -199,7 +199,7 @@ module Netzke
199
199
 
200
200
  // Now let Ext.grid.EditorGridPanel do the rest
201
201
  // Original initComponent
202
- Ext.netzke.cache.GridPanel.superclass.initComponent.call(this);
202
+ #{js_full_class_name}.superclass.initComponent.call(this);
203
203
 
204
204
  // Inform the server part about column operations
205
205
  if (this.persistentConfig) {
@@ -595,7 +595,7 @@ module Netzke
595
595
  },{
596
596
  text:'Cancel',
597
597
  handler:function(){
598
- this.ownerCt.ownerCt.close();
598
+ this.ownerCt.ownerCt.hide();
599
599
  }
600
600
  }]
601
601
  });
@@ -642,38 +642,15 @@ module Netzke
642
642
 
643
643
  :on_add_in_form => <<-END_OF_JAVASCRIPT.l,
644
644
  function(){
645
- if (!this.formWindow) {
646
- this.formWindow = new Ext.Window({
647
- title:'Add',
648
- layout: 'fit',
649
- modal: true,
650
- width: 400,
651
- height: Ext.lib.Dom.getViewHeight() *0.9,
652
- closeAction: 'hide',
653
- buttons:[{
654
- text: 'OK',
655
- handler: function(){
656
- this.ownerCt.ownerCt.getWidget().onApply();
657
- }
658
- },{
659
- text:'Cancel',
660
- handler:function(){
661
- this.ownerCt.ownerCt.close();
662
- }
663
- }]
664
- });
665
- }
666
-
667
- this.formWindow.show(null, function(){
668
- this.formWindow.closeRes = 'cancel';
669
- if (!this.formWindow.getWidget()){
670
- this.loadAggregatee({id:"newRecordForm", container:this.formWindow.id});
671
- }
672
- }, this);
673
-
645
+ this.loadAggregatee({id: "addForm", callback: function(form){
646
+ form.on('close', function(){
647
+ if (form.closeRes === "ok") {
648
+ this.store.reload();
649
+ }
650
+ }, this);
651
+ }, scope: this});
674
652
  }
675
653
  END_OF_JAVASCRIPT
676
-
677
654
  }
678
655
  ) if config[:edit_in_form_available]
679
656
 
@@ -37,7 +37,7 @@ module Netzke
37
37
  }
38
38
  END_OF_JAVASCRIPT
39
39
 
40
- :restore_defaults => <<-END_OF_JAVASCRIPT.l,
40
+ :on_restore_defaults => <<-END_OF_JAVASCRIPT.l,
41
41
  function(){
42
42
  this.restoreDefaults();
43
43
  }
@@ -78,7 +78,7 @@ module Netzke
78
78
 
79
79
  # somewhat sofisticated code to convert all NetzkePreferences for current widget into a hash ("un-flatten")
80
80
  def attributes
81
- prefs = NetzkePreference.find_all_for_widget(self.class.widget.id_name)
81
+ prefs = NetzkePreference.find_all_for_widget(self.class.widget.global_id)
82
82
  res = {}
83
83
  prefs.each do |p|
84
84
  tmp_res = {}
@@ -93,13 +93,11 @@ module Netzke
93
93
  end
94
94
 
95
95
  def method_missing(method_name, *args)
96
- # Rails.logger.debug "!!! method_name: #{method_name.inspect}"
97
96
  method_name = method_name.to_s
98
97
  method_name_without_equal_sign = method_name.sub(/=$/, '')
99
- NetzkePreference.widget_name = self.class.widget.id_name
98
+ NetzkePreference.widget_name = self.class.widget.global_id
100
99
 
101
100
  if method_name =~ /=$/
102
- # current_value = NetzkePreference[method_name_without_equal_sign] # may be nil
103
101
  current_value = self.class.widget.flat_independent_config(method_name_without_equal_sign)
104
102
 
105
103
  begin
@@ -108,11 +106,9 @@ module Netzke
108
106
  new_value = current_value
109
107
  end
110
108
 
111
- # default_value = self.class.widget.flat_default_config(method_name_without_equal_sign)
112
109
  initial_value = self.class.widget.flat_initial_config(method_name_without_equal_sign)
113
110
 
114
111
  new_value = nil if new_value == initial_value
115
- # Rails.logger.debug "!!! new_value: #{new_value.inspect}"
116
112
  NetzkePreference[method_name_without_equal_sign] = new_value
117
113
  else
118
114
  res = self.class.widget.flat_independent_config(method_name_without_equal_sign)
@@ -24,7 +24,7 @@ module Netzke
24
24
 
25
25
  :render => <<-END_OF_JAVASCRIPT.l,
26
26
  function(el){
27
- Ext.netzke.cache.#{short_widget_class_name}.superclass.render.call(this, el);
27
+ #{js_full_class_name}.superclass.render.call(this, el);
28
28
 
29
29
  // We do this all in +render+ because only at this moment the activeTab is actually activated
30
30
  var activeTab = this.getActiveTab();
@@ -38,7 +38,8 @@ module Netzke
38
38
  var preloadedItemConfig = this[fitPanel.widget.camelize(true)+"Config"];
39
39
  if (preloadedItemConfig){
40
40
  // preloaded widget only needs to be instantiated, as its class and configuration have already been loaded
41
- fitPanel.add(new Ext.netzke.cache[preloadedItemConfig.widgetClassName](preloadedItemConfig));
41
+ var klass = this.classifyScopedName(preloadedItemConfig.scopedClassName);
42
+ fitPanel.add(new klass(preloadedItemConfig));
42
43
  fitPanel.doLayout();
43
44
  } else {
44
45
  // load the widget from the server
@@ -103,7 +104,7 @@ module Netzke
103
104
  def js_config
104
105
  super.merge({
105
106
  :items => fit_panels,
106
- :active_tab => id_name + '_active' # id of the fit panel that is active
107
+ :active_tab => global_id + '_active' # id of the fit panel that is active
107
108
  })
108
109
  end
109
110
 
@@ -149,7 +150,7 @@ module Netzke
149
150
  res = []
150
151
  items.each_with_index do |item, i|
151
152
  item_config = {
152
- :id => item[:active] && id_name + '_active',
153
+ :id => item[:active] && global_id + '_active',
153
154
  :title => item[:title] || (item[:name] && item[:name].humanize),
154
155
  :widget => item[:name] # to know which fit-panel will load which widget
155
156
  }
@@ -9,7 +9,7 @@ module Netzke
9
9
  {
10
10
  :init_component => <<-END_OF_JAVASCRIPT.l,
11
11
  function(){
12
- Ext.netzke.cache.#{short_widget_class_name}.superclass.initComponent.call(this);
12
+ #{js_full_class_name}.superclass.initComponent.call(this);
13
13
 
14
14
  var setCentralWidgetEvents = function(){
15
15
  this.getCenterWidget().on('addclick', function(){
@@ -13,7 +13,7 @@ class Netzke::TreePanel < Netzke::Base
13
13
 
14
14
  def js_config
15
15
  super.deep_merge({
16
- :loader => {:data_url => id_name+"__get_children".l}
16
+ :loader => {:data_url => global_id+"__get_children".l}
17
17
  })
18
18
  end
19
19
 
@@ -0,0 +1,77 @@
1
+ module Netzke
2
+ # == Window
3
+ # Ext.Window-based widget
4
+ #
5
+ # == Features
6
+ # * Persistent position
7
+ # * Persistent dimensions
8
+ #
9
+ # == 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%"
13
+ class Window < Base
14
+ # Based on Ext.Window, naturally
15
+ def self.js_base_class
16
+ "Ext.Window"
17
+ end
18
+
19
+ # Set the passed item as the only aggregatee
20
+ def initial_aggregatees
21
+ {:item => config[:item]}
22
+ end
23
+
24
+ # Extends the JavaScript class
25
+ def self.js_extend_properties
26
+ {
27
+ :layout => "fit",
28
+ :init_component => <<-END_OF_JAVASCRIPT.l,
29
+ function(){
30
+ // Width and height may be specified as percentage of available space, e.g. "60%".
31
+ // Convert them into actual pixels.
32
+ Ext.each(["width", "length"], function(k){
33
+ if (Ext.isString(this[k])) {
34
+ this[k] = Ext.lib.Dom.getViewHeight() * parseFloat("." + this[k].substr(0, this[k].length - 1)); // "66%" => ".66"
35
+ }
36
+ });
37
+
38
+ // Superclass' initComponent
39
+ #{js_full_class_name}.superclass.initComponent.call(this);
40
+
41
+ // Set the move and resize events after window is shown, so that they don't fire at initial rendering
42
+ this.on("show", function(){
43
+ this.on("move", this.onMove, this);
44
+ this.on("resize", this.onSelfResize, this, {buffer: 50}); // Work around firing "resize" event twice (currently a bug in ExtJS)
45
+ }, this);
46
+ this.instantiateChild(this.itemConfig);
47
+ }
48
+ END_OF_JAVASCRIPT
49
+
50
+ :on_move => <<-END_OF_JAVASCRIPT.l,
51
+ function(w,x,y){
52
+ this.moveToPosition({x:x, y:y});
53
+ }
54
+ END_OF_JAVASCRIPT
55
+
56
+ :on_self_resize => <<-END_OF_JAVASCRIPT.l,
57
+ function(w, width, height){
58
+ this.selfResize({w:width, h:height});
59
+ }
60
+ END_OF_JAVASCRIPT
61
+ }
62
+ end
63
+
64
+ # Processing API calls from client
65
+ api :move_to_position
66
+ def move_to_position(params)
67
+ update_persistent_ext_config(:x => params[:x].to_i, :y => params[:y].to_i)
68
+ {}
69
+ end
70
+
71
+ api :self_resize
72
+ def self_resize(params)
73
+ update_persistent_ext_config(:width => params[:w].to_i, :height => params[:h].to_i)
74
+ {}
75
+ end
76
+ end
77
+ end
@@ -25,7 +25,7 @@ module Netzke
25
25
 
26
26
  :init_component => <<-END_OF_JAVASCRIPT.l,
27
27
  function(){
28
- Ext.netzke.cache.#{short_widget_class_name}.superclass.initComponent.call(this);
28
+ #{js_full_class_name}.superclass.initComponent.call(this);
29
29
 
30
30
  // instantiate the item
31
31
  this.instantiateChild(this.itemConfig);
@@ -14,7 +14,7 @@ class AccordionPanelTest < ActiveSupport::TestCase
14
14
  assert_equal(2, accordion.initial_aggregatees.keys.size)
15
15
  assert_equal("item0", accordion.aggregatees[:item0][:name])
16
16
  assert_equal("second_panel", accordion.aggregatees[:second_panel][:name])
17
- assert_equal("Panel", accordion.js_config[:second_panel_config][:widget_class_name])
17
+ assert_equal("Panel", accordion.js_config[:second_panel_config][:scoped_class_name])
18
18
  end
19
19
 
20
20
  end
@@ -15,7 +15,7 @@ require 'netzke/active_record/basepack'
15
15
  class GridPanelTest < ActiveSupport::TestCase
16
16
 
17
17
  test "api" do
18
- grid = Netzke::GridPanel.new(:name => 'grid', :data_class_name => 'Book', :layout_manager => false, :columns => [:id, :title, :recent])
18
+ grid = Netzke::GridPanel.new(:name => 'grid', :data_class_name => 'Book', :columns => [:id, :title, :recent])
19
19
 
20
20
  # post
21
21
  res = grid.post_data("created_records" => [{:title => 'Lord of the Rings'}].to_nifty_json)
@@ -36,7 +36,16 @@ class GridPanelTest < ActiveSupport::TestCase
36
36
  assert_equal(nil, Book.first)
37
37
 
38
38
  end
39
-
39
+
40
+ test "normalize index" do
41
+ grid = Netzke::GridPanel.new(:name => 'grid', :data_class_name => 'Book', :columns => [:id, :col0, {:name => :col1, :excluded => true}, :col2, {:name => :col3, :excluded => true}, :col4, :col5])
42
+
43
+ assert_equal(0, grid.normalize_index(0))
44
+ assert_equal(1, grid.normalize_index(1))
45
+ assert_equal(3, grid.normalize_index(2))
46
+ assert_equal(5, grid.normalize_index(3))
47
+ assert_equal(6, grid.normalize_index(4))
48
+ end
40
49
 
41
50
  # TODO: add tests with association column
42
51
 
@@ -15,7 +15,7 @@ class TabPanelTest < ActiveSupport::TestCase
15
15
  assert_equal("item0", tab_panel.aggregatees[:item0][:name])
16
16
  assert_equal("second_panel", tab_panel.aggregatees[:second_panel][:name])
17
17
  assert(tab_panel.aggregatees[:second_panel][:active])
18
- assert_equal("Panel", tab_panel.js_config[:second_panel_config][:widget_class_name])
18
+ assert_equal("Panel", tab_panel.js_config[:second_panel_config][:scoped_class_name])
19
19
  end
20
20
 
21
21
  end
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.4
4
+ version: 0.5.5
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: 2009-10-12 00:00:00 -05:00
12
+ date: 2009-11-09 00:00:00 -06: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.4.4
23
+ version: 0.4.5.2
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: searchlogic
@@ -42,7 +42,7 @@ dependencies:
42
42
  - !ruby/object:Gem::Version
43
43
  version: 2.0.0
44
44
  version:
45
- description: Pre-built Netzke widgets for your RIA
45
+ 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
46
46
  email: sergei@playcode.nl
47
47
  executables: []
48
48
 
@@ -59,7 +59,6 @@ files:
59
59
  - README.rdoc
60
60
  - Rakefile
61
61
  - TODO.rdoc
62
- - VERSION
63
62
  - autotest/discover.rb
64
63
  - init.rb
65
64
  - install.rb
@@ -79,12 +78,14 @@ files:
79
78
  - lib/netzke/fields_configurator.rb
80
79
  - lib/netzke/form_panel.rb
81
80
  - lib/netzke/form_panel_api.rb
81
+ - lib/netzke/form_panel_extras/javascripts/netzkefileupload.js
82
82
  - lib/netzke/form_panel_extras/javascripts/xcheckbox.js
83
83
  - lib/netzke/form_panel_js.rb
84
84
  - lib/netzke/grid_panel.rb
85
85
  - lib/netzke/grid_panel_api.rb
86
86
  - lib/netzke/grid_panel_extras/javascripts/filters.js
87
87
  - lib/netzke/grid_panel_extras/javascripts/rows-dd.js
88
+ - lib/netzke/grid_panel_extras/record_form_window.rb
88
89
  - lib/netzke/grid_panel_js.rb
89
90
  - lib/netzke/masquerade_selector.rb
90
91
  - lib/netzke/panel.rb
@@ -95,6 +96,7 @@ files:
95
96
  - lib/netzke/tab_panel.rb
96
97
  - lib/netzke/table_editor.rb
97
98
  - lib/netzke/tree_panel.rb
99
+ - lib/netzke/window.rb
98
100
  - lib/netzke/wrapper.rb
99
101
  - stylesheets/basepack.css
100
102
  - tasks/netzke_basepack_tasks.rake
@@ -169,7 +171,7 @@ rubyforge_project: netzke-basepack
169
171
  rubygems_version: 1.3.5
170
172
  signing_key:
171
173
  specification_version: 3
172
- summary: Pre-built Netzke widgets for your RIA
174
+ summary: Pre-built Rails + ExtJS widgets for your RIA
173
175
  test_files:
174
176
  - test/app_root/app/controllers/application.rb
175
177
  - test/app_root/app/models/book.rb
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.5.4