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
@@ -10,6 +10,7 @@ module ActiveScaffold
|
|
10
10
|
include ActiveScaffold::Helpers::ListColumnHelpers
|
11
11
|
include ActiveScaffold::Helpers::ShowColumnHelpers
|
12
12
|
include ActiveScaffold::Helpers::FormColumnHelpers
|
13
|
+
include ActiveScaffold::Helpers::TabsHelpers
|
13
14
|
include ActiveScaffold::Helpers::SearchColumnHelpers
|
14
15
|
include ActiveScaffold::Helpers::HumanConditionHelpers
|
15
16
|
|
@@ -61,24 +62,23 @@ module ActiveScaffold
|
|
61
62
|
# it's call many times and we can cache same result
|
62
63
|
@_loading_indicator_path ||= image_path('active_scaffold/indicator.gif')
|
63
64
|
# it's call many times in long lists, image_tag is a bit slower
|
64
|
-
tag
|
65
|
+
tag.img(src: @_loading_indicator_path, style: 'visibility:hidden;', id: loading_indicator_id(options), alt: 'loading indicator', class: 'loading-indicator')
|
65
66
|
end
|
66
67
|
|
67
68
|
# Creates a javascript-based link that toggles the visibility of some element on the page.
|
68
69
|
# By default, it toggles the visibility of the sibling after the one it's nested in.
|
69
|
-
# You may pass custom javascript logic in options[:of] to change that, though. For example, you could say :of => '$("my_div_id")'.
|
70
70
|
# You may also flag whether the other element is visible by default or not, and the initial text will adjust accordingly.
|
71
71
|
def link_to_visibility_toggle(id, options = {})
|
72
72
|
options[:hide_label] ||= as_(:hide)
|
73
73
|
options[:show_label] ||= as_(:show_block)
|
74
74
|
label = options[:default_visible].nil? || options[:default_visible] ? options[:hide_label] : options[:show_label]
|
75
|
-
data = {:
|
76
|
-
link_to label, '#', :
|
75
|
+
data = {show: options[:show_label], hide: options[:hide_label], toggable: id}
|
76
|
+
link_to label, '#', data: data, style: 'display: none;', class: 'as-js-button visibility-toggle'
|
77
77
|
end
|
78
78
|
|
79
79
|
def list_row_class(record)
|
80
80
|
class_override_helper = override_helper_per_model(:list_row_class, record.class)
|
81
|
-
class_override_helper
|
81
|
+
class_override_helper == :list_row_class ? '' : send(class_override_helper, record)
|
82
82
|
end
|
83
83
|
|
84
84
|
def list_row_attributes(tr_class, tr_id, data_refresh)
|
@@ -88,6 +88,7 @@ module ActiveScaffold
|
|
88
88
|
def column_attributes(column, record)
|
89
89
|
method = override_helper column, 'column_attributes'
|
90
90
|
return send(method, record) if method
|
91
|
+
|
91
92
|
{}
|
92
93
|
end
|
93
94
|
|
@@ -138,6 +139,7 @@ module ActiveScaffold
|
|
138
139
|
|
139
140
|
def empty_field_text
|
140
141
|
return @_empty_field_text if defined? @_empty_field_text
|
142
|
+
|
141
143
|
@_empty_field_text = (active_scaffold_config.list.empty_field_text if active_scaffold_config.actions.include?(:list))
|
142
144
|
end
|
143
145
|
|
@@ -188,7 +190,7 @@ module ActiveScaffold
|
|
188
190
|
end
|
189
191
|
|
190
192
|
def display_message(message)
|
191
|
-
message = safe_join message, tag
|
193
|
+
message = safe_join message, tag.br if message.is_a?(Array)
|
192
194
|
if (highlights = active_scaffold_config.user.highlight_messages)
|
193
195
|
message = highlights.inject(message) do |msg, (phrases, highlighter)|
|
194
196
|
highlight(msg, phrases, highlighter || {})
|
@@ -196,8 +198,8 @@ module ActiveScaffold
|
|
196
198
|
end
|
197
199
|
if (format = active_scaffold_config.user.timestamped_messages)
|
198
200
|
format = :short if format == true
|
199
|
-
messages = [content_tag(:div, l(Time.current, :
|
200
|
-
messages << content_tag(:div, message, :
|
201
|
+
messages = [content_tag(:div, l(Time.current, format: format), class: 'timestamp')]
|
202
|
+
messages << content_tag(:div, message, class: 'message-content')
|
201
203
|
message = safe_join messages, ' '
|
202
204
|
end
|
203
205
|
message
|
@@ -205,10 +207,10 @@ module ActiveScaffold
|
|
205
207
|
|
206
208
|
def active_scaffold_error_messages_for(*params)
|
207
209
|
options = params.extract_options!.symbolize_keys
|
208
|
-
options.reverse_merge!(:
|
210
|
+
options.reverse_merge!(container_tag: :div, list_type: :ul)
|
209
211
|
|
210
212
|
objects = Array.wrap(options.delete(:object) || params).map do |object|
|
211
|
-
object = instance_variable_get("@#{object}") unless object.respond_to?(:to_model)
|
213
|
+
object = instance_variable_get(:"@#{object}") unless object.respond_to?(:to_model)
|
212
214
|
object = convert_to_model(object)
|
213
215
|
|
214
216
|
options[:object_name] ||= object.class.model_name.human.downcase if object.class.respond_to?(:model_name)
|
@@ -237,19 +239,19 @@ module ActiveScaffold
|
|
237
239
|
if options.include?(:header_message)
|
238
240
|
options[:header_message]
|
239
241
|
else
|
240
|
-
as_('errors.template.header', :
|
242
|
+
as_('errors.template.header', count: count, model: options[:object_name].to_s.tr('_', ' '))
|
241
243
|
end
|
242
244
|
|
243
245
|
message = options.include?(:message) ? options[:message] : as_('errors.template.body')
|
244
246
|
|
245
247
|
error_messages = objects.sum([]) do |object|
|
246
248
|
object.errors.full_messages.map do |msg|
|
247
|
-
options[:list_type]
|
249
|
+
options[:list_type] == :br ? msg : content_tag(:li, msg)
|
248
250
|
end
|
249
251
|
end
|
250
252
|
error_messages =
|
251
253
|
if options[:list_type] == :br
|
252
|
-
safe_join error_messages, tag
|
254
|
+
safe_join error_messages, tag.br
|
253
255
|
else
|
254
256
|
content_tag options[:list_type], safe_join(error_messages)
|
255
257
|
end
|
@@ -14,8 +14,7 @@ module ActiveScaffold
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def as_marked=(value)
|
17
|
-
|
18
|
-
if value == true
|
17
|
+
if [true, 'true', 1, '1', 'T', 't'].include?(value.respond_to?(:downcase) ? value.downcase : value)
|
19
18
|
marked_records[id.to_s] = true unless as_marked
|
20
19
|
else
|
21
20
|
marked_records.delete(id.to_s)
|
@@ -2,12 +2,14 @@ module ActiveScaffold
|
|
2
2
|
module OrmChecks
|
3
3
|
class << self
|
4
4
|
def active_record?(klass)
|
5
|
-
return unless defined? ActiveRecord
|
5
|
+
return false unless defined? ActiveRecord
|
6
|
+
|
6
7
|
klass < ActiveRecord::Base
|
7
8
|
end
|
8
9
|
|
9
10
|
def mongoid?(klass)
|
10
|
-
return unless defined? Mongoid
|
11
|
+
return false unless defined? Mongoid
|
12
|
+
|
11
13
|
klass < Mongoid::Document
|
12
14
|
end
|
13
15
|
|
@@ -61,7 +63,7 @@ module ActiveScaffold
|
|
61
63
|
if active_record? klass
|
62
64
|
klass.content_columns
|
63
65
|
elsif mongoid? klass
|
64
|
-
klass.fields.
|
66
|
+
klass.fields.except('_id').values
|
65
67
|
else
|
66
68
|
[]
|
67
69
|
end
|
@@ -108,7 +110,7 @@ module ActiveScaffold
|
|
108
110
|
|
109
111
|
%i[_table_name _quoted_table_name _columns _columns_hash _reflect_on_all_associations _content_columns].each do |method|
|
110
112
|
define_method method do
|
111
|
-
ActiveScaffold::OrmChecks.send method.to_s[1
|
113
|
+
ActiveScaffold::OrmChecks.send method.to_s[1..], active_record_class
|
112
114
|
end
|
113
115
|
end
|
114
116
|
|
@@ -22,6 +22,7 @@ class Paginator
|
|
22
22
|
@count = count
|
23
23
|
@per_page = per_page
|
24
24
|
raise MissingSelectError, 'Must provide block to select data for each page' unless select
|
25
|
+
|
25
26
|
@select = select
|
26
27
|
end
|
27
28
|
|
@@ -78,7 +79,7 @@ class Paginator
|
|
78
79
|
|
79
80
|
attr_reader :number, :pager
|
80
81
|
|
81
|
-
def initialize(pager, number, &select)
|
82
|
+
def initialize(pager, number, &select) # :nodoc:
|
82
83
|
@pager = pager
|
83
84
|
@number = number
|
84
85
|
@offset = (number - 1) * pager.per_page
|
@@ -125,7 +126,7 @@ class Paginator
|
|
125
126
|
end
|
126
127
|
end
|
127
128
|
|
128
|
-
def ==(other)
|
129
|
+
def ==(other) # :nodoc:
|
129
130
|
@pager == other.pager && number == other.number
|
130
131
|
end
|
131
132
|
end
|
@@ -14,6 +14,10 @@ module ActiveScaffold
|
|
14
14
|
RequestStore.store[:attr_Registry_unauthorized_columns] ||= Hash.new { |h, k| h[k] = [] }
|
15
15
|
end
|
16
16
|
|
17
|
+
def self.column_links
|
18
|
+
RequestStore.store[:column_links] ||= {}
|
19
|
+
end
|
20
|
+
|
17
21
|
def self.cache(kind, key = nil, &block)
|
18
22
|
unless key
|
19
23
|
key = kind
|
@@ -22,6 +26,7 @@ module ActiveScaffold
|
|
22
26
|
RequestStore.store[:attr_Registry_cache] ||= {}
|
23
27
|
cache = RequestStore.store[:attr_Registry_cache][kind] ||= {}
|
24
28
|
return cache[key] if cache.include? key
|
29
|
+
|
25
30
|
cache[key] ||= yield
|
26
31
|
end
|
27
32
|
end
|
@@ -8,6 +8,7 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
8
8
|
|
9
9
|
class Connection < ActiveRecord::ConnectionAdapters::AbstractAdapter
|
10
10
|
attr_reader :klass
|
11
|
+
|
11
12
|
def initialize(klass, *args)
|
12
13
|
super(nil, *args)
|
13
14
|
@klass = klass
|
@@ -17,15 +18,13 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
17
18
|
klass.columns
|
18
19
|
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
klass ? [klass.table_name] : []
|
23
|
-
end
|
21
|
+
def data_sources
|
22
|
+
klass ? [klass.table_name] : []
|
24
23
|
end
|
25
24
|
end
|
26
25
|
|
27
26
|
class Column < ActiveRecord::ConnectionAdapters::Column
|
28
|
-
def initialize(name, default, sql_type = nil, null = true, **)
|
27
|
+
def initialize(name, default, sql_type = nil, null = true, **) # rubocop:disable Style/OptionalBooleanParameter
|
29
28
|
metadata = ActiveRecord::Base.connection.send :fetch_type_metadata, sql_type
|
30
29
|
super(name, default, metadata, null)
|
31
30
|
end
|
@@ -41,7 +40,7 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
41
40
|
if klass < ActiveScaffold::Tableless
|
42
41
|
class << scope; include RelationExtension; end
|
43
42
|
assoc_conditions = scope.proxy_association&.send(:association_scope)&.conditions
|
44
|
-
if assoc_conditions
|
43
|
+
if assoc_conditions.present?
|
45
44
|
scope.conditions.concat(assoc_conditions.map { |c| c.is_a?(Hash) ? c[klass.table_name] || c : c })
|
46
45
|
end
|
47
46
|
end
|
@@ -59,6 +58,14 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
59
58
|
def get_records # rubocop:disable Naming/AccessorMethodName
|
60
59
|
klass < ActiveScaffold::Tableless ? scope.to_a : super
|
61
60
|
end
|
61
|
+
|
62
|
+
def reader
|
63
|
+
super.tap do |proxy|
|
64
|
+
if klass < ActiveScaffold::Tableless
|
65
|
+
def proxy.exists?(...) = scope.exists?(...)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
62
69
|
end
|
63
70
|
|
64
71
|
module CollectionAssociation
|
@@ -111,9 +118,7 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
111
118
|
|
112
119
|
def except(*skips)
|
113
120
|
super.tap do |new_relation|
|
114
|
-
unless new_relation.is_a?(RelationExtension)
|
115
|
-
class << new_relation; include RelationExtension; end
|
116
|
-
end
|
121
|
+
class << new_relation; include RelationExtension; end unless new_relation.is_a?(RelationExtension)
|
117
122
|
new_relation.conditions.concat conditions unless skips.include? :where
|
118
123
|
end
|
119
124
|
end
|
@@ -147,6 +152,10 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
147
152
|
include RelationExtension
|
148
153
|
end
|
149
154
|
class << self
|
155
|
+
def find(*ids)
|
156
|
+
ids.length == 1 ? all.find(*ids[0]) : super # rubocop:disable Rails/RedundantActiveRecordAllMethod
|
157
|
+
end
|
158
|
+
|
150
159
|
private
|
151
160
|
|
152
161
|
def relation
|
@@ -170,7 +179,7 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
170
179
|
end
|
171
180
|
|
172
181
|
def self.columns
|
173
|
-
@tableless_columns ||= []
|
182
|
+
@tableless_columns ||= [] # rubocop:disable Naming/MemoizedInstanceVariableName
|
174
183
|
end
|
175
184
|
|
176
185
|
def self.table_name
|
@@ -203,6 +212,7 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
203
212
|
unless operation == 'count' && [relation.klass.primary_key, :all].include?(column_name)
|
204
213
|
raise "self.execute_simple_calculation must be implemented in a Tableless model to support #{operation} #{column_name}#{' distinct' if distinct} columns"
|
205
214
|
end
|
215
|
+
|
206
216
|
find_all(relation).size
|
207
217
|
end
|
208
218
|
|
@@ -210,11 +220,11 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
|
|
210
220
|
raise 'destroy must be implemented in a Tableless model'
|
211
221
|
end
|
212
222
|
|
213
|
-
def _create_record
|
214
|
-
run_callbacks(:create) {}
|
223
|
+
def _create_record # :nodoc:
|
224
|
+
run_callbacks(:create) {} # run callbacks but do nothing
|
215
225
|
end
|
216
226
|
|
217
|
-
def _update_record(*)
|
218
|
-
run_callbacks(:update) {}
|
227
|
+
def _update_record(*) # :nodoc:
|
228
|
+
run_callbacks(:update) {} # run callbacks but do nothing
|
219
229
|
end
|
220
230
|
end
|
data/lib/active_scaffold.rb
CHANGED
@@ -51,45 +51,20 @@ module ActiveScaffold
|
|
51
51
|
mattr_accessor :javascripts, instance_writer: false
|
52
52
|
self.javascripts = []
|
53
53
|
|
54
|
-
mattr_reader :threadsafe
|
55
54
|
def self.threadsafe!
|
56
|
-
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.js_framework=(framework)
|
60
|
-
warning = 'js_framework is deprecated as prototype support will be removed in 4.0'
|
61
|
-
case framework
|
62
|
-
when :jquery then
|
63
|
-
warning +=
|
64
|
-
if defined? Jquery
|
65
|
-
', it can be removed as it defaults to :jquery'
|
66
|
-
else
|
67
|
-
", it's still needed in this version, as you are not using jquery-rails gem"
|
68
|
-
end
|
69
|
-
when :prototype then warning += ', convert your app to jQuery, and remove this call'
|
70
|
-
end
|
71
|
-
deprecator.warn warning
|
72
|
-
@@js_framework = framework
|
73
|
-
end
|
74
|
-
|
75
|
-
def self.js_framework
|
76
|
-
@@js_framework ||=
|
77
|
-
if defined? Jquery
|
78
|
-
:jquery
|
79
|
-
elsif defined? PrototypeRails
|
80
|
-
:prototype
|
81
|
-
end
|
55
|
+
ActiveSupport::Deprecation.warn 'Threadsafe is enabled always, no need to require it anymore'
|
82
56
|
end
|
83
57
|
|
84
58
|
mattr_writer :jquery_ui_loaded, instance_writer: false
|
85
59
|
def self.jquery_ui_included?
|
86
60
|
return true if @@jquery_ui_loaded
|
87
|
-
|
61
|
+
|
62
|
+
Jquery::Rails.const_defined?(:JQUERY_UI_VERSION) || Jquery.const_defined?(:Ui) if Object.const_defined?(:Jquery)
|
88
63
|
end
|
89
64
|
|
90
65
|
mattr_writer :js_config, instance_writer: false
|
91
66
|
def self.js_config
|
92
|
-
@@js_config ||= {:
|
67
|
+
@@js_config ||= {scroll_on_close: :checkInViewport}
|
93
68
|
end
|
94
69
|
|
95
70
|
# exclude bridges you do not need, add to an initializer
|
@@ -102,18 +77,17 @@ module ActiveScaffold
|
|
102
77
|
end
|
103
78
|
|
104
79
|
mattr_accessor :nested_subforms, instance_writer: false
|
80
|
+
def nested_subforms=(*)
|
81
|
+
ActiveSupport::Deprecation.warn 'Nested subforms are enabled by default already'
|
82
|
+
end
|
105
83
|
|
106
84
|
def self.root
|
107
|
-
File.dirname(__FILE__)
|
85
|
+
"#{File.dirname(__FILE__)}/.."
|
108
86
|
end
|
109
87
|
|
110
88
|
def self.defaults(&block)
|
111
89
|
ActiveScaffold::Config::Core.configure(&block)
|
112
90
|
end
|
113
|
-
|
114
|
-
def self.deprecator
|
115
|
-
@deprecator ||= ActiveSupport::Deprecation.new('4.0', 'ActiveScaffold')
|
116
|
-
end
|
117
91
|
end
|
118
92
|
require 'active_scaffold/engine'
|
119
93
|
require 'ice_nine'
|
@@ -7,31 +7,31 @@ module ActiveScaffold
|
|
7
7
|
|
8
8
|
source_root File.expand_path('../templates', __dir__)
|
9
9
|
|
10
|
-
check_class_collision :
|
10
|
+
check_class_collision suffix: 'Controller'
|
11
11
|
|
12
|
-
class_option :orm, :
|
13
|
-
:
|
12
|
+
class_option :orm, banner: 'NAME', type: :string, required: true,
|
13
|
+
desc: 'ORM to generate the controller for'
|
14
14
|
|
15
|
-
desc
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
desc <<~DESC
|
16
|
+
Description:
|
17
|
+
Stubs out a active_scaffolded controller. Pass the model name,
|
18
|
+
either CamelCased or under_scored.
|
19
|
+
The controller name is retrieved as a pluralized version of the model
|
20
|
+
name.
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
To create a controller within a module, specify the model name as a
|
23
|
+
path like 'parent_module/controller_name'.
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
This generates a controller class in app/controllers and invokes helper,
|
26
|
+
template engine and test framework generators.
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
Example:
|
29
|
+
`rails generate active_scaffold:controller CreditCard`
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
Credit card controller with URLs like /credit_card/debit.
|
32
|
+
Controller: app/controllers/credit_cards_controller.rb
|
33
|
+
Functional Test: test/functional/credit_cards_controller_test.rb
|
34
|
+
Helper: app/helpers/credit_cards_helper.rb
|
35
35
|
DESC
|
36
36
|
|
37
37
|
def create_controller_files
|
@@ -39,7 +39,7 @@ module ActiveScaffold
|
|
39
39
|
template 'helper.rb', File.join('app/helpers', class_path, "#{controller_file_name}_helper.rb")
|
40
40
|
end
|
41
41
|
|
42
|
-
hook_for :test_framework, :
|
42
|
+
hook_for :test_framework, as: :scaffold
|
43
43
|
|
44
44
|
def create_view_root_folder
|
45
45
|
empty_directory File.join('app/views', controller_file_path)
|
@@ -14,13 +14,8 @@ module ActiveScaffold
|
|
14
14
|
def add_to_javascript_manifest
|
15
15
|
file = 'app/assets/javascripts/application.js'
|
16
16
|
unless File.exist?(file)
|
17
|
-
|
18
|
-
|
19
|
-
return
|
20
|
-
end
|
21
|
-
say_status :missing, file, :red
|
22
|
-
return if options[:pretend]
|
23
|
-
raise Thor::Error, "JS file #{file} is required for ActiveScaffold"
|
17
|
+
create_javascript_manifest file
|
18
|
+
return
|
24
19
|
end
|
25
20
|
original_js = File.binread(file)
|
26
21
|
if original_js.include?('require active_scaffold')
|
@@ -36,6 +31,7 @@ module ActiveScaffold
|
|
36
31
|
def add_to_stylesheet_manifest
|
37
32
|
file = 'app/assets/stylesheets/application.css'
|
38
33
|
return unless File.exist?(file)
|
34
|
+
|
39
35
|
original_css = File.binread(file)
|
40
36
|
if original_css.match?(/require active_scaffold$/)
|
41
37
|
say_status('skipped', 'insert into app/assets/stylesheets/application.css', :yellow)
|
@@ -78,7 +74,7 @@ module ActiveScaffold
|
|
78
74
|
|
79
75
|
def setup_jquery(file, original_js = nil, where: 'ujs')
|
80
76
|
original_js ||= File.binread(file)
|
81
|
-
if
|
77
|
+
if defined? Jquery
|
82
78
|
unless original_js.include?('require jquery')
|
83
79
|
insert_into_file file, before: %r{//= require +.*#{where}['"]?\n} do
|
84
80
|
"//= require jquery\n"
|
@@ -8,42 +8,42 @@ module ActiveScaffold
|
|
8
8
|
remove_hook_for :resource_route
|
9
9
|
remove_class_option :actions
|
10
10
|
|
11
|
-
desc
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
11
|
+
desc <<~DESC
|
12
|
+
Description:
|
13
|
+
Scaffolds an entire resource, from model and migration to controller,
|
14
|
+
along with a full test suite and configured to use active_scaffold.
|
15
|
+
The resource is ready to use as a starting point for your RESTful,
|
16
|
+
resource-oriented application.
|
17
|
+
|
18
|
+
Pass the name of the model (in singular form), either CamelCased or
|
19
|
+
under_scored, as the first argument, and an optional list of attribute
|
20
|
+
pairs.
|
21
|
+
|
22
|
+
Attribute pairs are field:type arguments specifying the
|
23
|
+
model's attributes. Timestamps are added by default, so you don't have to
|
24
|
+
specify them by hand as 'created_at:datetime updated_at:datetime'.
|
25
|
+
|
26
|
+
You don't have to think up every attribute up front, but it helps to
|
27
|
+
sketch out a few so you can start working with the resource immediately.
|
28
|
+
|
29
|
+
For example, 'active_scaffold post title:string body:text published:boolean'
|
30
|
+
gives you a model with those three attributes, a controller configured to use active_scaffold,
|
31
|
+
as well as a resources :posts with additional active_scaffold routes
|
32
|
+
declaration in config/routes.rb.
|
33
|
+
|
34
|
+
If you want to remove all the generated files, run
|
35
|
+
'rails destroy active_scaffold ModelName'.
|
36
|
+
|
37
|
+
Examples:
|
38
|
+
`rails generate active_scaffold:resource post`
|
39
|
+
`rails generate active_scaffold:resource post title:string body:text published:boolean`
|
40
|
+
`rails generate active_scaffold:resource purchase order_id:integer amount:decimal`
|
41
41
|
DESC
|
42
42
|
|
43
43
|
def add_resource_route
|
44
44
|
routing_code = class_path.collect { |namespace| "namespace :#{namespace} do " }.join(' ')
|
45
45
|
routing_code << "resources :#{file_name.pluralize}, concerns: :active_scaffold"
|
46
|
-
routing_code << ' end' * class_path.size
|
46
|
+
routing_code << (' end' * class_path.size)
|
47
47
|
log :route, routing_code
|
48
48
|
in_root do
|
49
49
|
inject_into_file 'config/routes.rb', " #{routing_code}\n", after: /^[ ]*concern :active_scaffold,.*\n/, verbose: false, force: true
|
data/lib/tasks/brakeman.rake
CHANGED
@@ -3,7 +3,7 @@ namespace :brakeman do
|
|
3
3
|
task :run, :output_files do |_t, args|
|
4
4
|
require 'brakeman'
|
5
5
|
|
6
|
-
files = args[:output_files].split
|
6
|
+
files = args[:output_files].split if args[:output_files]
|
7
7
|
Brakeman.run app_path: '.', output_files: files, print_report: true
|
8
8
|
end
|
9
9
|
|