netzke-basepack 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +27 -2
- data/TODO.rdoc +1 -5
- data/app/models/netzke_persistent_array_auto_model.rb +0 -1
- data/features/components_in_view.feature +11 -0
- data/features/form_panel.feature +49 -0
- data/features/grid_panel.feature +32 -1
- data/features/i18n.feature +18 -0
- data/features/nested_attributes.feature +23 -0
- data/features/search_in_grid.feature +9 -9
- data/features/simple_app.feature +10 -0
- data/features/step_definitions/grid_panel_steps.rb +23 -0
- data/features/support/paths.rb +6 -0
- data/features/support/pickle.rb +0 -1
- data/features/virtual_attributes.feature +20 -0
- data/javascripts/basepack.js +166 -243
- data/lib/netzke-basepack.rb +3 -3
- data/lib/netzke/active_record.rb +6 -7
- data/lib/netzke/active_record/attributes.rb +214 -143
- data/lib/netzke/active_record/combobox_options.rb +12 -10
- data/lib/netzke/basepack.rb +6 -3
- data/lib/netzke/basepack/accordion_panel.rb +4 -2
- data/lib/netzke/basepack/auth_app.rb +152 -0
- data/lib/netzke/basepack/basic_app.rb +2 -262
- data/lib/netzke/basepack/form_panel.rb +35 -27
- data/lib/netzke/basepack/form_panel/fields.rb +35 -17
- data/lib/netzke/basepack/form_panel/javascripts/comma_list_cbg.js +59 -0
- data/lib/netzke/basepack/form_panel/javascripts/display_mode.js +62 -0
- data/lib/netzke/basepack/form_panel/javascripts/main.js +138 -0
- data/lib/netzke/basepack/form_panel/javascripts/n_radio_group.js +25 -0
- data/lib/netzke/basepack/form_panel/services.rb +12 -9
- data/lib/netzke/basepack/grid_panel.rb +87 -53
- data/lib/netzke/basepack/grid_panel/columns.rb +60 -15
- data/lib/netzke/basepack/grid_panel/javascripts/advanced_search.js +2 -64
- data/lib/netzke/basepack/grid_panel/javascripts/edit_in_form.js +2 -2
- data/lib/netzke/basepack/grid_panel/javascripts/{pre.js → main.js} +35 -17
- data/lib/netzke/basepack/grid_panel/javascripts/misc.js +4 -0
- data/lib/netzke/basepack/grid_panel/services.rb +17 -14
- data/lib/netzke/basepack/paging_form_panel.rb +92 -0
- data/lib/netzke/basepack/simple_app.rb +71 -0
- data/lib/netzke/basepack/simple_app/javascripts/main.js +53 -0
- data/lib/netzke/basepack/{basic_app → simple_app/javascripts}/statusbar_ext.js +0 -0
- data/lib/netzke/basepack/tab_panel.rb +2 -12
- data/lib/netzke/basepack/tab_panel/javascripts/main.js +11 -0
- data/lib/netzke/basepack/version.rb +2 -2
- data/lib/netzke/basepack/window.rb +6 -7
- data/lib/netzke/basepack/wrap_lazy_loaded.rb +3 -1
- data/lib/netzke/data_accessor.rb +25 -14
- data/lib/netzke/ext.rb +1 -1
- data/locales/en.yml +22 -0
- data/netzke-basepack.gemspec +66 -12
- data/spec/active_record/attributes_spec.rb +31 -2
- data/spec/factories.rb +16 -1
- data/test/rails_app/Gemfile +2 -2
- data/test/rails_app/Gemfile.lock +76 -77
- data/test/rails_app/app/components/author_grid.rb +7 -0
- data/test/rails_app/app/components/book_form.rb +24 -0
- data/test/rails_app/app/components/book_grid.rb +6 -1
- data/test/rails_app/app/components/book_grid_with_default_values.rb +11 -0
- data/test/rails_app/app/components/book_grid_with_nested_attributes.rb +13 -0
- data/test/rails_app/app/components/book_grid_with_virtual_attributes.rb +22 -0
- data/test/rails_app/app/components/book_paging_form_panel.rb +20 -0
- data/test/rails_app/app/components/book_presentation.rb +18 -0
- data/test/rails_app/app/components/books_bound_to_author.rb +10 -0
- data/test/rails_app/app/components/form_without_model.rb +19 -0
- data/test/rails_app/app/components/lockable_book_form.rb +17 -0
- data/test/rails_app/app/components/lockable_user_form.rb +7 -0
- data/test/rails_app/app/components/simple_window.rb +10 -0
- data/test/rails_app/app/components/some_accordion_panel.rb +22 -0
- data/test/rails_app/app/components/{simple_basic_app.rb → some_auth_app.rb} +3 -3
- data/test/rails_app/app/components/some_border_layout.rb +10 -7
- data/test/rails_app/app/components/some_simple_app.rb +34 -0
- data/test/rails_app/app/components/some_tab_panel.rb +16 -11
- data/test/rails_app/app/components/user_form.rb +11 -4
- data/test/rails_app/app/components/user_grid.rb +7 -1
- data/test/rails_app/app/components/window_component_loader.rb +1 -0
- data/test/rails_app/app/controllers/application_controller.rb +6 -0
- data/test/rails_app/app/controllers/components_controller.rb +3 -3
- data/test/rails_app/app/controllers/welcome_controller.rb +2 -2
- data/test/rails_app/app/helpers/embedded_components_helper.rb +2 -0
- data/test/rails_app/app/models/address.rb +3 -0
- data/test/rails_app/app/models/author.rb +2 -0
- data/test/rails_app/app/models/book.rb +1 -0
- data/test/rails_app/app/models/user.rb +1 -2
- data/test/rails_app/app/views/components/simple_panel.html.erb +1 -0
- data/test/rails_app/app/views/layouts/nested.html.erb +5 -0
- data/test/rails_app/config/application.rb +1 -1
- data/test/rails_app/config/initializers/netzke.rb +0 -4
- data/test/rails_app/config/locales/es.yml +16 -0
- data/test/rails_app/config/routes.rb +4 -1
- data/test/rails_app/db/development_structure.sql +33 -4
- data/test/rails_app/db/migrate/20101026190021_create_books.rb +2 -0
- data/test/rails_app/db/migrate/20110101143818_create_addresses.rb +17 -0
- data/test/rails_app/db/schema.rb +33 -1
- data/test/rails_app/spec/controllers/embedded_components_controller_spec.rb +12 -0
- data/test/rails_app/spec/helpers/embedded_components_helper_spec.rb +15 -0
- data/test/rails_app/spec/models/address_spec.rb +5 -0
- data/test/rails_app/spec/views/embedded_components/index.html.erb_spec.rb +5 -0
- metadata +67 -13
- data/features/basic_app.feature +0 -12
- data/lib/netzke/active_record/association_attributes.rb +0 -102
- data/lib/netzke/basepack/form_panel/javascripts/pre.js +0 -76
- data/lib/netzke/basepack/form_panel/javascripts/xcheckbox.js +0 -82
- data/lib/netzke/basepack/grid_panel/javascript.rb +0 -69
- data/locale/en.yml +0 -16
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
# Specs in this file have access to a helper object that includes
|
4
|
+
# the EmbeddedComponentsHelper. For example:
|
5
|
+
#
|
6
|
+
# describe EmbeddedComponentsHelper do
|
7
|
+
# describe "string concat" do
|
8
|
+
# it "concats two strings with spaces" do
|
9
|
+
# helper.concat_strings("this","that").should == "this that"
|
10
|
+
# end
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
describe EmbeddedComponentsHelper do
|
14
|
+
pending "add some examples to (or delete) #{__FILE__}"
|
15
|
+
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 6
|
8
|
-
-
|
9
|
-
version: 0.6.
|
8
|
+
- 3
|
9
|
+
version: 0.6.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Sergei Kozlov
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2011-01-14 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -97,10 +97,13 @@ files:
|
|
97
97
|
- autotest/discover.rb
|
98
98
|
- config/database.yml
|
99
99
|
- features/accordion_panel.feature
|
100
|
-
- features/
|
100
|
+
- features/components_in_view.feature
|
101
101
|
- features/form_panel.feature
|
102
102
|
- features/grid_panel.feature
|
103
|
+
- features/i18n.feature
|
104
|
+
- features/nested_attributes.feature
|
103
105
|
- features/search_in_grid.feature
|
106
|
+
- features/simple_app.feature
|
104
107
|
- features/simple_panel.feature
|
105
108
|
- features/step_definitions/accordion_steps.rb
|
106
109
|
- features/step_definitions/generic_steps.rb
|
@@ -111,6 +114,7 @@ files:
|
|
111
114
|
- features/support/paths.rb
|
112
115
|
- features/support/pickle.rb
|
113
116
|
- features/tab_panel.feature
|
117
|
+
- features/virtual_attributes.feature
|
114
118
|
- features/window.feature
|
115
119
|
- from_05_to_06.rdoc
|
116
120
|
- generators/netzke_basepack/netzke_basepack_generator.rb
|
@@ -121,35 +125,41 @@ files:
|
|
121
125
|
- javascripts/basepack.js
|
122
126
|
- lib/netzke-basepack.rb
|
123
127
|
- lib/netzke/active_record.rb
|
124
|
-
- lib/netzke/active_record/association_attributes.rb
|
125
128
|
- lib/netzke/active_record/attributes.rb
|
126
129
|
- lib/netzke/active_record/combobox_options.rb
|
127
130
|
- lib/netzke/active_record/relation_extensions.rb
|
128
131
|
- lib/netzke/basepack.rb
|
129
132
|
- lib/netzke/basepack/accordion_panel.rb
|
133
|
+
- lib/netzke/basepack/auth_app.rb
|
130
134
|
- lib/netzke/basepack/basic_app.rb
|
131
|
-
- lib/netzke/basepack/basic_app/statusbar_ext.js
|
132
135
|
- lib/netzke/basepack/border_layout_panel.rb
|
133
136
|
- lib/netzke/basepack/form_panel.rb
|
134
137
|
- lib/netzke/basepack/form_panel/fields.rb
|
138
|
+
- lib/netzke/basepack/form_panel/javascripts/comma_list_cbg.js
|
139
|
+
- lib/netzke/basepack/form_panel/javascripts/display_mode.js
|
140
|
+
- lib/netzke/basepack/form_panel/javascripts/main.js
|
141
|
+
- lib/netzke/basepack/form_panel/javascripts/n_radio_group.js
|
135
142
|
- lib/netzke/basepack/form_panel/javascripts/netzkefileupload.js
|
136
|
-
- lib/netzke/basepack/form_panel/javascripts/pre.js
|
137
|
-
- lib/netzke/basepack/form_panel/javascripts/xcheckbox.js
|
138
143
|
- lib/netzke/basepack/form_panel/services.rb
|
139
144
|
- lib/netzke/basepack/grid_panel.rb
|
140
145
|
- lib/netzke/basepack/grid_panel/columns.rb
|
141
|
-
- lib/netzke/basepack/grid_panel/javascript.rb
|
142
146
|
- lib/netzke/basepack/grid_panel/javascripts/advanced_search.js
|
143
147
|
- lib/netzke/basepack/grid_panel/javascripts/edit_in_form.js
|
144
|
-
- lib/netzke/basepack/grid_panel/javascripts/
|
148
|
+
- lib/netzke/basepack/grid_panel/javascripts/main.js
|
149
|
+
- lib/netzke/basepack/grid_panel/javascripts/misc.js
|
145
150
|
- lib/netzke/basepack/grid_panel/javascripts/rows-dd.js
|
146
151
|
- lib/netzke/basepack/grid_panel/multi_edit_form.rb
|
147
152
|
- lib/netzke/basepack/grid_panel/record_form_window.rb
|
148
153
|
- lib/netzke/basepack/grid_panel/search_window.rb
|
149
154
|
- lib/netzke/basepack/grid_panel/services.rb
|
155
|
+
- lib/netzke/basepack/paging_form_panel.rb
|
150
156
|
- lib/netzke/basepack/panel.rb
|
151
157
|
- lib/netzke/basepack/search_panel.rb
|
158
|
+
- lib/netzke/basepack/simple_app.rb
|
159
|
+
- lib/netzke/basepack/simple_app/javascripts/main.js
|
160
|
+
- lib/netzke/basepack/simple_app/javascripts/statusbar_ext.js
|
152
161
|
- lib/netzke/basepack/tab_panel.rb
|
162
|
+
- lib/netzke/basepack/tab_panel/javascripts/main.js
|
153
163
|
- lib/netzke/basepack/version.rb
|
154
164
|
- lib/netzke/basepack/window.rb
|
155
165
|
- lib/netzke/basepack/wrap_lazy_loaded.rb
|
@@ -160,7 +170,7 @@ files:
|
|
160
170
|
- lib/netzke/json_array_editor.rb
|
161
171
|
- lib/netzke/masquerade_selector.rb
|
162
172
|
- lib/tasks/netzke_basepack_tasks.rake
|
163
|
-
-
|
173
|
+
- locales/en.yml
|
164
174
|
- netzke-basepack.gemspec
|
165
175
|
- spec/active_record/attributes_spec.rb
|
166
176
|
- spec/active_record/relation_extensions_spec.rb
|
@@ -183,15 +193,29 @@ files:
|
|
183
193
|
- test/rails_app/Gemfile.lock
|
184
194
|
- test/rails_app/README
|
185
195
|
- test/rails_app/Rakefile
|
196
|
+
- test/rails_app/app/components/author_grid.rb
|
197
|
+
- test/rails_app/app/components/book_form.rb
|
186
198
|
- test/rails_app/app/components/book_grid.rb
|
199
|
+
- test/rails_app/app/components/book_grid_with_default_values.rb
|
200
|
+
- test/rails_app/app/components/book_grid_with_nested_attributes.rb
|
201
|
+
- test/rails_app/app/components/book_grid_with_virtual_attributes.rb
|
202
|
+
- test/rails_app/app/components/book_paging_form_panel.rb
|
203
|
+
- test/rails_app/app/components/book_presentation.rb
|
204
|
+
- test/rails_app/app/components/books_bound_to_author.rb
|
205
|
+
- test/rails_app/app/components/form_without_model.rb
|
187
206
|
- test/rails_app/app/components/generic_user_form.rb
|
207
|
+
- test/rails_app/app/components/lockable_book_form.rb
|
208
|
+
- test/rails_app/app/components/lockable_user_form.rb
|
188
209
|
- test/rails_app/app/components/simple_accordion.rb
|
189
|
-
- test/rails_app/app/components/simple_basic_app.rb
|
190
210
|
- test/rails_app/app/components/simple_panel.rb
|
191
211
|
- test/rails_app/app/components/simple_tab_panel.rb
|
212
|
+
- test/rails_app/app/components/simple_window.rb
|
192
213
|
- test/rails_app/app/components/simple_wrapper.rb
|
214
|
+
- test/rails_app/app/components/some_accordion_panel.rb
|
215
|
+
- test/rails_app/app/components/some_auth_app.rb
|
193
216
|
- test/rails_app/app/components/some_border_layout.rb
|
194
217
|
- test/rails_app/app/components/some_search_panel.rb
|
218
|
+
- test/rails_app/app/components/some_simple_app.rb
|
195
219
|
- test/rails_app/app/components/some_tab_panel.rb
|
196
220
|
- test/rails_app/app/components/user_form.rb
|
197
221
|
- test/rails_app/app/components/user_form_with_default_fields.rb
|
@@ -202,12 +226,16 @@ files:
|
|
202
226
|
- test/rails_app/app/controllers/components_controller.rb
|
203
227
|
- test/rails_app/app/controllers/welcome_controller.rb
|
204
228
|
- test/rails_app/app/helpers/application_helper.rb
|
229
|
+
- test/rails_app/app/helpers/embedded_components_helper.rb
|
230
|
+
- test/rails_app/app/models/address.rb
|
205
231
|
- test/rails_app/app/models/author.rb
|
206
232
|
- test/rails_app/app/models/book.rb
|
207
233
|
- test/rails_app/app/models/role.rb
|
208
234
|
- test/rails_app/app/models/user.rb
|
209
235
|
- test/rails_app/app/presenters/forms/generic_user.rb
|
236
|
+
- test/rails_app/app/views/components/simple_panel.html.erb
|
210
237
|
- test/rails_app/app/views/layouts/application.html.erb
|
238
|
+
- test/rails_app/app/views/layouts/nested.html.erb
|
211
239
|
- test/rails_app/config.ru
|
212
240
|
- test/rails_app/config/application.rb
|
213
241
|
- test/rails_app/config/boot.rb
|
@@ -230,6 +258,7 @@ files:
|
|
230
258
|
- test/rails_app/db/migrate/20100914104236_create_roles.rb
|
231
259
|
- test/rails_app/db/migrate/20101026185816_create_authors.rb
|
232
260
|
- test/rails_app/db/migrate/20101026190021_create_books.rb
|
261
|
+
- test/rails_app/db/migrate/20110101143818_create_addresses.rb
|
233
262
|
- test/rails_app/db/schema.rb
|
234
263
|
- test/rails_app/db/seeds.rb
|
235
264
|
- test/rails_app/features/support/paths.rb
|
@@ -249,10 +278,14 @@ files:
|
|
249
278
|
- test/rails_app/public/robots.txt
|
250
279
|
- test/rails_app/public/stylesheets/.gitkeep
|
251
280
|
- test/rails_app/script/rails
|
281
|
+
- test/rails_app/spec/controllers/embedded_components_controller_spec.rb
|
282
|
+
- test/rails_app/spec/helpers/embedded_components_helper_spec.rb
|
283
|
+
- test/rails_app/spec/models/address_spec.rb
|
252
284
|
- test/rails_app/spec/models/author_spec.rb
|
253
285
|
- test/rails_app/spec/models/book_spec.rb
|
254
286
|
- test/rails_app/spec/models/role_spec.rb
|
255
287
|
- test/rails_app/spec/models/user_spec.rb
|
288
|
+
- test/rails_app/spec/views/embedded_components/index.html.erb_spec.rb
|
256
289
|
- test/rails_app/test/performance/browsing_test.rb
|
257
290
|
- test/rails_app/test/test_helper.rb
|
258
291
|
- test/rails_app/tmp/restart.txt
|
@@ -308,15 +341,29 @@ test_files:
|
|
308
341
|
- spec/factories.rb
|
309
342
|
- spec/spec_helper.rb
|
310
343
|
- test/console_with_fixtures.rb
|
344
|
+
- test/rails_app/app/components/author_grid.rb
|
345
|
+
- test/rails_app/app/components/book_form.rb
|
311
346
|
- test/rails_app/app/components/book_grid.rb
|
347
|
+
- test/rails_app/app/components/book_grid_with_default_values.rb
|
348
|
+
- test/rails_app/app/components/book_grid_with_nested_attributes.rb
|
349
|
+
- test/rails_app/app/components/book_grid_with_virtual_attributes.rb
|
350
|
+
- test/rails_app/app/components/book_paging_form_panel.rb
|
351
|
+
- test/rails_app/app/components/book_presentation.rb
|
352
|
+
- test/rails_app/app/components/books_bound_to_author.rb
|
353
|
+
- test/rails_app/app/components/form_without_model.rb
|
312
354
|
- test/rails_app/app/components/generic_user_form.rb
|
355
|
+
- test/rails_app/app/components/lockable_book_form.rb
|
356
|
+
- test/rails_app/app/components/lockable_user_form.rb
|
313
357
|
- test/rails_app/app/components/simple_accordion.rb
|
314
|
-
- test/rails_app/app/components/simple_basic_app.rb
|
315
358
|
- test/rails_app/app/components/simple_panel.rb
|
316
359
|
- test/rails_app/app/components/simple_tab_panel.rb
|
360
|
+
- test/rails_app/app/components/simple_window.rb
|
317
361
|
- test/rails_app/app/components/simple_wrapper.rb
|
362
|
+
- test/rails_app/app/components/some_accordion_panel.rb
|
363
|
+
- test/rails_app/app/components/some_auth_app.rb
|
318
364
|
- test/rails_app/app/components/some_border_layout.rb
|
319
365
|
- test/rails_app/app/components/some_search_panel.rb
|
366
|
+
- test/rails_app/app/components/some_simple_app.rb
|
320
367
|
- test/rails_app/app/components/some_tab_panel.rb
|
321
368
|
- test/rails_app/app/components/user_form.rb
|
322
369
|
- test/rails_app/app/components/user_form_with_default_fields.rb
|
@@ -327,6 +374,8 @@ test_files:
|
|
327
374
|
- test/rails_app/app/controllers/components_controller.rb
|
328
375
|
- test/rails_app/app/controllers/welcome_controller.rb
|
329
376
|
- test/rails_app/app/helpers/application_helper.rb
|
377
|
+
- test/rails_app/app/helpers/embedded_components_helper.rb
|
378
|
+
- test/rails_app/app/models/address.rb
|
330
379
|
- test/rails_app/app/models/author.rb
|
331
380
|
- test/rails_app/app/models/book.rb
|
332
381
|
- test/rails_app/app/models/role.rb
|
@@ -350,13 +399,18 @@ test_files:
|
|
350
399
|
- test/rails_app/db/migrate/20100914104236_create_roles.rb
|
351
400
|
- test/rails_app/db/migrate/20101026185816_create_authors.rb
|
352
401
|
- test/rails_app/db/migrate/20101026190021_create_books.rb
|
402
|
+
- test/rails_app/db/migrate/20110101143818_create_addresses.rb
|
353
403
|
- test/rails_app/db/schema.rb
|
354
404
|
- test/rails_app/db/seeds.rb
|
355
405
|
- test/rails_app/features/support/paths.rb
|
406
|
+
- test/rails_app/spec/controllers/embedded_components_controller_spec.rb
|
407
|
+
- test/rails_app/spec/helpers/embedded_components_helper_spec.rb
|
408
|
+
- test/rails_app/spec/models/address_spec.rb
|
356
409
|
- test/rails_app/spec/models/author_spec.rb
|
357
410
|
- test/rails_app/spec/models/book_spec.rb
|
358
411
|
- test/rails_app/spec/models/role_spec.rb
|
359
412
|
- test/rails_app/spec/models/user_spec.rb
|
413
|
+
- test/rails_app/spec/views/embedded_components/index.html.erb_spec.rb
|
360
414
|
- test/rails_app/test/performance/browsing_test.rb
|
361
415
|
- test/rails_app/test/test_helper.rb
|
362
416
|
- test/schema.rb
|
data/features/basic_app.feature
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
Feature: Basic application
|
2
|
-
In order to value
|
3
|
-
As a role
|
4
|
-
I want feature
|
5
|
-
|
6
|
-
@javascript
|
7
|
-
Scenario: BasicApp should load its components dynamically
|
8
|
-
Given I am on the SimpleBasicApp test page
|
9
|
-
When I press "Simple accordion"
|
10
|
-
Then I should see "Simple basic app simple accordion"
|
11
|
-
|
12
|
-
|
@@ -1,102 +0,0 @@
|
|
1
|
-
require "active_record"
|
2
|
-
|
3
|
-
module Netzke::ActiveRecord
|
4
|
-
# Provides extensions to all ActiveRecord-based classes
|
5
|
-
module AssociationAttributes
|
6
|
-
module ClassMethods
|
7
|
-
end
|
8
|
-
|
9
|
-
module InstanceMethods
|
10
|
-
# Allow nested association access (assocs separated by "." or "__"), e.g.: proxy_service.asset__gui_folder__name
|
11
|
-
# Example:
|
12
|
-
#
|
13
|
-
# Book.first.genre__name = 'Fantasy'
|
14
|
-
#
|
15
|
-
# is the same as:
|
16
|
-
#
|
17
|
-
# Book.first.genre = Genre.find_by_name('Fantasy')
|
18
|
-
#
|
19
|
-
# The result - easier forms and grids that handle nested models: simply specify column/field name as "genre__name".
|
20
|
-
def method_missing_with_basepack(method, *args, &block)
|
21
|
-
# if refering to a column, just pass it to the original method_missing
|
22
|
-
return method_missing_without_basepack(method, *args, &block) if self.class.column_names.include?(method.to_s)
|
23
|
-
|
24
|
-
split = method.to_s.split(/\.|__/)
|
25
|
-
if split.size > 1
|
26
|
-
if split.last =~ /=$/
|
27
|
-
if split.size == 2
|
28
|
-
# search for association and assign it to self
|
29
|
-
assoc = self.class.reflect_on_association(split.first.to_sym)
|
30
|
-
assoc_method = split.last.chop
|
31
|
-
if assoc
|
32
|
-
begin
|
33
|
-
assoc_instance = assoc.klass.send("find_by_#{assoc_method}", *args)
|
34
|
-
rescue NoMethodError
|
35
|
-
assoc_instance = nil
|
36
|
-
logger.debug "!!! no find_by_#{assoc_method} method for class #{assoc.klass.name}\n"
|
37
|
-
end
|
38
|
-
if (assoc_instance)
|
39
|
-
self.send("#{split.first}=", assoc_instance)
|
40
|
-
else
|
41
|
-
logger.debug "!!! Couldn't find association #{split.first} by #{assoc_method} '#{args.first}'"
|
42
|
-
end
|
43
|
-
else
|
44
|
-
method_missing_without_basepack(method, *args, &block)
|
45
|
-
end
|
46
|
-
else
|
47
|
-
method_missing_without_basepack(method, *args, &block)
|
48
|
-
end
|
49
|
-
else
|
50
|
-
res = self
|
51
|
-
split.each do |m|
|
52
|
-
if res.respond_to?(m)
|
53
|
-
res = res.send(m) unless res.nil?
|
54
|
-
else
|
55
|
-
res.nil? ? nil : method_missing_without_basepack(method, *args, &block)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
res
|
59
|
-
end
|
60
|
-
else
|
61
|
-
method_missing_without_basepack(method, *args, &block)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
# Make respond_to? return true for association assignment method, like "genre__name="
|
66
|
-
def respond_to_with_basepack?(method, include_private = false)
|
67
|
-
split = method.to_s.split(/__/)
|
68
|
-
if split.size > 1
|
69
|
-
if split.last =~ /=$/
|
70
|
-
if split.size == 2
|
71
|
-
# search for association and assign it to self
|
72
|
-
assoc = self.class.reflect_on_association(split.first.to_sym)
|
73
|
-
assoc_method = split.last.chop
|
74
|
-
if assoc
|
75
|
-
assoc.klass.respond_to?("find_by_#{assoc_method}")
|
76
|
-
else
|
77
|
-
respond_to_without_basepack?(method, include_private)
|
78
|
-
end
|
79
|
-
else
|
80
|
-
respond_to_without_basepack?(method, include_private)
|
81
|
-
end
|
82
|
-
else
|
83
|
-
# self.respond_to?(split.first) ? self.send(split.first).respond_to?(split[1..-1].join("__")) : false
|
84
|
-
respond_to_without_basepack?(method, include_private)
|
85
|
-
end
|
86
|
-
else
|
87
|
-
respond_to_without_basepack?(method, include_private)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def self.included(receiver)
|
93
|
-
receiver.extend ClassMethods
|
94
|
-
|
95
|
-
receiver.send :include, InstanceMethods
|
96
|
-
receiver.alias_method_chain :method_missing, :basepack
|
97
|
-
receiver.alias_method_chain :respond_to?, :basepack
|
98
|
-
end
|
99
|
-
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
@@ -1,76 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
Static part of FormPanel's JavaScript class.
|
3
|
-
*/
|
4
|
-
Netzke.pre.FormPanel = Ext.extend(Ext.form.FormPanel, {
|
5
|
-
bodyStyle : 'padding:5px 5px 0',
|
6
|
-
autoScroll : true,
|
7
|
-
labelWidth : 150,
|
8
|
-
|
9
|
-
defaults : {
|
10
|
-
anchor : '-20', // to leave some space for the scrollbar
|
11
|
-
listeners : {
|
12
|
-
// On "return" key, submit the form
|
13
|
-
specialkey : {
|
14
|
-
fn : function(field, event){
|
15
|
-
if (event.getKey() == 13) this.ownerCt.onApply();
|
16
|
-
}
|
17
|
-
}
|
18
|
-
}
|
19
|
-
},
|
20
|
-
|
21
|
-
initComponent : function(){
|
22
|
-
this.recordFields = []; // Record
|
23
|
-
this.recordIndex = 0;
|
24
|
-
|
25
|
-
var Record = Ext.data.Record.create(this.recordFields);
|
26
|
-
this.reader = new Ext.data.RecordArrayReader({root:"data"}, Record);
|
27
|
-
|
28
|
-
// Now let Ext.form.FormPanel do the rest
|
29
|
-
Netzke.pre.FormPanel.superclass.initComponent.call(this);
|
30
|
-
|
31
|
-
// Apply event
|
32
|
-
this.addEvents('apply');
|
33
|
-
},
|
34
|
-
|
35
|
-
onApply : function() {
|
36
|
-
if (this.fireEvent('apply', this)) {
|
37
|
-
var values = this.getForm().getValues();
|
38
|
-
|
39
|
-
// do not send values from disabled fields and empty values
|
40
|
-
for (var fieldName in values) {
|
41
|
-
var field = this.getForm().findField(fieldName);
|
42
|
-
if (!field || field.disabled) delete values[fieldName];
|
43
|
-
}
|
44
|
-
|
45
|
-
if (this.fileUpload) {
|
46
|
-
// Not a Netzke's standard endpoint call, because the form is multipart
|
47
|
-
this.getForm().submit({
|
48
|
-
url: this.endpointUrl("netzke_submit"),
|
49
|
-
params: {
|
50
|
-
data: Ext.encode(values)
|
51
|
-
},
|
52
|
-
failure: function(form, action){
|
53
|
-
// It will always be failure, as we don't play along with the Ext success indication (not returning {success: true})
|
54
|
-
this.bulkExecute(Ext.decode(action.response.responseText));
|
55
|
-
this.fireEvent('submitsuccess');
|
56
|
-
},
|
57
|
-
scope: this
|
58
|
-
});
|
59
|
-
} else {
|
60
|
-
// Submit the data and process the result
|
61
|
-
this.netzkeSubmit(Ext.apply((this.baseParams || {}), {data:Ext.encode(values)}), function(result){
|
62
|
-
if (result === "ok") {this.fireEvent("submitsuccess")};
|
63
|
-
}, this);
|
64
|
-
}
|
65
|
-
}
|
66
|
-
},
|
67
|
-
|
68
|
-
setFormValues : function(values){
|
69
|
-
var normValues = {};
|
70
|
-
for (var key in values) {
|
71
|
-
normValues[key.underscore()] = values[key];
|
72
|
-
}
|
73
|
-
this.getForm().setValues(normValues);
|
74
|
-
}
|
75
|
-
|
76
|
-
});
|