netzke-basepack 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -0
  3. data/Gemfile +2 -2
  4. data/README.md +6 -0
  5. data/lib/netzke-basepack.rb +1 -0
  6. data/lib/netzke/basepack/columns.rb +13 -0
  7. data/lib/netzke/basepack/data_adapters/active_record_adapter.rb +64 -37
  8. data/lib/netzke/basepack/form.rb +5 -1
  9. data/lib/netzke/basepack/form/javascripts/form.js +9 -9
  10. data/lib/netzke/basepack/grid.rb +51 -2
  11. data/lib/netzke/basepack/grid/javascripts/event_handling.js +1 -13
  12. data/lib/netzke/basepack/grid/javascripts/grid.js +29 -16
  13. data/lib/netzke/basepack/grid/javascripts/remember_selection.js +25 -0
  14. data/lib/netzke/basepack/query_builder.rb +2 -1
  15. data/lib/netzke/basepack/search_panel.rb +17 -32
  16. data/lib/netzke/basepack/search_panel/javascripts/condition_field.js +11 -4
  17. data/lib/netzke/basepack/version.rb +1 -1
  18. data/locales/es.yml +99 -0
  19. data/locales/nl.yml +99 -0
  20. data/test/basepack_test_app/app/components/book_grid_date_default_filtering.rb +12 -0
  21. data/test/basepack_test_app/app/components/book_grid_default_filtering.rb +12 -0
  22. data/test/basepack_test_app/app/components/book_grid_with_custom_columns.rb +2 -1
  23. data/test/basepack_test_app/app/components/book_query_builder.rb +1 -1
  24. data/test/basepack_test_app/app/components/book_search_panel.rb +4 -2
  25. data/test/basepack_test_app/app/components/panel_with_grid_with_default_filtering.rb +30 -0
  26. data/test/basepack_test_app/app/controllers/components_controller.rb +8 -0
  27. data/test/basepack_test_app/app/models/author.rb +2 -2
  28. data/test/basepack_test_app/app/models/book.rb +1 -1
  29. data/test/basepack_test_app/app/models/user.rb +1 -1
  30. data/test/basepack_test_app/config/routes.rb +2 -1
  31. data/test/basepack_test_app/db/development.sqlite3 +0 -0
  32. data/test/basepack_test_app/db/seeds.rb +7 -7
  33. data/test/basepack_test_app/db/test.sqlite3 +0 -0
  34. data/test/basepack_test_app/features/form_panel.feature +2 -16
  35. data/test/basepack_test_app/features/grid.feature +20 -18
  36. data/test/basepack_test_app/features/grid_default_filters.feature +42 -0
  37. data/test/basepack_test_app/features/grid_sorting.feature +4 -9
  38. data/test/basepack_test_app/features/paging_form_panel.feature +12 -29
  39. data/test/basepack_test_app/features/search_in_grid.feature +95 -42
  40. data/test/basepack_test_app/features/step_definitions/grid_panel_steps.rb +6 -0
  41. data/test/basepack_test_app/features/window.feature +1 -0
  42. data/test/basepack_test_app/log/development.log +20592 -0
  43. data/test/basepack_test_app/log/test.log +110433 -0
  44. data/test/basepack_test_app/spec/active_record_adapter_spec.rb +8 -0
  45. data/test/basepack_test_app/spec/fixtures/users.yml +3 -0
  46. data/test/basepack_test_app/tmp/cache/assets/C92/5A0/sprockets%2F39e75754782ee12179bf35c9a0971d80 +0 -0
  47. data/test/basepack_test_app/tmp/cache/assets/C9F/750/sprockets%2F20ce3d64040a5d3a0a8883bd60754356 +0 -0
  48. data/test/basepack_test_app/tmp/cache/assets/CC4/C00/sprockets%2Fc615df52887d8c2e67e8413576a419c5 +0 -0
  49. data/test/basepack_test_app/tmp/cache/assets/D0E/870/sprockets%2Fa593bf4fac106add88c9434141a49663 +0 -0
  50. data/test/basepack_test_app/tmp/cache/assets/D14/8E0/sprockets%2F20748e8d1d7d090d122904a9fe6f18fc +0 -0
  51. data/test/basepack_test_app/tmp/cache/assets/D3E/DA0/sprockets%2Fa175f1ac5996544b908ba3ba3f64c4f3 +0 -0
  52. data/test/basepack_test_app/tmp/cache/assets/D43/C00/sprockets%2F7bc60c758776356d615ab5edff201ee2 +0 -0
  53. data/test/basepack_test_app/tmp/cache/assets/D98/9C0/sprockets%2F18b80e8fe200aebc522e561a867ea6fb +0 -0
  54. data/test/basepack_test_app/tmp/cache/assets/DB0/6E0/sprockets%2F03e33f5a4779eeb48bcfc86ee717fb55 +0 -0
  55. data/test/basepack_test_app/tmp/pids/server.pid +1 -0
  56. metadata +17 -4
  57. data/test/basepack_test_app/features/tab_panel.feature +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c9340dda35d30acdef96c1d3d6ed14780fbcea6
4
- data.tar.gz: f4838e6df0aa0d3b05cb58703395e19920fa486f
3
+ metadata.gz: 1cf0253e7faf8d9b55ec4d2fa9ce2cadbbd67001
4
+ data.tar.gz: 160491e2c4291ac17a98587f1bafc23c41b5d372
5
5
  SHA512:
6
- metadata.gz: a4258b10db1a2e559fb465d4c7ebb2c1fd6892c06b0b3719272c520dfc840bff407bb8d8233e522c30cce49c13f5220700a4e3ccdb5ded4a96e24de396c63155
7
- data.tar.gz: 2f0ddb6f61f86ad79ca962fe395ced4ad2982674232f5945659b3dbb1111d970463661eb07f341d8361c6430a183cc034747e6aca453e3aa397761270f1731ee
6
+ metadata.gz: 0bd90a75392a7a98308282006b47d2d2eb33d4d3769eab68f6873d7ffa707dea63c3201b9bd970ed7f47e0c3bdf1ec36bb834c09f836036d70a64d10159f1e4d
7
+ data.tar.gz: b2fd784bff28d8f61b42e5f340d6e0ff5144bb4d3347c4621b529c30abbeae13b41e01cd882e452548873f65fddc927215a54e7c00e87bca9a3eb71f2dbc5170
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 0.8.3 - 2013-04-24
2
+ * improvements
3
+ * implement advanced searching by association (issue #93)
4
+ * a few improvements on grid column filtering (by Simon Willmann)
5
+ * bug fix
6
+ * was crashing when an attribute with name like `author__id` was attempted to be read on a nil association
7
+ * boolean search from the search panel works now
8
+
1
9
  # 0.8.2 - 2013-03-16
2
10
  * improvements
3
11
  * Add grid column config option `filter_with` (by firemind)
data/Gemfile CHANGED
@@ -13,11 +13,11 @@ group :test do
13
13
  gem 'factory_girl'
14
14
  gem 'pickle'
15
15
  gem 'capybara', '~> 1.0'
16
- gem 'cucumber-rails'
16
+ gem 'cucumber-rails', require: false
17
17
  gem 'database_cleaner'
18
18
  gem 'rspec-rails'
19
19
  end
20
20
 
21
21
  group :test, :development do
22
- gem 'pry'
22
+ gem 'pry-rails'
23
23
  end
data/README.md CHANGED
@@ -76,6 +76,12 @@ There's some work being done in the direction of implementing [DataMapper](https
76
76
 
77
77
  Netzke Basepack can make use of FamFamFam Silk icon set (http://www.famfamfam.com/archive/silk-icons-thats-your-lot/). To enable this, download the icons and put the "icons" folder into your app's public/images folder. Then restart your application.
78
78
 
79
+ ## Contributions and support
80
+
81
+ Help developing Netzke by submitting a pull request when you think others can benefit from it.
82
+
83
+ If you feel particularily generous, you can donate a couple of bucks a week at [GitTip](https://www.gittip.com/nomadcoder/).
84
+
79
85
  ## Useful links
80
86
  * [Project website](http://netzke.org)
81
87
  * [Live-demo](http://netzke-demo.herokuapp.com)
@@ -14,6 +14,7 @@ module Netzke
14
14
  I18n.load_path << File.dirname(__FILE__) + '/../locales/en.yml'
15
15
  I18n.load_path << File.dirname(__FILE__) + '/../locales/de.yml'
16
16
  I18n.load_path << File.dirname(__FILE__) + '/../locales/ru.yml'
17
+ I18n.load_path << File.dirname(__FILE__) + '/../locales/es.yml'
17
18
 
18
19
  config.after_initialize do
19
20
  Netzke::Core.external_ext_css << "#{Netzke::Core.ext_uri}/examples/ux/grid/css/RangeMenu"
@@ -126,6 +126,19 @@ module Netzke
126
126
  end
127
127
  end
128
128
 
129
+ # ATM the same attributes are used as in forms
130
+ def attributes_for_search
131
+ columns_taken_over_to_forms.map do |c|
132
+ {name: c.name, text: c.text, attr_type: c.attr_type}.tap do |a|
133
+ if c[:assoc]
134
+ a[:text].sub!(" ", " ")
135
+ a[:assoc] = true
136
+ a[:attr_type] = :string
137
+ end
138
+ end
139
+ end
140
+ end
141
+
129
142
  private
130
143
 
131
144
  # Based on initial column config, e.g.:
@@ -55,24 +55,12 @@ module Netzke::Basepack::DataAdapters
55
55
 
56
56
  # apply sorting if needed
57
57
  if params[:sort] && sort_params = params[:sort].first
58
- assoc, method = sort_params["property"].split('__')
59
58
  dir = sort_params["direction"].downcase
60
-
61
- # if a sorting scope is set, call the scope with the given direction
62
59
  column = columns.detect { |c| c[:name] == sort_params["property"] }
63
- if column.has_key?(:sorting_scope)
64
- relation = relation.send(column[:sorting_scope].to_sym, dir.to_sym)
65
- else
66
- relation = if method.nil?
67
- relation.order("#{@model_class.table_name}.#{assoc} #{dir}")
68
- else
69
- assoc = @model_class.reflect_on_association(assoc.to_sym)
70
- relation.joins(assoc.name).order("#{assoc.klass.table_name}.#{method} #{dir}")
71
- end
72
- end
60
+ relation = apply_sorting(relation, column, dir)
73
61
  end
74
62
 
75
- page = params[:limit] ? params[:start].to_i/params[:limit].to_i + 1 : 1
63
+ #page = params[:limit] ? params[:start].to_i/params[:limit].to_i + 1 : 1
76
64
  if params[:limit]
77
65
  relation.offset(params[:start]).limit(params[:limit])
78
66
  else
@@ -80,16 +68,35 @@ module Netzke::Basepack::DataAdapters
80
68
  end
81
69
  end
82
70
 
71
+ def apply_sorting(relation, column, dir)
72
+ assoc, method = column[:name].split('__')
73
+
74
+ # if a sorting scope is set, call the scope with the given direction
75
+ if column.has_key?(:sorting_scope)
76
+ relation = relation.send(column[:sorting_scope].to_sym, dir.to_sym)
77
+ else
78
+ relation = if method.nil?
79
+ relation.order("#{@model_class.table_name}.#{assoc} #{dir}")
80
+ else
81
+ assoc = @model_class.reflect_on_association(assoc.to_sym)
82
+ relation.joins(assoc.name).order("#{assoc.klass.table_name}.#{method} #{dir}")
83
+ end
84
+ end
85
+
86
+ relation
87
+ end
88
+ protected :apply_sorting
89
+
90
+ # If get_relation was called before (e.g. through get_records), then this method won't call it again, but use its latest result.
91
+ # FIXME: it's pretty awkward and should be refactored
83
92
  def count_records(params, columns=[])
84
93
  # build initial relation based on passed params
85
- relation = get_relation(params)
86
-
94
+ relation = @relation || get_relation(params)
87
95
  # addressing the n+1 query problem
88
96
  columns.each do |c|
89
97
  assoc, method = c[:name].split('__')
90
98
  relation = relation.includes(assoc.to_sym) if method
91
99
  end
92
-
93
100
  relation.count
94
101
  end
95
102
 
@@ -122,11 +129,14 @@ module Netzke::Basepack::DataAdapters
122
129
 
123
130
  if assoc.klass.column_names.include?(assoc_method)
124
131
  # apply query
125
- relation = relation.where(["#{assoc_method} like ?", "%#{query}%"]) if query.present?
132
+ assoc_arel_table = assoc.klass.arel_table
133
+
134
+ relation = relation.where(assoc_arel_table[assoc_method].matches("%#{query}%")) if query.present?
126
135
  relation.all.map{ |r| [r.id, r.send(assoc_method)] }
127
136
  else
137
+ query.downcase!
128
138
  # an expensive search!
129
- relation.all.map{ |r| [r.id, r.send(assoc_method)] }.select{ |id,value| value.include?(query) }
139
+ relation.all.map{ |r| [r.id, r.send(assoc_method)] }.select{ |id,value| value.downcase.include?(query) }
130
140
  end
131
141
 
132
142
  else
@@ -216,7 +226,8 @@ module Netzke::Basepack::DataAdapters
216
226
  split = a[:name].to_s.split(/\.|__/)
217
227
  assoc = @model_class.reflect_on_association(split.first.to_sym)
218
228
  if through_association
219
- split.inject(r) do |r,m| # TODO: do we really need to descend deeper than 1 level?
229
+ split.inject(r) do |r,m| # Do we *really* need to descend deeper than 1 level?
230
+ return nil if r.nil?
220
231
  if r.respond_to?(m)
221
232
  r.send(m)
222
233
  else
@@ -291,8 +302,6 @@ module Netzke::Basepack::DataAdapters
291
302
 
292
303
  # An ActiveRecord::Relation instance encapsulating all the necessary conditions.
293
304
  def get_relation(params = {})
294
- @arel = @model_class.arel_table
295
-
296
305
  relation = @model_class.scoped
297
306
 
298
307
  relation = apply_column_filters(relation, params[:filter]) if params[:filter]
@@ -313,7 +322,7 @@ module Netzke::Basepack::DataAdapters
313
322
 
314
323
  relation = relation.extend_with(params[:scope]) if params[:scope]
315
324
 
316
- relation
325
+ @relation = relation
317
326
  end
318
327
  protected :get_relation
319
328
 
@@ -342,7 +351,6 @@ module Netzke::Basepack::DataAdapters
342
351
  # relation.where(["id > ?", 10]).where(["food_name like ?", "%pizza%"])
343
352
  def apply_column_filters(relation, column_filter)
344
353
  res = relation
345
- operator_map = {"lt" => "<", "gt" => ">", "eq" => "="}
346
354
 
347
355
  # these are still JSON-encoded due to the migration to Ext.direct
348
356
  column_filter=JSON.parse(column_filter)
@@ -351,15 +359,16 @@ module Netzke::Basepack::DataAdapters
351
359
  if method
352
360
  assoc = @model_class.reflect_on_association(assoc.to_sym)
353
361
  if assoc.klass.column_names.include? method
354
- field = [assoc.klass.table_name, method].join('.').to_sym
362
+ field = method
363
+ arel_table = assoc.klass.arel_table
355
364
  end
356
365
  else
357
366
  field = assoc.to_sym
367
+ arel_table = @model_class.arel_table
358
368
  end
359
369
 
360
370
  value = v["value"]
361
-
362
- op = operator_map[v['comparison']]
371
+ op = v['comparison']
363
372
 
364
373
  col_filter = @cls.inject(nil) { |fil, col|
365
374
  if col.is_a?(Hash) && col[:filter_with] && col[:name].to_sym == v['field'].to_sym
@@ -372,38 +381,56 @@ module Netzke::Basepack::DataAdapters
372
381
  col_filter = nil
373
382
  next
374
383
  end
384
+
385
+
375
386
  case v["type"]
376
387
  when "string"
377
- res = res.where(["#{field} like ?", "%#{value}%"])
388
+ res = res.where(arel_table[field].matches("%#{value}%"))
378
389
  when "date"
379
390
  # convert value to the DB date
380
- value.match /(\d\d)\/(\d\d)\/(\d\d\d\d)/
381
- res = res.where("#{field} #{op} ?", "#{$3}-#{$1}-#{$2}".to_time)
391
+ value.match(/(\d\d)\/(\d\d)\/(\d\d\d\d)/)
392
+ if op == 'eq'
393
+ res = res.where(arel_table[field].ge("#{$3}-#{$1}-#{$2}".to_date.beginning_of_day))
394
+ res = res.where(arel_table[field].le("#{$3}-#{$1}-#{$2}".to_date.end_of_day))
395
+ else
396
+ res = res.where(arel_table[field].send(op, "#{$3}-#{$1}-#{$2}".to_time))
397
+ end
382
398
  when "numeric"
383
- res = res.where(["#{field} #{op} ?", value])
384
- else
385
- res = res.where(["#{field} = ?", value])
399
+ res = res.where(arel_table[field].send(op, value))
400
+ else # boolean
401
+ res = res.where(arel_table[field].eq(value))
386
402
  end
387
403
  end
388
404
 
389
405
  res
390
406
  end
391
-
392
407
  protected :apply_column_filters
393
408
 
394
409
  def predicates_for_and_conditions(conditions)
395
410
  return nil if conditions.empty?
396
411
 
397
412
  predicates = conditions.map do |q|
413
+ assoc, method = q["attr"].split('__')
414
+ if method
415
+ assoc = @model_class.reflect_on_association(assoc.to_sym)
416
+ assoc_arel = assoc.klass.arel_table
417
+ attr = method
418
+ arel_table = Arel::Table.new(assoc.klass.table_name.to_sym)
419
+ else
420
+ attr = assoc
421
+ arel_table = @model_class.arel_table
422
+ end
423
+
398
424
  value = q["value"]
425
+
399
426
  case q["operator"]
400
427
  when "contains"
401
- @arel[q["attr"]].matches "%#{value}%"
428
+ arel_table[attr].matches "%#{value}%"
402
429
  else
403
430
  if value == false || value == true
404
- @arel[q["attr"]].eq(value ? 1 : 0)
431
+ arel_table[attr].eq(value)
405
432
  else
406
- @arel[q["attr"]].send(q["operator"], value)
433
+ arel_table[attr].send(q["operator"], value)
407
434
  end
408
435
  end
409
436
  end
@@ -46,6 +46,7 @@ module Netzke
46
46
 
47
47
  configure_locked(c)
48
48
  configure_bbar(c)
49
+ configure_apply_on_return(c)
49
50
 
50
51
  if data_adapter
51
52
  c.pri = data_adapter.primary_key
@@ -75,9 +76,12 @@ module Netzke
75
76
  end
76
77
 
77
78
  def configure_bbar(c)
78
- c[:bbar] = [:apply] if c[:bbar].nil? && !c[:read_only]
79
+ c[:bbar] = ["->", :apply] if c[:bbar].nil? && !c[:read_only]
79
80
  end
80
81
 
82
+ def configure_apply_on_return(c)
83
+ c[:apply_on_return] = c[:apply_on_return].nil? ? true : !!c[:apply_on_return]
84
+ end
81
85
 
82
86
  # Extra JavaScripts and stylesheets
83
87
  css_configure do |c|
@@ -4,15 +4,7 @@
4
4
  fieldDefaults : { labelWidth : 150 },
5
5
 
6
6
  defaults : {
7
- anchor : '-20', // to leave some space for the scrollbar
8
- listeners : {
9
- // On "return" key, submit the form
10
- specialkey : {
11
- fn : function(field, event){
12
- if (event.getKey() == 13) this.ownerCt.onApply();
13
- }
14
- }
15
- }
7
+ anchor : '-20' // to leave some space for the scrollbar
16
8
  },
17
9
 
18
10
  initComponent: function(){
@@ -43,6 +35,14 @@
43
35
 
44
36
  // To inform the parent about the apply event
45
37
  this.addEvents('apply', 'cancel');
38
+
39
+ if (this.applyOnReturn) {
40
+ Ext.each(this.query('field'), function(field) {
41
+ field.on('specialkey', function(field, event) {
42
+ if (event.getKey() == 13) this.up('form').onApply();
43
+ });
44
+ });
45
+ }
46
46
  },
47
47
 
48
48
  afterRender: function(){
@@ -53,7 +53,7 @@ module Netzke
53
53
  # [:+load_inline_data+]
54
54
  # (defaults to false) grid is being loaded along with its initial data; use with precaution, preferred method is auto-loading of data in a separate server request (see +data_store+)
55
55
  # [:+data_store+]
56
- # (defaults to {}) extra configuration for the JS class's internal store (see {Ext.data.Store}[http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store] ). For example, to disable auto loading of data, do:
56
+ # (defaults to empty Hash) extra configuration for the JS class's internal store (see {Ext.data.Store}[http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store] ). For example, to disable auto loading of data, do:
57
57
  #
58
58
  # data_store: {auto_load: false}
59
59
  #
@@ -111,6 +111,20 @@ module Netzke
111
111
  # super + [:extra_column]
112
112
  # end
113
113
  #
114
+ # === Configuring default filters on grid columns
115
+ # Default Filters can either be configured on the grid itself
116
+ #
117
+ # def configure(c)
118
+ # super
119
+ # c.default_filters = [{name: "Mark"}, {age: {gt: 10}}]
120
+ # end
121
+ #
122
+ # or as a component configuration
123
+ #
124
+ # component :tasks |c|
125
+ # c.klass = TaskGrid
126
+ # c.default_filters = [{due_date: {before: Time.now}}]
127
+ # end
114
128
  #
115
129
  # == One-to-many association support
116
130
  # If the model bound to a grid +belongs_to+ another model, Grid can display an "assocition column" - where the user can select the associated record from a drop-down box. You can specify which method of the association should be used as the display value for the drop-down box options by using the double-underscore notation on the column name, where the association name is separated from the association method by "__" (double underscore). For example, let's say we have a Book that +belongs_to+ model Author, and Author responds to +first_name+. This way, the book grid can have a column defined as follows:
@@ -162,6 +176,7 @@ module Netzke
162
176
  # c.edit_in_form_available = false
163
177
  # c.advanced_search_available = false
164
178
  # c.column_filters_available = false
179
+ # c.remember_selection_available = false
165
180
  # end
166
181
  #
167
182
  # Most of these options influence the amount of JavaScript code that is generated for this component's class, in the way that the less functionality is enabled, the less code is generated.
@@ -173,6 +188,8 @@ module Netzke
173
188
  # (defaults to true) include code for (multi-record) editing and adding records through a form
174
189
  # [:+advanced_search_available+]
175
190
  # (defaults to true) include code for extended configurable search
191
+ # [:+remember_selection_available+]
192
+ # (defaults to true) include code for re-selecting records after grid reload
176
193
  class Grid < Netzke::Base
177
194
  include self::Services
178
195
  include Columns
@@ -191,12 +208,16 @@ module Netzke
191
208
  class_attribute :edit_inline_available
192
209
  self.edit_inline_available = true
193
210
 
211
+ class_attribute :remember_selection_available
212
+ self.remember_selection_available = true
213
+
194
214
  # JavaScript class configuration
195
215
  js_configure do |c|
196
216
  c.extend = "Ext.grid.Panel"
197
217
  c.mixin :grid, :event_handling
198
218
  c.mixin :advanced_search if advanced_search_available
199
219
  c.mixin :edit_in_form if edit_in_form_available
220
+ c.mixin :remember_selection if remember_selection_available
200
221
 
201
222
  c.translate *%w[are_you_sure confirmation]
202
223
 
@@ -248,6 +269,34 @@ module Netzke
248
269
  c.columns_order = columns_order
249
270
  c.inline_data = get_data if c.load_inline_data
250
271
  c.pri = data_adapter.primary_key
272
+ if c.default_filters
273
+ populate_cols_with_filters(c)
274
+ end
275
+ end
276
+
277
+ def populate_cols_with_filters(c)
278
+ c.default_filters.each do |f|
279
+
280
+ c.columns.each do |col|
281
+ if col[:name].to_sym == f[:column].to_sym
282
+ if f[:value].is_a?(Hash)
283
+ val = {}
284
+ f[:value].each do |k,v|
285
+ val[k] = (v.is_a?(Time) || v.is_a?(Date) || v.is_a?(ActiveSupport::TimeWithZone)) ? ActiveSupport::JSON::Variable.new("new Date('#{v.strftime("%m/%d/%Y")}')") : v
286
+ end
287
+ else
288
+ val = f[:value]
289
+ end
290
+ new_filter = {value: val, active: true}
291
+ if col[:filter]
292
+ col[:filter].merge! new_filter
293
+ else
294
+ col[:filter] = new_filter
295
+ end
296
+ end
297
+ end
298
+ end
299
+ c.default_filters = nil
251
300
  end
252
301
 
253
302
  def config
@@ -342,7 +391,7 @@ module Netzke
342
391
  component :search_window do |c|
343
392
  c.klass = SearchWindow
344
393
  c.model = config.model
345
- c.fields = default_fields_for_forms
394
+ c.fields = attributes_for_search
346
395
  end
347
396
 
348
397
  protected
@@ -147,21 +147,9 @@
147
147
  this.moveRows({ids: Ext.encode(ids), new_index: newIndex});
148
148
  },
149
149
 
150
- // Other methods. TODO: revise
151
- //
152
-
153
150
  /* Exception handler. TODO: will responses with status 200 land here? */
154
151
  loadExceptionHandler: function(proxy, response, operation){
155
- this.netzkeFeedback(response.message);
156
- // if (response.status == 200 && (responseObject = Ext.decode(response.responseText)) && responseObject.flash){
157
- // this.feedback(responseObject.flash);
158
- // } else {
159
- // if (error){
160
- // this.feedback(error.message);
161
- // } else {
162
- // this.feedback(response.statusText);
163
- // }
164
- // }
152
+ Netzke.warning('Server exception occured. Override loadExceptionHandler, or catch globally by listenning to serverexception event of Netzke.directProvider');
165
153
  },
166
154
 
167
155
  // Inline editing of 1 row