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.
- data/.travis.yml +15 -10
- data/{CHANGELOG.rdoc → CHANGELOG.md} +146 -110
- data/LICENSE +7 -1
- data/README.md +47 -56
- data/Rakefile +5 -5
- data/config/before-travis.sh +10 -0
- data/javascripts/basepack.js +0 -130
- data/javascripts/netzkeremotecombo.js +59 -0
- data/lib/netzke/basepack.rb +9 -14
- data/lib/netzke/basepack/accordion.rb +45 -0
- data/lib/netzke/basepack/active_record.rb +12 -0
- data/lib/netzke/basepack/active_record/relation_extensions.rb +27 -0
- data/lib/netzke/basepack/columns.rb +309 -0
- data/lib/netzke/basepack/data_accessor.rb +22 -12
- data/lib/netzke/basepack/data_adapters/abstract_adapter.rb +75 -11
- data/lib/netzke/basepack/data_adapters/active_record_adapter.rb +154 -49
- data/lib/netzke/basepack/fields.rb +162 -0
- data/lib/netzke/basepack/form.rb +136 -0
- data/lib/netzke/basepack/{form_panel → form}/javascripts/comma_list_cbg.js +0 -1
- data/lib/netzke/basepack/{form_panel/javascripts/form_panel.js → form/javascripts/form.js} +20 -26
- data/lib/netzke/basepack/{form_panel → form}/javascripts/n_radio_group.js +0 -1
- data/lib/netzke/basepack/{form_panel → form}/javascripts/readonly_mode.js +0 -0
- data/lib/netzke/basepack/form/services.rb +115 -0
- data/lib/netzke/basepack/{form_panel → form}/stylesheets/readonly_mode.css +0 -0
- data/lib/netzke/basepack/grid.rb +355 -0
- data/lib/netzke/basepack/{grid_panel → grid}/javascripts/advanced_search.js +1 -1
- data/lib/netzke/basepack/{grid_panel → grid}/javascripts/check_column_fix.js +0 -0
- data/lib/netzke/basepack/{grid_panel → grid}/javascripts/edit_in_form.js +3 -3
- data/lib/netzke/basepack/{grid_panel → grid}/javascripts/event_handling.js +5 -2
- data/lib/netzke/basepack/{grid_panel/javascripts/grid_panel.js → grid/javascripts/grid.js} +120 -132
- data/lib/netzke/basepack/{grid_panel → grid}/javascripts/misc.js +0 -0
- data/lib/netzke/basepack/grid/services.rb +216 -0
- data/lib/netzke/basepack/item_persistence.rb +44 -0
- data/lib/netzke/basepack/item_persistence/events_plugin.rb +47 -0
- data/lib/netzke/basepack/{paging_form_panel.rb → paging_form.rb} +24 -30
- data/lib/netzke/basepack/{paging_form_panel/javascripts/paging_form_panel.js → paging_form/javascripts/paging_form.js} +2 -4
- data/lib/netzke/basepack/query_builder.rb +44 -73
- data/lib/netzke/basepack/query_builder/javascripts/query_builder.js +16 -2
- data/lib/netzke/basepack/record_form_window.rb +67 -0
- data/lib/netzke/basepack/search_panel.rb +22 -24
- data/lib/netzke/basepack/search_panel/javascripts/condition_field.js +2 -2
- data/lib/netzke/basepack/search_window.rb +47 -53
- data/lib/netzke/basepack/simple_app.rb +10 -13
- data/lib/netzke/basepack/simple_app/javascripts/simple_app.js +2 -8
- data/lib/netzke/basepack/tab_panel.rb +5 -4
- data/lib/netzke/basepack/tab_panel/javascripts/tab_panel.js +5 -5
- data/lib/netzke/basepack/version.rb +2 -2
- data/lib/netzke/basepack/viewport.rb +16 -0
- data/lib/netzke/basepack/window.rb +27 -18
- data/lib/netzke/basepack/window/javascripts/window.js +7 -1
- data/lib/netzke/basepack/wrap_lazy_loaded.rb +18 -18
- data/locales/en.yml +40 -24
- data/netzke-basepack.gemspec +51 -82
- data/stylesheets/basepack.css +0 -41
- data/test/basepack_test_app/Gemfile +9 -46
- data/test/basepack_test_app/Gemfile.lock +61 -96
- data/test/basepack_test_app/app/components/author_form.rb +8 -5
- data/test/basepack_test_app/app/components/author_grid.rb +2 -2
- data/test/basepack_test_app/app/components/book_form.rb +34 -31
- data/test/basepack_test_app/app/components/book_form_with_defaults.rb +6 -7
- data/test/basepack_test_app/app/components/book_form_with_file_upload.rb +10 -0
- data/test/basepack_test_app/app/components/book_form_with_nested_attributes.rb +5 -6
- data/test/basepack_test_app/app/components/book_grid.rb +19 -8
- data/test/basepack_test_app/app/components/book_grid_filtering.rb +4 -7
- data/test/basepack_test_app/app/components/book_grid_loader.rb +28 -15
- data/test/basepack_test_app/app/components/book_grid_with_custom_columns.rb +45 -21
- data/test/basepack_test_app/app/components/book_grid_with_default_values.rb +26 -8
- data/test/basepack_test_app/app/components/book_grid_with_excluded_columns.rb +11 -0
- data/test/basepack_test_app/app/components/book_grid_with_extra_feedback.rb +2 -2
- data/test/basepack_test_app/app/components/book_grid_with_extra_filters.rb +7 -6
- data/test/basepack_test_app/app/components/book_grid_with_mass_assignment_security.rb +9 -0
- data/test/basepack_test_app/app/components/book_grid_with_nested_attributes.rb +9 -9
- data/test/basepack_test_app/app/components/book_grid_with_overridden_columns.rb +5 -3
- data/test/basepack_test_app/app/components/book_grid_with_paging.rb +6 -8
- data/test/basepack_test_app/app/components/book_grid_with_persistence.rb +6 -4
- data/test/basepack_test_app/app/components/book_grid_with_scope.rb +6 -0
- data/test/basepack_test_app/app/components/book_grid_with_scoped_authors.rb +10 -7
- data/test/basepack_test_app/app/components/book_grid_with_virtual_attributes.rb +21 -13
- data/test/basepack_test_app/app/components/book_paging_form.rb +21 -0
- data/test/basepack_test_app/app/components/book_query_builder.rb +7 -6
- data/test/basepack_test_app/app/components/book_with_custom_primary_key_grid.rb +6 -7
- data/test/basepack_test_app/app/components/books_bound_to_author.rb +9 -7
- data/test/basepack_test_app/app/components/border_layout_panel_with_persistence.rb +12 -0
- data/test/basepack_test_app/app/components/double_book_grid.rb +19 -14
- data/test/basepack_test_app/app/components/form_without_model.rb +15 -16
- data/test/basepack_test_app/app/components/grid_with_initial_sorting.rb +7 -0
- data/test/basepack_test_app/app/components/grid_with_inline_data.rb +7 -0
- data/test/basepack_test_app/app/components/paging_form_with_search.rb +2 -2
- data/test/basepack_test_app/app/components/panel_with_persistent_regions.rb +35 -0
- data/test/basepack_test_app/app/components/query_builder.rb +7 -0
- data/test/basepack_test_app/app/components/simple_panel.rb +16 -11
- data/test/basepack_test_app/app/components/simple_window.rb +7 -6
- data/test/basepack_test_app/app/components/some_accordion.rb +18 -0
- data/test/basepack_test_app/app/components/some_auth_app.rb +5 -5
- data/test/basepack_test_app/app/components/some_border_layout.rb +20 -20
- data/test/basepack_test_app/app/components/some_search_panel.rb +6 -0
- data/test/basepack_test_app/app/components/some_simple_app.rb +30 -16
- data/test/basepack_test_app/app/components/some_tab_panel.rb +18 -15
- data/test/basepack_test_app/app/components/user_form.rb +18 -16
- data/test/basepack_test_app/app/components/user_form_with_default_fields.rb +5 -6
- data/test/basepack_test_app/app/components/user_grid.rb +11 -6
- data/test/basepack_test_app/app/components/user_grid_with_customized_form_fields.rb +5 -3
- data/test/basepack_test_app/app/components/window_component_loader.rb +25 -21
- data/test/basepack_test_app/app/models/address.rb +0 -26
- data/test/basepack_test_app/app/models/author.rb +0 -31
- data/test/basepack_test_app/app/models/book.rb +1 -42
- data/test/basepack_test_app/app/models/book_with_custom_primary_key.rb +1 -23
- data/test/basepack_test_app/app/models/role.rb +0 -21
- data/test/basepack_test_app/app/models/user.rb +0 -24
- data/test/basepack_test_app/app/views/layouts/components.html.erb +1 -1
- data/test/basepack_test_app/config/application.rb +1 -1
- data/test/basepack_test_app/config/database.yml.travis +2 -6
- data/test/basepack_test_app/config/initializers/netzke.rb +1 -6
- data/test/basepack_test_app/db/schema.rb +14 -14
- data/test/basepack_test_app/features/accordion_panel.feature +2 -2
- data/test/basepack_test_app/features/form_panel.feature +7 -7
- data/test/basepack_test_app/features/grid_panel.feature +93 -39
- data/test/basepack_test_app/features/grid_panel_with_custom_primary_key.feature +2 -1
- data/test/basepack_test_app/features/grid_sorting.feature +30 -6
- data/test/basepack_test_app/features/paging_form_panel.feature +7 -7
- data/test/basepack_test_app/features/persistent_regions.feature +30 -0
- data/test/basepack_test_app/features/search_in_grid.feature +5 -5
- data/test/basepack_test_app/features/simple_app.feature +6 -7
- data/test/basepack_test_app/features/step_definitions/form_panel_steps.rb +1 -1
- data/test/basepack_test_app/features/step_definitions/generic_steps.rb +109 -4
- data/test/basepack_test_app/features/step_definitions/grid_panel_steps.rb +8 -10
- data/test/basepack_test_app/features/step_definitions/window_steps.rb +27 -0
- data/test/basepack_test_app/features/tab_panel.feature +1 -1
- data/test/basepack_test_app/features/window.feature +17 -0
- data/test/unit/accordion_panel_test.rb +2 -2
- data/test/unit/grid_panel_test.rb +4 -4
- metadata +57 -83
- data/TODO.rdoc +0 -8
- data/lib/generators/netzke/basepack_generator.rb +0 -10
- data/lib/generators/netzke/templates/assets/ts-checkbox.gif +0 -0
- data/lib/generators/netzke/templates/create_netzke_field_lists.rb +0 -18
- data/lib/netzke/active_record.rb +0 -20
- data/lib/netzke/active_record/attributes.rb +0 -259
- data/lib/netzke/active_record/combobox_options.rb +0 -16
- data/lib/netzke/active_record/relation_extensions.rb +0 -37
- data/lib/netzke/basepack/accordion_panel.rb +0 -39
- data/lib/netzke/basepack/action_column.rb +0 -68
- data/lib/netzke/basepack/action_column/javascripts/action_column.js +0 -61
- data/lib/netzke/basepack/auth_app.rb +0 -159
- data/lib/netzke/basepack/basic_app.rb +0 -7
- data/lib/netzke/basepack/border_layout_panel.rb +0 -53
- data/lib/netzke/basepack/border_layout_panel/javascripts/border_layout_panel.js +0 -40
- data/lib/netzke/basepack/data_adapters/data_mapper_adapter.rb +0 -264
- data/lib/netzke/basepack/data_adapters/sequel_adapter.rb +0 -260
- data/lib/netzke/basepack/form_panel.rb +0 -144
- data/lib/netzke/basepack/form_panel/fields.rb +0 -208
- data/lib/netzke/basepack/form_panel/javascripts/misc.js +0 -4
- data/lib/netzke/basepack/form_panel/services.rb +0 -142
- data/lib/netzke/basepack/grid_panel.rb +0 -441
- data/lib/netzke/basepack/grid_panel/columns.rb +0 -400
- data/lib/netzke/basepack/grid_panel/javascripts/rows-dd.js +0 -281
- data/lib/netzke/basepack/grid_panel/record_form_window.rb +0 -41
- data/lib/netzke/basepack/grid_panel/services.rb +0 -235
- data/lib/netzke/basepack/panel.rb +0 -11
- data/lib/netzke/basepack/wrapper.rb +0 -28
- data/lib/netzke/data_mapper.rb +0 -18
- data/lib/netzke/data_mapper/attributes.rb +0 -273
- data/lib/netzke/data_mapper/combobox_options.rb +0 -11
- data/lib/netzke/data_mapper/relation_extensions.rb +0 -38
- data/lib/netzke/sequel.rb +0 -18
- data/lib/netzke/sequel/attributes.rb +0 -274
- data/lib/netzke/sequel/combobox_options.rb +0 -10
- data/lib/netzke/sequel/relation_extensions.rb +0 -40
- data/locales/zh-cn.yml +0 -79
- data/test/basepack_test_app/app/components/book_form_with_custom_fields.rb +0 -21
- data/test/basepack_test_app/app/components/book_grid_with_column_actions.rb +0 -15
- data/test/basepack_test_app/app/components/book_grid_with_defaults.rb +0 -6
- data/test/basepack_test_app/app/components/book_paging_form_panel.rb +0 -22
- data/test/basepack_test_app/app/components/generic_user_form.rb +0 -12
- data/test/basepack_test_app/app/components/simple_accordion.rb +0 -11
- data/test/basepack_test_app/app/components/simple_tab_panel.rb +0 -11
- data/test/basepack_test_app/app/components/simple_wrapper.rb +0 -7
- data/test/basepack_test_app/app/components/some_accordion_panel.rb +0 -22
- data/test/basepack_test_app/app/presenters/forms/generic_user.rb +0 -6
- data/test/basepack_test_app/app/views/components/loadable_window.html.erb +0 -9
- data/test/basepack_test_app/app/views/components/simple_panel.html.erb +0 -1
- data/test/basepack_test_app/features/components_in_view.feature +0 -11
- data/test/basepack_test_app/features/simple_panel.feature +0 -11
- data/test/basepack_test_app/features/validations_in_grid.feature +0 -13
- data/test/basepack_test_app/features/virtual_attributes.feature +0 -16
- data/test/basepack_test_app/spec/components/form_panel_spec.rb +0 -53
- data/test/basepack_test_app/spec/components/grid_panel_spec.rb +0 -10
- data/test/basepack_test_app/spec/data_adapter/adapter_spec.rb +0 -68
- data/test/basepack_test_app/spec/data_adapter/attributes_spec.rb +0 -56
- data/test/basepack_test_app/spec/data_adapter/relation_extensions_spec.rb +0 -125
- data/test/basepack_test_app/spec/factories.rb +0 -28
- data/test/basepack_test_app/spec/spec_helper.rb +0 -39
@@ -1,24 +1,37 @@
|
|
1
1
|
class BookGridLoader < Netzke::Base
|
2
|
-
|
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 :
|
5
|
-
|
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
|
-
|
11
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
20
|
+
c.on_load_one = <<-JS
|
21
|
+
function(){
|
22
|
+
this.netzkeLoadComponent('book_grid_one');
|
23
|
+
}
|
24
|
+
JS
|
21
25
|
|
22
|
-
|
26
|
+
c.on_load_two = <<-JS
|
27
|
+
function(){
|
28
|
+
this.netzkeLoadComponent('book_grid_two');
|
29
|
+
}
|
30
|
+
JS
|
31
|
+
end
|
23
32
|
|
24
|
-
|
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::
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
column :
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
column :
|
11
|
-
|
12
|
-
|
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::
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
column :
|
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
|
@@ -1,8 +1,8 @@
|
|
1
|
-
class BookGridWithExtraFeedback < Netzke::Basepack::
|
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
|
-
|
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
|
9
|
-
super
|
10
|
-
|
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
|
@@ -1,13 +1,13 @@
|
|
1
|
-
class BookGridWithNestedAttributes < Netzke::Basepack::
|
2
|
-
def
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
10
|
-
|
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::
|
1
|
+
class BookGridWithOverriddenColumns < Netzke::Basepack::Grid
|
2
2
|
model "Book"
|
3
3
|
|
4
4
|
# First way to override a column
|
5
|
-
|
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::
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
4
|
-
|
5
|
-
|
6
|
-
super.merge :persistence => true
|
6
|
+
def configure(c)
|
7
|
+
c.persistence = true
|
8
|
+
super
|
7
9
|
end
|
8
10
|
end
|
@@ -1,8 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
10
|
+
|
11
|
+
end
|
@@ -1,21 +1,29 @@
|
|
1
|
-
|
2
|
-
|
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
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
21
|
+
def custom_fields
|
14
22
|
[
|
15
|
-
|
16
|
-
{:name =>
|
17
|
-
|
18
|
-
{:name =>
|
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
|
3
|
-
super
|
4
|
-
|
5
|
-
|
6
|
-
|
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::
|
1
|
+
class BookWithCustomPrimaryKeyGrid < Netzke::Basepack::Grid
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
super
|
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::
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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
|