netzke-basepack 0.7.7 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. data/.travis.yml +15 -10
  2. data/{CHANGELOG.rdoc → CHANGELOG.md} +146 -110
  3. data/LICENSE +7 -1
  4. data/README.md +47 -56
  5. data/Rakefile +5 -5
  6. data/config/before-travis.sh +10 -0
  7. data/javascripts/basepack.js +0 -130
  8. data/javascripts/netzkeremotecombo.js +59 -0
  9. data/lib/netzke/basepack.rb +9 -14
  10. data/lib/netzke/basepack/accordion.rb +45 -0
  11. data/lib/netzke/basepack/active_record.rb +12 -0
  12. data/lib/netzke/basepack/active_record/relation_extensions.rb +27 -0
  13. data/lib/netzke/basepack/columns.rb +309 -0
  14. data/lib/netzke/basepack/data_accessor.rb +22 -12
  15. data/lib/netzke/basepack/data_adapters/abstract_adapter.rb +75 -11
  16. data/lib/netzke/basepack/data_adapters/active_record_adapter.rb +154 -49
  17. data/lib/netzke/basepack/fields.rb +162 -0
  18. data/lib/netzke/basepack/form.rb +136 -0
  19. data/lib/netzke/basepack/{form_panel → form}/javascripts/comma_list_cbg.js +0 -1
  20. data/lib/netzke/basepack/{form_panel/javascripts/form_panel.js → form/javascripts/form.js} +20 -26
  21. data/lib/netzke/basepack/{form_panel → form}/javascripts/n_radio_group.js +0 -1
  22. data/lib/netzke/basepack/{form_panel → form}/javascripts/readonly_mode.js +0 -0
  23. data/lib/netzke/basepack/form/services.rb +115 -0
  24. data/lib/netzke/basepack/{form_panel → form}/stylesheets/readonly_mode.css +0 -0
  25. data/lib/netzke/basepack/grid.rb +355 -0
  26. data/lib/netzke/basepack/{grid_panel → grid}/javascripts/advanced_search.js +1 -1
  27. data/lib/netzke/basepack/{grid_panel → grid}/javascripts/check_column_fix.js +0 -0
  28. data/lib/netzke/basepack/{grid_panel → grid}/javascripts/edit_in_form.js +3 -3
  29. data/lib/netzke/basepack/{grid_panel → grid}/javascripts/event_handling.js +5 -2
  30. data/lib/netzke/basepack/{grid_panel/javascripts/grid_panel.js → grid/javascripts/grid.js} +120 -132
  31. data/lib/netzke/basepack/{grid_panel → grid}/javascripts/misc.js +0 -0
  32. data/lib/netzke/basepack/grid/services.rb +216 -0
  33. data/lib/netzke/basepack/item_persistence.rb +44 -0
  34. data/lib/netzke/basepack/item_persistence/events_plugin.rb +47 -0
  35. data/lib/netzke/basepack/{paging_form_panel.rb → paging_form.rb} +24 -30
  36. data/lib/netzke/basepack/{paging_form_panel/javascripts/paging_form_panel.js → paging_form/javascripts/paging_form.js} +2 -4
  37. data/lib/netzke/basepack/query_builder.rb +44 -73
  38. data/lib/netzke/basepack/query_builder/javascripts/query_builder.js +16 -2
  39. data/lib/netzke/basepack/record_form_window.rb +67 -0
  40. data/lib/netzke/basepack/search_panel.rb +22 -24
  41. data/lib/netzke/basepack/search_panel/javascripts/condition_field.js +2 -2
  42. data/lib/netzke/basepack/search_window.rb +47 -53
  43. data/lib/netzke/basepack/simple_app.rb +10 -13
  44. data/lib/netzke/basepack/simple_app/javascripts/simple_app.js +2 -8
  45. data/lib/netzke/basepack/tab_panel.rb +5 -4
  46. data/lib/netzke/basepack/tab_panel/javascripts/tab_panel.js +5 -5
  47. data/lib/netzke/basepack/version.rb +2 -2
  48. data/lib/netzke/basepack/viewport.rb +16 -0
  49. data/lib/netzke/basepack/window.rb +27 -18
  50. data/lib/netzke/basepack/window/javascripts/window.js +7 -1
  51. data/lib/netzke/basepack/wrap_lazy_loaded.rb +18 -18
  52. data/locales/en.yml +40 -24
  53. data/netzke-basepack.gemspec +51 -82
  54. data/stylesheets/basepack.css +0 -41
  55. data/test/basepack_test_app/Gemfile +9 -46
  56. data/test/basepack_test_app/Gemfile.lock +61 -96
  57. data/test/basepack_test_app/app/components/author_form.rb +8 -5
  58. data/test/basepack_test_app/app/components/author_grid.rb +2 -2
  59. data/test/basepack_test_app/app/components/book_form.rb +34 -31
  60. data/test/basepack_test_app/app/components/book_form_with_defaults.rb +6 -7
  61. data/test/basepack_test_app/app/components/book_form_with_file_upload.rb +10 -0
  62. data/test/basepack_test_app/app/components/book_form_with_nested_attributes.rb +5 -6
  63. data/test/basepack_test_app/app/components/book_grid.rb +19 -8
  64. data/test/basepack_test_app/app/components/book_grid_filtering.rb +4 -7
  65. data/test/basepack_test_app/app/components/book_grid_loader.rb +28 -15
  66. data/test/basepack_test_app/app/components/book_grid_with_custom_columns.rb +45 -21
  67. data/test/basepack_test_app/app/components/book_grid_with_default_values.rb +26 -8
  68. data/test/basepack_test_app/app/components/book_grid_with_excluded_columns.rb +11 -0
  69. data/test/basepack_test_app/app/components/book_grid_with_extra_feedback.rb +2 -2
  70. data/test/basepack_test_app/app/components/book_grid_with_extra_filters.rb +7 -6
  71. data/test/basepack_test_app/app/components/book_grid_with_mass_assignment_security.rb +9 -0
  72. data/test/basepack_test_app/app/components/book_grid_with_nested_attributes.rb +9 -9
  73. data/test/basepack_test_app/app/components/book_grid_with_overridden_columns.rb +5 -3
  74. data/test/basepack_test_app/app/components/book_grid_with_paging.rb +6 -8
  75. data/test/basepack_test_app/app/components/book_grid_with_persistence.rb +6 -4
  76. data/test/basepack_test_app/app/components/book_grid_with_scope.rb +6 -0
  77. data/test/basepack_test_app/app/components/book_grid_with_scoped_authors.rb +10 -7
  78. data/test/basepack_test_app/app/components/book_grid_with_virtual_attributes.rb +21 -13
  79. data/test/basepack_test_app/app/components/book_paging_form.rb +21 -0
  80. data/test/basepack_test_app/app/components/book_query_builder.rb +7 -6
  81. data/test/basepack_test_app/app/components/book_with_custom_primary_key_grid.rb +6 -7
  82. data/test/basepack_test_app/app/components/books_bound_to_author.rb +9 -7
  83. data/test/basepack_test_app/app/components/border_layout_panel_with_persistence.rb +12 -0
  84. data/test/basepack_test_app/app/components/double_book_grid.rb +19 -14
  85. data/test/basepack_test_app/app/components/form_without_model.rb +15 -16
  86. data/test/basepack_test_app/app/components/grid_with_initial_sorting.rb +7 -0
  87. data/test/basepack_test_app/app/components/grid_with_inline_data.rb +7 -0
  88. data/test/basepack_test_app/app/components/paging_form_with_search.rb +2 -2
  89. data/test/basepack_test_app/app/components/panel_with_persistent_regions.rb +35 -0
  90. data/test/basepack_test_app/app/components/query_builder.rb +7 -0
  91. data/test/basepack_test_app/app/components/simple_panel.rb +16 -11
  92. data/test/basepack_test_app/app/components/simple_window.rb +7 -6
  93. data/test/basepack_test_app/app/components/some_accordion.rb +18 -0
  94. data/test/basepack_test_app/app/components/some_auth_app.rb +5 -5
  95. data/test/basepack_test_app/app/components/some_border_layout.rb +20 -20
  96. data/test/basepack_test_app/app/components/some_search_panel.rb +6 -0
  97. data/test/basepack_test_app/app/components/some_simple_app.rb +30 -16
  98. data/test/basepack_test_app/app/components/some_tab_panel.rb +18 -15
  99. data/test/basepack_test_app/app/components/user_form.rb +18 -16
  100. data/test/basepack_test_app/app/components/user_form_with_default_fields.rb +5 -6
  101. data/test/basepack_test_app/app/components/user_grid.rb +11 -6
  102. data/test/basepack_test_app/app/components/user_grid_with_customized_form_fields.rb +5 -3
  103. data/test/basepack_test_app/app/components/window_component_loader.rb +25 -21
  104. data/test/basepack_test_app/app/models/address.rb +0 -26
  105. data/test/basepack_test_app/app/models/author.rb +0 -31
  106. data/test/basepack_test_app/app/models/book.rb +1 -42
  107. data/test/basepack_test_app/app/models/book_with_custom_primary_key.rb +1 -23
  108. data/test/basepack_test_app/app/models/role.rb +0 -21
  109. data/test/basepack_test_app/app/models/user.rb +0 -24
  110. data/test/basepack_test_app/app/views/layouts/components.html.erb +1 -1
  111. data/test/basepack_test_app/config/application.rb +1 -1
  112. data/test/basepack_test_app/config/database.yml.travis +2 -6
  113. data/test/basepack_test_app/config/initializers/netzke.rb +1 -6
  114. data/test/basepack_test_app/db/schema.rb +14 -14
  115. data/test/basepack_test_app/features/accordion_panel.feature +2 -2
  116. data/test/basepack_test_app/features/form_panel.feature +7 -7
  117. data/test/basepack_test_app/features/grid_panel.feature +93 -39
  118. data/test/basepack_test_app/features/grid_panel_with_custom_primary_key.feature +2 -1
  119. data/test/basepack_test_app/features/grid_sorting.feature +30 -6
  120. data/test/basepack_test_app/features/paging_form_panel.feature +7 -7
  121. data/test/basepack_test_app/features/persistent_regions.feature +30 -0
  122. data/test/basepack_test_app/features/search_in_grid.feature +5 -5
  123. data/test/basepack_test_app/features/simple_app.feature +6 -7
  124. data/test/basepack_test_app/features/step_definitions/form_panel_steps.rb +1 -1
  125. data/test/basepack_test_app/features/step_definitions/generic_steps.rb +109 -4
  126. data/test/basepack_test_app/features/step_definitions/grid_panel_steps.rb +8 -10
  127. data/test/basepack_test_app/features/step_definitions/window_steps.rb +27 -0
  128. data/test/basepack_test_app/features/tab_panel.feature +1 -1
  129. data/test/basepack_test_app/features/window.feature +17 -0
  130. data/test/unit/accordion_panel_test.rb +2 -2
  131. data/test/unit/grid_panel_test.rb +4 -4
  132. metadata +57 -83
  133. data/TODO.rdoc +0 -8
  134. data/lib/generators/netzke/basepack_generator.rb +0 -10
  135. data/lib/generators/netzke/templates/assets/ts-checkbox.gif +0 -0
  136. data/lib/generators/netzke/templates/create_netzke_field_lists.rb +0 -18
  137. data/lib/netzke/active_record.rb +0 -20
  138. data/lib/netzke/active_record/attributes.rb +0 -259
  139. data/lib/netzke/active_record/combobox_options.rb +0 -16
  140. data/lib/netzke/active_record/relation_extensions.rb +0 -37
  141. data/lib/netzke/basepack/accordion_panel.rb +0 -39
  142. data/lib/netzke/basepack/action_column.rb +0 -68
  143. data/lib/netzke/basepack/action_column/javascripts/action_column.js +0 -61
  144. data/lib/netzke/basepack/auth_app.rb +0 -159
  145. data/lib/netzke/basepack/basic_app.rb +0 -7
  146. data/lib/netzke/basepack/border_layout_panel.rb +0 -53
  147. data/lib/netzke/basepack/border_layout_panel/javascripts/border_layout_panel.js +0 -40
  148. data/lib/netzke/basepack/data_adapters/data_mapper_adapter.rb +0 -264
  149. data/lib/netzke/basepack/data_adapters/sequel_adapter.rb +0 -260
  150. data/lib/netzke/basepack/form_panel.rb +0 -144
  151. data/lib/netzke/basepack/form_panel/fields.rb +0 -208
  152. data/lib/netzke/basepack/form_panel/javascripts/misc.js +0 -4
  153. data/lib/netzke/basepack/form_panel/services.rb +0 -142
  154. data/lib/netzke/basepack/grid_panel.rb +0 -441
  155. data/lib/netzke/basepack/grid_panel/columns.rb +0 -400
  156. data/lib/netzke/basepack/grid_panel/javascripts/rows-dd.js +0 -281
  157. data/lib/netzke/basepack/grid_panel/record_form_window.rb +0 -41
  158. data/lib/netzke/basepack/grid_panel/services.rb +0 -235
  159. data/lib/netzke/basepack/panel.rb +0 -11
  160. data/lib/netzke/basepack/wrapper.rb +0 -28
  161. data/lib/netzke/data_mapper.rb +0 -18
  162. data/lib/netzke/data_mapper/attributes.rb +0 -273
  163. data/lib/netzke/data_mapper/combobox_options.rb +0 -11
  164. data/lib/netzke/data_mapper/relation_extensions.rb +0 -38
  165. data/lib/netzke/sequel.rb +0 -18
  166. data/lib/netzke/sequel/attributes.rb +0 -274
  167. data/lib/netzke/sequel/combobox_options.rb +0 -10
  168. data/lib/netzke/sequel/relation_extensions.rb +0 -40
  169. data/locales/zh-cn.yml +0 -79
  170. data/test/basepack_test_app/app/components/book_form_with_custom_fields.rb +0 -21
  171. data/test/basepack_test_app/app/components/book_grid_with_column_actions.rb +0 -15
  172. data/test/basepack_test_app/app/components/book_grid_with_defaults.rb +0 -6
  173. data/test/basepack_test_app/app/components/book_paging_form_panel.rb +0 -22
  174. data/test/basepack_test_app/app/components/generic_user_form.rb +0 -12
  175. data/test/basepack_test_app/app/components/simple_accordion.rb +0 -11
  176. data/test/basepack_test_app/app/components/simple_tab_panel.rb +0 -11
  177. data/test/basepack_test_app/app/components/simple_wrapper.rb +0 -7
  178. data/test/basepack_test_app/app/components/some_accordion_panel.rb +0 -22
  179. data/test/basepack_test_app/app/presenters/forms/generic_user.rb +0 -6
  180. data/test/basepack_test_app/app/views/components/loadable_window.html.erb +0 -9
  181. data/test/basepack_test_app/app/views/components/simple_panel.html.erb +0 -1
  182. data/test/basepack_test_app/features/components_in_view.feature +0 -11
  183. data/test/basepack_test_app/features/simple_panel.feature +0 -11
  184. data/test/basepack_test_app/features/validations_in_grid.feature +0 -13
  185. data/test/basepack_test_app/features/virtual_attributes.feature +0 -16
  186. data/test/basepack_test_app/spec/components/form_panel_spec.rb +0 -53
  187. data/test/basepack_test_app/spec/components/grid_panel_spec.rb +0 -10
  188. data/test/basepack_test_app/spec/data_adapter/adapter_spec.rb +0 -68
  189. data/test/basepack_test_app/spec/data_adapter/attributes_spec.rb +0 -56
  190. data/test/basepack_test_app/spec/data_adapter/relation_extensions_spec.rb +0 -125
  191. data/test/basepack_test_app/spec/factories.rb +0 -28
  192. data/test/basepack_test_app/spec/spec_helper.rb +0 -39
@@ -1,24 +1,37 @@
1
1
  class BookGridLoader < Netzke::Base
2
- js_property :layout, :fit
2
+ component :book_grid_one do |c|
3
+ c.klass = Netzke::Basepack::Grid
4
+ c.model = "Book"
5
+ c.title = "One"
6
+ end
3
7
 
4
- component :book_grid_one, :class_name => "Netzke::Basepack::GridPanel", :model => "Book", :lazy_loading => true
5
- component :book_grid_two, :class_name => "Netzke::Basepack::GridPanel", :model => "Book", :lazy_loading => true
8
+ component :book_grid_two do |c|
9
+ c.klass = Netzke::Basepack::Grid
10
+ c.model = "Book"
11
+ c.title = "Two"
12
+ end
6
13
 
7
14
  action :load_one
8
15
  action :load_two
9
16
 
10
- js_method :on_load_one, <<-JS
11
- function(){
12
- this.loadNetzkeComponent({name: 'book_grid_one', container: this.id});
13
- }
14
- JS
17
+ js_configure do |c|
18
+ c.layout = :fit
15
19
 
16
- js_method :on_load_two, <<-JS
17
- function(){
18
- this.loadNetzkeComponent({name: 'book_grid_two', container: this.id});
19
- }
20
- JS
20
+ c.on_load_one = <<-JS
21
+ function(){
22
+ this.netzkeLoadComponent('book_grid_one');
23
+ }
24
+ JS
21
25
 
22
- js_property :bbar, [:load_one.action, :load_two.action]
26
+ c.on_load_two = <<-JS
27
+ function(){
28
+ this.netzkeLoadComponent('book_grid_two');
29
+ }
30
+ JS
31
+ end
23
32
 
24
- end
33
+ def configure(c)
34
+ super
35
+ c.bbar = [:load_one, :load_two]
36
+ end
37
+ end
@@ -1,27 +1,51 @@
1
- class BookGridWithCustomColumns < Netzke::Basepack::GridPanel
2
- js_property :title, "Books"
3
-
4
- model "Book"
5
-
6
- column :author__first_name, :renderer => :my_renderer
7
- column :author__last_name, :renderer => :uppercase
8
- column :author__name, :flex => 1, :text => "Author"
9
- column :title, :flex => 1
10
- column :digitized
11
- column :rating,
12
- :editor => {
1
+ class BookGridWithCustomColumns < Netzke::Basepack::Grid
2
+ column :author__first_name do |c|
3
+ c.renderer = :my_renderer
4
+ end
5
+
6
+ column :author__last_name do |c|
7
+ c.renderer = :uppercase
8
+ end
9
+
10
+ column :author_name do |c|
11
+ c.flex = 1
12
+ c.text = "Author"
13
+ end
14
+
15
+ column :title do |c|
16
+ c.flex = 1
17
+ end
18
+
19
+ column :extra_column do |c|
20
+ c.text = "Extra"
21
+ end
22
+
23
+ column :rating do |c|
24
+ c.editor = {
13
25
  :trigger_action => :all,
14
26
  :xtype => :combo,
15
27
  :store => [[1, "Good"], [2, "Average"], [3, "Poor"]]
16
- },
17
- :renderer => "function(v){return ['', 'Good', 'Average', 'Poor'][v];}"
18
- column :exemplars
19
- column :updated_at
20
-
21
- js_method :my_renderer, <<-JS
22
- function(value){
23
- return value ? "*" + value + "*" : "";
24
28
  }
25
- JS
26
29
 
30
+ c.renderer = "function(v){return ['', 'Good', 'Average', 'Poor'][v];}"
31
+ end
32
+
33
+ def configure(c)
34
+ c.model = "Book"
35
+ c.columns = [ :author__first_name, :author__last_name, :author__name, :title, :digitized, :rating, :exemplars, :updated_at ]
36
+ super
37
+ end
38
+
39
+ # This way we'll always have the extra_column, independent of the columns provided in the configuration
40
+ def columns
41
+ super + [:extra_column]
42
+ end
43
+
44
+ js_configure do |c|
45
+ c.my_renderer = <<-JS
46
+ function(value){
47
+ return value ? "*" + value + "*" : "";
48
+ }
49
+ JS
50
+ end
27
51
  end
@@ -1,9 +1,27 @@
1
- class BookGridWithDefaultValues < Netzke::Basepack::GridPanel
2
- model "Book"
3
- js_property :title, "Books"
4
-
5
- column :title, :default_value => "Lolita"
6
- column :author__last_name, :default_value => Author.first.id
7
- column :exemplars, :default_value => 100
8
- column :digitized, :default_value => true
1
+ class BookGridWithDefaultValues < Netzke::Basepack::Grid
2
+ def configure(c)
3
+ c.model = "Book"
4
+ c.title = "Books"
5
+ super
6
+ end
7
+
8
+ column :title do |c|
9
+ c.default_value = "Lolita"
10
+ end
11
+
12
+ column :author__last_name do |c|
13
+ c.default_value = Author.first.id
14
+ end
15
+
16
+ column :exemplars do |c|
17
+ c.default_value = 100
18
+ end
19
+
20
+ column :digitized do |c|
21
+ c.default_value = true
22
+ end
23
+
24
+ def columns
25
+ [ :title, :author__last_name, :exemplars, :digitized ]
26
+ end
9
27
  end
@@ -0,0 +1,11 @@
1
+ class BookGridWithExcludedColumns < Netzke::Basepack::Grid
2
+ model "Book"
3
+
4
+ column :notes do |c|
5
+ c.excluded = true
6
+ end
7
+
8
+ column :exemplars do |c|
9
+ c.excluded = true
10
+ end
11
+ end
@@ -1,8 +1,8 @@
1
- class BookGridWithExtraFeedback < Netzke::Basepack::GridPanel
1
+ class BookGridWithExtraFeedback < Netzke::Basepack::Grid
2
2
  model "Book"
3
3
 
4
4
  # Override the get_data endpoint
5
5
  def get_data_endpoint(params)
6
6
  super.merge(:netzke_feedback => "Data loaded!")
7
7
  end
8
- end
8
+ end
@@ -1,14 +1,15 @@
1
1
  # This requires a patch to Ext examples/ux/grid
2
- class BookGridWithExtraFilters < Netzke::Basepack::GridPanel
2
+ # NOTE: not used!
3
+ class BookGridWithExtraFilters < Netzke::Basepack::Grid
4
+ model "Book"
5
+
3
6
  js_include Netzke::Core.ext_path.join("examples", "ux/grid/filter/EneFilter.js")
4
7
  js_include Netzke::Core.ext_path.join("examples", "ux/grid/menu/EneMenu.js")
5
8
 
6
9
  Netzke::Core.external_ext_css << "#{Netzke::Core.ext_uri}/examples/ux/grid/css/EneMenu"
7
10
 
8
- def default_config
9
- super.merge(
10
- :model => "Book",
11
- :columns => [{:name => :title, :filter => {:type => :ene}}, :exemplars, :digitized, :notes]
12
- )
11
+ def configure(c)
12
+ super
13
+ c.columns = [{:name => :title, :filter => {:type => :ene}}, :exemplars, :digitized, :notes]
13
14
  end
14
15
  end
@@ -0,0 +1,9 @@
1
+ class BookGridWithMassAssignmentSecurity < Netzke::Basepack::Grid
2
+ def configure(c)
3
+ c.model = "Book"
4
+ # Only allow assigning those attributes that are accessible for the :user role in the Book model
5
+ c.role = :user
6
+
7
+ super
8
+ end
9
+ end
@@ -1,13 +1,13 @@
1
- class BookGridWithNestedAttributes < Netzke::Basepack::GridPanel
2
- def configuration
3
- super.merge(
4
- :model => "Book",
5
- :columns => [:title, {:name => :author__first_name, :nested_attribute => true}, {:name => :author__last_name, :nested_attribute => true}]
6
- )
1
+ class BookGridWithNestedAttributes < Netzke::Basepack::Grid
2
+ def configure(c)
3
+ c.columns = [:title, {:name => :author__first_name, :nested_attribute => true}, {:name => :author__last_name, :nested_attribute => true}]
4
+ c.model = "Book"
5
+ super
7
6
  end
8
7
 
9
- def default_fields_for_forms
10
- [{:name => :title}, {:name => :author__first_name, :nested_attribute => true}, {:name => :author__last_name, :nested_attribute => true}]
8
+ # Override edit_window component in order to provide a custom list of fields for the form
9
+ def edit_window_component(c)
10
+ super
11
+ c.form_config.items = [{:name => :title}, {:name => :author__first_name, :nested_attribute => true}, {:name => :author__last_name, :nested_attribute => true}]
11
12
  end
12
-
13
13
  end
@@ -1,8 +1,10 @@
1
- class BookGridWithOverriddenColumns < Netzke::Basepack::GridPanel
1
+ class BookGridWithOverriddenColumns < Netzke::Basepack::Grid
2
2
  model "Book"
3
3
 
4
4
  # First way to override a column
5
- override_column :title, :renderer => "uppercase"
5
+ column :title do |c|
6
+ c.renderer = "uppercase"
7
+ end
6
8
 
7
9
  # Second way to override a column
8
10
  # def default_config
@@ -12,4 +14,4 @@ class BookGridWithOverriddenColumns < Netzke::Basepack::GridPanel
12
14
  # }
13
15
  # end
14
16
  # end
15
- end
17
+ end
@@ -1,10 +1,8 @@
1
- class BookGridWithPaging < Netzke::Basepack::GridPanel
2
- js_property :title, "Books with paging"
3
-
4
- def default_config
5
- super.merge(
6
- :model => "Book",
7
- :rows_per_page => 2
8
- )
1
+ class BookGridWithPaging < Netzke::Basepack::Grid
2
+ def configure(c)
3
+ c.model = "Book"
4
+ c.title = "Books with paging"
5
+ c.rows_per_page = 2
6
+ super
9
7
  end
10
8
  end
@@ -1,8 +1,10 @@
1
1
  class BookGridWithPersistence < BookGrid
2
+ column :author__name do |c|
3
+ c.excluded = true
4
+ end
2
5
 
3
- override_column :author__name, :included => false
4
-
5
- def default_config
6
- super.merge :persistence => true
6
+ def configure(c)
7
+ c.persistence = true
8
+ super
7
9
  end
8
10
  end
@@ -0,0 +1,6 @@
1
+ class BookGridWithScope < BookGrid
2
+ def configure(c)
3
+ super
4
+ c.scope = lambda {|r| r.where(author_id: Author.first.try(:id))}
5
+ end
6
+ end
@@ -1,8 +1,11 @@
1
- class BookGridWithScopedAuthors < Netzke::Basepack::GridPanel
2
- def configuration
3
- super.tap do |c|
4
- c[:model] = "Book"
5
- c[:columns] = [:title, {:name => :author__first_name, :scope => lambda{ |r| r.where(:first_name.matches => "%tom%") }}]
6
- end
1
+ # NOTE: not used
2
+ class BookGridWithScopedAuthors < Netzke::Basepack::Grid
3
+
4
+ model "Book"
5
+
6
+ def configure(c)
7
+ super
8
+ c.columns = [:title, {:name => :author__first_name, :scope => lambda{ |r| r.where("first_name LIKE ?", "%tom%")}}]
7
9
  end
8
- end
10
+
11
+ end
@@ -1,21 +1,29 @@
1
- class BookGridWithVirtualAttributes < Netzke::Basepack::GridPanel
2
- js_property :title, "Books"
3
-
1
+ # This has been excluded from tests in 0-8. In 0-8 the values in the association columns/fields are passed as integers (id of associated record), not as string. So, the author_first_name_setter won't work as planned here.
2
+ class BookGridWithVirtualAttributes < Netzke::Basepack::Grid
4
3
  include Extras::BookPresentation
5
4
 
6
- def default_config
7
- super.merge(
8
- :model => "Book",
9
- :columns => default_fields_for_forms
10
- )
5
+ model "Book"
6
+
7
+ def columns
8
+ custom_fields
9
+ end
10
+
11
+ component :add_window do |c|
12
+ super(c)
13
+ c.form_config.items = custom_fields
14
+ end
15
+
16
+ component :edit_window do |c|
17
+ super(c)
18
+ c.form_config.items = custom_fields
11
19
  end
12
20
 
13
- def default_fields_for_forms
21
+ def custom_fields
14
22
  [
15
- {:name => :title},
16
- {:name => :author__first_name, :setter => author_first_name_setter},
17
- {:name => :exemplars},
18
- {:name => :in_abundance, :getter => in_abundance_getter}
23
+ :title,
24
+ {:name => "author__first_name", :setter => author_first_name_setter},
25
+ :exemplars,
26
+ {:name => "in_abundance", :getter => in_abundance_getter}
19
27
  ]
20
28
  end
21
29
  end
@@ -0,0 +1,21 @@
1
+ class BookPagingForm < Netzke::Basepack::PagingForm
2
+ def configure(c)
3
+ c.title = "Digitized books"
4
+ c.model = "Book"
5
+ c.record = Book.first
6
+ # :scope => {:digitized => true},
7
+ c.mode = :lockable
8
+ c.items = [{:layout => :hbox, :label_align => :top, :border => false, :defaults => {:border => false}, :items => [{
9
+ :flex => 2,
10
+ :layout => :anchor,
11
+ :defaults => {:anchor => "-8"},
12
+ :items => [:title, :notes, :digitized, :created_at, :updated_at, :last_read_at]
13
+ },{
14
+ :flex => 1,
15
+ :layout => :anchor,
16
+ :defaults => {:anchor => "-8"},
17
+ :items => [:author__name, {:name => :author__first_name, :read_only => true}, :exemplars, :published_on]
18
+ }]}]
19
+ super
20
+ end
21
+ end
@@ -1,8 +1,9 @@
1
1
  class BookQueryBuilder < Netzke::Basepack::QueryBuilder
2
- def default_config
3
- super.tap do |s|
4
- s[:model] = "Book"
5
- s[:auto_scroll] = true
6
- end
2
+ def configure(c)
3
+ super
4
+
5
+ c.model = "Book"
6
+ c.auto_scroll = true
7
+ c.fields = []
7
8
  end
8
- end
9
+ end
@@ -1,10 +1,9 @@
1
- class BookWithCustomPrimaryKeyGrid < Netzke::Basepack::GridPanel
1
+ class BookWithCustomPrimaryKeyGrid < Netzke::Basepack::Grid
2
2
 
3
- js_property :title, "Books (model with non-standard id)"
4
-
5
- def default_config
6
- super.merge(
7
- :model => "BookWithCustomPrimaryKey"
8
- )
3
+ def configure(c)
4
+ c.title = "Books (model with non-standard id)"
5
+ c.model = "BookWithCustomPrimaryKey"
6
+ super
9
7
  end
8
+
10
9
  end
@@ -1,10 +1,12 @@
1
1
  # Grid with books that belong to the first author in the DB (assumes the existence of at least 1 author)
2
- class BooksBoundToAuthor < Netzke::Basepack::GridPanel
3
- def default_config
4
- super.merge(
5
- :model => "Book",
6
- :scope => {:author_id => Author.first.id},
7
- :strong_default_attrs => {:author_id => Author.first.id}
8
- )
2
+ class BooksBoundToAuthor < Netzke::Basepack::Grid
3
+
4
+ model "Book"
5
+
6
+ def configure(c)
7
+ c.scope = {:author_id => Author.first.id}
8
+ c.strong_default_attrs = {:author_id => Author.first.id}
9
+ super
9
10
  end
11
+
10
12
  end