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
@@ -2,10 +2,6 @@ module ActiveScaffold
|
|
2
2
|
module Helpers
|
3
3
|
# Helpers that assist with the rendering of a List Column
|
4
4
|
module ListColumnHelpers
|
5
|
-
def list_record_view
|
6
|
-
'list_record'
|
7
|
-
end
|
8
|
-
|
9
5
|
def get_column_value(record, column)
|
10
6
|
record = record.send(column.delegated_association.name) if column.delegated_association
|
11
7
|
if record
|
@@ -19,7 +15,7 @@ module ActiveScaffold
|
|
19
15
|
else
|
20
16
|
value = nil
|
21
17
|
end
|
22
|
-
value = ' '.html_safe if value.nil? || value.blank? # fix for IE 6
|
18
|
+
value = ' '.html_safe if value.nil? || value.blank? # fix for IE 6
|
23
19
|
value
|
24
20
|
rescue StandardError => e
|
25
21
|
logger.error "#{e.class.name}: #{e.message} -- on the ActiveScaffold column = :#{column.name} in #{controller.class}, record: #{record.inspect}"
|
@@ -37,7 +33,7 @@ module ActiveScaffold
|
|
37
33
|
# second, check if the dev has specified a valid list_ui for this column
|
38
34
|
elsif column.list_ui && (method = override_column_ui(column.list_ui))
|
39
35
|
[method, true]
|
40
|
-
elsif column.column && (method = override_column_ui(column.column_type))
|
36
|
+
elsif column.column && (method = override_column_ui(column.column_type)) # rubocop:disable Lint/DuplicateBranch
|
41
37
|
method
|
42
38
|
else
|
43
39
|
:format_column_value
|
@@ -53,9 +49,9 @@ module ActiveScaffold
|
|
53
49
|
associated = record.send(column.association.name) if column.association
|
54
50
|
authorized = link.action.nil?
|
55
51
|
authorized, reason = column_link_authorized?(link, column, record, associated) unless authorized
|
56
|
-
render_action_link(link, record, :
|
52
|
+
render_action_link(link, record, link: text, authorized: authorized, not_authorized_reason: reason)
|
57
53
|
elsif inplace_edit?(record, column)
|
58
|
-
active_scaffold_inplace_edit(record, column, :
|
54
|
+
active_scaffold_inplace_edit(record, column, formatted_column: text)
|
59
55
|
elsif column_wrap_tag
|
60
56
|
content_tag column_wrap_tag, text
|
61
57
|
else
|
@@ -68,6 +64,7 @@ module ActiveScaffold
|
|
68
64
|
|
69
65
|
def column_wrap_tag
|
70
66
|
return @_column_wrap_tag if defined? @_column_wrap_tag
|
67
|
+
|
71
68
|
@_column_wrap_tag = (active_scaffold_config.list.wrap_tag if active_scaffold_config.actions.include?(:list))
|
72
69
|
end
|
73
70
|
|
@@ -78,8 +75,8 @@ module ActiveScaffold
|
|
78
75
|
#
|
79
76
|
# Why is it not a configuration option? Because it seems like a somewhat rare request. But it
|
80
77
|
# could eventually be an option in config.list (and config.show, I guess).
|
81
|
-
def clean_column_value(
|
82
|
-
h(
|
78
|
+
def clean_column_value(value)
|
79
|
+
h(value)
|
83
80
|
end
|
84
81
|
|
85
82
|
##
|
@@ -95,12 +92,12 @@ module ActiveScaffold
|
|
95
92
|
end
|
96
93
|
|
97
94
|
def active_scaffold_column_marked(record, column, ui_options: column.options)
|
98
|
-
options = {:
|
99
|
-
content_tag(:span, check_box(:record, column.name, options), :
|
95
|
+
options = {id: nil, object: record}
|
96
|
+
content_tag(:span, check_box(:record, column.name, options), class: 'in_place_editor_field', data: {ie_id: record.to_param})
|
100
97
|
end
|
101
98
|
|
102
99
|
def active_scaffold_column_checkbox(record, column, ui_options: column.options)
|
103
|
-
options = {:
|
100
|
+
options = {disabled: true, id: nil, object: record}
|
104
101
|
options.delete(:disabled) if inplace_edit?(record, column)
|
105
102
|
check_box(:record, column.name, options)
|
106
103
|
end
|
@@ -141,6 +138,7 @@ module ActiveScaffold
|
|
141
138
|
def active_scaffold_column_telephone(record, column, ui_options: column.options)
|
142
139
|
phone = record.send column.name
|
143
140
|
return if phone.blank?
|
141
|
+
|
144
142
|
phone = number_to_phone(phone) unless ui_options[:format] == false
|
145
143
|
tel_to phone
|
146
144
|
end
|
@@ -241,6 +239,7 @@ module ActiveScaffold
|
|
241
239
|
column_value = column&.association_join_text
|
242
240
|
return column_value if column_value
|
243
241
|
return @_association_join_text if defined? @_association_join_text
|
242
|
+
|
244
243
|
@_association_join_text = active_scaffold_config.list.association_join_text
|
245
244
|
end
|
246
245
|
|
@@ -285,7 +284,7 @@ module ActiveScaffold
|
|
285
284
|
if column_empty?(column_value)
|
286
285
|
empty_field_text
|
287
286
|
elsif column_value.is_a?(Time) || column_value.is_a?(Date)
|
288
|
-
l(column_value, :
|
287
|
+
l(column_value, format: options[:format] || :default)
|
289
288
|
elsif !!column_value == column_value # rubocop:disable Style/DoubleNegation fast check for boolean
|
290
289
|
as_(column_value.to_s.to_sym)
|
291
290
|
else
|
@@ -318,11 +317,12 @@ module ActiveScaffold
|
|
318
317
|
# ==========
|
319
318
|
|
320
319
|
def inplace_edit?(record, column)
|
321
|
-
return unless column.inplace_edit
|
320
|
+
return false unless column.inplace_edit
|
322
321
|
if controller.respond_to?(:update_authorized?, true)
|
323
322
|
return Array(controller.send(:update_authorized?, record, column.name))[0]
|
324
323
|
end
|
325
|
-
|
324
|
+
|
325
|
+
record.authorized_for?(crud_type: :update, column: column.name)
|
326
326
|
end
|
327
327
|
|
328
328
|
def inplace_edit_cloning?(column)
|
@@ -335,30 +335,27 @@ module ActiveScaffold
|
|
335
335
|
element_cell_id(id: '--ID--', action: 'update_column', name: column.name.to_s)
|
336
336
|
end
|
337
337
|
tag_options = {id: cell_id.sub('--ID--', record.id.to_s), class: 'in_place_editor_field',
|
338
|
-
title: @_inplace_edit_title, data: {:
|
338
|
+
title: @_inplace_edit_title, data: {ie_id: record.to_param}}
|
339
339
|
tag_options[:data][:ie_update] = column.inplace_edit if column.inplace_edit != true
|
340
340
|
tag_options
|
341
341
|
end
|
342
342
|
|
343
343
|
def active_scaffold_inplace_edit(record, column, options = {})
|
344
344
|
formatted_column = options[:formatted_column] || format_column_value(record, column)
|
345
|
-
@_inplace_edit_handle ||= content_tag(:span, as_(:inplace_edit_handle), :
|
345
|
+
@_inplace_edit_handle ||= content_tag(:span, as_(:inplace_edit_handle), class: 'handle')
|
346
346
|
span = content_tag(:span, formatted_column, active_scaffold_inplace_edit_tag_options(record, column))
|
347
347
|
@_inplace_edit_handle + span
|
348
348
|
end
|
349
349
|
|
350
350
|
def inplace_edit_control(column)
|
351
351
|
return unless inplace_edit?(active_scaffold_config.model, column) && inplace_edit_cloning?(column)
|
352
|
-
|
353
|
-
column = column.dup
|
354
|
-
column.options = column.options.dup
|
355
|
-
end
|
352
|
+
|
356
353
|
column.form_ui = :select if column.association && column.form_ui.nil?
|
357
|
-
options = active_scaffold_input_options(column).merge(:
|
354
|
+
options = active_scaffold_input_options(column).merge(object: column.active_record_class.new)
|
358
355
|
options[:class] = "#{options[:class]} inplace_field"
|
359
|
-
options[:
|
356
|
+
options[:'data-id'] = options[:id]
|
360
357
|
options[:id] = nil
|
361
|
-
content_tag(:div, active_scaffold_input_for(column, nil, options), :
|
358
|
+
content_tag(:div, active_scaffold_input_for(column, nil, options), style: 'display:none;', class: inplace_edit_control_css_class)
|
362
359
|
end
|
363
360
|
|
364
361
|
def inplace_edit_control_css_class
|
@@ -368,7 +365,7 @@ module ActiveScaffold
|
|
368
365
|
INPLACE_EDIT_PLURAL_FORM_UI = %i[select record_select].freeze
|
369
366
|
def inplace_edit_data(column)
|
370
367
|
data = {}
|
371
|
-
data[:ie_url] = url_for(params_for(:
|
368
|
+
data[:ie_url] = url_for(params_for(action: 'update_column', column: column.name, id: '__id__'))
|
372
369
|
data[:ie_cancel_text] = column.options[:cancel_text] || as_(:cancel)
|
373
370
|
data[:ie_loading_text] = column.options[:loading_text] || as_(:loading)
|
374
371
|
data[:ie_save_text] = column.options[:save_text] || as_(:update)
|
@@ -383,7 +380,7 @@ module ActiveScaffold
|
|
383
380
|
elsif inplace_edit_cloning?(column)
|
384
381
|
data[:ie_mode] = :clone
|
385
382
|
elsif column.inplace_edit == :ajax
|
386
|
-
url = url_for(params_for(:
|
383
|
+
url = url_for(params_for(controller: params_for[:controller], action: 'render_field', id: '__id__', update_column: column.name))
|
387
384
|
plural = column.association&.collection? && !override_form_field?(column) && INPLACE_EDIT_PLURAL_FORM_UI.include?(column.form_ui)
|
388
385
|
data[:ie_render_url] = url
|
389
386
|
data[:ie_mode] = :ajax
|
@@ -396,7 +393,7 @@ module ActiveScaffold
|
|
396
393
|
|
397
394
|
def all_marked?
|
398
395
|
if active_scaffold_config.mark.mark_all_mode == :page
|
399
|
-
@page.items.
|
396
|
+
@page.items.all? { |record| marked_records.key?(record.id) }
|
400
397
|
else
|
401
398
|
marked_records.length >= @page.pager.count.to_i
|
402
399
|
end
|
@@ -404,8 +401,8 @@ module ActiveScaffold
|
|
404
401
|
|
405
402
|
def mark_column_heading
|
406
403
|
tag_options = {
|
407
|
-
:
|
408
|
-
:
|
404
|
+
id: "#{controller_id}_mark_heading",
|
405
|
+
class: 'mark_heading in_place_editor_field'
|
409
406
|
}
|
410
407
|
content_tag(:span, check_box_tag("#{controller_id}_mark_heading_span_input", '1', all_marked?), tag_options)
|
411
408
|
end
|
@@ -413,15 +410,15 @@ module ActiveScaffold
|
|
413
410
|
# COLUMN HEADINGS
|
414
411
|
|
415
412
|
def column_heading_attributes(column, sorting, sort_direction)
|
416
|
-
{:
|
413
|
+
{id: active_scaffold_column_header_id(column), class: column_heading_class(column, sorting), title: strip_tags(column.description).presence}
|
417
414
|
end
|
418
415
|
|
419
416
|
def render_column_heading(column, sorting, sort_direction)
|
420
417
|
tag_options = column_heading_attributes(column, sorting, sort_direction)
|
421
418
|
if column.name == :as_marked
|
422
419
|
tag_options[:data] = {
|
423
|
-
:
|
424
|
-
:
|
420
|
+
ie_mode: :inline_checkbox,
|
421
|
+
ie_url: url_for(params_for(action: 'mark', id: '__id__'))
|
425
422
|
}
|
426
423
|
elsif column.inplace_edit
|
427
424
|
tag_options[:data] = inplace_edit_data(column)
|
@@ -433,15 +430,15 @@ module ActiveScaffold
|
|
433
430
|
if column.name == :as_marked
|
434
431
|
mark_column_heading
|
435
432
|
elsif column.sortable?
|
436
|
-
options = {:
|
433
|
+
options = {id: nil, class: 'as_sort',
|
437
434
|
'data-page-history' => controller_id,
|
438
|
-
:
|
435
|
+
remote: true, method: :get}
|
439
436
|
url_options = {action: :index, page: 1, sort: column.name, sort_direction: sort_direction}
|
440
437
|
# :id needed because rails reuse it even if it was deleted from params (like do_refresh_list does)
|
441
438
|
url_options[:id] = nil if @remove_id_from_list_links
|
442
439
|
url_options = params_for(url_options)
|
443
|
-
|
444
|
-
url_options[:search] = search_params
|
440
|
+
if !active_scaffold_config.store_user_settings && respond_to?(:search_params) && search_params.present?
|
441
|
+
url_options[:search] = search_params
|
445
442
|
end
|
446
443
|
link_to column_heading_label(column), url_options, options
|
447
444
|
else
|
@@ -459,7 +456,7 @@ module ActiveScaffold
|
|
459
456
|
if column.calculate.instance_of? Proc
|
460
457
|
column.calculate.call(@records)
|
461
458
|
else
|
462
|
-
calculate_query(id_condition).calculate(column.calculate, column.name)
|
459
|
+
calculate_query(id_condition: id_condition).calculate(column.calculate, column.name)
|
463
460
|
end
|
464
461
|
end
|
465
462
|
|
@@ -2,7 +2,7 @@ module ActiveScaffold
|
|
2
2
|
module Helpers
|
3
3
|
module PaginationHelpers
|
4
4
|
def pagination_ajax_link(page_number, url_options, options)
|
5
|
-
link_to page_number, url_options.merge(:
|
5
|
+
link_to page_number, url_options.merge(page: page_number), options.merge(class: 'as_paginate')
|
6
6
|
end
|
7
7
|
|
8
8
|
def pagination_url_options(url_options = nil)
|
@@ -27,7 +27,7 @@ module ActiveScaffold
|
|
27
27
|
|
28
28
|
html = []
|
29
29
|
if current_page.number == 1
|
30
|
-
last_page = 0
|
30
|
+
last_page = 0 # rubocop:disable Lint/UselessAssignment
|
31
31
|
else
|
32
32
|
last_page = 1
|
33
33
|
last_page.upto([last_page + outer_window, current_page.number - 1].min) do |num|
|
@@ -36,7 +36,7 @@ module ActiveScaffold
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
if current_page.pager.infinite?
|
39
|
-
offsets.
|
39
|
+
offsets.reverse_each do |offset|
|
40
40
|
page = current_page.number - offset
|
41
41
|
next unless page < start_number && page > last_page
|
42
42
|
|
@@ -49,7 +49,7 @@ module ActiveScaffold
|
|
49
49
|
|
50
50
|
[start_number, last_page + 1].max.upto(end_number) do |num|
|
51
51
|
html << if current_page.number == num
|
52
|
-
content_tag(:span, num.to_s, :
|
52
|
+
content_tag(:span, num.to_s, class: 'as_paginate current')
|
53
53
|
else
|
54
54
|
pagination_ajax_link(num, url_options, options)
|
55
55
|
end
|
@@ -6,10 +6,8 @@ module ActiveScaffold
|
|
6
6
|
# It does not do any rendering. It only decides which method is responsible for rendering.
|
7
7
|
def active_scaffold_search_for(column, options = nil)
|
8
8
|
options ||= active_scaffold_search_options(column)
|
9
|
-
|
10
|
-
|
11
|
-
options = update_columns_options(column, nil, options, form_columns: search_columns, url_params: {form_action: :field_search})
|
12
|
-
end
|
9
|
+
search_columns = active_scaffold_config.field_search.columns.visible_columns_names
|
10
|
+
options = update_columns_options(column, nil, options, form_columns: search_columns, url_params: {form_action: :field_search})
|
13
11
|
record = options[:object]
|
14
12
|
if column.delegated_association
|
15
13
|
record = record.send(column.delegated_association.name) || column.active_record_class.new
|
@@ -21,26 +19,19 @@ module ActiveScaffold
|
|
21
19
|
send(method, record, options)
|
22
20
|
|
23
21
|
# second, check if the dev has specified a valid search_ui for this column, using specific ui for searches
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
# third, check if the dev has specified a valid search_ui for this column, using generic ui for forms
|
28
|
-
elsif column.search_ui && (method = override_input(column.search_ui))
|
22
|
+
# or generic ui for forms
|
23
|
+
elsif column.search_ui && (method = override_search(column.search_ui) || override_input(column.search_ui))
|
29
24
|
send(method, column, options, ui_options: column.search_ui_options || column.options)
|
30
25
|
|
31
|
-
#
|
32
|
-
elsif (method = override_form_field(column))
|
26
|
+
# third, check if the dev has created an override for this specific field
|
27
|
+
elsif (method = override_form_field(column)) # rubocop:disable Lint/DuplicateBranch
|
33
28
|
send(method, record, options)
|
34
29
|
|
35
30
|
# fallback: we get to make the decision
|
36
31
|
elsif column.association || column.virtual?
|
37
32
|
active_scaffold_search_text(column, options)
|
38
33
|
|
39
|
-
elsif (method = override_search(column.column_type))
|
40
|
-
# if we (or someone else) have created a custom render option for the column type, use that
|
41
|
-
send(method, column, options)
|
42
|
-
|
43
|
-
elsif (method = override_input(column.column_type))
|
34
|
+
elsif (method = override_search(column.column_type) || override_input(column.column_type))
|
44
35
|
# if we (or someone else) have created a custom render option for the column type, use that
|
45
36
|
send(method, column, options)
|
46
37
|
|
@@ -60,7 +51,7 @@ module ActiveScaffold
|
|
60
51
|
end
|
61
52
|
|
62
53
|
def search_attribute(column, record)
|
63
|
-
column_options = active_scaffold_search_options(column).merge(:
|
54
|
+
column_options = active_scaffold_search_options(column).merge(object: record)
|
64
55
|
content_tag :dl do
|
65
56
|
content_tag(:dt, label_tag(search_label_for(column, column_options), search_column_label(column, record))) <<
|
66
57
|
content_tag(:dd, active_scaffold_search_for(column, column_options))
|
@@ -165,7 +156,7 @@ module ActiveScaffold
|
|
165
156
|
select_options << [as_(:true), true] # rubocop:disable Lint/BooleanSymbol
|
166
157
|
select_options << [as_(:false), false] # rubocop:disable Lint/BooleanSymbol
|
167
158
|
|
168
|
-
select_tag(options[:name], options_for_select(select_options, ActiveScaffold::Core.column_type_cast(options[:value], column.column)), :
|
159
|
+
select_tag(options[:name], options_for_select(select_options, ActiveScaffold::Core.column_type_cast(options[:value], column.column)), id: options[:id])
|
169
160
|
end
|
170
161
|
# we can't use checkbox ui because it's not possible to decide whether search for this field or not
|
171
162
|
alias active_scaffold_search_checkbox active_scaffold_search_boolean
|
@@ -183,6 +174,7 @@ module ActiveScaffold
|
|
183
174
|
|
184
175
|
def active_scaffold_group_column
|
185
176
|
return if active_scaffold_config.field_search.group_options.blank?
|
177
|
+
|
186
178
|
@_active_scaffold_group_column ||= begin
|
187
179
|
column = ActiveScaffold::DataStructures::Column.new(:active_scaffold_group, active_scaffold_config.model)
|
188
180
|
column.label = :group_by
|
@@ -194,12 +186,13 @@ module ActiveScaffold
|
|
194
186
|
select_options = []
|
195
187
|
select_options << [as_(:_select_), nil]
|
196
188
|
select_options.concat(ActiveScaffold::Finder::NULL_COMPARATORS.collect { |comp| [as_(comp), comp] })
|
197
|
-
select_tag(options[:name], options_for_select(select_options, options[:value]), :
|
189
|
+
select_tag(options[:name], options_for_select(select_options, options[:value]), id: options[:id])
|
198
190
|
end
|
199
191
|
|
200
192
|
def field_search_params_range_values(column)
|
201
193
|
values = field_search_params[column.name.to_s]
|
202
194
|
return nil unless values.is_a? Hash
|
195
|
+
|
203
196
|
[values['opt'], values['from'].presence, values['to'].presence]
|
204
197
|
end
|
205
198
|
|
@@ -220,13 +213,14 @@ module ActiveScaffold
|
|
220
213
|
end
|
221
214
|
|
222
215
|
def active_scaffold_search_select_comparator_options(column, ui_options: column.options)
|
223
|
-
select_options = [[as_('='
|
216
|
+
select_options = [[as_(:'='), '=']]
|
224
217
|
select_options.concat(ActiveScaffold::Finder::NULL_COMPARATORS.collect { |comp| [as_(comp), comp] })
|
225
218
|
select_options
|
226
219
|
end
|
227
220
|
|
228
221
|
def include_null_comparators?(column, ui_options: column.options)
|
229
222
|
return ui_options[:null_comparators] if ui_options.key? :null_comparators
|
223
|
+
|
230
224
|
if column.association
|
231
225
|
!column.association.belongs_to? || active_scaffold_config.columns[column.association.foreign_key].null?
|
232
226
|
else
|
@@ -244,8 +238,8 @@ module ActiveScaffold
|
|
244
238
|
to_value = controller.class.condition_value_for_numeric(column, to_value)
|
245
239
|
from_value = format_number_value(from_value, ui_options) if from_value.is_a?(Numeric)
|
246
240
|
to_value = format_number_value(to_value, ui_options) if to_value.is_a?(Numeric)
|
247
|
-
from_options = active_scaffold_input_text_options(input_options.merge(:
|
248
|
-
to_options = from_options.merge(:
|
241
|
+
from_options = active_scaffold_input_text_options(input_options.merge(id: options[:id], size: text_field_size))
|
242
|
+
to_options = from_options.merge(id: "#{options[:id]}_to")
|
249
243
|
|
250
244
|
from_field = send(input_method, "#{options[:name]}[from]", from_value, input_options)
|
251
245
|
to_field = send(input_method, "#{options[:name]}[to]", to_value, to_options)
|
@@ -289,7 +283,7 @@ module ActiveScaffold
|
|
289
283
|
active_scaffold_search_datetime_numeric_tag(column, options, current_search, ui_options: ui_options, field_ui: field_ui),
|
290
284
|
active_scaffold_search_datetime_range_tag(column, options, current_search)
|
291
285
|
]
|
292
|
-
safe_join tags, ' '.html_safe
|
286
|
+
safe_join tags, ' '.html_safe
|
293
287
|
end
|
294
288
|
|
295
289
|
def active_scaffold_search_timestamp(column, options, ui_options: column.options)
|
@@ -328,8 +322,8 @@ module ActiveScaffold
|
|
328
322
|
end
|
329
323
|
]
|
330
324
|
content_tag('span', safe_join(numeric_controls),
|
331
|
-
:
|
332
|
-
:
|
325
|
+
id: "#{options[:id]}_numeric", class: 'search-date-numeric',
|
326
|
+
style: ActiveScaffold::Finder::NUMERIC_COMPARATORS.include?(current_search['opt']) ? nil : 'display: none')
|
333
327
|
end
|
334
328
|
|
335
329
|
def active_scaffold_search_datetime_trend_tag(column, options, current_search)
|
@@ -361,11 +355,7 @@ module ActiveScaffold
|
|
361
355
|
end
|
362
356
|
|
363
357
|
def column_datetime?(column)
|
364
|
-
|
365
|
-
end
|
366
|
-
|
367
|
-
def field_search_datetime_value(value)
|
368
|
-
Time.zone.local(value[:year].to_i, value[:month].to_i, value[:day].to_i, value[:hour].to_i, value[:minute].to_i, value[:second].to_i) unless value.nil? || value[:year].blank?
|
358
|
+
!column.column.nil? && %i[datetime time].include?(column.column_type)
|
369
359
|
end
|
370
360
|
|
371
361
|
def active_scaffold_search_datetime_field(column, options, current_search, name, ui_options: column.options)
|
@@ -373,7 +363,7 @@ module ActiveScaffold
|
|
373
363
|
type = "#{'date' unless options[:discard_date]}#{'time' unless options[:discard_time]}"
|
374
364
|
field_name = "#{options[:name]}[#{name}]"
|
375
365
|
if options[:use_select]
|
376
|
-
send("select_#{type}", current_search[name], options.reverse_merge(include_blank: true, prefix: field_name))
|
366
|
+
send(:"select_#{type}", current_search[name], options.reverse_merge(include_blank: true, prefix: field_name))
|
377
367
|
else
|
378
368
|
helper = "#{type}#{'_local' if type == 'datetime'}_field_tag"
|
379
369
|
send(helper, field_name, current_search[name], options.except(:name, :object, :use_select).merge(id: "#{options[:id]}_#{name}"))
|
@@ -381,11 +371,11 @@ module ActiveScaffold
|
|
381
371
|
end
|
382
372
|
|
383
373
|
def active_scaffold_search_date_field(column, options, current_search, name, ui_options: column.options)
|
384
|
-
active_scaffold_search_datetime_field(column, options.merge!(:
|
374
|
+
active_scaffold_search_datetime_field(column, options.merge!(discard_time: true), current_search, name, ui_options: ui_options)
|
385
375
|
end
|
386
376
|
|
387
377
|
def active_scaffold_search_time_field(column, options, current_search, name, ui_options: column.options)
|
388
|
-
active_scaffold_search_datetime_field(column, options.merge!(:
|
378
|
+
active_scaffold_search_datetime_field(column, options.merge!(discard_date: true), current_search, name, ui_options: ui_options)
|
389
379
|
end
|
390
380
|
|
391
381
|
##
|
@@ -409,8 +399,9 @@ module ActiveScaffold
|
|
409
399
|
def visibles_and_hiddens(search_config)
|
410
400
|
visibles = []
|
411
401
|
hiddens = []
|
412
|
-
search_config.columns.each_column do |column|
|
402
|
+
search_config.columns.each_column(flatten: true) do |column|
|
413
403
|
next unless column.search_sql
|
404
|
+
|
414
405
|
if search_config.optional_columns.include?(column.name) && !searched_by?(column)
|
415
406
|
hiddens << column
|
416
407
|
else
|
@@ -5,6 +5,7 @@ module ActiveScaffold
|
|
5
5
|
def show_column_value(record, column)
|
6
6
|
value_record = column.delegated_association ? record.send(column.delegated_association.name) : record
|
7
7
|
return get_column_value(record, column) unless value_record
|
8
|
+
|
8
9
|
# check for an override helper
|
9
10
|
if (method = show_column_override(column))
|
10
11
|
# we only pass the record as the argument. we previously also passed the formatted_value,
|
@@ -14,10 +15,10 @@ module ActiveScaffold
|
|
14
15
|
# second, check if the dev has specified a valid list_ui for this column
|
15
16
|
elsif column.show_ui && (method = override_show_column_ui(column.show_ui))
|
16
17
|
send(method, value_record, column, ui_options: column.show_ui_options || column.options)
|
17
|
-
elsif column.column && (method = override_show_column_ui(column.column_type))
|
18
|
+
elsif column.column && (method = override_show_column_ui(column.column_type)) # rubocop:disable Lint/DuplicateBranch
|
18
19
|
send(method, value_record, column)
|
19
20
|
else
|
20
|
-
get_column_value(
|
21
|
+
get_column_value(value_record, column)
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
@@ -27,12 +28,14 @@ module ActiveScaffold
|
|
27
28
|
|
28
29
|
def active_scaffold_show_horizontal(record, column, ui_options: column.options)
|
29
30
|
raise ':horizontal show_ui must be used on association column' unless column.association
|
30
|
-
|
31
|
+
|
32
|
+
render partial: 'show_association', locals: {column: column, parent_record: record, show_partial: :horizontal}
|
31
33
|
end
|
32
34
|
|
33
35
|
def active_scaffold_show_vertical(record, column, ui_options: column.options)
|
34
36
|
raise ':vertical show_ui must be used on association column' unless column.association
|
35
|
-
|
37
|
+
|
38
|
+
render partial: 'show_association', locals: {column: column, parent_record: record, show_partial: :vertical}
|
36
39
|
end
|
37
40
|
|
38
41
|
def show_columns_for(record, parent_column = nil, hash = {})
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module ActiveScaffold
|
2
|
+
module Helpers
|
3
|
+
# Helpers that assist with rendering of tabs in forms
|
4
|
+
module TabsHelpers
|
5
|
+
def active_scaffold_tabbed_by(column, record, scope, subsection_id, &block)
|
6
|
+
add_tab_url = params_for(action: 'render_field', tabbed_by: column.tabbed_by, id: record.to_param, column: column.label)
|
7
|
+
refresh_opts = {refresh_link: {text: 'Add tab', class: 'refresh-link add-tab'}}
|
8
|
+
tab_options = send(override_helper_per_model(:active_scaffold_tab_options, record.class), column, record)
|
9
|
+
used_tabs = send(override_helper_per_model(:active_scaffold_current_tabs, record.class), column, record, tab_options)
|
10
|
+
input_helper = override_helper_per_model(:active_scaffold_input_for_tabbed, record.class)
|
11
|
+
send(input_helper, column, record, subsection_id, tab_options, used_tabs.map(&:first)) <<
|
12
|
+
active_scaffold_refresh_link(nil, {'data-update_url' => url_for(add_tab_url)}, record, refresh_opts) <<
|
13
|
+
active_scaffold_tabs_for(column, record, subsection_id, tab_options, used_tabs, &block)
|
14
|
+
end
|
15
|
+
|
16
|
+
def active_scaffold_input_for_tabbed(column, record, subsection_id, tab_options, used_tabs)
|
17
|
+
hidden_style = 'display: none;'
|
18
|
+
blank_choice = content_tag(:option, as_(:_select_), value: '')
|
19
|
+
option_tags = tab_options.inject(blank_choice) do |html, (label, value, tab_record)|
|
20
|
+
used = used_tabs.include?(tab_record || value)
|
21
|
+
html << content_tag(:option, label, value: value, style: (hidden_style if used))
|
22
|
+
end
|
23
|
+
select_tag(nil, option_tags, class: "#{column.tabbed_by}-input", id: "#{subsection_id}_input")
|
24
|
+
end
|
25
|
+
|
26
|
+
def active_scaffold_current_tabs(column, record, tab_options)
|
27
|
+
used_choices = Set.new
|
28
|
+
column.each_column do |col|
|
29
|
+
tabbed_by = col.options[:tabbed_by] || column.tabbed_by
|
30
|
+
tab_values = record.send(col.name).map(&tabbed_by).compact
|
31
|
+
if tabbed_by_association(col, tabbed_by)
|
32
|
+
tab_values.map! { |value| [value, value.id.to_s] }
|
33
|
+
else
|
34
|
+
tab_values.map! { |value| [tab_options.find { |_, tab_value, _| value == tab_value }&.first || value, value] }
|
35
|
+
end
|
36
|
+
used_choices.merge tab_values
|
37
|
+
end
|
38
|
+
used_choices
|
39
|
+
end
|
40
|
+
|
41
|
+
def active_scaffold_tab_options(column, record)
|
42
|
+
subform_column = column.first
|
43
|
+
if subform_column
|
44
|
+
tabbed_by = subform_column.options[:tabbed_by] || column.tabbed_by
|
45
|
+
if tabbed_by_association(subform_column, tabbed_by)
|
46
|
+
subform_record = record.send(subform_column.name).first_or_initialize
|
47
|
+
tab_column = active_scaffold_config_for(subform_column.association.klass).columns[tabbed_by]
|
48
|
+
end
|
49
|
+
end
|
50
|
+
if tab_column
|
51
|
+
label_method = (tab_column.form_ui_options || tab_column.options)[:label_method] || :to_label
|
52
|
+
sorted_association_options_find(tab_column.association, nil, subform_record).map do |opt_record|
|
53
|
+
[opt_record.send(label_method), opt_record.id, opt_record]
|
54
|
+
end
|
55
|
+
else
|
56
|
+
[]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def active_scaffold_tab(label, tab_id, active)
|
61
|
+
content_tag :li, class: "nav-item #{:active if active}" do
|
62
|
+
link_to(label, "##{tab_id}", class: 'nav-link', data: {toggle: :tab})
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def active_scaffold_tab_content(tab_id, active, content)
|
67
|
+
content_tag(:div, content, class: "tab-pane fade#{' in active' if active}", id: tab_id)
|
68
|
+
end
|
69
|
+
|
70
|
+
def active_scaffold_tabs_for(column, record, subsection_id, tab_options, used_tabs)
|
71
|
+
used_tabs = used_tabs.map { |value, value_id| [value, clean_id(value_id || value.to_s)] }
|
72
|
+
content_tag(:div, class: 'tabbed') do
|
73
|
+
content_tag(:ul, class: 'nav nav-tabs') do
|
74
|
+
tabs = used_tabs.map.with_index do |(tab_value, id), i|
|
75
|
+
active_scaffold_tab tab_options.find { |_, value, tab_record| tab_value == (tab_record || value) }&.first, "#{subsection_id}-#{id}-tab", i.zero?
|
76
|
+
end
|
77
|
+
safe_join tabs
|
78
|
+
end << content_tag(:div, class: 'tab-content') do
|
79
|
+
tabs = used_tabs.map.with_index do |(tab_value, id), i|
|
80
|
+
active_scaffold_tab_content("#{subsection_id}-#{id}-tab", i.zero?, yield(tab_value, id))
|
81
|
+
end
|
82
|
+
safe_join(tabs)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|