active_scaffold 3.7.12 → 4.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +9 -23
- data/README.md +3 -2
- data/app/assets/config/active_scaffold_manifest.js +3 -0
- data/app/assets/javascripts/active_scaffold.js.erb +24 -34
- data/app/assets/javascripts/jquery/active_scaffold.js +41 -58
- data/app/assets/javascripts/jquery/date_picker_bridge.js.erb +1 -1
- data/app/assets/stylesheets/active_scaffold_colors.scss +0 -7
- data/app/assets/stylesheets/active_scaffold_extensions.css.erb +2 -2
- data/app/assets/stylesheets/active_scaffold_jquery_ui.css.erb +7 -7
- data/app/assets/stylesheets/active_scaffold_layout.css +57 -30
- data/app/views/active_scaffold_overrides/_add_existing_form.html.erb +10 -10
- data/app/views/active_scaffold_overrides/_base_form.html.erb +21 -21
- data/app/views/active_scaffold_overrides/_create_form.html.erb +10 -7
- data/app/views/active_scaffold_overrides/_create_form_on_list.html.erb +5 -5
- data/app/views/active_scaffold_overrides/_field_search.html.erb +6 -6
- data/app/views/active_scaffold_overrides/_form.html.erb +11 -14
- data/app/views/active_scaffold_overrides/_form_association.html.erb +21 -12
- data/app/views/active_scaffold_overrides/_form_association_footer.html.erb +19 -10
- data/app/views/active_scaffold_overrides/_form_association_record.html.erb +15 -21
- data/app/views/active_scaffold_overrides/_form_messages.html.erb +2 -2
- data/app/views/active_scaffold_overrides/_horizontal_subform.html.erb +7 -6
- data/app/views/active_scaffold_overrides/_human_conditions.html.erb +2 -2
- data/app/views/active_scaffold_overrides/_list.html.erb +15 -8
- data/app/views/active_scaffold_overrides/_list_calculations.html.erb +2 -3
- data/app/views/active_scaffold_overrides/_list_header.html.erb +2 -2
- data/app/views/active_scaffold_overrides/_list_inline_adapter.html.erb +5 -5
- data/app/views/active_scaffold_overrides/_list_messages.html.erb +12 -3
- data/app/views/active_scaffold_overrides/_list_pagination.html.erb +3 -3
- data/app/views/active_scaffold_overrides/_list_pagination_links.html.erb +4 -4
- data/app/views/active_scaffold_overrides/_list_record.html.erb +6 -6
- data/app/views/active_scaffold_overrides/_list_with_header.html.erb +4 -4
- data/app/views/active_scaffold_overrides/_messages.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_refresh_list.js.erb +2 -2
- data/app/views/active_scaffold_overrides/_render_field.js.erb +4 -4
- data/app/views/active_scaffold_overrides/_row.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_search.html.erb +6 -5
- data/app/views/active_scaffold_overrides/_show.html.erb +3 -3
- data/app/views/active_scaffold_overrides/_show_actions.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_show_association.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_show_association_horizontal.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_show_association_vertical.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_show_columns.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_show_horizontal_record.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_update_actions.html.erb +1 -1
- data/app/views/active_scaffold_overrides/_update_calculations.js.erb +2 -2
- data/app/views/active_scaffold_overrides/_update_column.js.erb +8 -7
- data/app/views/active_scaffold_overrides/_update_form.html.erb +5 -5
- data/app/views/active_scaffold_overrides/_update_messages.js.erb +1 -1
- data/app/views/active_scaffold_overrides/_vertical_subform.html.erb +4 -3
- data/app/views/active_scaffold_overrides/action_confirmation.html.erb +3 -3
- data/app/views/active_scaffold_overrides/add_existing.js.erb +6 -6
- data/app/views/active_scaffold_overrides/add_existing_form.html.erb +1 -1
- data/app/views/active_scaffold_overrides/add_tab.js.erb +15 -0
- data/app/views/active_scaffold_overrides/create.html.erb +1 -1
- data/app/views/active_scaffold_overrides/delete.html.erb +4 -4
- data/app/views/active_scaffold_overrides/destroy.js.erb +15 -13
- data/app/views/active_scaffold_overrides/edit_associated.js.erb +3 -3
- data/app/views/active_scaffold_overrides/field_search.html.erb +1 -1
- data/app/views/active_scaffold_overrides/form_messages.js.erb +1 -1
- data/app/views/active_scaffold_overrides/list.html.erb +1 -1
- data/app/views/active_scaffold_overrides/on_action_update.js.erb +13 -8
- data/app/views/active_scaffold_overrides/on_create.js.erb +34 -6
- data/app/views/active_scaffold_overrides/on_mark.js.erb +3 -3
- data/app/views/active_scaffold_overrides/on_update.js.erb +9 -9
- data/app/views/active_scaffold_overrides/render_field.js.erb +1 -1
- data/app/views/active_scaffold_overrides/render_field_inplace.html.erb +1 -1
- data/app/views/active_scaffold_overrides/row.js.erb +2 -2
- data/app/views/active_scaffold_overrides/search.html.erb +1 -1
- data/app/views/active_scaffold_overrides/show.html.erb +3 -3
- data/app/views/active_scaffold_overrides/update.html.erb +2 -2
- data/app/views/active_scaffold_overrides/update_column.js.erb +4 -4
- data/app/views/active_scaffold_overrides/update_row.js.erb +1 -1
- data/lib/active_scaffold/actions/common_search.rb +5 -3
- data/lib/active_scaffold/actions/core.rb +57 -32
- data/lib/active_scaffold/actions/create.rb +19 -17
- data/lib/active_scaffold/actions/delete.rb +10 -12
- data/lib/active_scaffold/actions/field_search.rb +28 -13
- data/lib/active_scaffold/actions/list.rb +34 -34
- data/lib/active_scaffold/actions/mark.rb +5 -5
- data/lib/active_scaffold/actions/nested.rb +64 -56
- data/lib/active_scaffold/actions/search.rb +2 -2
- data/lib/active_scaffold/actions/show.rb +5 -5
- data/lib/active_scaffold/actions/subform.rb +15 -4
- data/lib/active_scaffold/actions/update.rb +20 -20
- data/lib/active_scaffold/active_record_permissions.rb +4 -3
- data/lib/active_scaffold/attribute_params.rb +51 -50
- data/lib/active_scaffold/bridges/active_storage/active_storage_bridge.rb +4 -4
- data/lib/active_scaffold/bridges/active_storage/active_storage_helpers.rb +6 -2
- data/lib/active_scaffold/bridges/active_storage.rb +1 -1
- data/lib/active_scaffold/bridges/ancestry/ancestry_bridge.rb +3 -3
- data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +4 -1
- data/lib/active_scaffold/bridges/bitfields.rb +1 -1
- data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +9 -8
- data/lib/active_scaffold/bridges/cancan.rb +8 -8
- data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +1 -1
- data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +4 -3
- data/lib/active_scaffold/bridges/carrierwave.rb +2 -2
- data/lib/active_scaffold/bridges/chosen.rb +1 -5
- data/lib/active_scaffold/bridges/country_select/country_select_bridge_helper.rb +4 -2
- data/lib/active_scaffold/bridges/date_picker/ext.rb +20 -12
- data/lib/active_scaffold/bridges/date_picker/helper.rb +37 -33
- data/lib/active_scaffold/bridges/date_picker.rb +1 -4
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +1 -1
- data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +3 -2
- data/lib/active_scaffold/bridges/dragonfly.rb +1 -1
- data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +3 -2
- data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +2 -1
- data/lib/active_scaffold/bridges/file_column/form_ui.rb +4 -9
- data/lib/active_scaffold/bridges/file_column/list_ui.rb +6 -3
- data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +3 -3
- data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +1 -4
- data/lib/active_scaffold/bridges/file_column.rb +1 -0
- data/lib/active_scaffold/bridges/paper_trail/actions.rb +4 -2
- data/lib/active_scaffold/bridges/paper_trail/config.rb +1 -1
- data/lib/active_scaffold/bridges/paper_trail/helper.rb +1 -1
- data/lib/active_scaffold/bridges/paper_trail/paper_trail_bridge.rb +2 -1
- data/lib/active_scaffold/bridges/paperclip/list_ui.rb +3 -2
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +1 -1
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +10 -9
- data/lib/active_scaffold/bridges/paperclip.rb +2 -1
- data/lib/active_scaffold/bridges/record_select/helpers.rb +10 -11
- data/lib/active_scaffold/bridges/semantic_attributes/column.rb +3 -1
- data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +3 -7
- data/lib/active_scaffold/bridges/tiny_mce.rb +2 -7
- data/lib/active_scaffold/bridges/usa_state_select/usa_state_select_helper.rb +7 -7
- data/lib/active_scaffold/bridges.rb +7 -5
- data/lib/active_scaffold/config/base.rb +20 -24
- data/lib/active_scaffold/config/core.rb +27 -39
- data/lib/active_scaffold/config/create.rb +1 -1
- data/lib/active_scaffold/config/delete.rb +9 -9
- data/lib/active_scaffold/config/field_search.rb +4 -9
- data/lib/active_scaffold/config/form.rb +3 -1
- data/lib/active_scaffold/config/list.rb +19 -15
- data/lib/active_scaffold/config/nested.rb +2 -2
- data/lib/active_scaffold/config/search.rb +5 -5
- data/lib/active_scaffold/config/show.rb +1 -1
- data/lib/active_scaffold/config/subform.rb +1 -1
- data/lib/active_scaffold/config/update.rb +4 -5
- data/lib/active_scaffold/configurable.rb +2 -1
- data/lib/active_scaffold/constraints.rb +16 -11
- data/lib/active_scaffold/core.rb +25 -27
- data/lib/active_scaffold/data_structures/action_columns.rb +10 -3
- data/lib/active_scaffold/data_structures/action_link.rb +19 -9
- data/lib/active_scaffold/data_structures/action_links.rb +20 -26
- data/lib/active_scaffold/data_structures/actions.rb +3 -3
- data/lib/active_scaffold/data_structures/association/abstract.rb +8 -4
- data/lib/active_scaffold/data_structures/association/active_mongoid.rb +1 -0
- data/lib/active_scaffold/data_structures/association/active_record.rb +1 -4
- data/lib/active_scaffold/data_structures/column.rb +368 -327
- data/lib/active_scaffold/data_structures/columns.rb +3 -2
- data/lib/active_scaffold/data_structures/nested_info.rb +6 -5
- data/lib/active_scaffold/data_structures/proxy_column.rb +68 -0
- data/lib/active_scaffold/data_structures/set.rb +7 -4
- data/lib/active_scaffold/data_structures/sorting.rb +21 -12
- data/lib/active_scaffold/engine.rb +12 -12
- data/lib/active_scaffold/extensions/action_controller_rendering.rb +5 -5
- data/lib/active_scaffold/extensions/action_controller_rescueing.rb +1 -1
- data/lib/active_scaffold/extensions/action_view_rendering.rb +29 -31
- data/lib/active_scaffold/extensions/ice_nine.rb +2 -1
- data/lib/active_scaffold/extensions/localize.rb +2 -2
- data/lib/active_scaffold/extensions/name_option_for_datetime.rb +1 -1
- data/lib/active_scaffold/extensions/routing_mapper.rb +5 -4
- data/lib/active_scaffold/extensions/unsaved_associated.rb +3 -2
- data/lib/active_scaffold/finder.rb +71 -78
- data/lib/active_scaffold/helpers/action_link_helpers.rb +37 -49
- data/lib/active_scaffold/helpers/association_helpers.rb +3 -2
- data/lib/active_scaffold/helpers/controller_helpers.rb +18 -16
- data/lib/active_scaffold/helpers/form_column_helpers.rb +69 -53
- data/lib/active_scaffold/helpers/human_condition_helpers.rb +17 -15
- data/lib/active_scaffold/helpers/id_helpers.rb +5 -5
- data/lib/active_scaffold/helpers/list_column_helpers.rb +35 -38
- data/lib/active_scaffold/helpers/pagination_helpers.rb +4 -4
- data/lib/active_scaffold/helpers/search_column_helpers.rb +25 -34
- data/lib/active_scaffold/helpers/show_column_helpers.rb +7 -4
- data/lib/active_scaffold/helpers/tabs_helpers.rb +88 -0
- data/lib/active_scaffold/helpers/view_helpers.rb +15 -13
- data/lib/active_scaffold/marked_model.rb +1 -2
- data/lib/active_scaffold/orm_checks.rb +6 -4
- data/lib/active_scaffold/paginator.rb +3 -2
- data/lib/active_scaffold/registry.rb +5 -0
- data/lib/active_scaffold/tableless.rb +24 -14
- data/lib/active_scaffold/version.rb +4 -4
- data/lib/active_scaffold.rb +8 -34
- data/lib/generators/active_scaffold/controller_generator.rb +20 -20
- data/lib/generators/active_scaffold/install_generator.rb +4 -8
- data/lib/generators/active_scaffold/resource_generator.rb +31 -31
- data/lib/tasks/brakeman.rake +1 -1
- data/shoulda_macros/macros.rb +14 -14
- metadata +11 -232
- data/app/assets/javascripts/prototype/active_scaffold.js +0 -1249
- data/app/assets/javascripts/prototype/active_scaffold_chosen.js +0 -0
- data/app/assets/javascripts/prototype/dhtml_history.js +0 -870
- data/app/assets/javascripts/prototype/form_enhancements.js +0 -117
- data/app/assets/javascripts/prototype/tiny_mce_bridge.js +0 -17
- data/app/views/active_scaffold_overrides/_list_messages_content.html.erb +0 -8
- data/app/views/active_scaffold_overrides/_new_record.js.erb +0 -15
- data/app/views/active_scaffold_overrides/_popup_adapter.html.erb +0 -20
- data/app/views/active_scaffold_overrides/_refresh_create_form.js.erb +0 -12
- data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +0 -58
- data/lib/active_scaffold/bridges/calendar_date_select.rb +0 -17
- data/lib/active_scaffold/data_structures/action_link_separator.rb +0 -13
- data/lib/active_scaffold/extensions/cow_proxy.rb +0 -102
- data/test/active_scaffold_config_mock.rb +0 -33
- data/test/bridges/bridge_test.rb +0 -88
- data/test/bridges/date_picker_test.rb +0 -31
- data/test/bridges/paper_trail_test.rb +0 -16
- data/test/bridges/paperclip_test.rb +0 -85
- data/test/bridges/tiny_mce_test.rb +0 -61
- data/test/class_with_finder.rb +0 -42
- data/test/company.rb +0 -97
- data/test/config/base_test.rb +0 -17
- data/test/config/core_test.rb +0 -66
- data/test/config/create_test.rb +0 -72
- data/test/config/delete_test.rb +0 -35
- data/test/config/field_search_test.rb +0 -49
- data/test/config/list_test.rb +0 -134
- data/test/config/nested_test.rb +0 -55
- data/test/config/search_test.rb +0 -62
- data/test/config/show_test.rb +0 -45
- data/test/config/subform_test.rb +0 -19
- data/test/config/update_test.rb +0 -52
- data/test/const_mocker.rb +0 -32
- data/test/data_structures/action_columns_test.rb +0 -112
- data/test/data_structures/action_link_test.rb +0 -79
- data/test/data_structures/action_links_test.rb +0 -78
- data/test/data_structures/actions_test.rb +0 -25
- data/test/data_structures/association_column_test.rb +0 -41
- data/test/data_structures/column_test.rb +0 -186
- data/test/data_structures/columns_test.rb +0 -68
- data/test/data_structures/set_test.rb +0 -84
- data/test/data_structures/sorting_test.rb +0 -148
- data/test/data_structures/standard_column_test.rb +0 -23
- data/test/data_structures/validation_reflection_test.rb +0 -69
- data/test/data_structures/virtual_column_test.rb +0 -23
- data/test/extensions/action_view_rendering_test.rb +0 -20
- data/test/extensions/active_record_test.rb +0 -44
- data/test/extensions/routing_mapper_test.rb +0 -73
- data/test/helpers/form_column_helpers_test.rb +0 -34
- data/test/helpers/list_column_helpers_test.rb +0 -53
- data/test/helpers/pagination_helpers_test.rb +0 -65
- data/test/helpers/search_column_helpers_test.rb +0 -15
- data/test/misc/active_record_permissions_test.rb +0 -193
- data/test/misc/attribute_params_test.rb +0 -460
- data/test/misc/calculation_test.rb +0 -39
- data/test/misc/configurable_test.rb +0 -97
- data/test/misc/constraints_test.rb +0 -209
- data/test/misc/convert_numbers_format_test.rb +0 -171
- data/test/misc/finder_test.rb +0 -124
- data/test/misc/lang_test.rb +0 -10
- data/test/misc/parse_datetime_test.rb +0 -159
- data/test/misc/render_test.rb +0 -9
- data/test/misc/tableless_test.rb +0 -56
- data/test/mock_app/.gitignore +0 -2
- data/test/mock_app/Rakefile +0 -7
- data/test/mock_app/app/assets/config/manifest.js +0 -0
- data/test/mock_app/app/controllers/addresses_controller.rb +0 -4
- data/test/mock_app/app/controllers/application_controller.rb +0 -10
- data/test/mock_app/app/controllers/buildings_controller.rb +0 -4
- data/test/mock_app/app/controllers/cars_controller.rb +0 -5
- data/test/mock_app/app/controllers/contacts_controller.rb +0 -4
- data/test/mock_app/app/controllers/floors_controller.rb +0 -6
- data/test/mock_app/app/controllers/people_controller.rb +0 -8
- data/test/mock_app/app/controllers/roles_controller.rb +0 -4
- data/test/mock_app/app/helpers/application_helper.rb +0 -3
- data/test/mock_app/app/models/address.rb +0 -3
- data/test/mock_app/app/models/building.rb +0 -9
- data/test/mock_app/app/models/car.rb +0 -3
- data/test/mock_app/app/models/contact.rb +0 -3
- data/test/mock_app/app/models/file_model.rb +0 -31
- data/test/mock_app/app/models/floor.rb +0 -8
- data/test/mock_app/app/models/person.rb +0 -12
- data/test/mock_app/app/models/role.rb +0 -3
- data/test/mock_app/app/views/active_scaffold_overrides/_form.html.erb +0 -2
- data/test/mock_app/app/views/active_scaffold_overrides/list.html.erb +0 -2
- data/test/mock_app/app/views/people/_first_name_form_column.html.erb +0 -2
- data/test/mock_app/app/views/people/_form.html.erb +0 -2
- data/test/mock_app/app/views/people/list.html.erb +0 -2
- data/test/mock_app/config/application.rb +0 -14
- data/test/mock_app/config/boot.rb +0 -7
- data/test/mock_app/config/database.yml +0 -16
- data/test/mock_app/config/environment.rb +0 -6
- data/test/mock_app/config/environments/development.rb +0 -24
- data/test/mock_app/config/environments/production.rb +0 -49
- data/test/mock_app/config/environments/test.rb +0 -34
- data/test/mock_app/config/initializers/backtrace_silencers.rb +0 -7
- data/test/mock_app/config/initializers/inflections.rb +0 -10
- data/test/mock_app/config/initializers/mime_types.rb +0 -5
- data/test/mock_app/config/initializers/secret_token.rb +0 -11
- data/test/mock_app/config/initializers/session_store.rb +0 -8
- data/test/mock_app/config/initializers/wrap_parameters.rb +0 -14
- data/test/mock_app/config/locales/en.yml +0 -5
- data/test/mock_app/config/routes.rb +0 -17
- data/test/mock_app/config.ru +0 -4
- data/test/mock_app/db/schema.rb +0 -68
- data/test/mock_app/db/test.sqlite3 +0 -1
- data/test/model_stub.rb +0 -64
- data/test/performance/list_cars_performance_test.rb +0 -34
- data/test/performance/list_people_performance_test.rb +0 -31
- data/test/performance_test_help.rb +0 -3
- data/test/run_all.rb +0 -6
- data/test/test_helper.rb +0 -71
- data/vendor/assets/javascripts/getprototypeof.js +0 -12
@@ -14,7 +14,7 @@ module ActiveScaffold::Config
|
|
14
14
|
# --------------------------
|
15
15
|
# the ActionLink for this action
|
16
16
|
cattr_accessor :link, instance_accessor: false
|
17
|
-
@@link = ActiveScaffold::DataStructures::ActionLink.new('show_search', :
|
17
|
+
@@link = ActiveScaffold::DataStructures::ActionLink.new('show_search', label: :search, type: :collection, security_method: :search_authorized?, ignore_method: :search_ignore?)
|
18
18
|
|
19
19
|
# A flag for how the search should do full-text searching in the database:
|
20
20
|
# * :full: LIKE %?%
|
@@ -43,7 +43,7 @@ module ActiveScaffold::Config
|
|
43
43
|
def columns
|
44
44
|
# we want to delay initializing to the @core.columns set for as long as possible. Too soon and .search_sql will not be available to .searchable?
|
45
45
|
unless defined? @columns
|
46
|
-
self.columns = @core.columns.
|
46
|
+
self.columns = @core.columns.filter_map { |c| c.name if @core.columns._inheritable.include?(c.name) && c.searchable? && c.association.nil? && c.text? }
|
47
47
|
end
|
48
48
|
@columns
|
49
49
|
end
|
@@ -57,21 +57,21 @@ module ActiveScaffold::Config
|
|
57
57
|
# Default is :full
|
58
58
|
attr_accessor :text_search
|
59
59
|
|
60
|
-
attr_accessor :split_terms
|
61
|
-
|
62
|
-
attr_accessor :reset_form
|
60
|
+
attr_accessor :split_terms, :reset_form
|
63
61
|
|
64
62
|
# the ActionLink for this action
|
65
63
|
attr_accessor :link
|
66
64
|
|
67
65
|
# whether submits the search as you type
|
68
66
|
attr_writer :live
|
67
|
+
|
69
68
|
def live?
|
70
69
|
@live
|
71
70
|
end
|
72
71
|
|
73
72
|
UserSettings.class_eval do
|
74
73
|
attr_writer :live
|
74
|
+
|
75
75
|
def live?
|
76
76
|
defined?(@live) ? @live : @conf.live?
|
77
77
|
end
|
@@ -9,7 +9,7 @@ module ActiveScaffold::Config
|
|
9
9
|
# global level configuration
|
10
10
|
# --------------------------
|
11
11
|
cattr_accessor :link, instance_accessor: false
|
12
|
-
@@link = ActiveScaffold::DataStructures::ActionLink.new('show', :
|
12
|
+
@@link = ActiveScaffold::DataStructures::ActionLink.new('show', label: :show, type: :member, security_method: :show_authorized?, ignore_method: :show_ignore?)
|
13
13
|
|
14
14
|
cattr_accessor :inline_links, instance_accessor: false
|
15
15
|
@@inline_links = false
|
@@ -17,7 +17,7 @@ module ActiveScaffold::Config
|
|
17
17
|
def self.link=(val)
|
18
18
|
@@link = val
|
19
19
|
end
|
20
|
-
@@link = ActiveScaffold::DataStructures::ActionLink.new('edit', :
|
20
|
+
@@link = ActiveScaffold::DataStructures::ActionLink.new('edit', label: :edit, type: :member, security_method: :update_authorized?, ignore_method: :update_ignore?)
|
21
21
|
|
22
22
|
cattr_accessor :nested_links, instance_accessor: false
|
23
23
|
@@nested_links = false
|
@@ -25,16 +25,15 @@ module ActiveScaffold::Config
|
|
25
25
|
cattr_accessor :add_locking_column, instance_accessor: false
|
26
26
|
@@add_locking_column = true
|
27
27
|
|
28
|
-
columns_accessor :columns, :
|
28
|
+
columns_accessor :columns, copy: :create
|
29
29
|
|
30
30
|
# instance-level configuration
|
31
31
|
# ----------------------------
|
32
32
|
|
33
|
-
attr_accessor :nested_links
|
34
|
-
|
35
|
-
attr_accessor :add_locking_column
|
33
|
+
attr_accessor :nested_links, :add_locking_column
|
36
34
|
|
37
35
|
attr_writer :hide_nested_column
|
36
|
+
|
38
37
|
def hide_nested_column
|
39
38
|
@hide_nested_column.nil? ? true : @hide_nested_column
|
40
39
|
end
|
@@ -9,6 +9,7 @@ module ActiveScaffold
|
|
9
9
|
module Configurable
|
10
10
|
def configure(&configuration_block)
|
11
11
|
return unless configuration_block
|
12
|
+
|
12
13
|
@configuration_binding = configuration_block.binding.eval('self')
|
13
14
|
ret = instance_exec(self, &configuration_block)
|
14
15
|
@configuration_binding = nil
|
@@ -16,7 +17,7 @@ module ActiveScaffold
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def method_missing(name, *args)
|
19
|
-
if @configuration_binding&.respond_to?(name, true)
|
20
|
+
if @configuration_binding&.respond_to?(name, true) # rubocop:disable Lint/RedundantSafeNavigation
|
20
21
|
@configuration_binding.send(name, *args)
|
21
22
|
else
|
22
23
|
super
|
@@ -13,6 +13,7 @@ module ActiveScaffold
|
|
13
13
|
|
14
14
|
def columns_from_constraint(column_name, value)
|
15
15
|
return if params_hash?(value)
|
16
|
+
|
16
17
|
if value.is_a?(Array)
|
17
18
|
column = active_scaffold_config.columns[column_name]
|
18
19
|
if column&.association&.polymorphic?
|
@@ -37,16 +38,18 @@ module ActiveScaffold
|
|
37
38
|
constrained_fields |= active_scaffold_constraints.flat_map { |k, v| columns_from_constraint(k, v) }.compact
|
38
39
|
exclude_actions = []
|
39
40
|
%i[list update].each do |action_name|
|
40
|
-
if active_scaffold_config.actions.include? action_name
|
41
|
-
exclude_actions << action_name
|
41
|
+
if active_scaffold_config.actions.include?(action_name) && !active_scaffold_config.send(action_name).hide_nested_column
|
42
|
+
exclude_actions << action_name
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
46
|
# we actually want to do this whether constrained_fields exist or not, so that we can reset the array when they don't
|
46
47
|
active_scaffold_config.actions.each do |action_name|
|
47
48
|
next if exclude_actions.include?(action_name)
|
49
|
+
|
48
50
|
action = active_scaffold_config.send(action_name)
|
49
51
|
next unless action.respond_to? :columns
|
52
|
+
|
50
53
|
action.columns.constraint_columns = constrained_fields
|
51
54
|
end
|
52
55
|
end
|
@@ -67,13 +70,13 @@ module ActiveScaffold
|
|
67
70
|
# Assume this is a multi-level association constraint.
|
68
71
|
# example:
|
69
72
|
# data model: Park -> Den -> Bear
|
70
|
-
# constraint: :
|
73
|
+
# constraint: den: {park: 5}
|
71
74
|
if params_hash? v
|
72
75
|
far_association = column.association.klass.reflect_on_association(v.keys.first)
|
73
76
|
field = far_association.klass.primary_key
|
74
77
|
table = far_association.table_name
|
75
78
|
|
76
|
-
active_scaffold_references.
|
79
|
+
active_scaffold_references.push({k => far_association.name}) # e.g. {den: :park}
|
77
80
|
hash_conditions.deep_merge!(table => {field => v.values.first})
|
78
81
|
|
79
82
|
# association column constraint
|
@@ -93,7 +96,7 @@ module ActiveScaffold
|
|
93
96
|
raise ActiveScaffold::MalformedConstraint, constraint_error(active_scaffold_config.model, k), caller
|
94
97
|
end
|
95
98
|
end
|
96
|
-
conditions.
|
99
|
+
conditions.compact_blank
|
97
100
|
end
|
98
101
|
|
99
102
|
def join_from_association_constraint(column)
|
@@ -131,7 +134,8 @@ module ActiveScaffold
|
|
131
134
|
unless value.is_a?(Array) && value.size >= 2
|
132
135
|
raise ActiveScaffold::MalformedConstraint, polymorphic_constraint_error(association), caller
|
133
136
|
end
|
134
|
-
|
137
|
+
|
138
|
+
condition = {table => {association.foreign_type => value[0], field => value.size == 2 ? value[1] : value[1..]}}
|
135
139
|
else
|
136
140
|
condition = {table => {field.to_s => value}}
|
137
141
|
end
|
@@ -169,14 +173,15 @@ module ActiveScaffold
|
|
169
173
|
unless v.is_a?(Array) && v.size >= 2
|
170
174
|
raise ActiveScaffold::MalformedConstraint, polymorphic_constraint_error(column.association), caller
|
171
175
|
end
|
176
|
+
|
172
177
|
if v.size == 2
|
173
|
-
record.send("#{k}=", v[0].constantize.find(v[1]))
|
178
|
+
record.send(:"#{k}=", v[0].constantize.find(v[1]))
|
174
179
|
else
|
175
|
-
record.send("#{column.association.foreign_type}=", v[0])
|
180
|
+
record.send(:"#{column.association.foreign_type}=", v[0])
|
176
181
|
end
|
177
182
|
elsif !column.association.source_reflection&.options&.include?(:through) && # regular singular association, or one-level through association
|
178
183
|
!v.is_a?(Array)
|
179
|
-
record.send("#{k}=", column.association.klass.find(v))
|
184
|
+
record.send(:"#{k}=", column.association.klass.find(v))
|
180
185
|
|
181
186
|
# setting the belongs_to side of a has_one isn't safe. if the has_one was already
|
182
187
|
# specified, rails won't automatically clear out the previous associated record.
|
@@ -185,11 +190,11 @@ module ActiveScaffold
|
|
185
190
|
# run operations where activerecord auto-saves the object.
|
186
191
|
reverse = column.association.reverse_association
|
187
192
|
if reverse&.singular? && !reverse.belongs_to? && options[:allow_autosave]
|
188
|
-
record.send(k).send("#{reverse.name}=", record)
|
193
|
+
record.send(k).send(:"#{reverse.name}=", record)
|
189
194
|
end
|
190
195
|
end
|
191
196
|
else
|
192
|
-
record.send("#{k}=", v)
|
197
|
+
record.send(:"#{k}=", v)
|
193
198
|
end
|
194
199
|
end
|
195
200
|
end
|
data/lib/active_scaffold/core.rb
CHANGED
@@ -7,21 +7,12 @@ module ActiveScaffold
|
|
7
7
|
def setup_user_settings
|
8
8
|
config = self.class.active_scaffold_config
|
9
9
|
config.new_user_settings(user_settings_storage, params)
|
10
|
-
return if ActiveScaffold.threadsafe
|
11
|
-
config.actions.each do |action_name|
|
12
|
-
conf_instance = config.send(action_name) rescue next # rubocop:disable Style/RescueModifier
|
13
|
-
config.user.action_user_settings(conf_instance)
|
14
|
-
end
|
15
10
|
end
|
16
11
|
|
17
12
|
def active_scaffold_config
|
18
13
|
@active_scaffold_config ||= begin
|
19
14
|
setup_user_settings unless self.class.active_scaffold_config.user
|
20
|
-
|
21
|
-
self.class.active_scaffold_config.user
|
22
|
-
else
|
23
|
-
self.class.active_scaffold_config
|
24
|
-
end
|
15
|
+
self.class.active_scaffold_config.user
|
25
16
|
end
|
26
17
|
end
|
27
18
|
|
@@ -33,7 +24,6 @@ module ActiveScaffold
|
|
33
24
|
def active_scaffold_session_storage(id = nil)
|
34
25
|
session_index = active_scaffold_session_storage_key(id)
|
35
26
|
session[session_index] ||= {}
|
36
|
-
session[session_index]
|
37
27
|
end
|
38
28
|
|
39
29
|
def user_settings_storage
|
@@ -83,7 +73,7 @@ module ActiveScaffold
|
|
83
73
|
active_scaffold_config.actions.each do |mod|
|
84
74
|
include "ActiveScaffold::Actions::#{mod.to_s.camelize}".constantize
|
85
75
|
mod_conf = active_scaffold_config.send(mod)
|
86
|
-
active_scaffold_config._setup_action(mod)
|
76
|
+
active_scaffold_config._setup_action(mod)
|
87
77
|
next unless mod_conf.respond_to?(:link) && (link = mod_conf.link)
|
88
78
|
|
89
79
|
# sneak the action links from the actions into the main set
|
@@ -97,13 +87,12 @@ module ActiveScaffold
|
|
97
87
|
end
|
98
88
|
end
|
99
89
|
_add_sti_create_links if active_scaffold_config.add_sti_create_links?
|
100
|
-
return unless ActiveScaffold.threadsafe
|
101
90
|
active_scaffold_config._cache_lazy_values
|
102
91
|
active_scaffold_config.deep_freeze!
|
103
92
|
end
|
104
93
|
|
105
94
|
module Prefixes
|
106
|
-
define_method
|
95
|
+
define_method :local_prefixes do
|
107
96
|
@local_prefixes ||= begin
|
108
97
|
prefixes = super()
|
109
98
|
unless superclass.uses_active_scaffold? || prefixes.include?('active_scaffold_overrides')
|
@@ -118,11 +107,12 @@ module ActiveScaffold
|
|
118
107
|
def _add_sti_create_links
|
119
108
|
new_action_link = active_scaffold_config.action_links.collection['new']
|
120
109
|
return if new_action_link.nil? || active_scaffold_config.sti_children.empty?
|
110
|
+
|
121
111
|
active_scaffold_config.action_links.collection.delete('new')
|
122
112
|
active_scaffold_config.sti_children.each do |child|
|
123
113
|
new_sti_link = Marshal.load(Marshal.dump(new_action_link)) # deep clone
|
124
|
-
new_sti_link.label = as_(:create_model, :
|
125
|
-
new_sti_link.parameters = {:
|
114
|
+
new_sti_link.label = as_(:create_model, model: child.to_s.camelize.constantize.model_name.human)
|
115
|
+
new_sti_link.parameters = {parent_sti: controller_path}
|
126
116
|
new_sti_link.controller = proc { active_scaffold_controller_for(child.to_s.camelize.constantize).controller_path }
|
127
117
|
active_scaffold_config.action_links.collection.create.add(new_sti_link)
|
128
118
|
end
|
@@ -132,8 +122,10 @@ module ActiveScaffold
|
|
132
122
|
# because otherwise the Nested module could be disabled. Actually, it could still be disabled later, couldn't it?
|
133
123
|
def links_for_associations
|
134
124
|
return unless active_scaffold_config.actions.include?(:list) && active_scaffold_config.actions.include?(:nested)
|
125
|
+
|
135
126
|
active_scaffold_config.columns.each do |column|
|
136
127
|
next unless column.link.nil? && column.autolink?
|
128
|
+
|
137
129
|
# lazy load of action_link, cause it was really slowing down app in dev mode
|
138
130
|
# and might lead to trouble cause of cyclic constantization of controllers
|
139
131
|
# and might be unnecessary cause it is done before columns are configured
|
@@ -155,12 +147,13 @@ module ActiveScaffold
|
|
155
147
|
|
156
148
|
def link_for_association(column, options = {})
|
157
149
|
return if (controller = active_scaffold_controller_for_column(column, options)).nil?
|
158
|
-
|
159
|
-
|
150
|
+
|
151
|
+
options.reverse_merge! position: :after, type: :member, column: column,
|
152
|
+
controller: (controller == :polymorph ? controller : "/#{controller.controller_path}")
|
160
153
|
options[:parameters] ||= {}
|
161
|
-
options[:parameters].reverse_merge! :
|
154
|
+
options[:parameters].reverse_merge! association: column.association.name
|
162
155
|
if column.association.collection?
|
163
|
-
ActiveScaffold::DataStructures::ActionLink.new('index', options.merge(:
|
156
|
+
ActiveScaffold::DataStructures::ActionLink.new('index', options.merge(refresh_on_close: true))
|
164
157
|
else
|
165
158
|
actions = controller.active_scaffold_config.actions unless controller == :polymorph
|
166
159
|
actions ||= %i[create update show]
|
@@ -175,9 +168,9 @@ module ActiveScaffold
|
|
175
168
|
end
|
176
169
|
|
177
170
|
def link_for_association_as_scope(scope, options = {})
|
178
|
-
options.reverse_merge! :
|
171
|
+
options.reverse_merge! label: scope, position: :after, type: :member, controller: controller_path
|
179
172
|
options[:parameters] ||= {}
|
180
|
-
options[:parameters].reverse_merge! :
|
173
|
+
options[:parameters].reverse_merge! named_scope: scope
|
181
174
|
ActiveScaffold::DataStructures::ActionLink.new('index', options)
|
182
175
|
end
|
183
176
|
|
@@ -185,7 +178,7 @@ module ActiveScaffold
|
|
185
178
|
as_path = File.realpath File.join(ActiveScaffold::Config::Core.plugin_directory, 'app', 'views')
|
186
179
|
index = view_paths.find_index { |p| p.to_s == as_path }
|
187
180
|
if index
|
188
|
-
self.view_paths = view_paths[0..index - 1] + Array(path) + view_paths[index
|
181
|
+
self.view_paths = view_paths[0..index - 1] + Array(path) + view_paths[index..]
|
189
182
|
else
|
190
183
|
append_view_path path
|
191
184
|
end
|
@@ -219,8 +212,9 @@ module ActiveScaffold
|
|
219
212
|
|
220
213
|
def active_scaffold_controller_for(klass)
|
221
214
|
return self if uses_active_scaffold? && klass == active_scaffold_config.model
|
215
|
+
|
222
216
|
# noinspection RubyArgCount
|
223
|
-
ActiveScaffold::Core.active_scaffold_controller_for(klass, to_s.deconstantize
|
217
|
+
ActiveScaffold::Core.active_scaffold_controller_for(klass, "#{to_s.deconstantize}::")
|
224
218
|
end
|
225
219
|
|
226
220
|
def uses_active_scaffold?
|
@@ -238,9 +232,10 @@ module ActiveScaffold
|
|
238
232
|
class_names.each do |controller_name|
|
239
233
|
begin
|
240
234
|
controller = "#{namespace}#{controller_name.camelize}Controller".constantize
|
241
|
-
rescue NameError =>
|
235
|
+
rescue NameError => e
|
242
236
|
# Only rescue NameError associated with the controller constant not existing - not other compile errors
|
243
|
-
raise unless
|
237
|
+
raise unless e.message["uninitialized constant #{controller}"]
|
238
|
+
|
244
239
|
error_message << "#{namespace}#{controller_name.camelize}Controller"
|
245
240
|
next
|
246
241
|
end
|
@@ -248,10 +243,11 @@ module ActiveScaffold
|
|
248
243
|
unless controller.active_scaffold_config.model.to_s == klass.to_s
|
249
244
|
raise ActiveScaffold::ControllerNotFound, "ActiveScaffold on #{controller} is not for #{klass} model.", caller
|
250
245
|
end
|
246
|
+
|
251
247
|
return controller
|
252
248
|
end
|
253
249
|
end
|
254
|
-
raise ActiveScaffold::ControllerNotFound,
|
250
|
+
raise ActiveScaffold::ControllerNotFound, "Could not find #{error_message.join(' or ')}", caller
|
255
251
|
end
|
256
252
|
|
257
253
|
def self.column_type_cast(value, column)
|
@@ -268,11 +264,13 @@ module ActiveScaffold
|
|
268
264
|
|
269
265
|
def self.mongoid_column_type_cast(value, column)
|
270
266
|
return Time.zone.at(value.to_i) if [Time, DateTime].include?(column.type) && value =~ /\A\d+\z/
|
267
|
+
|
271
268
|
column.type.evolve value
|
272
269
|
end
|
273
270
|
|
274
271
|
def self.active_record_column_type_cast(value, column_or_type)
|
275
272
|
return Time.zone.at(value.to_i) if %i[time datetime].include?(column_or_type.type) && value =~ /\A\d+\z/
|
273
|
+
|
276
274
|
cast_type = column_or_type.is_a?(ActiveRecord::ConnectionAdapters::Column) ? ActiveRecord::Type.lookup(column_or_type.type) : column_or_type
|
277
275
|
cast_type ? cast_type.cast(value) : value
|
278
276
|
end
|
@@ -9,6 +9,11 @@ module ActiveScaffold::DataStructures
|
|
9
9
|
|
10
10
|
# labels are useful for the Create/Update forms, when we display columns in a grouped fashion and want to name them separately
|
11
11
|
attr_writer :label
|
12
|
+
|
13
|
+
# a common column in the association columns included in the group, used to group the records from the
|
14
|
+
# association columns and split them in tabs
|
15
|
+
attr_accessor :tabbed_by
|
16
|
+
|
12
17
|
def label
|
13
18
|
as_(@label) if @label
|
14
19
|
end
|
@@ -22,7 +27,7 @@ module ActiveScaffold::DataStructures
|
|
22
27
|
end
|
23
28
|
|
24
29
|
# this is so that array.delete and array.include?, etc., will work by column name
|
25
|
-
def ==(other)
|
30
|
+
def ==(other) # :nodoc:
|
26
31
|
# another ActionColumns
|
27
32
|
if other.class == self.class
|
28
33
|
label == other.label
|
@@ -59,6 +64,7 @@ module ActiveScaffold::DataStructures
|
|
59
64
|
def skip_column?(column_name, options)
|
60
65
|
# skip if this matches a constrained column
|
61
66
|
return true if constraint_columns.include?(column_name.to_sym)
|
67
|
+
|
62
68
|
# skip this field if it's not authorized
|
63
69
|
unless options[:for].authorized_for?(action: options[:action], crud_type: options[:crud_type] || action&.crud_type || :read, column: column_name)
|
64
70
|
unauthorized_columns << column_name.to_sym
|
@@ -68,7 +74,7 @@ module ActiveScaffold::DataStructures
|
|
68
74
|
end
|
69
75
|
|
70
76
|
def each_column(options = {}, &proc)
|
71
|
-
columns = options[:core_columns] || action.core.columns
|
77
|
+
columns = options[:core_columns] || (action.core.user || action.core).columns
|
72
78
|
self.unauthorized_columns = []
|
73
79
|
options[:for] ||= columns.active_record_class
|
74
80
|
|
@@ -81,6 +87,7 @@ module ActiveScaffold::DataStructures
|
|
81
87
|
end
|
82
88
|
else
|
83
89
|
next if skip_column?(item, options)
|
90
|
+
|
84
91
|
yield columns[item] || ActiveScaffold::DataStructures::Column.new(item.to_sym, columns.active_record_class)
|
85
92
|
end
|
86
93
|
end
|
@@ -134,7 +141,7 @@ module ActiveScaffold::DataStructures
|
|
134
141
|
|
135
142
|
# called during clone or dup. makes the clone/dup deeper.
|
136
143
|
def initialize_copy(from)
|
137
|
-
@set = from.instance_variable_get(
|
144
|
+
@set = from.instance_variable_get(:@set).clone
|
138
145
|
end
|
139
146
|
end
|
140
147
|
end
|
@@ -59,8 +59,10 @@ module ActiveScaffold::DataStructures
|
|
59
59
|
|
60
60
|
# a hash of request parameters
|
61
61
|
attr_writer :parameters
|
62
|
+
|
62
63
|
def parameters
|
63
64
|
return @parameters || NO_OPTIONS if frozen?
|
65
|
+
|
64
66
|
@parameters ||= NO_OPTIONS.dup
|
65
67
|
end
|
66
68
|
|
@@ -77,6 +79,7 @@ module ActiveScaffold::DataStructures
|
|
77
79
|
|
78
80
|
# what string to use to represent this action
|
79
81
|
attr_writer :label
|
82
|
+
|
80
83
|
def label(record = nil)
|
81
84
|
case @label
|
82
85
|
when Symbol
|
@@ -88,7 +91,7 @@ module ActiveScaffold::DataStructures
|
|
88
91
|
end
|
89
92
|
end
|
90
93
|
|
91
|
-
# image to use {:
|
94
|
+
# image to use {name: 'arrow.png', size: '16x16'}
|
92
95
|
attr_accessor :image
|
93
96
|
|
94
97
|
# if the action requires confirmation
|
@@ -99,6 +102,7 @@ module ActiveScaffold::DataStructures
|
|
99
102
|
|
100
103
|
def confirm(label = '')
|
101
104
|
return @confirm if !confirm? || @confirm.is_a?(String)
|
105
|
+
|
102
106
|
ActiveScaffold::Registry.cache(:translations, @confirm) { as_(@confirm) } % {label: label}
|
103
107
|
end
|
104
108
|
|
@@ -108,6 +112,7 @@ module ActiveScaffold::DataStructures
|
|
108
112
|
|
109
113
|
# if the action uses a DHTML based (i.e. 2-phase) confirmation
|
110
114
|
attr_reader :dhtml_confirm
|
115
|
+
|
111
116
|
def dhtml_confirm=(value)
|
112
117
|
@confirm = nil if value
|
113
118
|
@dhtml_confirm = value
|
@@ -121,6 +126,7 @@ module ActiveScaffold::DataStructures
|
|
121
126
|
# if method return false, link will be disabled
|
122
127
|
# note that this is only the UI part of the security. to prevent URL hax0rz, you also need security on requests (e.g. don't execute update method unless authorized).
|
123
128
|
attr_writer :security_method
|
129
|
+
|
124
130
|
def security_method
|
125
131
|
@security_method || "#{action}_authorized?"
|
126
132
|
end
|
@@ -137,7 +143,7 @@ module ActiveScaffold::DataStructures
|
|
137
143
|
attr_accessor :ignore_method
|
138
144
|
|
139
145
|
# the crud type of the (eventual?) action. different than :method, because this crud action may not be imminent.
|
140
|
-
# this is used to determine record-level authorization (e.g. record.authorized_for?(:
|
146
|
+
# this is used to determine record-level authorization (e.g. record.authorized_for?(crud_type: link.crud_type).
|
141
147
|
# options are :create, :read, :update, and :delete
|
142
148
|
attr_accessor :crud_type
|
143
149
|
|
@@ -157,6 +163,7 @@ module ActiveScaffold::DataStructures
|
|
157
163
|
def popup=(val)
|
158
164
|
@popup = (val == true)
|
159
165
|
return unless @popup
|
166
|
+
|
160
167
|
self.inline = self.page = false
|
161
168
|
|
162
169
|
# the :method parameter doesn't mix with the :popup parameter
|
@@ -180,23 +187,22 @@ module ActiveScaffold::DataStructures
|
|
180
187
|
end
|
181
188
|
|
182
189
|
# where the result of this action should insert in the display.
|
183
|
-
# for :
|
190
|
+
# for type: :collection, supported values are:
|
184
191
|
# :top
|
185
|
-
# :replace (
|
186
|
-
# :popup (popup with JS library)
|
192
|
+
# :replace (for updating the entire table)
|
187
193
|
# false (no attempt at positioning)
|
188
|
-
# for :
|
194
|
+
# for type: :member, supported values are:
|
189
195
|
# :before
|
190
|
-
# :replace
|
196
|
+
# :replace
|
191
197
|
# :after
|
192
|
-
# :table (to hide the entire table)
|
193
|
-
# :popup (popup with JS library)
|
194
198
|
# false (no attempt at positioning)
|
195
199
|
attr_writer :position
|
200
|
+
|
196
201
|
def position
|
197
202
|
return @position unless @position.nil? || @position == true
|
198
203
|
return :replace if type == :member
|
199
204
|
return :top if type == :collection
|
205
|
+
|
200
206
|
raise "what should the default position be for #{type}?"
|
201
207
|
end
|
202
208
|
|
@@ -205,8 +211,10 @@ module ActiveScaffold::DataStructures
|
|
205
211
|
|
206
212
|
# html options for the link
|
207
213
|
attr_writer :html_options
|
214
|
+
|
208
215
|
def html_options
|
209
216
|
return @html_options || NO_OPTIONS if frozen?
|
217
|
+
|
210
218
|
@html_options ||= NO_OPTIONS.dup
|
211
219
|
end
|
212
220
|
|
@@ -215,6 +223,7 @@ module ActiveScaffold::DataStructures
|
|
215
223
|
|
216
224
|
# don't close the panel when another action link is open
|
217
225
|
attr_writer :keep_open
|
226
|
+
|
218
227
|
def keep_open?
|
219
228
|
@keep_open
|
220
229
|
end
|
@@ -231,6 +240,7 @@ module ActiveScaffold::DataStructures
|
|
231
240
|
|
232
241
|
def name_to_cache
|
233
242
|
return @name_to_cache if defined? @name_to_cache
|
243
|
+
|
234
244
|
[
|
235
245
|
controller || 'self',
|
236
246
|
type,
|
@@ -34,12 +34,6 @@ module ActiveScaffold::DataStructures
|
|
34
34
|
end
|
35
35
|
alias << add
|
36
36
|
|
37
|
-
def add_separator(weight = 0)
|
38
|
-
raise 'Call add_separator on a group' if name == :root
|
39
|
-
|
40
|
-
add_to_set ActionLinkSeparator.new(weight)
|
41
|
-
end
|
42
|
-
|
43
37
|
def add_to_set(link)
|
44
38
|
@set << link
|
45
39
|
end
|
@@ -57,8 +51,6 @@ module ActiveScaffold::DataStructures
|
|
57
51
|
def [](val)
|
58
52
|
links = []
|
59
53
|
@set.each do |item|
|
60
|
-
next if item == :separator
|
61
|
-
|
62
54
|
if item.is_a?(ActiveScaffold::DataStructures::ActionLinks)
|
63
55
|
collected = item[val]
|
64
56
|
links << collected unless collected.nil?
|
@@ -72,8 +64,6 @@ module ActiveScaffold::DataStructures
|
|
72
64
|
def find_duplicate(link)
|
73
65
|
links = []
|
74
66
|
@set.each do |item|
|
75
|
-
next if item == :separator
|
76
|
-
|
77
67
|
if item.is_a?(ActiveScaffold::DataStructures::ActionLinks)
|
78
68
|
collected = item.find_duplicate(link)
|
79
69
|
links << collected unless collected.nil?
|
@@ -86,8 +76,6 @@ module ActiveScaffold::DataStructures
|
|
86
76
|
|
87
77
|
def delete(val)
|
88
78
|
each(include_set: true) do |link, set|
|
89
|
-
next if link == :separator
|
90
|
-
|
91
79
|
if link.action.to_s == val.to_s
|
92
80
|
set.delete link
|
93
81
|
break
|
@@ -98,6 +86,7 @@ module ActiveScaffold::DataStructures
|
|
98
86
|
def delete_group(name)
|
99
87
|
@set.each do |group|
|
100
88
|
next unless group.is_a?(ActiveScaffold::DataStructures::ActionLinks)
|
89
|
+
|
101
90
|
if group.name == name
|
102
91
|
@set.delete group
|
103
92
|
break
|
@@ -121,6 +110,12 @@ module ActiveScaffold::DataStructures
|
|
121
110
|
end
|
122
111
|
end
|
123
112
|
|
113
|
+
def collect_by_type(type = nil)
|
114
|
+
links = []
|
115
|
+
subgroup(type).each(type) { |link| links << link }
|
116
|
+
links
|
117
|
+
end
|
118
|
+
|
124
119
|
def collect
|
125
120
|
@set
|
126
121
|
end
|
@@ -136,6 +131,8 @@ module ActiveScaffold::DataStructures
|
|
136
131
|
end
|
137
132
|
|
138
133
|
if group.nil?
|
134
|
+
raise "Can't add new subgroup '#{name}', links are frozen" if frozen?
|
135
|
+
|
139
136
|
group = ActiveScaffold::DataStructures::ActionLinks.new(name)
|
140
137
|
group.label = label || name
|
141
138
|
group.default_type = self.name == :root ? (name.to_sym if %w[member collection].include?(name.to_s)) : default_type
|
@@ -145,6 +142,7 @@ module ActiveScaffold::DataStructures
|
|
145
142
|
end
|
146
143
|
|
147
144
|
attr_writer :label
|
145
|
+
|
148
146
|
def label(record)
|
149
147
|
case @label
|
150
148
|
when Symbol
|
@@ -157,13 +155,15 @@ module ActiveScaffold::DataStructures
|
|
157
155
|
end
|
158
156
|
|
159
157
|
def method_missing(name, *args, &block)
|
160
|
-
return super if name.match?(/[
|
158
|
+
return super if name.match?(/[=!?]$/)
|
159
|
+
return subgroup(name.to_sym, args.first, &block) if frozen?
|
160
|
+
|
161
161
|
class_eval <<-METHOD, __FILE__, __LINE__ + 1
|
162
|
-
def #{name}(label = nil)
|
163
|
-
@#{name} ||= subgroup('#{name}'
|
164
|
-
yield @#{name} if block_given?
|
165
|
-
@#{name}
|
166
|
-
end
|
162
|
+
def #{name}(label = nil) # def group_name(label = nil)
|
163
|
+
@#{name} ||= subgroup(:'#{name}', label) # @group_name ||= subgroup(:'group_name', label)
|
164
|
+
yield @#{name} if block_given? # yield @group_name if block_given?
|
165
|
+
@#{name} # @group_name
|
166
|
+
end # end
|
167
167
|
METHOD
|
168
168
|
send(name, args.first, &block)
|
169
169
|
end
|
@@ -173,20 +173,14 @@ module ActiveScaffold::DataStructures
|
|
173
173
|
end
|
174
174
|
|
175
175
|
attr_reader :name
|
176
|
-
attr_accessor :weight
|
177
|
-
attr_accessor :css_class
|
178
|
-
|
179
|
-
def name=(value)
|
180
|
-
self.css_class = value
|
181
|
-
end
|
182
|
-
ActiveScaffold.deprecator.deprecate_methods(self, :name= => :css_class=)
|
176
|
+
attr_accessor :weight, :css_class
|
183
177
|
|
184
178
|
protected
|
185
179
|
|
186
180
|
# called during clone or dup. makes the clone/dup deeper.
|
187
181
|
def initialize_copy(from)
|
188
182
|
@set = []
|
189
|
-
from.instance_variable_get(
|
183
|
+
from.instance_variable_get(:@set).each { |link| @set << link.clone }
|
190
184
|
end
|
191
185
|
end
|
192
186
|
end
|