netzke-basepack 0.7.1 → 0.7.2

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.
Files changed (39) hide show
  1. data/CHANGELOG.rdoc +22 -1
  2. data/Rakefile +1 -1
  3. data/lib/netzke/active_record/attributes.rb +1 -1
  4. data/lib/netzke/basepack/action_column.rb +70 -0
  5. data/lib/netzke/basepack/action_column/javascripts/action_column.js +61 -0
  6. data/lib/netzke/basepack/data_accessor.rb +12 -17
  7. data/lib/netzke/basepack/form_panel.rb +5 -4
  8. data/lib/netzke/basepack/form_panel/fields.rb +1 -1
  9. data/lib/netzke/basepack/form_panel/javascripts/form_panel.js +3 -3
  10. data/lib/netzke/basepack/grid_panel.rb +81 -30
  11. data/lib/netzke/basepack/grid_panel/columns.rb +20 -9
  12. data/lib/netzke/basepack/grid_panel/javascripts/event_handling.js +0 -1
  13. data/lib/netzke/basepack/grid_panel/javascripts/grid_panel.js +1 -1
  14. data/lib/netzke/basepack/grid_panel/record_form_window.rb +5 -5
  15. data/lib/netzke/basepack/grid_panel/services.rb +0 -1
  16. data/lib/netzke/basepack/version.rb +1 -1
  17. data/netzke-basepack.gemspec +11 -6
  18. data/test/basepack_test_app/Gemfile.lock +1 -1
  19. data/test/basepack_test_app/app/components/author_grid.rb +1 -5
  20. data/test/basepack_test_app/app/components/book_form.rb +25 -24
  21. data/test/basepack_test_app/app/components/book_grid.rb +6 -9
  22. data/test/basepack_test_app/app/components/book_grid_with_column_actions.rb +15 -0
  23. data/test/basepack_test_app/app/components/book_grid_with_custom_columns.rb +16 -23
  24. data/test/basepack_test_app/app/components/book_grid_with_default_values.rb +5 -7
  25. data/test/basepack_test_app/app/components/book_grid_with_extra_feedback.rb +2 -5
  26. data/test/basepack_test_app/app/components/book_grid_with_overridden_columns.rb +15 -0
  27. data/test/basepack_test_app/app/components/book_grid_with_persistence.rb +0 -1
  28. data/test/basepack_test_app/app/components/book_paging_form_panel.rb +2 -2
  29. data/test/basepack_test_app/app/components/user_form.rb +16 -19
  30. data/test/basepack_test_app/app/components/user_grid.rb +6 -8
  31. data/test/basepack_test_app/db/migrate/20110909071740_add_published_on_to_books.rb +5 -0
  32. data/test/basepack_test_app/db/schema.rb +2 -1
  33. data/test/basepack_test_app/features/form_panel.feature +11 -0
  34. data/test/basepack_test_app/features/grid_panel.feature +34 -33
  35. data/test/basepack_test_app/features/grid_panel_filters.feature +61 -0
  36. data/test/basepack_test_app/features/paging_form_panel.feature +7 -30
  37. data/test/basepack_test_app/features/step_definitions/grid_panel_steps.rb +28 -0
  38. metadata +15 -10
  39. data/lib/netzke/basepack/grid_panel/multi_edit_form.rb +0 -16
@@ -1,24 +1,21 @@
1
1
  class UserForm < Netzke::Basepack::FormPanel
2
- js_property :title, User.model_name.human
2
+ title User.model_name.human
3
3
 
4
- def configuration
5
- sup = super
6
- sup.merge({
7
- :model => 'User',
8
- :record_id => User.first.try(:id),
9
- :items => [
10
- {:xtype => 'fieldset', :title => "Basic Info", :checkboxToggle => true, :items => [
11
- :first_name,
12
- {:name => :last_name}
13
- ]},
14
- {:xtype => 'fieldset', :title => "Timestamps", :items => [
15
- {:name => :created_at, :disabled => true},
16
- {:name => :updated_at, :disabled => true}
17
- ]},
18
- :role__name
19
- ]
20
- })
21
- end
4
+ model "User"
5
+
6
+ record_id User.first.try(:id)
7
+
8
+ items [
9
+ {:xtype => 'fieldset', :title => "Basic Info", :checkboxToggle => true, :items => [
10
+ :first_name,
11
+ {:name => :last_name}
12
+ ]},
13
+ {:xtype => 'fieldset', :title => "Timestamps", :items => [
14
+ {:name => :created_at, :disabled => true},
15
+ {:name => :updated_at, :disabled => true}
16
+ ]},
17
+ :role__name
18
+ ]
22
19
 
23
20
  # Uncomment for visual mask testing
24
21
  # def netzke_submit_endpoint(params)
@@ -1,10 +1,8 @@
1
1
  class UserGrid < Netzke::Basepack::GridPanel
2
- js_property :title, "Users"
3
- def configuration
4
- super.merge(
5
- :model => "User"
6
- # :columns => [:first_name, {:name => :address__city}]
7
- # :edit_form_config => {:items => [{:name => :first_name, :xtype => :htmleditor}]}
8
- )
9
- end
2
+ title "Users"
3
+ model "User"
4
+
5
+ add_form_config :class_name => "UserForm"
6
+ edit_form_config :class_name => "UserForm"
7
+ multi_edit_form_config :class_name => "UserForm"
10
8
  end
@@ -0,0 +1,5 @@
1
+ class AddPublishedOnToBooks < ActiveRecord::Migration
2
+ def change
3
+ add_column :books, :published_on, :date
4
+ end
5
+ end
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20110901114016) do
14
+ ActiveRecord::Schema.define(:version => 20110909071740) do
15
15
 
16
16
  create_table "addresses", :force => true do |t|
17
17
  t.integer "user_id"
@@ -48,6 +48,7 @@ ActiveRecord::Schema.define(:version => 20110901114016) do
48
48
  t.datetime "created_at"
49
49
  t.datetime "updated_at"
50
50
  t.datetime "last_read_at"
51
+ t.date "published_on"
51
52
  end
52
53
 
53
54
  create_table "netzke_component_states", :force => true do |t|
@@ -72,6 +72,17 @@ Scenario: Checkbox field should work properly
72
72
  And a book should exist with digitized: true, author: that author, exemplars: 4
73
73
  And a book should not exist with digitized: false, author: that author
74
74
 
75
+ @javascript
76
+ Scenario: Editing and immediately submitting the form
77
+ Given an author exists with first_name: "Carlos", last_name: "Castaneda"
78
+ And a book exists with title: "Journey to Ixtlan", author: that author
79
+ When I go to the BookForm test page
80
+ Then the form should show author__name: "Castaneda, Carlos"
81
+
82
+ When I press "Apply"
83
+ And I wait for the response from the server
84
+ Then the form should show author__name: "Castaneda, Carlos"
85
+
75
86
  # @javascript
76
87
  # Scenario: Checkbox group for tags should work properly
77
88
  # Given a book exists with title: "Some Title"
@@ -3,14 +3,15 @@ Feature: Grid panel
3
3
  As a role
4
4
  I want feature
5
5
 
6
- Scenario: UserGrid should render properly
7
- Given a user exists with first_name: "Carlos", last_name: "Castaneda"
8
- And a user exists with first_name: "Taisha", last_name: "Abelar"
9
- When I go to the UserGrid test page
10
- Then I should see "Carlos"
11
- And I should see "Castaneda"
12
- And I should see "Taisha"
13
- And I should see "Abelar"
6
+ @javascript
7
+ Scenario: UserGrid should correctly display data
8
+ Given an author exists with first_name: "Vladimir", last_name: "Nabokov"
9
+ And a book exists with author: that author, title: "Lolita", last_read_at: "2011-12-13", published_on: "2005-01-30"
10
+
11
+ When I go to the BookGrid test page
12
+ Then I should see "Nabokov, Vladimir"
13
+ And I should see "12/13/2011"
14
+ And I should see "01/30/2005"
14
15
 
15
16
  @javascript
16
17
  Scenario: Adding a record via "Add in form"
@@ -59,8 +60,8 @@ Scenario: Multi-editing records
59
60
  And I press "Edit in form"
60
61
  And I fill in "First name:" with "Maxim"
61
62
  And I press "OK"
62
- Then I should see "Updated 2 records."
63
- And the following users should exist:
63
+ And I wait for the response from the server
64
+ Then the following users should exist:
64
65
  | first_name | last_name |
65
66
  | Maxim | Castaneda |
66
67
  | Maxim | Hesse |
@@ -113,29 +114,6 @@ Scenario: Inline editing
113
114
  And a book should exist with title: "Collector", exemplars: 200
114
115
  But a book should not exist with title: "Magus"
115
116
 
116
- @javascript
117
- Scenario: Column filters
118
- Given the following books exist:
119
- | title | exemplars | digitized | notes |
120
- | Journey to Ixtlan | 10 | true | A must-read |
121
- | Lolita | 5 | false | To read |
122
- | Getting Things Done | 3 | true | Productivity |
123
- When I go to the BookGrid test page
124
- And I enable filter on column "exemplars" with value "{gt:6}"
125
- Then the grid should show 1 records
126
-
127
- When I clear all filters in the grid
128
- And I enable filter on column "notes" with value "'read'"
129
- Then the grid should show 2 records
130
-
131
- When I clear all filters in the grid
132
- And I enable filter on column "digitized" with value "false"
133
- Then the grid should show 1 records
134
-
135
- When I clear all filters in the grid
136
- And I enable filter on column "digitized" with value "true"
137
- Then the grid should show 2 records
138
-
139
117
  @javascript
140
118
  Scenario: Inline editing of association
141
119
  Given an author exists with first_name: "Vladimir", last_name: "Nabokov"
@@ -248,3 +226,26 @@ Scenario: I must see total records value
248
226
 
249
227
  When I go to the BookGridWithPaging test page
250
228
  Then I should see "of 2" within paging toolbar
229
+
230
+ @javascript
231
+ Scenario: GridPanel with overridden columns
232
+ Given an author exists with first_name: "Vladimir", last_name: "Nabokov"
233
+ And a book exists with title: "Lolita", author: that author
234
+ When I go to the BookGridWithOverriddenColumns test page
235
+ Then I should see "LOLITA"
236
+ And I should see "Nabokov, Vladimir"
237
+
238
+ @javascript
239
+ Scenario: Virtual attributes should not be editable
240
+ Given a book exists with title: "Some Title"
241
+ When I go to the BookGridWithVirtualAttributes test page
242
+ Then the grid's column "In abundance" should not be editable
243
+
244
+ @javascript
245
+ Scenario: Delete record via an column action
246
+ Given a book exists with title: "Some Title"
247
+ When I go to the BookGridWithColumnActions test page
248
+ And I click the "Delete row" action icon
249
+ And I press "Yes"
250
+ Then I should see "Deleted 1 record(s)"
251
+ And a book should not exist with title: "Some Title"
@@ -0,0 +1,61 @@
1
+ Feature: Grid panel filters
2
+ In order to value
3
+ As a role
4
+ I want feature
5
+
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 |
12
+
13
+ @javascript
14
+ Scenario: Numeric and text filter
15
+ When I go to the BookGrid test page
16
+ And I enable filter on column "exemplars" with value "{gt:6}"
17
+ Then the grid should show 1 records
18
+
19
+ When I clear all filters in the grid
20
+ And I enable filter on column "exemplars" with value "{eq:5}"
21
+ Then the grid should show 1 records
22
+
23
+ When I clear all filters in the grid
24
+ And I enable filter on column "exemplars" with value "{eq:6}"
25
+ Then the grid should show 0 records
26
+
27
+ # Due to some mystery, this wouldn't work in a separate scenario (e.g. Text filter)
28
+ When I clear all filters in the grid
29
+ And I enable filter on column "notes" with value "'read'"
30
+ Then the grid should show 2 records
31
+
32
+ When I clear all filters in the grid
33
+ And I enable date filter on column "last_read_at" with value "on 04/25/2011"
34
+ Then the grid should show 1 records
35
+
36
+ When I clear all filters in the grid
37
+ And I enable date filter on column "last_read_at" with value "after 04/25/2011"
38
+ Then the grid should show 1 records
39
+
40
+ When I clear all filters in the grid
41
+ And I enable date filter on column "last_read_at" with value "before 12/24/2010"
42
+ Then the grid should show 1 records
43
+
44
+ When I clear all filters in the grid
45
+ And I enable date filter on column "last_read_at" with value "after 12/23/2010"
46
+ Then the grid should show 2 records
47
+
48
+ When I clear all filters in the grid
49
+ And I enable date filter on column "last_read_at" with value "after 12/23/2010"
50
+ And I enable date filter on column "last_read_at" with value "before 04/26/2011"
51
+ Then the grid should show 1 records
52
+
53
+ @javascript
54
+ Scenario: Boolean filter
55
+ When I go to the BookGrid test page
56
+ And I enable filter on column "digitized" with value "false"
57
+ Then the grid should show 1 records
58
+
59
+ When I clear all filters in the grid
60
+ And I enable filter on column "digitized" with value "true"
61
+ Then the grid should show 2 records
@@ -3,14 +3,15 @@ Feature: Paging form panel
3
3
  As a role
4
4
  I want feature
5
5
 
6
- @javascript
7
- Scenario: Paging through records
6
+ Background:
8
7
  Given the following books exist:
9
- | title |
10
- | Journey to Ixtlan |
11
- | Lolita |
12
- | Getting Things Done |
8
+ | title | exemplars | digitized | notes | published_on | last_read_at |
9
+ | Journey to Ixtlan | 10 | true | A must-read | 2001-01-02 | 2011-01-02 |
10
+ | Lolita | 5 | false | To read | 1988-04-05 | 2011-03-04 |
11
+ | Getting Things Done | 3 | true | Productivity | 2005-06-07 | 2011-12-13 |
13
12
 
13
+ @javascript
14
+ Scenario: Paging through records
14
15
  When I go to the BookPagingFormPanel test page
15
16
  Then I should see "Journey to Ixtlan"
16
17
 
@@ -24,12 +25,6 @@ Scenario: Paging through records
24
25
 
25
26
  @javascript
26
27
  Scenario: Searching
27
- Given the following books exist:
28
- | title | exemplars | digitized | notes |
29
- | Journey to Ixtlan | 10 | true | A must-read |
30
- | Lolita | 5 | false | To read |
31
- | Getting Things Done | 3 | true | Productivity |
32
-
33
28
  When I go to the BookPagingFormPanel test page
34
29
  And I press "Search"
35
30
  And I wait for the response from the server
@@ -42,25 +37,7 @@ Scenario: Searching
42
37
  And I wait for the response from the server
43
38
  Then the form should show title: "Getting Things Done"
44
39
 
45
- @javascript
46
- Scenario: Editing and immediately submitting the form
47
- Given an author exists with first_name: "Carlos", last_name: "Castaneda"
48
- And a book exists with title: "Journey to Ixtlan", author: that author
49
- When I go to the BookPagingFormPanel test page
50
- Then the form should show author__name: "Castaneda, Carlos"
51
-
52
- When I press "Edit"
53
- And I press "Apply"
54
- And I wait for the response from the server
55
- Then the form should show author__name: "Castaneda, Carlos"
56
-
57
40
  @javascript
58
41
  Scenario: I must see total records value
59
- Given the following books exist:
60
- | title |
61
- | Journey to Ixtlan |
62
- | Lolita |
63
- | Getting Things Done |
64
-
65
42
  When I go to the BookPagingFormPanel test page
66
43
  Then I should see "of 3" within paging toolbar
@@ -54,6 +54,22 @@ When /^I enable filter on column "([^"]*)" with value "([^"]*)"$/ do |column, va
54
54
  sleep 1
55
55
  end
56
56
 
57
+ # E.g.: And I enable date filter on column "last_read_at" with value "after 04/25/2011" (this date should be in the US format)
58
+ When /^I enable date filter on column "([^"]*)" with value "([^"]*)"$/ do |column, value|
59
+ operand, date = value.split
60
+ page.driver.browser.execute_script <<-JS
61
+ var grid = Ext.ComponentQuery.query('gridpanel')[0],
62
+ filter, value;
63
+ grid.features[0].createFilters();
64
+ filter = grid.filters.getFilter('#{column}');
65
+ value = filter.getValue();
66
+ value.#{operand} = new Date('#{date}'); // merge the new value with the current one
67
+ filter.setValue(value);
68
+ filter.setActive(true);
69
+ JS
70
+ sleep 1
71
+ end
72
+
57
73
  When /^I clear all filters in the grid$/ do
58
74
  page.driver.browser.execute_script <<-JS
59
75
  var components = [];
@@ -148,3 +164,15 @@ Then /^the grid should have records sorted by "([^"]*)"\s?(asc|desc)?$/ do |colu
148
164
  return (columnValues.length > 0) && (columnValues.toString() === Ext.Array.sort(columnValues).toString());
149
165
  JS
150
166
  end
167
+
168
+ Then /^the grid's column "([^"]*)" should not be editable$/ do |column_name|
169
+ column = column_name.downcase.gsub(' ', '_')
170
+ page.driver.browser.execute_script(<<-JS).should be_true
171
+ var col = Ext.ComponentQuery.query('gridcolumn[name="#{column}"]')[0];
172
+ return typeof col.getEditor() == 'undefined';
173
+ JS
174
+ end
175
+
176
+ When /^I click the "([^"]*)" action icon$/ do |action_name|
177
+ find("img[data-qtip='#{action_name}']").click
178
+ 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.7.1
4
+ version: 0.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,22 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-09-04 00:00:00.000000000Z
12
+ date: 2011-10-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: netzke-core
16
- requirement: &70122130214940 !ruby/object:Gem::Requirement
16
+ requirement: &70256296535300 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.7.0
21
+ version: 0.7.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70122130214940
24
+ version_requirements: *70256296535300
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: will_paginate
27
- requirement: &70122130214460 !ruby/object:Gem::Requirement
27
+ requirement: &70256296534640 !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: *70122130214460
35
+ version_requirements: *70256296534640
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: acts_as_list
38
- requirement: &70122130213980 !ruby/object:Gem::Requirement
38
+ requirement: &70256296533980 !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: *70122130213980
46
+ version_requirements: *70256296533980
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
@@ -77,6 +77,8 @@ files:
77
77
  - lib/netzke/active_record/relation_extensions.rb
78
78
  - lib/netzke/basepack.rb
79
79
  - lib/netzke/basepack/accordion_panel.rb
80
+ - lib/netzke/basepack/action_column.rb
81
+ - lib/netzke/basepack/action_column/javascripts/action_column.js
80
82
  - lib/netzke/basepack/auth_app.rb
81
83
  - lib/netzke/basepack/basic_app.rb
82
84
  - lib/netzke/basepack/border_layout_panel.rb
@@ -100,7 +102,6 @@ files:
100
102
  - lib/netzke/basepack/grid_panel/javascripts/grid_panel.js
101
103
  - lib/netzke/basepack/grid_panel/javascripts/misc.js
102
104
  - lib/netzke/basepack/grid_panel/javascripts/rows-dd.js
103
- - lib/netzke/basepack/grid_panel/multi_edit_form.rb
104
105
  - lib/netzke/basepack/grid_panel/record_form_window.rb
105
106
  - lib/netzke/basepack/grid_panel/services.rb
106
107
  - lib/netzke/basepack/paging_form_panel.rb
@@ -142,11 +143,13 @@ files:
142
143
  - test/basepack_test_app/app/components/book_form_with_nested_attributes.rb
143
144
  - test/basepack_test_app/app/components/book_grid.rb
144
145
  - test/basepack_test_app/app/components/book_grid_loader.rb
146
+ - test/basepack_test_app/app/components/book_grid_with_column_actions.rb
145
147
  - test/basepack_test_app/app/components/book_grid_with_custom_columns.rb
146
148
  - test/basepack_test_app/app/components/book_grid_with_default_values.rb
147
149
  - test/basepack_test_app/app/components/book_grid_with_extra_feedback.rb
148
150
  - test/basepack_test_app/app/components/book_grid_with_extra_filters.rb
149
151
  - test/basepack_test_app/app/components/book_grid_with_nested_attributes.rb
152
+ - test/basepack_test_app/app/components/book_grid_with_overridden_columns.rb
150
153
  - test/basepack_test_app/app/components/book_grid_with_paging.rb
151
154
  - test/basepack_test_app/app/components/book_grid_with_persistence.rb
152
155
  - test/basepack_test_app/app/components/book_grid_with_scoped_authors.rb
@@ -224,12 +227,14 @@ files:
224
227
  - test/basepack_test_app/db/migrate/20110213213050_create_netzke_component_states.rb
225
228
  - test/basepack_test_app/db/migrate/20110701070052_create_book_with_custom_primary_keys.rb
226
229
  - test/basepack_test_app/db/migrate/20110901114016_add_last_read_at_to_books.rb
230
+ - test/basepack_test_app/db/migrate/20110909071740_add_published_on_to_books.rb
227
231
  - test/basepack_test_app/db/schema.rb
228
232
  - test/basepack_test_app/db/seeds.rb
229
233
  - test/basepack_test_app/features/accordion_panel.feature
230
234
  - test/basepack_test_app/features/components_in_view.feature
231
235
  - test/basepack_test_app/features/form_panel.feature
232
236
  - test/basepack_test_app/features/grid_panel.feature
237
+ - test/basepack_test_app/features/grid_panel_filters.feature
233
238
  - test/basepack_test_app/features/grid_panel_with_custom_primary_key.feature
234
239
  - test/basepack_test_app/features/grid_sorting.feature
235
240
  - test/basepack_test_app/features/i18n.feature