netzke-basepack 0.7.2 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ = 0.7.3 - 2011-10-23
2
+ * bug fix
3
+ * :sorting_scope config option for GridPanel is now effective
4
+ * regression: filtering on association column is fix (covered with tests)
5
+
1
6
  = 0.7.2 - 2011-10-20
2
7
  * bug fix
3
8
  * Filter on a date column
data/README.md CHANGED
@@ -6,7 +6,7 @@ A pack of pre-built [Netzke](http://netzke.org) components - such as grid, form,
6
6
 
7
7
  * Ruby 1.9.2 (1.8.7 may work, too)
8
8
  * Rails >= 3.0.0
9
- * Ext JS >= 4.0.0
9
+ * Ext JS = 4.0.2a
10
10
 
11
11
  ## Installation
12
12
 
@@ -163,9 +163,9 @@ module Netzke
163
163
  assoc, method = v["field"].split('__')
164
164
  if method
165
165
  assoc = data_class.reflect_on_association(assoc.to_sym)
166
- field = [assoc.klass.table_name, method].join('.').to_sym
166
+ field = [assoc.klass.table_name, method].join('.')
167
167
  else
168
- field = assoc.to_sym
168
+ field = [table_name, assoc].join('.')
169
169
  end
170
170
 
171
171
  value = v["value"]
@@ -174,15 +174,15 @@ module Netzke
174
174
 
175
175
  case v["type"]
176
176
  when "string"
177
- res = res.where(["#{table_name}.#{field} like ?", "%#{value}%"])
177
+ res = res.where(["#{field} like ?", "%#{value}%"])
178
178
  when "date"
179
179
  # convert value to the DB date
180
180
  value.match /(\d\d)\/(\d\d)\/(\d\d\d\d)/
181
- res = res.where("#{table_name}.#{field} #{op} ?", "#{$3}-#{$1}-#{$2}")
181
+ res = res.where("#{field} #{op} ?", "#{$3}-#{$1}-#{$2}")
182
182
  when "numeric"
183
- res = res.where(["#{table_name}.#{field} #{op} ?", value])
183
+ res = res.where(["#{field} #{op} ?", value])
184
184
  else
185
- res = res.where(["#{table_name}.#{field} = ?", value])
185
+ res = res.where(["#{field} = ?", value])
186
186
  end
187
187
  end
188
188
 
@@ -214,7 +214,7 @@ module Netzke
214
214
  end
215
215
 
216
216
  def set_default_sortable(c)
217
- c[:sortable] = !c[:virtual] if c[:sortable].nil? # TODO: optimize - don't set it to false
217
+ c[:sortable] = !c[:virtual] || c[:sorting_scope] if c[:sortable].nil? # TODO: optimize - don't set it to false
218
218
  end
219
219
 
220
220
  def set_default_filterable(c)
@@ -211,6 +211,7 @@ module Netzke
211
211
  column = columns.detect { |c| c[:name] == sort_params["property"] }
212
212
  if column.has_key?(:sorting_scope)
213
213
  relation = relation.send(column[:sorting_scope].to_sym, dir.to_sym)
214
+ ::Rails.logger.debug "!!! relation: #{relation.inspect}\n"
214
215
  else
215
216
  relation = if method.nil?
216
217
  relation.order("#{assoc} #{dir}")
@@ -3,7 +3,7 @@ module Netzke
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 7
6
- PATCH = 2
6
+ PATCH = 3
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
9
9
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{netzke-basepack}
8
- s.version = "0.7.2"
8
+ s.version = "0.7.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Sergei Kozlov}]
12
- s.date = %q{2011-10-20}
12
+ s.date = %q{2011-10-23}
13
13
  s.description = %q{A set of full-featured extendible Netzke components (such as FormPanel, GridPanel, Window, BorderLayoutPanel, etc) which can be used as building block for your RIA}
14
14
  s.email = %q{sergei@playcode.nl}
15
15
  s.extra_rdoc_files = [
@@ -105,6 +105,7 @@ Gem::Specification.new do |s|
105
105
  "test/basepack_test_app/app/components/book_form_with_defaults.rb",
106
106
  "test/basepack_test_app/app/components/book_form_with_nested_attributes.rb",
107
107
  "test/basepack_test_app/app/components/book_grid.rb",
108
+ "test/basepack_test_app/app/components/book_grid_filtering.rb",
108
109
  "test/basepack_test_app/app/components/book_grid_loader.rb",
109
110
  "test/basepack_test_app/app/components/book_grid_with_column_actions.rb",
110
111
  "test/basepack_test_app/app/components/book_grid_with_custom_columns.rb",
@@ -6,4 +6,7 @@ class BookGrid < Netzke::Basepack::GridPanel
6
6
  add_form_config :class_name => "BookForm"
7
7
  edit_form_config :class_name => "BookForm"
8
8
  multi_edit_form_config :class_name => "BookForm"
9
+
10
+ # We need to specify how we want to sort on this virtual column:
11
+ override_column :author__name, :sorting_scope => :sorted_by_author_name
9
12
  end
@@ -0,0 +1,10 @@
1
+ class BookGridFiltering < Netzke::Basepack::GridPanel
2
+ model "Book"
3
+
4
+ column :title
5
+ column :author__first_name
6
+ column :exemplars
7
+ column :notes
8
+ column :last_read_at
9
+ column :digitized
10
+ end
@@ -1,4 +1,6 @@
1
1
  class Book < ActiveRecord::Base
2
2
  belongs_to :author
3
3
  validates_presence_of :title
4
+
5
+ scope :sorted_by_author_name, lambda { |dir| joins(:author).order("authors.last_name #{dir}, authors.first_name #{dir}") }
4
6
  end
@@ -4,15 +4,18 @@ Feature: Grid panel filters
4
4
  I want feature
5
5
 
6
6
  Background:
7
- Given the following books exist:
8
- | title | exemplars | digitized | notes | last_read_at |
9
- | Journey to Ixtlan | 10 | true | A must-read | 2011-04-25 |
10
- | Lolita | 5 | false | To read | 2010-12-23 |
11
- | Getting Things Done | 3 | true | Productivity | 2011-04-26 |
7
+ Given an author exists with first_name: "Vladimir", last_name: "Nabokov"
8
+ And a book exists with author: that author, title: "Lolita", exemplars: 5, digitized: false, notes: "To read", last_read_at: "2010-12-23"
9
+
10
+ And an author exists with first_name: "Carlos", last_name: "Castaneda"
11
+ And a book exists with author: that author, title: "Journey to Ixtlan", exemplars: 10, digitized: true, notes: "A must-read", last_read_at: "2011-04-25"
12
+
13
+ And an author exists with first_name: "David", last_name: "Allen"
14
+ And a book exists with author: that author, title: "Getting Things Done", exemplars: 3, digitized: true, notes: "Productivity", last_read_at: "2011-04-26"
12
15
 
13
16
  @javascript
14
17
  Scenario: Numeric and text filter
15
- When I go to the BookGrid test page
18
+ When I go to the BookGridFiltering test page
16
19
  And I enable filter on column "exemplars" with value "{gt:6}"
17
20
  Then the grid should show 1 records
18
21
 
@@ -24,11 +27,20 @@ Scenario: Numeric and text filter
24
27
  And I enable filter on column "exemplars" with value "{eq:6}"
25
28
  Then the grid should show 0 records
26
29
 
27
- # Due to some mystery, this wouldn't work in a separate scenario (e.g. Text filter)
30
+ # NOTE: due to some mystery, this wouldn't work in a separate scenario (e.g. "Text filter")
31
+ # That is, the filter just wouldn't get set.
28
32
  When I clear all filters in the grid
29
33
  And I enable filter on column "notes" with value "'read'"
30
34
  Then the grid should show 2 records
31
35
 
36
+ When I clear all filters in the grid
37
+ And I enable filter on column "author__first_name" with value "'d'"
38
+ Then the grid should show 2 records
39
+
40
+ When I clear all filters in the grid
41
+ And I enable filter on column "author__first_name" with value "'carl'"
42
+ Then the grid should show 1 records
43
+
32
44
  When I clear all filters in the grid
33
45
  And I enable date filter on column "last_read_at" with value "on 04/25/2011"
34
46
  Then the grid should show 1 records
@@ -52,7 +64,7 @@ Scenario: Numeric and text filter
52
64
 
53
65
  @javascript
54
66
  Scenario: Boolean filter
55
- When I go to the BookGrid test page
67
+ When I go to the BookGridFiltering test page
56
68
  And I enable filter on column "digitized" with value "false"
57
69
  Then the grid should show 1 records
58
70
 
@@ -22,11 +22,11 @@ Feature: Grid sorting
22
22
 
23
23
  @javascript
24
24
  Scenario: Sorting on association column
25
- Given an author exists with first_name: "Herman"
25
+ Given an author exists with first_name: "Herman", last_name: "Hesse"
26
26
  And a book exists with title: "Damian", author: that author
27
- And an author exists with first_name: "Carlos"
27
+ And an author exists with first_name: "Carlos", last_name: "Castaneda"
28
28
  And a book exists with title: "Journey", author: that author
29
- And an author exists with first_name: "John"
29
+ And an author exists with first_name: "John", last_name: "Fowles"
30
30
  And a book exists with title: "Magus", author: that author
31
31
 
32
32
  When I go to the BookGridWithCustomColumns test page
@@ -34,6 +34,14 @@ Feature: Grid sorting
34
34
  And I sleep 1 second
35
35
  Then the grid should have records sorted by "Author first name"
36
36
 
37
- And I click on column "Author first name"
37
+ When I click on column "Author first name"
38
38
  And I sleep 1 second
39
39
  Then the grid should have records sorted by "Author first name" desc
40
+
41
+ When I go to the BookGrid test page
42
+ And I click on column "Author name"
43
+ And I sleep 1 second
44
+ Then the grid should have records sorted by "Author name"
45
+ When I click on column "Author name"
46
+ And I sleep 1 second
47
+ Then the grid should have records sorted by "Author name" desc
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.7.2
4
+ version: 0.7.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-20 00:00:00.000000000Z
12
+ date: 2011-10-23 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: netzke-core
16
- requirement: &70256296535300 !ruby/object:Gem::Requirement
16
+ requirement: &70314345257960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.7.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70256296535300
24
+ version_requirements: *70314345257960
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: will_paginate
27
- requirement: &70256296534640 !ruby/object:Gem::Requirement
27
+ requirement: &70314345257080 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.0.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70256296534640
35
+ version_requirements: *70314345257080
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: acts_as_list
38
- requirement: &70256296533980 !ruby/object:Gem::Requirement
38
+ requirement: &70314345256340 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: 0.1.4
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70256296533980
46
+ version_requirements: *70314345256340
47
47
  description: A set of full-featured extendible Netzke components (such as FormPanel,
48
48
  GridPanel, Window, BorderLayoutPanel, etc) which can be used as building block for
49
49
  your RIA
@@ -142,6 +142,7 @@ files:
142
142
  - test/basepack_test_app/app/components/book_form_with_defaults.rb
143
143
  - test/basepack_test_app/app/components/book_form_with_nested_attributes.rb
144
144
  - test/basepack_test_app/app/components/book_grid.rb
145
+ - test/basepack_test_app/app/components/book_grid_filtering.rb
145
146
  - test/basepack_test_app/app/components/book_grid_loader.rb
146
147
  - test/basepack_test_app/app/components/book_grid_with_column_actions.rb
147
148
  - test/basepack_test_app/app/components/book_grid_with_custom_columns.rb