netzke-basepack 0.5.9 → 0.5.10

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.
data/CHANGELOG.rdoc CHANGED
@@ -1,4 +1,10 @@
1
- = v0.6.0 - EDGE
1
+ = v0.5.10 - 2010-06-14
2
+ * Impr: Checkbox replaced with tri-state checkbox in multi-edit form in GridPanel.
3
+ * Impr: Column renderers reworked, allowing for more flexibility and cleanness.
4
+ * Fix: After applying changes to a grid disable "Edit in form" action.
5
+ * Impr: A grid's forms are now getting the same fields as specified for the grid.
6
+
7
+ = v0.5.9 - 2010-06-11
2
8
  * !!!: after updating to this version, run script/generate netzke_basepack
3
9
  * New: tri-state checkbox introduced into the search form
4
10
  * Impr: better defaults for the search form
@@ -9,12 +15,12 @@
9
15
  * Fix: FieldsConfigurator should now work on Heroku
10
16
  * Fix: GridPanel date filter now should work
11
17
  * New: GridPanel now has a method on_data_changed that can be overridden by children to detect actions that modify data
12
- * New: New way of Netzke virtual attributes in AR models.
13
- * New: Grid/FormPanel refactoring.
18
+ * New: New way of configuring Netzke (virtual) attributes for AR models.
19
+ * Impr: Grid/FormPanel refactoring.
14
20
  * Impr: Multi-level column/fields configuration reworked and made more consistent.
15
21
  * New: New configuration layer introduced between the AR models and the rest of Netzke widgets. Use AttributesConfigurator to access it.
16
22
  * New: FamFamFam Silk icons support.
17
- * Impr: Reworked Netzke (virtual) attributes for Grid/FormPanel
23
+ * Impr: Reworked defining Netzke (virtual) attributes for Grid/FormPanel.
18
24
 
19
25
  = v0.5.8 - 2010-03-12
20
26
  * Fix: GertThiel's method_missing-related fix enabling better compatibility with other Ruby libs
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.9"
4
+ gemspec.version = "0.5.10"
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,23 +9,24 @@ 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.2")
12
+ gemspec.add_dependency("netzke-core", ">=0.5.3")
13
13
  gemspec.add_dependency("searchlogic", ">=2.0.0")
14
14
  gemspec.add_dependency("will_paginate", ">=2.0.0")
15
15
  gemspec.add_dependency("acts_as_list", ">=0.1.2")
16
16
  gemspec.post_install_message = <<-MESSAGE
17
17
 
18
- ========================================================================
18
+ ========================================================================
19
19
 
20
- Thanks for installing Netzke Basepack!
21
-
22
- Run "./script/generate netzke_basepack" to finish the installation.
20
+ Thanks for installing Netzke Basepack!
21
+
22
+ Don't forget to run "./script/generate netzke_basepack" for each
23
+ Rails app that will be using this gem.
23
24
 
24
- Netzke home page: http://netzke.org
25
- Netzke Google Groups: http://groups.google.com/group/netzke
26
- Netzke tutorials: http://blog.writelesscode.com
25
+ Netzke home page: http://netzke.org
26
+ Netzke Google Groups: http://groups.google.com/group/netzke
27
+ Netzke tutorials: http://blog.writelesscode.com
27
28
 
28
- ========================================================================
29
+ ========================================================================
29
30
 
30
31
  MESSAGE
31
32
 
@@ -38,42 +38,6 @@ Ext.netzke.ComboBox = Ext.extend(Ext.form.ComboBox, {
38
38
 
39
39
  Ext.reg('combobox', Ext.netzke.ComboBox);
40
40
 
41
- /*
42
- Accepts a string which either contains:
43
- Ext.util.Format method (e.g. 'usMoney'),
44
- or
45
- JSON-encoded array, where the first element is Ext.util.Format method (e.g. 'ellipsis'),
46
- and the rest of the elements - configuration parameters that should be passed to this method besids
47
- the value to be rendered (e.g. '2');
48
-
49
- Example of the latter: ["defaultValue", "MyDefaultValue"]
50
- */
51
- Ext.netzke.normalizedRenderer = function(config) {
52
- res = null;
53
-
54
- if (config) {
55
- try{
56
- config = Ext.decode(config); // it's an array consisting of renderer's name *and* eventual options
57
- } catch(e) {
58
- // leave config as is - it's supposed to be the renderer's name
59
- }
60
-
61
- if (Ext.isArray(config)) {
62
- res = function(v){
63
- var formatMethod = config[0];
64
- var valueAndOptions = config.slice(1);
65
- valueAndOptions.unshift(v);
66
- // call the Format function with the argument *and* configuration
67
- return Ext.util.Format[formatMethod] ? Ext.util.Format[formatMethod].apply(this, valueAndOptions) : "Unknown renderer";
68
- }
69
- } else {
70
- res = Ext.util.Format[config] ? Ext.util.Format[config] : function(v){return "Unknown renderer"}
71
- }
72
- }
73
-
74
- return res;
75
- };
76
-
77
41
  Ext.util.Format.mask = function(v){
78
42
  return "********";
79
43
  };
@@ -304,6 +304,7 @@ module Netzke
304
304
  :item => {
305
305
  :class_name => "FormPanel",
306
306
  :model => config[:model],
307
+ :fields => default_fields_for_forms,
307
308
  :persistent_config => config[:persistent_config],
308
309
  :strong_default_attrs => config[:strong_default_attrs],
309
310
  :ext_config => {
@@ -325,6 +326,7 @@ module Netzke
325
326
  :item => {
326
327
  :class_name => "FormPanel",
327
328
  :model => config[:model],
329
+ :fields => default_fields_for_forms,
328
330
  :persistent_config => config[:persistent_config],
329
331
  :ext_config => {
330
332
  :bbar => false,
@@ -334,17 +336,6 @@ module Netzke
334
336
  },
335
337
  },
336
338
 
337
- # :edit_form => {
338
- # :class_name => "FormPanel",
339
- # :model => data_class.name,
340
- # :persistent_config => config[:persistent_config],
341
- # :ext_config => {
342
- # :bbar => false,
343
- # :header => false,
344
- # :mode => ext_config[:mode]
345
- # }
346
- # },
347
-
348
339
  :multi_edit_form => {
349
340
  :class_name => "GridPanel::RecordFormWindow",
350
341
  :ext_config => {
@@ -352,8 +343,9 @@ module Netzke
352
343
  :button_align => "right"
353
344
  },
354
345
  :item => {
355
- :class_name => "FormPanel",
346
+ :class_name => "GridPanel::MultiEditForm",
356
347
  :model => config[:model],
348
+ :fields => default_fields_for_forms,
357
349
  :persistent_config => config[:persistent_config],
358
350
  :ext_config => {
359
351
  :bbar => false,
@@ -368,6 +360,7 @@ module Netzke
368
360
  res.merge!({
369
361
  :search_panel => {
370
362
  :class_name => "SearchPanel",
363
+ :fields => default_fields_for_forms,
371
364
  :search_class_name => config[:model],
372
365
  :persistent_config => config[:persistent_config],
373
366
  :ext_config => {
@@ -216,6 +216,10 @@ module Netzke
216
216
  c[:editor] = assoc_method_type == :boolean ? editor_for_attr_type(:boolean) : editor_for_association
217
217
  end
218
218
  end
219
+
220
+ def default_fields_for_forms
221
+ columns.map{ |c| {:name => c[:name]} }
222
+ end
219
223
 
220
224
  def self.included(receiver)
221
225
  receiver.extend ClassMethods
@@ -28,10 +28,15 @@ module Netzke
28
28
  edit_in_form_events = <<-END_OF_JAVASCRIPT if config[:edit_in_form_available]
29
29
  if (this.enableEditInForm) {
30
30
  this.getSelectionModel().on('selectionchange', function(selModel){
31
- // Disable "edit in form" button if new record is present in selection
32
- var disabled = !selModel.each(function(r){
33
- if (r.isNew) { return false; }
34
- });
31
+ var disabled;
32
+ if (!selModel.hasSelection()) {
33
+ disabled = true;
34
+ } else {
35
+ // Disable "edit in form" button if new record is present in selection
36
+ disabled = !selModel.each(function(r){
37
+ if (r.isNew) { return false; }
38
+ });
39
+ };
35
40
  this.actions.editInForm.setDisabled(disabled);
36
41
  }, this);
37
42
  }
@@ -111,23 +116,26 @@ module Netzke
111
116
  c.editor = null;
112
117
  }
113
118
 
119
+ // Normalize the renderer
120
+ this.normalizeRenderer(c);
121
+
114
122
  // set the renderer
115
- if (c.renderer && !Ext.isArray(c.renderer) && c.renderer.match(/^\\s*function\\s*\\(/)) {
116
- // if the renderer is an inline function - eval it (double escaping because we are inside of the Ruby string here...)
117
- eval("c.renderer = " + c.renderer + ";");
118
- } else if (Ext.isFunction(this[c.renderer])) {
119
- // whether the renderer is defined in this.scope
120
- c.renderer = this[c.renderer].createDelegate(this);
121
- } else {
122
- // othrewise it's a string representing the name of the renderer or an json-encoded array,
123
- // where the first parameter is the renderer's name, and the rest - parameters that should be
124
- // passed to the renderer at the moment of calling
125
- var renderer = Ext.netzke.normalizedRenderer(c.renderer);
126
- if (renderer != null) {
127
- c.renderer = renderer
128
- };
129
- }
130
-
123
+ // if (c.renderer && !Ext.isArray(c.renderer) && c.renderer.match(/^\\s*function\\s*\\(/)) {
124
+ // // if the renderer is an inline function - eval it (double escaping because we are inside of the Ruby string here...)
125
+ // eval("c.renderer = " + c.renderer + ";");
126
+ // } else if (Ext.isFunction(this[c.renderer])) {
127
+ // // whether the renderer is defined in this.scope
128
+ // c.renderer = this[c.renderer].createDelegate(this);
129
+ // } else {
130
+ // // othrewise it's a string representing the name of the renderer or a json-encoded array,
131
+ // // where the first parameter is the renderer's name, and the rest - parameters that should be
132
+ // // passed to the renderer at the moment of calling
133
+ // var renderer = Ext.netzke.normalizedRenderer(c.renderer);
134
+ // if (renderer != null) {
135
+ // c.renderer = renderer
136
+ // };
137
+ // }
138
+ //
131
139
  // add to the list
132
140
  cmConfig.push(c);
133
141
  }
@@ -584,6 +592,7 @@ module Netzke
584
592
  }
585
593
 
586
594
  this.getView().refresh();
595
+ this.getSelectionModel().fireEvent('selectionchange', this.getSelectionModel());
587
596
  }
588
597
  END_OF_JAVASCRIPT
589
598
 
@@ -600,6 +609,48 @@ module Netzke
600
609
  this.getSelectionModel().resumeEvents();
601
610
  }
602
611
  END_OF_JAVASCRIPT
612
+
613
+ # Normalizes the renderer for a column.
614
+ # Renderer may be:
615
+ # 1) a string that contains the name of the function to be used as renderer.
616
+ # 2) an array, where the first element is the function name, and the rest - the arguments
617
+ # that will be passed to that function along with the value to be rendered.
618
+ # The function is searched in the following objects: 1) Ext.util.Format, 2) this.
619
+ # If not found, it is simply evaluated. Handy, when as renderer we receive an inline JS function,
620
+ # or reference to a function in some other scope.
621
+ # So, these will work:
622
+ # * "uppercase"
623
+ # * ["ellipsis", 10]
624
+ # * ["substr", 3, 5]
625
+ # * "myRenderer" (if this.myRenderer is a function)
626
+ # * ["Some.scope.Format.customRenderer", 10, 20, 30] (if Some.scope.Format.customRenderer is a function)
627
+ # * "function(v){ return 'Value: ' + v; }"
628
+ :normalize_renderer => <<-END_OF_JAVASCRIPT.l,
629
+ function(c) {
630
+ if (!c.renderer) return;
631
+
632
+ var name, args = [];
633
+
634
+ if ('string' === typeof c.renderer) {
635
+ name = c.renderer;
636
+ } else {
637
+ name = c.renderer[0];
638
+ args = c.renderer.slice(1);
639
+ }
640
+
641
+ // First check whether Ext.util.Format has it
642
+ if (Ext.isFunction(Ext.util.Format[name])) {
643
+ c.renderer = Ext.util.Format[name].createDelegate(this, args, 1);
644
+ } else if (Ext.isFunction(this[name])) {
645
+ // ... then if our own class has it
646
+ c.renderer = this[name].createDelegate(this, args, 1);
647
+ } else {
648
+ // ... and, as last resort, evaluate it (allows passing inline javascript function as renderer)
649
+ eval("c.renderer = " + c.renderer + ";");
650
+ }
651
+ }
652
+ END_OF_JAVASCRIPT
653
+
603
654
 
604
655
  # :reorder_columns => <<-END_OF_JAVASCRIPT.l,
605
656
  # function(columns){
@@ -0,0 +1,14 @@
1
+ module Netzke
2
+ class GridPanel < Base
3
+ class MultiEditForm < FormPanel
4
+
5
+ # Replace checkbox for boolean fields with tristate checkbox
6
+ def attr_type_to_xtype_map
7
+ super.merge({
8
+ :boolean => :tricheckbox
9
+ })
10
+ end
11
+
12
+ end
13
+ end
14
+ end
@@ -149,11 +149,11 @@ module Netzke
149
149
 
150
150
  res.reject!{ |f| f[:virtual] }
151
151
 
152
- res.each do |f|
152
+ res.each do |f|
153
153
  f.merge!(:condition => "like", :default_value => nil)
154
154
  f.merge!(:xtype => xtype_for_attr_type(:string), :attr_type => "string") if f[:name].to_s.index("__")
155
- f.merge!(:condition => "greater_than") if [:datetime, :integer, :date].include?(f[:attr_type].to_sym)
156
- f.merge!(:condition => "equals") if f["attr_type"] == "boolean"
155
+ f.merge!(:condition => "greater_than") if [:datetime, :integer, :date].include?(f[:attr_type])
156
+ f.merge!(:condition => "equals") if f[:attr_type] == :boolean
157
157
  end
158
158
 
159
159
  res
File without changes
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: netzke-basepack
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 31
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 5
8
- - 9
9
- version: 0.5.9
9
+ - 10
10
+ version: 0.5.10
10
11
  platform: ruby
11
12
  authors:
12
13
  - Sergei Kozlov
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-06-11 00:00:00 +02:00
18
+ date: 2010-06-14 00:00:00 +02:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
@@ -25,11 +26,12 @@ dependencies:
25
26
  requirements:
26
27
  - - ">="
27
28
  - !ruby/object:Gem::Version
29
+ hash: 13
28
30
  segments:
29
31
  - 0
30
32
  - 5
31
- - 2
32
- version: 0.5.2
33
+ - 3
34
+ version: 0.5.3
33
35
  type: :runtime
34
36
  version_requirements: *id001
35
37
  - !ruby/object:Gem::Dependency
@@ -40,6 +42,7 @@ dependencies:
40
42
  requirements:
41
43
  - - ">="
42
44
  - !ruby/object:Gem::Version
45
+ hash: 15
43
46
  segments:
44
47
  - 2
45
48
  - 0
@@ -55,6 +58,7 @@ dependencies:
55
58
  requirements:
56
59
  - - ">="
57
60
  - !ruby/object:Gem::Version
61
+ hash: 15
58
62
  segments:
59
63
  - 2
60
64
  - 0
@@ -70,6 +74,7 @@ dependencies:
70
74
  requirements:
71
75
  - - ">="
72
76
  - !ruby/object:Gem::Version
77
+ hash: 31
73
78
  segments:
74
79
  - 0
75
80
  - 1
@@ -130,6 +135,7 @@ files:
130
135
  - lib/netzke/grid_panel/grid_panel_columns.rb
131
136
  - lib/netzke/grid_panel/grid_panel_js.rb
132
137
  - lib/netzke/grid_panel/javascripts/rows-dd.js
138
+ - lib/netzke/grid_panel/multi_edit_form.rb
133
139
  - lib/netzke/grid_panel/record_form_window.rb
134
140
  - lib/netzke/json_array_editor.rb
135
141
  - lib/netzke/masquerade_selector.rb
@@ -143,8 +149,8 @@ files:
143
149
  - lib/netzke/tree_panel.rb
144
150
  - lib/netzke/window.rb
145
151
  - lib/netzke/wrapper.rb
152
+ - lib/tasks/netzke_basepack_tasks.rake
146
153
  - stylesheets/basepack.css
147
- - tasks/netzke_basepack_tasks.rake
148
154
  - test/app_root/app/controllers/application.rb
149
155
  - test/app_root/app/models/book.rb
150
156
  - test/app_root/app/models/category.rb
@@ -199,7 +205,21 @@ has_rdoc: true
199
205
  homepage: http://github.com/skozlov/netzke-basepack
200
206
  licenses: []
201
207
 
202
- post_install_message: "\n ========================================================================\n\n Thanks for installing Netzke Basepack!\n \n Run \"./script/generate netzke_basepack\" to finish the installation.\n\n Netzke home page: http://netzke.org\n Netzke Google Groups: http://groups.google.com/group/netzke\n Netzke tutorials: http://blog.writelesscode.com\n\n ========================================================================\n\n"
208
+ post_install_message: |+
209
+
210
+ ========================================================================
211
+
212
+ Thanks for installing Netzke Basepack!
213
+
214
+ Don't forget to run "./script/generate netzke_basepack" for each
215
+ Rails app that will be using this gem.
216
+
217
+ Netzke home page: http://netzke.org
218
+ Netzke Google Groups: http://groups.google.com/group/netzke
219
+ Netzke tutorials: http://blog.writelesscode.com
220
+
221
+ ========================================================================
222
+
203
223
  rdoc_options:
204
224
  - --charset=UTF-8
205
225
  require_paths:
@@ -209,6 +229,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
209
229
  requirements:
210
230
  - - ">="
211
231
  - !ruby/object:Gem::Version
232
+ hash: 3
212
233
  segments:
213
234
  - 0
214
235
  version: "0"
@@ -217,6 +238,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
217
238
  requirements:
218
239
  - - ">="
219
240
  - !ruby/object:Gem::Version
241
+ hash: 3
220
242
  segments:
221
243
  - 0
222
244
  version: "0"