netzke-basepack 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/CHANGELOG.rdoc +17 -0
  2. data/README.rdoc +1 -1
  3. data/Rakefile +3 -0
  4. data/TODO.rdoc +1 -4
  5. data/features/form_panel.feature +2 -1
  6. data/features/grid_panel.feature +134 -5
  7. data/features/nested_attributes.feature +4 -1
  8. data/features/paging_form_panel.feature +41 -0
  9. data/features/search_in_grid.feature +20 -7
  10. data/features/step_definitions/form_panel_steps.rb +35 -0
  11. data/features/step_definitions/generic_steps.rb +20 -1
  12. data/features/step_definitions/grid_panel_steps.rb +63 -0
  13. data/features/support/env.rb +4 -0
  14. data/features/validations_in_grid.feature +13 -0
  15. data/features/virtual_attributes.feature +5 -9
  16. data/javascripts/basepack.js +21 -650
  17. data/javascripts/datetimefield.js +24 -0
  18. data/lib/generators/netzke/basepack_generator.rb +10 -0
  19. data/{generators/netzke_basepack/templates/public_assets → lib/generators/netzke/templates/assets}/ts-checkbox.gif +0 -0
  20. data/{generators/netzke_basepack → lib/generators/netzke}/templates/create_netzke_field_lists.rb +0 -0
  21. data/lib/netzke-basepack.rb +3 -41
  22. data/lib/netzke/active_record/attributes.rb +17 -21
  23. data/lib/netzke/basepack.rb +6 -1
  24. data/lib/netzke/basepack/data_accessor.rb +166 -0
  25. data/lib/netzke/basepack/form_panel.rb +69 -20
  26. data/lib/netzke/basepack/form_panel/fields.rb +15 -17
  27. data/lib/netzke/basepack/form_panel/javascripts/comma_list_cbg.js +7 -0
  28. data/lib/netzke/basepack/form_panel/javascripts/display_mode.js +6 -0
  29. data/lib/netzke/basepack/form_panel/javascripts/{main.js → form_panel.js} +42 -8
  30. data/lib/netzke/basepack/form_panel/javascripts/n_radio_group.js +24 -7
  31. data/lib/netzke/basepack/form_panel/javascripts/readonly_mode.js +52 -0
  32. data/lib/netzke/basepack/form_panel/services.rb +28 -2
  33. data/lib/netzke/basepack/form_panel/stylesheets/readonly_mode.css +14 -0
  34. data/lib/netzke/basepack/grid_panel.rb +151 -181
  35. data/lib/netzke/basepack/grid_panel/columns.rb +122 -84
  36. data/lib/netzke/basepack/grid_panel/javascripts/advanced_search.js +22 -27
  37. data/lib/netzke/basepack/grid_panel/javascripts/{main.js → grid_panel.js} +182 -108
  38. data/lib/netzke/basepack/grid_panel/record_form_window.rb +7 -2
  39. data/lib/netzke/basepack/grid_panel/services.rb +58 -39
  40. data/lib/netzke/basepack/paging_form_panel.rb +86 -25
  41. data/lib/netzke/basepack/query_builder.rb +105 -0
  42. data/lib/netzke/basepack/query_builder/javascripts/query_builder.js +140 -0
  43. data/lib/netzke/basepack/search_panel.rb +61 -44
  44. data/lib/netzke/basepack/search_panel/javascripts/condition_field.js +153 -0
  45. data/lib/netzke/basepack/search_panel/javascripts/search_panel.js +64 -0
  46. data/lib/netzke/basepack/search_window.rb +64 -0
  47. data/lib/netzke/basepack/simple_app.rb +1 -1
  48. data/lib/netzke/basepack/simple_app/javascripts/{main.js → simple_app.js} +0 -0
  49. data/lib/netzke/basepack/tab_panel.rb +1 -2
  50. data/lib/netzke/basepack/tab_panel/javascripts/{main.js → tab_panel.js} +0 -0
  51. data/lib/netzke/basepack/version.rb +1 -1
  52. data/locales/en.yml +71 -4
  53. data/netzke-basepack.gemspec +47 -22
  54. data/spec/active_record/attributes_spec.rb +6 -6
  55. data/spec/components/form_panel_spec.rb +2 -13
  56. data/stylesheets/datetimefield.css +54 -0
  57. data/test/rails_app/Gemfile +3 -3
  58. data/test/rails_app/Gemfile.lock +67 -57
  59. data/test/rails_app/README +1 -256
  60. data/test/rails_app/app/components/book_form.rb +1 -3
  61. data/test/rails_app/app/components/book_form_with_custom_fields.rb +20 -0
  62. data/test/rails_app/app/components/book_form_with_nested_attributes.rb +18 -0
  63. data/test/rails_app/app/components/book_grid.rb +3 -1
  64. data/test/rails_app/app/components/book_grid_loader.rb +24 -0
  65. data/test/rails_app/app/components/book_grid_with_custom_columns.rb +28 -0
  66. data/test/rails_app/app/components/book_grid_with_default_values.rb +1 -1
  67. data/test/rails_app/app/components/book_grid_with_virtual_attributes.rb +0 -1
  68. data/test/rails_app/app/components/book_paging_form_panel.rb +3 -2
  69. data/test/rails_app/app/components/book_presentation.rb +3 -3
  70. data/test/rails_app/app/components/book_query_builder.rb +8 -0
  71. data/test/rails_app/app/components/book_search_panel.rb +5 -0
  72. data/test/rails_app/app/components/book_search_panel/javascripts/i18n_de.js +6 -0
  73. data/test/rails_app/app/components/double_book_grid.rb +18 -0
  74. data/test/rails_app/app/components/form_without_model.rb +1 -1
  75. data/test/rails_app/app/components/paging_form_with_search.rb +39 -0
  76. data/test/rails_app/app/components/user_grid.rb +1 -1
  77. data/test/rails_app/app/models/author.rb +1 -0
  78. data/test/rails_app/config/application.rb +6 -1
  79. data/test/rails_app/config/database.yml +7 -5
  80. data/test/rails_app/config/environments/test.rb +1 -1
  81. data/test/rails_app/config/locales/de.yml +35 -0
  82. data/test/rails_app/config/locales/es.yml +84 -8
  83. data/test/rails_app/db/migrate/20101026190021_create_books.rb +2 -2
  84. data/test/rails_app/db/migrate/20110213213050_create_netzke_component_states.rb +20 -0
  85. data/test/rails_app/db/schema.rb +2 -18
  86. data/test/rails_app/public/netzke/basepack/ts-checkbox.gif +0 -0
  87. data/test/unit/active_record_basepack_test.rb +1 -1
  88. metadata +46 -45
  89. data/generators/netzke_basepack/netzke_basepack_generator.rb +0 -13
  90. data/lib/netzke/basepack/grid_panel/search_window.rb +0 -56
  91. data/lib/netzke/data_accessor.rb +0 -113
  92. data/lib/netzke/ext.rb +0 -7
  93. data/lib/netzke/fields_configurator.rb +0 -170
  94. data/lib/netzke/json_array_editor.rb +0 -67
  95. data/lib/netzke/masquerade_selector.rb +0 -53
  96. data/test/rails_app/app/components/some_search_panel.rb +0 -34
  97. data/test/rails_app/db/development_structure.sql +0 -93
  98. data/test/rails_app/db/migrate/20100905214933_create_netzke_preferences.rb +0 -16
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,20 @@
1
+ = v0.6.4 - 2011-02-26
2
+ * API changes
3
+ * The combo field able to talk to the server has changed its xtype from combobox to netzkeremotecombo. When getting values from the server via AJAX, it expects a 2-dimensional array now, where the first value is the real value (which gets submitted), and the second value is the display value.
4
+ * xdatetime is no more. datetimefield is used instead.
5
+
6
+ * enhancements
7
+ * Components updated to use Ext.Direct (by @pschyska)
8
+ * New, improved advanced search for GridPanel and PagingFormPanel.
9
+ * One-to-many association support in Form/GridPanel reworked to use the foreign id instead of a string. This gives us more flexibility about what to display in the association column/field, and also provides for performance improvements (no more need to search for the associated record based on the value provided from the column/field).
10
+ * GridPanel now memorizes its columns visibility, position and size (when :persistence is set to true)
11
+ * I18n for GridPanel
12
+ * A default value can now also be assigned to association column/field (the value must be the associated record's ID)
13
+ * Slightly optimized selenium tests (no artificial sleeping whenever possible)
14
+
15
+ * bug fix
16
+ * Long-standing visual issues with datetime columns in grid panel are solved.
17
+
1
18
  = v0.6.3 - 2011-01-14
2
19
  * compatibility with netzke-core 0.6.5
3
20
 
data/README.rdoc CHANGED
@@ -33,7 +33,7 @@ For more examples, see http://demo.netzke.com, and look into test/rails_app
33
33
 
34
34
  == Running tests
35
35
 
36
- Netzke-basepack is bundled with automated tests. To run them, you need to set up test/rails_app a similar way as you did with your own Rails app that is using Netzke, i.e.: 1) link Ext JS into the "public" folder, 2) link netzke-core into vendor/plugins, 3) run migrations and clone the development database structure into the test database.
36
+ Netzke-basepack is bundled with automated tests. To run them, you need to set up test/rails_app a similar way as you did with your own Rails app that is using Netzke, i.e.: 1) link Ext JS into the "public" folder, 2) link your copy of netzke-core and netzke-basepack into vendor/gems, 3) run migrations and clone the development database structure into the test database.
37
37
 
38
38
  After this you may run (*from the netzke-basepack folder*):
39
39
 
data/Rakefile CHANGED
@@ -19,6 +19,9 @@ begin
19
19
 
20
20
  Thanks for installing netzke-basepack!
21
21
 
22
+ Don't forget to run "rails generate netzke:baspack" to copy necessary
23
+ assets to your public folder!
24
+
22
25
  Netzke home page: http://netzke.org
23
26
  Netzke Google Groups: http://groups.google.com/group/netzke
24
27
  Netzke tutorials: http://blog.writelesscode.com
data/TODO.rdoc CHANGED
@@ -1,11 +1,8 @@
1
1
  == Priority
2
- * Make GridPanel show the mask straight after pressing "Apply"
2
+ * Commit persistence migrations in the test app
3
3
  * DataAccessor#to_array should not rescue exceptions, but rather check the availability of the attributes; `respond_to_with_basepack?` should be extended to also return true for association columns
4
4
  * GridPanel's read_only vs editable (doesn't work now) options
5
5
  * Find a way to print the grid nicely (along with the column and rows that don't fit on the screen)
6
6
 
7
7
  == Foolproof
8
8
  * Should not be possible to put the "ID" field on any place but first for grids (otherwise record ID is not correct)
9
-
10
- == Optimizations
11
- * Check persistent_config-related queries (aren't they too many?)
@@ -19,7 +19,8 @@ Scenario: Editing the record
19
19
  When I go to the UserForm test page
20
20
  And I fill in "First name:" with "Salvador"
21
21
  And I fill in "Last name:" with "Dali"
22
- And I fill in "Role name:" with "painter"
22
+ And I expand combobox "Role name"
23
+ And I select "painter" from combobox "Role name"
23
24
  And I press "Apply"
24
25
  And I go to the UserForm test page
25
26
  Then I should see "Salvador"
@@ -32,6 +32,7 @@ Scenario: Updating a record via "Edit in form"
32
32
  And I fill in "First name:" with "Maxim"
33
33
  And I fill in "Last name:" with "Osminogov"
34
34
  And I press "OK"
35
+ And I wait for the response from the server
35
36
  Then I should see "Maxim"
36
37
  And I should see "Osminogov"
37
38
  And a user should not exist with first_name: "Carlos"
@@ -43,7 +44,8 @@ Scenario: Deleting a record
43
44
  When I go to the UserGrid test page
44
45
  And I select all rows in the grid
45
46
  And I press "Delete"
46
- And I press "Yes"
47
+ Then I should see "Are you sure?"
48
+ When I press "Yes"
47
49
  Then I should see "Deleted 2 record(s)"
48
50
  Then a user should not exist with first_name: "Anton"
49
51
  And a user should not exist with first_name: "Maxim"
@@ -87,11 +89,18 @@ Scenario: Grid with strong_default_attrs
87
89
 
88
90
  @javascript
89
91
  Scenario: Grid with columns with default values
90
- Given I am on the BookGridWithDefaultValues test page
92
+ Given an author exists with last_name: "Nabokov"
93
+ And I am on the BookGridWithDefaultValues test page
94
+ When I press "Add"
95
+ Then I should see "Nabokov"
96
+ And I press "Apply"
97
+ And I wait for the response from the server
98
+ Then a book should exist with title: "Lolita", exemplars: 100, digitized: true, author: that author
99
+
91
100
  When I press "Add in form"
92
101
  And I press "OK"
93
- And I sleep 1 second
94
- Then a book should exist with title: "Lolita", exemplars: 100
102
+ And I wait for the response from the server
103
+ Then 2 books should exist with title: "Lolita", exemplars: 100, digitized: true, author: that author
95
104
 
96
105
  @javascript
97
106
  Scenario: Inline editing
@@ -99,7 +108,127 @@ Scenario: Inline editing
99
108
  When I go to the BookGrid test page
100
109
  And I edit row 1 of the grid with title: "Collector", exemplars: 200
101
110
  And I press "Apply"
102
- And I sleep 1 second
111
+ And I wait for the response from the server
103
112
  Then the grid should have 0 modified records
104
113
  And a book should exist with title: "Collector", exemplars: 200
105
114
  But a book should not exist with title: "Magus"
115
+
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
+ And I sleep 1 second
126
+ Then the grid should show 1 records
127
+
128
+ When I clear all filters in the grid
129
+ And I enable filter on column "notes" with value "'read'"
130
+ And I sleep 1 second
131
+ Then the grid should show 2 records
132
+
133
+ When I clear all filters in the grid
134
+ And I enable filter on column "digitized" with value "false"
135
+ And I sleep 1 second
136
+ Then the grid should show 1 records
137
+
138
+ When I clear all filters in the grid
139
+ And I enable filter on column "digitized" with value "true"
140
+ And I sleep 1 second
141
+ Then the grid should show 2 records
142
+
143
+ @javascript
144
+ Scenario: Inline editing of association
145
+ Given an author exists with first_name: "Vladimir", last_name: "Nabokov"
146
+ And a book exists with title: "Lolita", author: that author
147
+ And an author exists with first_name: "Herman", last_name: "Hesse"
148
+ When I go to the BookGrid test page
149
+ And I expand combobox "author__name" in row 1 of the grid
150
+ And I wait for the response from the server
151
+ And I select "Hesse, Herman" in combobox "author__name" in row 1 of the grid
152
+ And I edit row 1 of the grid with title: "Demian"
153
+ And I stop editing the grid
154
+ Then I should see "Hesse, Herman" within "#book_grid"
155
+
156
+ When I press "Apply"
157
+ And I wait for the response from the server
158
+ Then a book should exist with title: "Demian", author: that author
159
+ But a book should not exist with title: "Lolita"
160
+
161
+ @javascript
162
+ Scenario: Inline adding of records
163
+ Given an author: "Nabokov" exists with first_name: "Vladimir", last_name: "Nabokov"
164
+ And an author: "Hesse" exists with first_name: "Herman", last_name: "Hesse"
165
+
166
+ When I go to the BookGrid test page
167
+ And I press "Add"
168
+ And I expand combobox "author__name" in row 1 of the grid
169
+ And I wait for the response from the server
170
+ And I select "Hesse, Herman" in combobox "author__name" in row 1 of the grid
171
+ And I edit row 1 of the grid with title: "Demian"
172
+
173
+ And I press "Add"
174
+ And I expand combobox "author__name" in row 2 of the grid
175
+ And I wait for the response from the server
176
+ And I select "Nabokov, Vladimir" in combobox "author__name" in row 2 of the grid
177
+ And I edit row 2 of the grid with title: "Lolita"
178
+
179
+ And I stop editing the grid
180
+ And I press "Apply"
181
+ And I wait for the response from the server
182
+ Then a book should exist with title: "Lolita", author: author "Nabokov"
183
+ And a book should exist with title: "Demian", author: author "Hesse"
184
+
185
+ @javascript
186
+ Scenario: Inline adding of records in GridPanel with default values
187
+ Given an author: "Nabokov" exists with first_name: "Vladimir", last_name: "Nabokov"
188
+ And an author: "Hesse" exists with first_name: "Herman", last_name: "Hesse"
189
+
190
+ When I go to the BookGridWithDefaultValues test page
191
+ And I press "Add"
192
+ And I expand combobox "author__last_name" in row 1 of the grid
193
+ And I wait for the response from the server
194
+ And I select "Hesse" in combobox "author__last_name" in row 1 of the grid
195
+ And I edit row 1 of the grid with title: "Demian"
196
+
197
+ And I stop editing the grid
198
+ And I press "Apply"
199
+ And I wait for the response from the server
200
+ Then a book should exist with title: "Demian", author: author "Hesse"
201
+
202
+ @javascript
203
+ Scenario: Renderers for association columns should take effect
204
+ Given an author exists with first_name: "Vladimir", last_name: "Nabokov"
205
+ And a book exists with title: "Lolita", author: that author
206
+ When I go to the BookGridWithCustomColumns test page
207
+ Then I should see "NABOKOV"
208
+
209
+ @javascript
210
+ Scenario: Reloading grid data
211
+ Given a book exists with title: "Magus"
212
+ When I go to the BookGrid test page
213
+ And I reload the grid
214
+ And I reload the grid
215
+ Then I should not see "Internal Server Error"
216
+
217
+ @javascript
218
+ Scenario: Advanced search window should be hidable after loading grid panel dynamically second time
219
+ Given I am on the BookGridLoader test page
220
+ When I press "Load one"
221
+ And I wait for the response from the server
222
+ And I press "Search"
223
+ And I press "Cancel"
224
+
225
+ When I press "Load two"
226
+ And I wait for the response from the server
227
+
228
+ When I press "Load one"
229
+ And I wait for the response from the server
230
+
231
+ And I press "Search" within "#book_grid_loader__book_grid_one"
232
+ And I wait for the response from the server
233
+ And I press "Cancel" within "#book_grid_loader__book_grid_one__search_form"
234
+ Then the "book_grid_loader__book_grid_one__search_form" component should be hidden
@@ -8,7 +8,10 @@ Scenario: Grid with nested attributes
8
8
  Given an author exists with first_name: "Vlad", last_name: "Nabokoff"
9
9
  And a book exists with title: "Lola", author: that author
10
10
  When I go to the BookGridWithNestedAttributes test page
11
- And I select first row in the grid
11
+ Then I should see "Vlad" within "#book_grid_with_nested_attributes"
12
+ And I should see "Nabokoff" within "#book_grid_with_nested_attributes"
13
+
14
+ When I select first row in the grid
12
15
  And I press "Edit in form"
13
16
  And I fill in "Author first name:" with "Vladimir"
14
17
  And I fill in "Author last name:" with "Nabokov"
@@ -0,0 +1,41 @@
1
+ Feature: Paging form panel
2
+ In order to value
3
+ As a role
4
+ I want feature
5
+
6
+ @javascript
7
+ Scenario: Paging through records
8
+ Given the following books exist:
9
+ | title |
10
+ | Journey to Ixtlan |
11
+ | Lolita |
12
+ | Getting Things Done |
13
+
14
+ When I go to the BookPagingFormPanel test page
15
+ Then I should see "Journey to Ixtlan"
16
+
17
+ When I go forward one page
18
+ Then the form should show title: "Lolita"
19
+
20
+ When I go forward one page
21
+ Then the form should show title: "Getting Things Done"
22
+
23
+ @javascript
24
+ Scenario: Searching
25
+ Given the following books exist:
26
+ | title | exemplars | digitized | notes |
27
+ | Journey to Ixtlan | 10 | true | A must-read |
28
+ | Lolita | 5 | false | To read |
29
+ | Getting Things Done | 3 | true | Productivity |
30
+
31
+ When I go to the BookPagingFormPanel test page
32
+ And I press "Search"
33
+ And I wait for the response from the server
34
+ And I expand combobox "undefined_attr"
35
+ And I select "Exemplars" from combobox "undefined_attr"
36
+ And I expand combobox "exemplars_operator"
37
+ And I select "Less than" from combobox "exemplars_operator"
38
+ And I fill in "exemplars_value" with "5"
39
+ And I press "Search" within "#book_paging_form_panel__search_form"
40
+ And I wait for the response from the server
41
+ Then the form should show title: "Getting Things Done"
@@ -22,14 +22,27 @@ Feature: Search
22
22
  Then the grid should show 4 records
23
23
 
24
24
  When I press "Search"
25
- And I fill in "First name like:" with "ai"
25
+ And I wait for the response from the server
26
+ And I expand combobox "undefined_attr"
27
+ And I select "First name" from combobox "undefined_attr"
28
+ And I fill in "first_name_value" with "ai"
26
29
  And I press "Search" within "#user_grid__search_form"
27
30
  And I sleep 1 second
28
31
  Then the grid should show 2 records
29
32
 
30
- When I press "Search"
31
- And I fill in "Role name like:" with "adm"
32
- And I fill in "First name like:" with ""
33
- And I press "Search" within "#user_grid__search_form"
34
- And I sleep 1 second
35
- Then the grid should show 3 records
33
+ # When I press "Search"
34
+ # And I follow "+"
35
+ # And I expand combobox "undefined_attr"
36
+ # And I select "First name" from combobox "undefined_attr"
37
+ # And I fill in "first_name_value" with "in"
38
+ # And I press "Search" within "#user_grid__search_form"
39
+ # And I sleep 1 second
40
+ # Then the grid should show 3 records
41
+
42
+ # Search on association column not supported yet
43
+ # When I press "Search"
44
+ # And I fill in "Role name like:" with "adm"
45
+ # And I fill in "First name like:" with ""
46
+ # And I press "Search" within "#user_grid__search_form"
47
+ # And I sleep 1 second
48
+ # Then the grid should show 3 records
@@ -0,0 +1,35 @@
1
+ When /^I expand combobox "([^"]*)"$/ do |combo_label|
2
+ page.driver.browser.execute_script <<-JS
3
+ var combo = Ext.ComponentMgr.all.filter('fieldLabel', '#{combo_label}').first();
4
+ combo = combo || Ext.ComponentMgr.all.filter('name', '#{combo_label}').first();
5
+ combo.onTriggerClick();
6
+ JS
7
+
8
+ When "I wait for the response from the server"
9
+ end
10
+
11
+ When /^I select "([^"]*)" from combobox "([^"]*)"$/ do |value, combo_label|
12
+ page.driver.browser.execute_script <<-JS
13
+ var combo = Ext.ComponentMgr.all.filter('fieldLabel', '#{combo_label}').first();
14
+ combo = combo || Ext.ComponentMgr.all.filter('name', '#{combo_label}').first();
15
+ var index = combo.getStore().find('field2', '#{value}');
16
+ combo.select(index);
17
+ combo.onViewClick(false);
18
+ JS
19
+ end
20
+
21
+ Then /the form should show #{capture_fields}$/ do |fields|
22
+ fields = ActiveSupport::JSON.decode("{#{fields}}")
23
+ page.driver.browser.execute_script(<<-JS).should == true
24
+ var components = [];
25
+ for (var cmp in Netzke.page) { components.push(cmp); }
26
+ var form = Netzke.page[components[0]].getForm();
27
+ var result = true;
28
+ var values = #{fields.to_json};
29
+ for (var fieldName in values) {
30
+ result = form.findField(fieldName).getValue() === values[fieldName];
31
+ return result;
32
+ }
33
+ return result;
34
+ JS
35
+ end
@@ -12,4 +12,23 @@ end
12
12
 
13
13
  When /I sleep (\d+) seconds?/ do |arg1|
14
14
  sleep arg1.to_i
15
- end
15
+ end
16
+
17
+ When /^I wait for the response from the server$/ do
18
+ page.wait_until{ page.driver.browser.execute_script("return !Ext.Ajax.isLoading();") }
19
+ end
20
+
21
+ When /^I go forward one page$/ do
22
+ page.driver.browser.execute_script(<<-JS)
23
+ var toolbar = Ext.ComponentMgr.all.find(function(c){ return c.getXType() === 'paging'});
24
+ toolbar.moveNext();
25
+ JS
26
+ page.wait_until{ page.driver.browser.execute_script("return !Ext.Ajax.isLoading();") }
27
+ end
28
+
29
+ Then /^the "([^"]*)" component should be hidden$/ do |id|
30
+ page.driver.browser.execute_script(<<-JS).should be_false
31
+ var cmp = Ext.ComponentMgr.get("#{id}");
32
+ return cmp.isVisible();
33
+ JS
34
+ end
@@ -47,3 +47,66 @@ Then /^the grid should have (\d+) modified records$/ do |n|
47
47
  return grid.getStore().getModifiedRecords().length;
48
48
  JS
49
49
  end
50
+
51
+ When /^I enable filter on column "([^"]*)" with value "([^"]*)"$/ do |column, value|
52
+ page.driver.browser.execute_script <<-JS
53
+ var components = [];
54
+ for (var cmp in Netzke.page) { components.push(cmp); }
55
+ var grid = Netzke.page[components[0]];
56
+ var filter = grid.filters.getFilter(grid.getColumnModel().getDataIndex(grid.getColumnModel().findColumnIndex('#{column}')));
57
+ filter.setValue(#{value});
58
+ filter.setActive(true);
59
+ JS
60
+ end
61
+
62
+ When /^I clear all filters in the grid$/ do
63
+ page.driver.browser.execute_script <<-JS
64
+ var components = [];
65
+ for (var cmp in Netzke.page) { components.push(cmp); }
66
+ var grid = Netzke.page[components[0]];
67
+ grid.filters.clearFilters();
68
+ JS
69
+ end
70
+
71
+ When /^I expand combobox "([^"]*)" in row (\d+) of the grid$/ do |field, row|
72
+ page.driver.browser.execute_script <<-JS
73
+ var components = [];
74
+ for (var cmp in Netzke.page) { components.push(cmp); }
75
+ var grid = Netzke.page[components[0]];
76
+ var colId = grid.getColumnModel().findColumnIndex("#{field}");
77
+ var col = grid.getColumnModel().getColumnById(colId);
78
+ grid.startEditing(#{row.to_i - 1}, colId);
79
+ col.editor.onTriggerClick();
80
+ JS
81
+ end
82
+
83
+ When /^I select "([^"]*)" in combobox "([^"]*)" in row (\d+) of the grid$/ do |value, field, row|
84
+ page.driver.browser.execute_script <<-JS
85
+ var components = [];
86
+ for (var cmp in Netzke.page) { components.push(cmp); }
87
+ var grid = Netzke.page[components[0]];
88
+ var colId = grid.getColumnModel().findColumnIndex("#{field}");
89
+ var col = grid.getColumnModel().getColumnById(colId);
90
+ var index = col.editor.getStore().find('field2', '#{value}');
91
+ col.editor.setValue(col.editor.getStore().getAt(index).get('field1'));
92
+ col.editor.onTriggerClick();
93
+ JS
94
+ end
95
+
96
+ When /^I stop editing the grid$/ do
97
+ page.driver.browser.execute_script <<-JS
98
+ var components = [];
99
+ for (var cmp in Netzke.page) { components.push(cmp); }
100
+ var grid = Netzke.page[components[0]];
101
+ grid.stopEditing();
102
+ JS
103
+ end
104
+
105
+ When /^I reload the grid$/ do
106
+ page.driver.browser.execute_script <<-JS
107
+ var components = [];
108
+ for (var cmp in Netzke.page) { components.push(cmp); }
109
+ var grid = Netzke.page[components[0]];
110
+ grid.getStore().reload();
111
+ JS
112
+ end