active_scaffold 3.2.17 → 3.2.18
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.
- data/CHANGELOG +5 -1
- metadata +17 -261
- data/app/assets/images/active_scaffold/add.png +0 -0
- data/app/assets/images/active_scaffold/arrow_down.png +0 -0
- data/app/assets/images/active_scaffold/arrow_up.png +0 -0
- data/app/assets/images/active_scaffold/close.png +0 -0
- data/app/assets/images/active_scaffold/close_touch.png +0 -0
- data/app/assets/images/active_scaffold/config.png +0 -0
- data/app/assets/images/active_scaffold/cross.png +0 -0
- data/app/assets/images/active_scaffold/gears.png +0 -0
- data/app/assets/images/active_scaffold/indicator-small.gif +0 -0
- data/app/assets/images/active_scaffold/indicator.gif +0 -0
- data/app/assets/images/active_scaffold/magnifier.png +0 -0
- data/app/assets/javascripts/active_scaffold.js.erb +0 -19
- data/app/assets/javascripts/jquery/active_scaffold.js +0 -1113
- data/app/assets/javascripts/jquery/date_picker_bridge.js.erb +0 -24
- data/app/assets/javascripts/jquery/draggable_lists.js +0 -27
- data/app/assets/javascripts/jquery/jquery.editinplace.js +0 -743
- data/app/assets/javascripts/jquery/tiny_mce_bridge.js +0 -7
- data/app/assets/javascripts/prototype/active_scaffold.js +0 -1107
- 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/rico_corner.js +0 -370
- data/app/assets/javascripts/prototype/tiny_mce_bridge.js +0 -7
- data/app/assets/stylesheets/active_scaffold-ie.css.scss +0 -54
- data/app/assets/stylesheets/active_scaffold.css.scss +0 -14
- data/app/assets/stylesheets/active_scaffold_colors.css.scss +0 -395
- data/app/assets/stylesheets/active_scaffold_extensions.css.erb +0 -2
- data/app/assets/stylesheets/active_scaffold_images.css.scss +0 -40
- data/app/assets/stylesheets/active_scaffold_layout.css +0 -936
- data/app/assets/stylesheets/blue-theme.css +0 -74
- data/config/locales/de.yml +0 -125
- data/config/locales/en.yml +0 -127
- data/config/locales/es.yml +0 -128
- data/config/locales/fr.yml +0 -131
- data/config/locales/hu.yml +0 -126
- data/config/locales/ja.yml +0 -126
- data/config/locales/ru.yml +0 -135
- data/frontends/default/views/_action_group.html.erb +0 -24
- data/frontends/default/views/_add_existing_form.html.erb +0 -30
- data/frontends/default/views/_base_form.html.erb +0 -53
- data/frontends/default/views/_create_form.html.erb +0 -8
- data/frontends/default/views/_create_form_on_list.html.erb +0 -6
- data/frontends/default/views/_field_search.html.erb +0 -32
- data/frontends/default/views/_form.html.erb +0 -28
- data/frontends/default/views/_form_association.html.erb +0 -17
- data/frontends/default/views/_form_association_footer.html.erb +0 -47
- data/frontends/default/views/_form_attribute.html.erb +0 -23
- data/frontends/default/views/_form_hidden_attribute.html.erb +0 -7
- data/frontends/default/views/_form_messages.html.erb +0 -5
- data/frontends/default/views/_horizontal_subform.html.erb +0 -22
- data/frontends/default/views/_horizontal_subform_footer.html.erb +0 -0
- data/frontends/default/views/_horizontal_subform_header.html.erb +0 -11
- data/frontends/default/views/_horizontal_subform_record.html.erb +0 -43
- data/frontends/default/views/_human_conditions.html.erb +0 -1
- data/frontends/default/views/_list.html.erb +0 -18
- data/frontends/default/views/_list_actions.html.erb +0 -15
- data/frontends/default/views/_list_calculations.html.erb +0 -16
- data/frontends/default/views/_list_column_headings.html.erb +0 -12
- data/frontends/default/views/_list_header.html.erb +0 -10
- data/frontends/default/views/_list_inline_adapter.html.erb +0 -21
- data/frontends/default/views/_list_messages.html.erb +0 -28
- data/frontends/default/views/_list_pagination.html.erb +0 -11
- data/frontends/default/views/_list_pagination_links.html.erb +0 -9
- data/frontends/default/views/_list_record.html.erb +0 -13
- data/frontends/default/views/_list_record_columns.html.erb +0 -8
- data/frontends/default/views/_list_with_header.html.erb +0 -36
- data/frontends/default/views/_messages.html.erb +0 -10
- data/frontends/default/views/_refresh_list.js.erb +0 -1
- data/frontends/default/views/_render_field.js.erb +0 -20
- data/frontends/default/views/_row.html.erb +0 -1
- data/frontends/default/views/_search.html.erb +0 -34
- data/frontends/default/views/_search_attribute.html.erb +0 -10
- data/frontends/default/views/_show.html.erb +0 -8
- data/frontends/default/views/_show_columns.html.erb +0 -15
- data/frontends/default/views/_update_actions.html.erb +0 -9
- data/frontends/default/views/_update_calculations.js.erb +0 -4
- data/frontends/default/views/_update_form.html.erb +0 -6
- data/frontends/default/views/_update_messages.js.erb +0 -2
- data/frontends/default/views/_vertical_subform.html.erb +0 -12
- data/frontends/default/views/_vertical_subform_record.html.erb +0 -43
- data/frontends/default/views/action_confirmation.html.erb +0 -13
- data/frontends/default/views/add_existing.js.erb +0 -14
- data/frontends/default/views/add_existing_form.html.erb +0 -5
- data/frontends/default/views/create.html.erb +0 -5
- data/frontends/default/views/delete.html.erb +0 -13
- data/frontends/default/views/destroy.js.erb +0 -26
- data/frontends/default/views/edit_associated.js.erb +0 -12
- data/frontends/default/views/field_search.html.erb +0 -5
- data/frontends/default/views/form_messages.js.erb +0 -1
- data/frontends/default/views/list.html.erb +0 -1
- data/frontends/default/views/on_action_update.js.erb +0 -22
- data/frontends/default/views/on_create.js.erb +0 -38
- data/frontends/default/views/on_mark.js.erb +0 -6
- data/frontends/default/views/on_update.js.erb +0 -29
- data/frontends/default/views/refresh_list.js.erb +0 -2
- data/frontends/default/views/render_field.js.erb +0 -1
- data/frontends/default/views/row.js.erb +0 -2
- data/frontends/default/views/search.html.erb +0 -5
- data/frontends/default/views/show.html.erb +0 -5
- data/frontends/default/views/update.html.erb +0 -8
- data/frontends/default/views/update_column.js.erb +0 -15
- data/frontends/default/views/update_row.js.erb +0 -1
- data/lib/active_scaffold.rb +0 -373
- data/lib/active_scaffold/actions/common_search.rb +0 -22
- data/lib/active_scaffold/actions/core.rb +0 -203
- data/lib/active_scaffold/actions/create.rb +0 -139
- data/lib/active_scaffold/actions/delete.rb +0 -74
- data/lib/active_scaffold/actions/field_search.rb +0 -78
- data/lib/active_scaffold/actions/list.rb +0 -208
- data/lib/active_scaffold/actions/mark.rb +0 -89
- data/lib/active_scaffold/actions/nested.rb +0 -244
- data/lib/active_scaffold/actions/search.rb +0 -48
- data/lib/active_scaffold/actions/show.rb +0 -61
- data/lib/active_scaffold/actions/subform.rb +0 -23
- data/lib/active_scaffold/actions/update.rb +0 -156
- data/lib/active_scaffold/active_record_permissions.rb +0 -135
- data/lib/active_scaffold/attribute_params.rb +0 -200
- data/lib/active_scaffold/bridges.rb +0 -61
- data/lib/active_scaffold/bridges/ancestry.rb +0 -5
- data/lib/active_scaffold/bridges/ancestry/ancestry_bridge.rb +0 -39
- data/lib/active_scaffold/bridges/bitfields.rb +0 -6
- data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +0 -37
- data/lib/active_scaffold/bridges/calendar_date_select.rb +0 -24
- data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +0 -66
- data/lib/active_scaffold/bridges/cancan.rb +0 -15
- data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +0 -127
- data/lib/active_scaffold/bridges/carrierwave.rb +0 -12
- data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +0 -31
- data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge_helpers.rb +0 -10
- data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +0 -45
- data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +0 -17
- data/lib/active_scaffold/bridges/country_helper.rb +0 -9
- data/lib/active_scaffold/bridges/country_helper/country_helper_bridge.rb +0 -358
- data/lib/active_scaffold/bridges/date_picker.rb +0 -23
- data/lib/active_scaffold/bridges/date_picker/ext.rb +0 -63
- data/lib/active_scaffold/bridges/date_picker/helper.rb +0 -180
- data/lib/active_scaffold/bridges/dragonfly.rb +0 -9
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +0 -34
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge_helpers.rb +0 -10
- data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +0 -27
- data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +0 -16
- data/lib/active_scaffold/bridges/file_column.rb +0 -11
- data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +0 -46
- data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +0 -57
- data/lib/active_scaffold/bridges/file_column/form_ui.rb +0 -34
- data/lib/active_scaffold/bridges/file_column/list_ui.rb +0 -26
- data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +0 -43
- data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +0 -9
- data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +0 -15
- data/lib/active_scaffold/bridges/paperclip.rb +0 -12
- data/lib/active_scaffold/bridges/paperclip/form_ui.rb +0 -27
- data/lib/active_scaffold/bridges/paperclip/list_ui.rb +0 -16
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +0 -36
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +0 -24
- data/lib/active_scaffold/bridges/record_select.rb +0 -11
- data/lib/active_scaffold/bridges/record_select/helpers.rb +0 -92
- data/lib/active_scaffold/bridges/semantic_attributes.rb +0 -5
- data/lib/active_scaffold/bridges/semantic_attributes/column.rb +0 -20
- data/lib/active_scaffold/bridges/shared/date_bridge.rb +0 -209
- data/lib/active_scaffold/bridges/tiny_mce.rb +0 -17
- data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +0 -46
- data/lib/active_scaffold/config/base.rb +0 -75
- data/lib/active_scaffold/config/core.rb +0 -236
- data/lib/active_scaffold/config/create.rb +0 -32
- data/lib/active_scaffold/config/delete.rb +0 -32
- data/lib/active_scaffold/config/field_search.rb +0 -79
- data/lib/active_scaffold/config/form.rb +0 -64
- data/lib/active_scaffold/config/list.rb +0 -247
- data/lib/active_scaffold/config/mark.rb +0 -30
- data/lib/active_scaffold/config/nested.rb +0 -42
- data/lib/active_scaffold/config/search.rb +0 -73
- data/lib/active_scaffold/config/show.rb +0 -31
- data/lib/active_scaffold/config/subform.rb +0 -35
- data/lib/active_scaffold/config/update.rb +0 -33
- data/lib/active_scaffold/configurable.rb +0 -29
- data/lib/active_scaffold/constraints.rb +0 -171
- data/lib/active_scaffold/data_structures/action_columns.rb +0 -142
- data/lib/active_scaffold/data_structures/action_link.rb +0 -185
- data/lib/active_scaffold/data_structures/action_links.rb +0 -191
- data/lib/active_scaffold/data_structures/actions.rb +0 -45
- data/lib/active_scaffold/data_structures/bridge.rb +0 -22
- data/lib/active_scaffold/data_structures/column.rb +0 -401
- data/lib/active_scaffold/data_structures/columns.rb +0 -75
- data/lib/active_scaffold/data_structures/error_message.rb +0 -24
- data/lib/active_scaffold/data_structures/nested_info.rb +0 -171
- data/lib/active_scaffold/data_structures/set.rb +0 -61
- data/lib/active_scaffold/data_structures/sorting.rb +0 -167
- data/lib/active_scaffold/engine.rb +0 -4
- data/lib/active_scaffold/extensions/action_controller_rendering.rb +0 -20
- data/lib/active_scaffold/extensions/action_controller_rescueing.rb +0 -7
- data/lib/active_scaffold/extensions/action_view_rendering.rb +0 -115
- data/lib/active_scaffold/extensions/active_record_offset.rb +0 -12
- data/lib/active_scaffold/extensions/array.rb +0 -7
- data/lib/active_scaffold/extensions/cache_association.rb +0 -16
- data/lib/active_scaffold/extensions/localize.rb +0 -10
- data/lib/active_scaffold/extensions/name_option_for_datetime.rb +0 -12
- data/lib/active_scaffold/extensions/nil_id_in_url_params.rb +0 -7
- data/lib/active_scaffold/extensions/paginator_extensions.rb +0 -26
- data/lib/active_scaffold/extensions/reverse_associations.rb +0 -64
- data/lib/active_scaffold/extensions/routing_mapper.rb +0 -48
- data/lib/active_scaffold/extensions/to_label.rb +0 -8
- data/lib/active_scaffold/extensions/unsaved_associated.rb +0 -61
- data/lib/active_scaffold/extensions/unsaved_record.rb +0 -20
- data/lib/active_scaffold/extensions/usa_state.rb +0 -46
- data/lib/active_scaffold/finder.rb +0 -399
- data/lib/active_scaffold/helpers/association_helpers.rb +0 -42
- data/lib/active_scaffold/helpers/controller_helpers.rb +0 -94
- data/lib/active_scaffold/helpers/form_column_helpers.rb +0 -322
- data/lib/active_scaffold/helpers/human_condition_helpers.rb +0 -64
- data/lib/active_scaffold/helpers/id_helpers.rb +0 -131
- data/lib/active_scaffold/helpers/list_column_helpers.rb +0 -374
- data/lib/active_scaffold/helpers/pagination_helpers.rb +0 -62
- data/lib/active_scaffold/helpers/search_column_helpers.rb +0 -257
- data/lib/active_scaffold/helpers/show_column_helpers.rb +0 -44
- data/lib/active_scaffold/helpers/view_helpers.rb +0 -398
- data/lib/active_scaffold/marked_model.rb +0 -38
- data/lib/active_scaffold/paginator.rb +0 -136
- data/lib/active_scaffold/responds_to_parent.rb +0 -70
- data/lib/active_scaffold/tableless.rb +0 -83
- data/lib/active_scaffold/version.rb +0 -9
- data/lib/active_scaffold_env.rb +0 -13
- data/lib/generators/active_scaffold/USAGE +0 -29
- data/lib/generators/active_scaffold/active_scaffold_generator.rb +0 -21
- data/lib/generators/active_scaffold_controller/USAGE +0 -19
- data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +0 -29
- data/lib/generators/active_scaffold_controller/templates/controller.rb +0 -4
- data/lib/generators/active_scaffold_controller/templates/helper.rb +0 -2
- data/public/blank.html +0 -33
- data/shoulda_macros/macros.rb +0 -136
- data/vendor/assets/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/vendor/assets/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/vendor/assets/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/vendor/assets/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/vendor/assets/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/vendor/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/vendor/assets/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/vendor/assets/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/vendor/assets/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/vendor/assets/images/ui-icons_222222_256x240.png +0 -0
- data/vendor/assets/images/ui-icons_228ef1_256x240.png +0 -0
- data/vendor/assets/images/ui-icons_ef8c08_256x240.png +0 -0
- data/vendor/assets/images/ui-icons_ffd27a_256x240.png +0 -0
- data/vendor/assets/images/ui-icons_ffffff_256x240.png +0 -0
- data/vendor/assets/javascripts/jquery-ui-timepicker-addon.js +0 -1276
- data/vendor/assets/stylesheets/jquery-ui.css +0 -568
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
module ActiveScaffold
|
|
2
|
-
module Helpers
|
|
3
|
-
module PaginationHelpers
|
|
4
|
-
def pagination_ajax_link(page_number, url_options, options)
|
|
5
|
-
link_to page_number, url_options.merge(:page => page_number), options.merge(:class => "as_paginate")
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def pagination_ajax_links(current_page, url_options, options, inner_window, outer_window)
|
|
9
|
-
start_number = current_page.number - inner_window
|
|
10
|
-
end_number = current_page.number + inner_window
|
|
11
|
-
start_number = 1 if start_number <= 0
|
|
12
|
-
if current_page.pager.infinite?
|
|
13
|
-
offsets = [20, 100]
|
|
14
|
-
else
|
|
15
|
-
end_number = current_page.pager.last.number if end_number > current_page.pager.last.number
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
html = []
|
|
19
|
-
if current_page.number == 1
|
|
20
|
-
last_page = 0
|
|
21
|
-
else
|
|
22
|
-
last_page = 1
|
|
23
|
-
last_page.upto([last_page + outer_window, current_page.number - 1].min) do |num|
|
|
24
|
-
html << pagination_ajax_link(num, url_options, options)
|
|
25
|
-
last_page = num
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
if current_page.pager.infinite?
|
|
29
|
-
offsets.reverse.each do |offset|
|
|
30
|
-
page = current_page.number - offset
|
|
31
|
-
if page < start_number && page > last_page
|
|
32
|
-
html << '..' if page > last_page + 1
|
|
33
|
-
html << pagination_ajax_link(page, params)
|
|
34
|
-
last_page = page
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
html << ".." if start_number > last_page + 1
|
|
39
|
-
|
|
40
|
-
[start_number, last_page + 1].max.upto(end_number) do |num|
|
|
41
|
-
if current_page.number == num
|
|
42
|
-
html << content_tag(:span, num.to_s, {:class => "as_paginate current"})
|
|
43
|
-
else
|
|
44
|
-
html << pagination_ajax_link(num, url_options, options)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
if current_page.pager.infinite?
|
|
49
|
-
offsets.each do |offset|
|
|
50
|
-
html << '..' << pagination_ajax_link(current_page.number + offset, url_options, options)
|
|
51
|
-
end
|
|
52
|
-
else
|
|
53
|
-
html << ".." unless end_number >= current_page.pager.last.number - outer_window - 1
|
|
54
|
-
[end_number + 1, current_page.pager.last.number - outer_window].max.upto(current_page.pager.last.number) do |num|
|
|
55
|
-
html << pagination_ajax_link(num, url_options, options)
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
html.join(' ').html_safe
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
end
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
module ActiveScaffold
|
|
2
|
-
module Helpers
|
|
3
|
-
# Helpers that assist with the rendering of a Form Column
|
|
4
|
-
module SearchColumnHelpers
|
|
5
|
-
# This method decides which input to use for the given column.
|
|
6
|
-
# It does not do any rendering. It only decides which method is responsible for rendering.
|
|
7
|
-
def active_scaffold_search_for(column)
|
|
8
|
-
options = active_scaffold_search_options(column)
|
|
9
|
-
|
|
10
|
-
# first, check if the dev has created an override for this specific field for search
|
|
11
|
-
if (method = override_search_field(column))
|
|
12
|
-
send(method, @record, options)
|
|
13
|
-
|
|
14
|
-
# second, check if the dev has specified a valid search_ui for this column, using specific ui for searches
|
|
15
|
-
elsif column.search_ui and (method = override_search(column.search_ui))
|
|
16
|
-
send(method, column, options)
|
|
17
|
-
|
|
18
|
-
# third, check if the dev has specified a valid search_ui for this column, using generic ui for forms
|
|
19
|
-
elsif column.search_ui and (method = override_input(column.search_ui))
|
|
20
|
-
send(method, column, options)
|
|
21
|
-
|
|
22
|
-
# fourth, check if the dev has created an override for this specific field
|
|
23
|
-
elsif (method = override_form_field(column))
|
|
24
|
-
send(method, @record, options)
|
|
25
|
-
|
|
26
|
-
# fallback: we get to make the decision
|
|
27
|
-
else
|
|
28
|
-
if column.association or column.virtual?
|
|
29
|
-
active_scaffold_search_text(column, options)
|
|
30
|
-
|
|
31
|
-
else # regular model attribute column
|
|
32
|
-
# if we (or someone else) have created a custom render option for the column type, use that
|
|
33
|
-
if (method = override_search(column.column.type))
|
|
34
|
-
send(method, column, options)
|
|
35
|
-
# if we (or someone else) have created a custom render option for the column type, use that
|
|
36
|
-
elsif (method = override_input(column.column.type))
|
|
37
|
-
send(method, column, options)
|
|
38
|
-
# final ultimate fallback: use rails' generic input method
|
|
39
|
-
else
|
|
40
|
-
# for textual fields we pass different options
|
|
41
|
-
text_types = [:text, :string, :integer, :float, :decimal]
|
|
42
|
-
options = active_scaffold_input_text_options(options) if text_types.include?(column.column.type)
|
|
43
|
-
text_field(:record, column.name, options.merge(column.options))
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
# the standard active scaffold options used for class, name and scope
|
|
50
|
-
def active_scaffold_search_options(column)
|
|
51
|
-
{ :name => "search[#{column.name}]", :class => "#{column.name}-input", :id => "search_#{column.name}", :value => field_search_params[column.name] }
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
##
|
|
55
|
-
## Search input methods
|
|
56
|
-
##
|
|
57
|
-
|
|
58
|
-
def active_scaffold_search_multi_select(column, options)
|
|
59
|
-
associated = options.delete :value
|
|
60
|
-
associated = [associated].compact unless associated.is_a? Array
|
|
61
|
-
associated.collect!(&:to_i)
|
|
62
|
-
|
|
63
|
-
if column.association
|
|
64
|
-
select_options = options_for_association(column.association, false)
|
|
65
|
-
else
|
|
66
|
-
select_options = column.options[:options].collect do |text, value|
|
|
67
|
-
active_scaffold_translated_option(column, text, value)
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
return as_(:no_options) if select_options.empty?
|
|
71
|
-
|
|
72
|
-
active_scaffold_checkbox_list(column, select_options, associated, options)
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def active_scaffold_search_select(column, html_options)
|
|
76
|
-
associated = html_options.delete :value
|
|
77
|
-
if column.association
|
|
78
|
-
associated = associated.is_a?(Array) ? associated.map(&:to_i) : associated.to_i unless associated.nil?
|
|
79
|
-
method = column.association.macro == :belongs_to ? column.association.foreign_key : column.name
|
|
80
|
-
select_options = options_for_association(column.association, true)
|
|
81
|
-
else
|
|
82
|
-
method = column.name
|
|
83
|
-
select_options = column.options[:options].collect do |text, value|
|
|
84
|
-
active_scaffold_translated_option(column, text, value)
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
options = { :selected => associated }.merge! column.options
|
|
89
|
-
html_options.merge! column.options[:html_options] || {}
|
|
90
|
-
if html_options[:multiple]
|
|
91
|
-
html_options[:name] += '[]'
|
|
92
|
-
else
|
|
93
|
-
options[:include_blank] ||= as_(:_select_)
|
|
94
|
-
end
|
|
95
|
-
select(:record, method, select_options, options, html_options)
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def active_scaffold_search_text(column, options)
|
|
99
|
-
text_field :record, column.name, active_scaffold_input_text_options(options)
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
# we can't use active_scaffold_input_boolean because we need to have a nil value even when column can't be null
|
|
103
|
-
# to decide whether search for this field or not
|
|
104
|
-
def active_scaffold_search_boolean(column, options)
|
|
105
|
-
select_options = []
|
|
106
|
-
select_options << [as_(:_select_), nil]
|
|
107
|
-
select_options << [as_(:true), true]
|
|
108
|
-
select_options << [as_(:false), false]
|
|
109
|
-
|
|
110
|
-
select_tag(options[:name], options_for_select(select_options, column.column.type_cast(field_search_params[column.name])))
|
|
111
|
-
end
|
|
112
|
-
# we can't use checkbox ui because it's not possible to decide whether search for this field or not
|
|
113
|
-
alias_method :active_scaffold_search_checkbox, :active_scaffold_search_boolean
|
|
114
|
-
|
|
115
|
-
def active_scaffold_search_null(column, options)
|
|
116
|
-
select_options = []
|
|
117
|
-
select_options << [as_(:_select_), nil]
|
|
118
|
-
select_options.concat ActiveScaffold::Finder::NullComparators.collect {|comp| [as_(comp), comp]}
|
|
119
|
-
select_tag(options[:name], options_for_select(select_options, field_search_params[column.name]))
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
def field_search_params_range_values(column)
|
|
123
|
-
values = field_search_params[column.name]
|
|
124
|
-
return nil if values.nil?
|
|
125
|
-
return values[:opt], (values[:from].blank? ? nil : values[:from]), (values[:to].blank? ? nil : values[:to])
|
|
126
|
-
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
def active_scaffold_search_range_string?(column)
|
|
130
|
-
(column.column && column.column.text?) || column.search_ui == :string
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
def include_null_comparators?(column)
|
|
134
|
-
return column.options[:null_comparators] if column.options.has_key? :null_comparators
|
|
135
|
-
if column.association
|
|
136
|
-
column.association.macro != :belongs_to || active_scaffold_config.columns[column.association.foreign_key].column.try(:null)
|
|
137
|
-
else
|
|
138
|
-
column.column.try(:null)
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
def active_scaffold_search_range_comparator_options(column)
|
|
143
|
-
select_options = ActiveScaffold::Finder::NumericComparators.collect {|comp| [as_(comp.downcase.to_sym), comp]}
|
|
144
|
-
if active_scaffold_search_range_string?(column)
|
|
145
|
-
select_options.unshift *ActiveScaffold::Finder::StringComparators.collect {|title, comp| [as_(title), comp]}
|
|
146
|
-
end
|
|
147
|
-
if include_null_comparators? column
|
|
148
|
-
select_options += ActiveScaffold::Finder::NullComparators.collect {|comp| [as_(comp), comp]}
|
|
149
|
-
end
|
|
150
|
-
select_options
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
def include_null_comparators?(column)
|
|
154
|
-
return column.options[:null_comparators] if column.options.has_key? :null_comparators
|
|
155
|
-
if column.association
|
|
156
|
-
column.association.macro != :belongs_to || active_scaffold_config.columns[column.association.foreign_key].column.try(:null)
|
|
157
|
-
else
|
|
158
|
-
column.column.try(:null)
|
|
159
|
-
end
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
def active_scaffold_search_range(column, options)
|
|
163
|
-
opt_value, from_value, to_value = field_search_params_range_values(column)
|
|
164
|
-
|
|
165
|
-
select_options = active_scaffold_search_range_comparator_options(column)
|
|
166
|
-
if active_scaffold_search_range_string?(column)
|
|
167
|
-
text_field_size = 15
|
|
168
|
-
opt_value ||= '%?%'
|
|
169
|
-
else
|
|
170
|
-
text_field_size = 10
|
|
171
|
-
opt_value ||= '='
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
from_value = controller.class.condition_value_for_numeric(column, from_value)
|
|
175
|
-
to_value = controller.class.condition_value_for_numeric(column, to_value)
|
|
176
|
-
from_value = format_number_value(from_value, column.options) if from_value.is_a?(Numeric)
|
|
177
|
-
to_value = format_number_value(to_value, column.options) if to_value.is_a?(Numeric)
|
|
178
|
-
html = select_tag("#{options[:name]}[opt]",
|
|
179
|
-
options_for_select(select_options, opt_value),
|
|
180
|
-
:id => "#{options[:id]}_opt",
|
|
181
|
-
:class => "as_search_range_option")
|
|
182
|
-
html << content_tag("span", :id => "#{options[:id]}_numeric", :style => ActiveScaffold::Finder::NullComparators.include?(opt_value) ? "display: none" : nil) do
|
|
183
|
-
text_field_tag("#{options[:name]}[from]", from_value, active_scaffold_input_text_options(:id => options[:id], :size => text_field_size)) <<
|
|
184
|
-
content_tag(:span, (' - ' + text_field_tag("#{options[:name]}[to]", to_value,
|
|
185
|
-
active_scaffold_input_text_options(:id => "#{options[:id]}_to", :size => text_field_size))).html_safe,
|
|
186
|
-
:id => "#{options[:id]}_between", :class => "as_search_range_between", :style => (opt_value == 'BETWEEN') ? nil : "display: none")
|
|
187
|
-
end
|
|
188
|
-
content_tag :span, html, :class => 'search_range'
|
|
189
|
-
end
|
|
190
|
-
alias_method :active_scaffold_search_integer, :active_scaffold_search_range
|
|
191
|
-
alias_method :active_scaffold_search_decimal, :active_scaffold_search_range
|
|
192
|
-
alias_method :active_scaffold_search_float, :active_scaffold_search_range
|
|
193
|
-
alias_method :active_scaffold_search_string, :active_scaffold_search_range
|
|
194
|
-
|
|
195
|
-
def field_search_datetime_value(value)
|
|
196
|
-
DateTime.new(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?
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
def active_scaffold_search_datetime(column, options)
|
|
200
|
-
opt_value, from_value, to_value = field_search_params_range_values(column)
|
|
201
|
-
options = column.options.merge(options)
|
|
202
|
-
helper = "select_#{'date' unless options[:discard_date]}#{'time' unless options[:discard_time]}"
|
|
203
|
-
|
|
204
|
-
send(helper, field_search_datetime_value(from_value), {:include_blank => true, :prefix => "#{options[:name]}[from]"}.merge(options)) <<
|
|
205
|
-
' - '.html_safe << send(helper, field_search_datetime_value(to_value), {:include_blank => true, :prefix => "#{options[:name]}[to]"}.merge(options))
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
def active_scaffold_search_date(column, options)
|
|
209
|
-
active_scaffold_search_datetime(column, options.merge!(:discard_time => true))
|
|
210
|
-
end
|
|
211
|
-
def active_scaffold_search_time(column, options)
|
|
212
|
-
active_scaffold_search_datetime(column, options.merge!(:discard_date => true))
|
|
213
|
-
end
|
|
214
|
-
alias_method :active_scaffold_search_timestamp, :active_scaffold_search_datetime
|
|
215
|
-
|
|
216
|
-
##
|
|
217
|
-
## Search column override signatures
|
|
218
|
-
##
|
|
219
|
-
|
|
220
|
-
def override_search_field(column)
|
|
221
|
-
override_helper column, 'search_column'
|
|
222
|
-
end
|
|
223
|
-
|
|
224
|
-
# the naming convention for overriding search input types with helpers
|
|
225
|
-
def override_search(form_ui)
|
|
226
|
-
method = "active_scaffold_search_#{form_ui}"
|
|
227
|
-
method if respond_to? method
|
|
228
|
-
end
|
|
229
|
-
|
|
230
|
-
def visibles_and_hiddens(search_config)
|
|
231
|
-
visibles = []
|
|
232
|
-
hiddens = []
|
|
233
|
-
search_config.columns.each do |column|
|
|
234
|
-
next unless column.search_sql
|
|
235
|
-
if search_config.optional_columns.include?(column.name) && !searched_by?(column)
|
|
236
|
-
hiddens << column
|
|
237
|
-
else
|
|
238
|
-
visibles << column
|
|
239
|
-
end
|
|
240
|
-
end
|
|
241
|
-
return visibles, hiddens
|
|
242
|
-
end
|
|
243
|
-
|
|
244
|
-
def searched_by?(column)
|
|
245
|
-
value = field_search_params[column.name]
|
|
246
|
-
case value
|
|
247
|
-
when Hash
|
|
248
|
-
!value['from'].blank?
|
|
249
|
-
when String
|
|
250
|
-
!value.blank?
|
|
251
|
-
else
|
|
252
|
-
false
|
|
253
|
-
end
|
|
254
|
-
end
|
|
255
|
-
end
|
|
256
|
-
end
|
|
257
|
-
end
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
module ActiveScaffold
|
|
2
|
-
module Helpers
|
|
3
|
-
# Helpers that assist with the rendering of a List Column
|
|
4
|
-
module ShowColumnHelpers
|
|
5
|
-
def show_column_value(record, column)
|
|
6
|
-
# check for an override helper
|
|
7
|
-
if (method = show_column_override(column))
|
|
8
|
-
# we only pass the record as the argument. we previously also passed the formatted_value,
|
|
9
|
-
# but mike perham pointed out that prohibited the usage of overrides to improve on the
|
|
10
|
-
# performance of our default formatting. see issue #138.
|
|
11
|
-
if method(method).arity == 1
|
|
12
|
-
ActiveSupport::Deprecation.warn("Add column argument to field override, signature is unified with list_ui")
|
|
13
|
-
send(method, record)
|
|
14
|
-
else
|
|
15
|
-
send(method, record, column)
|
|
16
|
-
end
|
|
17
|
-
# second, check if the dev has specified a valid list_ui for this column
|
|
18
|
-
elsif column.list_ui and (method = override_show_column_ui(column.list_ui))
|
|
19
|
-
send(method, column, record)
|
|
20
|
-
else
|
|
21
|
-
if column.column and (method = override_show_column_ui(column.column.type))
|
|
22
|
-
send(method, column, record)
|
|
23
|
-
else
|
|
24
|
-
get_column_value(record, column)
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def active_scaffold_show_text(column, record)
|
|
30
|
-
simple_format(clean_column_value(record.send(column.name)))
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def show_column_override(column)
|
|
34
|
-
override_helper column, 'show_column'
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
# the naming convention for overriding show types with helpers
|
|
38
|
-
def override_show_column_ui(list_ui)
|
|
39
|
-
method = "active_scaffold_show_#{list_ui}"
|
|
40
|
-
method if respond_to? method
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
@@ -1,398 +0,0 @@
|
|
|
1
|
-
module ActiveScaffold
|
|
2
|
-
module Helpers
|
|
3
|
-
# All extra helpers that should be included in the View.
|
|
4
|
-
# Also a dumping ground for uncategorized helpers.
|
|
5
|
-
module ViewHelpers
|
|
6
|
-
include ActiveScaffold::Helpers::IdHelpers
|
|
7
|
-
include ActiveScaffold::Helpers::AssociationHelpers
|
|
8
|
-
include ActiveScaffold::Helpers::PaginationHelpers
|
|
9
|
-
include ActiveScaffold::Helpers::ListColumnHelpers
|
|
10
|
-
include ActiveScaffold::Helpers::ShowColumnHelpers
|
|
11
|
-
include ActiveScaffold::Helpers::FormColumnHelpers
|
|
12
|
-
include ActiveScaffold::Helpers::SearchColumnHelpers
|
|
13
|
-
include ActiveScaffold::Helpers::HumanConditionHelpers
|
|
14
|
-
|
|
15
|
-
##
|
|
16
|
-
## Delegates
|
|
17
|
-
##
|
|
18
|
-
|
|
19
|
-
# access to the configuration variable
|
|
20
|
-
def active_scaffold_config
|
|
21
|
-
controller.class.active_scaffold_config
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def active_scaffold_config_for(*args)
|
|
25
|
-
controller.class.active_scaffold_config_for(*args)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def active_scaffold_controller_for(*args)
|
|
29
|
-
controller.class.active_scaffold_controller_for(*args)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
##
|
|
33
|
-
## Uncategorized
|
|
34
|
-
##
|
|
35
|
-
|
|
36
|
-
def controller_path_for_activerecord(klass)
|
|
37
|
-
begin
|
|
38
|
-
controller = active_scaffold_controller_for(klass)
|
|
39
|
-
controller.controller_path
|
|
40
|
-
rescue ActiveScaffold::ControllerNotFound
|
|
41
|
-
controller = nil
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# This is the template finder logic, keep it updated with however we find stuff in rails
|
|
46
|
-
# currently this very similar to the logic in ActionBase::Base.render for options file
|
|
47
|
-
def template_exists?(template_name, partial = false)
|
|
48
|
-
lookup_context.exists? template_name, '', partial
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def generate_temporary_id
|
|
52
|
-
(Time.now.to_f*1000).to_i.to_s
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
# Turns [[label, value]] into <option> tags
|
|
56
|
-
# Takes optional parameter of :include_blank
|
|
57
|
-
def option_tags_for(select_options, options = {})
|
|
58
|
-
select_options.insert(0,[as_(:_select_),nil]) if options[:include_blank]
|
|
59
|
-
select_options.collect do |option|
|
|
60
|
-
label, value = option[0], option[1]
|
|
61
|
-
value.nil? ? "<option value="">#{label}</option>" : "<option value=\"#{value}\">#{label}</option>"
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
# Should this column be displayed in the subform?
|
|
66
|
-
def in_subform?(column, parent_record)
|
|
67
|
-
return true unless column.association
|
|
68
|
-
|
|
69
|
-
# Polymorphic associations can't appear because they *might* be the reverse association, and because you generally don't assign an association from the polymorphic side ... I think.
|
|
70
|
-
return false if column.polymorphic_association?
|
|
71
|
-
|
|
72
|
-
# A column shouldn't be in the subform if it's the reverse association to the parent
|
|
73
|
-
return false if column.association.inverse_for?(parent_record.class)
|
|
74
|
-
|
|
75
|
-
return true
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def form_remote_upload_tag(url_for_options = {}, options = {})
|
|
79
|
-
options[:target] = action_iframe_id(url_for_options)
|
|
80
|
-
options[:multipart] ||= true
|
|
81
|
-
options[:class] = "#{options[:class]} as_remote_upload".strip
|
|
82
|
-
output=""
|
|
83
|
-
output << form_tag(url_for_options, options)
|
|
84
|
-
(output << "<iframe id='#{action_iframe_id(url_for_options)}' name='#{action_iframe_id(url_for_options)}' style='display:none'></iframe>").html_safe
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
# a general-use loading indicator (the "stuff is happening, please wait" feedback)
|
|
88
|
-
def loading_indicator_tag(options)
|
|
89
|
-
image_tag "active_scaffold/indicator.gif", :style => "visibility:hidden;", :id => loading_indicator_id(options), :alt => "loading indicator", :class => "loading-indicator"
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# Creates a javascript-based link that toggles the visibility of some element on the page.
|
|
93
|
-
# By default, it toggles the visibility of the sibling after the one it's nested in. You may pass custom javascript logic in options[:of] to change that, though. For example, you could say :of => '$("my_div_id")'.
|
|
94
|
-
# You may also flag whether the other element is visible by default or not, and the initial text will adjust accordingly.
|
|
95
|
-
def link_to_visibility_toggle(id, options = {})
|
|
96
|
-
options[:default_visible] = true if options[:default_visible].nil?
|
|
97
|
-
options[:hide_label] = as_(:hide)
|
|
98
|
-
options[:show_label] = as_(:show)
|
|
99
|
-
javascript_tag("ActiveScaffold.create_visibility_toggle('#{id}', #{options.to_json});")
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def skip_action_link(link, *args)
|
|
103
|
-
(!link.ignore_method.nil? && controller.respond_to?(link.ignore_method) && controller.send(link.ignore_method, *args)) || ((link.security_method_set? or controller.respond_to? link.security_method) and !controller.send(link.security_method, *args))
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def render_action_link(link, url_options, record = nil, html_options = {})
|
|
107
|
-
url_options = action_link_url_options(link, url_options, record)
|
|
108
|
-
html_options = action_link_html_options(link, url_options, record, html_options)
|
|
109
|
-
action_link_html(link, url_options, html_options, record)
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def render_group_action_link(link, url_options, options, record = nil)
|
|
113
|
-
if link.type == :member && !options[:authorized]
|
|
114
|
-
action_link_html(link, nil, {:class => "disabled #{link.action}#{link.html_options[:class].blank? ? '' : (' ' + link.html_options[:class])}"}, record)
|
|
115
|
-
else
|
|
116
|
-
render_action_link(link, url_options, record)
|
|
117
|
-
end
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
def action_link_url_options(link, url_options, record, options = {})
|
|
121
|
-
url_options = url_options.clone
|
|
122
|
-
url_options[:action] = link.action
|
|
123
|
-
url_options[:controller] = link.controller.to_s if link.controller
|
|
124
|
-
url_options.delete(:search) if link.controller and link.controller.to_s != params[:controller]
|
|
125
|
-
url_options.merge! link.parameters if link.parameters
|
|
126
|
-
if link.dynamic_parameters.is_a?(Proc)
|
|
127
|
-
if record.nil?
|
|
128
|
-
url_options.merge! link.dynamic_parameters.call
|
|
129
|
-
elsif link.dynamic_parameters.arity == 0
|
|
130
|
-
ActiveSupport::Deprecation.warn("dynamic_parameters must be a block with an argument for member action links, instead of using @link_record")
|
|
131
|
-
@link_record = record
|
|
132
|
-
url_options.merge! self.instance_eval(&(link.dynamic_parameters))
|
|
133
|
-
@link_record = nil
|
|
134
|
-
else
|
|
135
|
-
url_options.merge! link.dynamic_parameters.call(record)
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
url_options_for_nested_link(link.column, record, link, url_options, options) if link.nested_link?
|
|
139
|
-
url_options_for_sti_link(link.column, record, link, url_options, options) unless record.nil? || active_scaffold_config.sti_children.nil?
|
|
140
|
-
url_options[:_method] = link.method if !link.confirm? && link.inline? && link.method != :get
|
|
141
|
-
url_options
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
def action_link_html_options(link, url_options, record, html_options)
|
|
145
|
-
link_id = get_action_link_id(url_options, record, link.column)
|
|
146
|
-
html_options.reverse_merge! link.html_options.merge(:class => link.action.to_s)
|
|
147
|
-
|
|
148
|
-
# Needs to be in html_options to as the adding _method to the url is no longer supported by Rails
|
|
149
|
-
html_options[:method] = link.method if link.method != :get
|
|
150
|
-
|
|
151
|
-
html_options[:class] += ' as_action' if link.inline?
|
|
152
|
-
html_options[:data] = {}
|
|
153
|
-
html_options[:data][:confirm] = link.confirm(record.try(:to_label)) if link.confirm?
|
|
154
|
-
html_options[:data][:position] = link.position if link.position and link.inline?
|
|
155
|
-
html_options[:data][:action] = link.action if link.inline?
|
|
156
|
-
html_options[:data][:'cancel-refresh'] = true if link.inline? and link.refresh_on_close
|
|
157
|
-
if link.popup?
|
|
158
|
-
html_options[:data][:popup] = true
|
|
159
|
-
html_options[:target] = '_blank'
|
|
160
|
-
end
|
|
161
|
-
html_options[:id] = link_id
|
|
162
|
-
html_options[:remote] = true unless link.page? || link.popup?
|
|
163
|
-
if link.dhtml_confirm?
|
|
164
|
-
html_options[:class] += ' as_action' if !link.inline?
|
|
165
|
-
html_options[:page_link] = 'true' if !link.inline?
|
|
166
|
-
html_options[:dhtml_confirm] = link.dhtml_confirm.value
|
|
167
|
-
html_options[:onclick] = link.dhtml_confirm.onclick_function(controller, link_id)
|
|
168
|
-
end
|
|
169
|
-
html_options[:class] += " #{link.html_options[:class]}" unless link.html_options[:class].blank?
|
|
170
|
-
html_options
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
def get_action_link_id(url_options, record = nil, column = nil)
|
|
174
|
-
id = url_options[:id] || url_options[:parent_id]
|
|
175
|
-
id = "#{column.association.name}-#{record.id}" if column && column.plural_association?
|
|
176
|
-
if record.try(column.association.name.to_sym).present?
|
|
177
|
-
id = "#{column.association.name}-#{record.send(column.association.name).id}-#{record.id}"
|
|
178
|
-
else
|
|
179
|
-
id = "#{column.association.name}-#{record.id}" unless record.nil?
|
|
180
|
-
end if column && column.singular_association?
|
|
181
|
-
id = "#{id}-#{url_options[:batch_scope].downcase}" if url_options[:batch_scope]
|
|
182
|
-
action_id = "#{id_from_controller(url_options[:controller]) + '-' if url_options[:parent_controller] || url_options[:controller] != controller.controller_path}#{url_options[:action].to_s}"
|
|
183
|
-
action_link_id(action_id, id)
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
def action_link_html(link, url, html_options, record)
|
|
187
|
-
# issue 260, use url_options[:link] if it exists. This prevents DB data from being localized.
|
|
188
|
-
label = url.delete(:link) if url.is_a?(Hash)
|
|
189
|
-
label ||= link.label
|
|
190
|
-
if link.image.nil?
|
|
191
|
-
html = link_to(label, url, html_options)
|
|
192
|
-
else
|
|
193
|
-
html = link_to(image_tag(link.image[:name], :size => link.image[:size], :alt => label, :title => label), url, html_options)
|
|
194
|
-
end
|
|
195
|
-
# if url is nil we would like to generate an anchor without href attribute
|
|
196
|
-
url.nil? ? html.sub(/href=".*?"/, '').html_safe : html.html_safe
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
def url_options_for_nested_link(column, record, link, url_options, options = {})
|
|
200
|
-
if column && column.association
|
|
201
|
-
url_options[:parent_scaffold] = controller_path
|
|
202
|
-
url_options[column.association.active_record.name.foreign_key.to_sym] = url_options.delete(:id)
|
|
203
|
-
url_options[:id] = record.send(column.association.name).id if column.singular_association? && record.send(column.association.name).present?
|
|
204
|
-
url_options[:eid] = nil # needed for nested scaffolds open from an embedded scaffold
|
|
205
|
-
elsif link.parameters && link.parameters[:named_scope]
|
|
206
|
-
url_options[:parent_scaffold] = controller_path
|
|
207
|
-
url_options[active_scaffold_config.model.name.foreign_key.to_sym] = url_options.delete(:id)
|
|
208
|
-
url_options[:eid] = nil # needed for nested scaffolds open from an embedded scaffold
|
|
209
|
-
end
|
|
210
|
-
url_options.except! *params_conditions
|
|
211
|
-
url_options.except! *nested.constrained_fields if nested?
|
|
212
|
-
end
|
|
213
|
-
|
|
214
|
-
def url_options_for_sti_link(column, record, link, url_options, options = {})
|
|
215
|
-
#need to find out controller of current record type
|
|
216
|
-
#and set parameters
|
|
217
|
-
# its quite difficult to detect an sti link
|
|
218
|
-
# if link.column.nil? we are sure that it is nt an singular association inline autolink
|
|
219
|
-
# howver that will not work if a sti parent is an singular association inline autolink
|
|
220
|
-
if link.column.nil?
|
|
221
|
-
sti_controller_path = controller_path_for_activerecord(record.class)
|
|
222
|
-
if sti_controller_path
|
|
223
|
-
url_options[:controller] = sti_controller_path
|
|
224
|
-
url_options[:parent_sti] = controller_path
|
|
225
|
-
end
|
|
226
|
-
end
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
def list_row_class(record)
|
|
230
|
-
class_override_helper = :"#{clean_class_name(record.class.name)}_list_row_class"
|
|
231
|
-
respond_to?(class_override_helper) ? send(class_override_helper, record) : ''
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
def column_attributes(column, record)
|
|
235
|
-
method = override_helper column, 'column_attributes'
|
|
236
|
-
return send(method, record) if method
|
|
237
|
-
{}
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
def column_class(column, column_value, record)
|
|
241
|
-
classes = []
|
|
242
|
-
classes << "#{column.name}-column"
|
|
243
|
-
if column.css_class.is_a?(Proc)
|
|
244
|
-
css_class = column.css_class.call(column_value, record)
|
|
245
|
-
classes << css_class unless css_class.nil?
|
|
246
|
-
else
|
|
247
|
-
classes << column.css_class
|
|
248
|
-
end unless column.css_class.nil?
|
|
249
|
-
|
|
250
|
-
classes << 'empty' if column_empty? column_value
|
|
251
|
-
classes << 'sorted' if active_scaffold_config.list.user.sorting.sorts_on?(column)
|
|
252
|
-
classes << 'numeric' if column.column and [:decimal, :float, :integer].include?(column.column.type)
|
|
253
|
-
classes << 'in_place_editor_field' if inplace_edit?(record, column) or column.list_ui == :marked
|
|
254
|
-
classes.join(' ').rstrip
|
|
255
|
-
end
|
|
256
|
-
|
|
257
|
-
def column_heading_class(column, sorting)
|
|
258
|
-
classes = []
|
|
259
|
-
classes << "#{column.name}-column_heading"
|
|
260
|
-
classes << "sorted #{sorting.direction_of(column).downcase}" if sorting.sorts_on? column
|
|
261
|
-
classes << column.css_class unless column.css_class.nil? || column.css_class.is_a?(Proc)
|
|
262
|
-
classes.join(' ')
|
|
263
|
-
end
|
|
264
|
-
|
|
265
|
-
def as_main_div_class
|
|
266
|
-
classes = ["active-scaffold", "active-scaffold-#{controller_id}", "#{id_from_controller params[:controller]}-view", "#{active_scaffold_config.theme}-theme"]
|
|
267
|
-
classes << "as_touch" if touch_device?
|
|
268
|
-
classes.join(' ')
|
|
269
|
-
end
|
|
270
|
-
|
|
271
|
-
def column_empty?(column_value)
|
|
272
|
-
empty = column_value.nil?
|
|
273
|
-
empty ||= column_value.blank? if column_value.respond_to? :blank?
|
|
274
|
-
empty ||= [' ', active_scaffold_config.list.empty_field_text].include? column_value if String === column_value
|
|
275
|
-
return empty
|
|
276
|
-
end
|
|
277
|
-
|
|
278
|
-
def column_calculation(column)
|
|
279
|
-
unless column.calculate.instance_of? Proc
|
|
280
|
-
calculate(column)
|
|
281
|
-
else
|
|
282
|
-
column.calculate.call(@records)
|
|
283
|
-
end
|
|
284
|
-
end
|
|
285
|
-
|
|
286
|
-
def render_column_calculation(column)
|
|
287
|
-
calculation = column_calculation(column)
|
|
288
|
-
override_formatter = "render_#{column.name}_#{column.calculate.is_a?(Proc) ? :calculate : column.calculate}"
|
|
289
|
-
calculation = send(override_formatter, calculation) if respond_to? override_formatter
|
|
290
|
-
|
|
291
|
-
"#{"#{as_(column.calculate)}: " unless column.calculate.is_a? Proc}#{format_column_value nil, column, calculation}"
|
|
292
|
-
end
|
|
293
|
-
|
|
294
|
-
def column_show_add_existing(column)
|
|
295
|
-
(column.allow_add_existing and options_for_association_count(column.association) > 0)
|
|
296
|
-
end
|
|
297
|
-
|
|
298
|
-
def column_show_add_new(column, associated, record)
|
|
299
|
-
value = (column.plural_association? && !column.readonly_association?) || (column.singular_association? and not associated.empty?)
|
|
300
|
-
value = false unless column.association.klass.authorized_for?(:crud_type => :create)
|
|
301
|
-
value
|
|
302
|
-
end
|
|
303
|
-
|
|
304
|
-
def clean_column_name(name)
|
|
305
|
-
name.to_s.gsub('?', '')
|
|
306
|
-
end
|
|
307
|
-
|
|
308
|
-
def clean_class_name(name)
|
|
309
|
-
name.underscore.gsub('/', '_')
|
|
310
|
-
end
|
|
311
|
-
|
|
312
|
-
# the naming convention for overriding with helpers
|
|
313
|
-
def override_helper_name(column, suffix, class_prefix = false)
|
|
314
|
-
"#{clean_class_name(column.active_record_class.name) + '_' if class_prefix}#{clean_column_name(column.name)}_#{suffix}"
|
|
315
|
-
end
|
|
316
|
-
|
|
317
|
-
def override_helper(column, suffix)
|
|
318
|
-
method_with_class = override_helper_name(column, suffix, true)
|
|
319
|
-
return method_with_class if respond_to?(method_with_class)
|
|
320
|
-
method = override_helper_name(column, suffix)
|
|
321
|
-
method if respond_to?(method)
|
|
322
|
-
end
|
|
323
|
-
|
|
324
|
-
def display_message(message)
|
|
325
|
-
if (highlights = active_scaffold_config.highlight_messages)
|
|
326
|
-
message = highlights.inject(message) do |msg, (phrases, highlighter)|
|
|
327
|
-
highlight(msg, phrases, highlighter)
|
|
328
|
-
end
|
|
329
|
-
end
|
|
330
|
-
if (format = active_scaffold_config.timestamped_messages)
|
|
331
|
-
format = :short if format == true
|
|
332
|
-
message = "#{content_tag :div, l(Time.current, :format => format), :class => 'timestamp'} #{content_tag :div, message, :class => 'message-content'}".html_safe
|
|
333
|
-
end
|
|
334
|
-
message
|
|
335
|
-
end
|
|
336
|
-
|
|
337
|
-
def active_scaffold_error_messages_for(*params)
|
|
338
|
-
options = params.extract_options!.symbolize_keys
|
|
339
|
-
options.reverse_merge!(:container_tag => :div, :list_type => :ul)
|
|
340
|
-
|
|
341
|
-
objects = Array.wrap(options.delete(:object) || params).map do |object|
|
|
342
|
-
object = instance_variable_get("@#{object}") unless object.respond_to?(:to_model)
|
|
343
|
-
object = convert_to_model(object)
|
|
344
|
-
|
|
345
|
-
if object.class.respond_to?(:model_name)
|
|
346
|
-
options[:object_name] ||= object.class.model_name.human.downcase
|
|
347
|
-
end
|
|
348
|
-
|
|
349
|
-
object
|
|
350
|
-
end
|
|
351
|
-
|
|
352
|
-
objects.compact!
|
|
353
|
-
count = objects.inject(0) {|sum, object| sum + object.errors.count }
|
|
354
|
-
|
|
355
|
-
unless count.zero?
|
|
356
|
-
html = {}
|
|
357
|
-
[:id, :class].each do |key|
|
|
358
|
-
if options.include?(key)
|
|
359
|
-
value = options[key]
|
|
360
|
-
html[key] = value unless value.blank?
|
|
361
|
-
else
|
|
362
|
-
html[key] = 'errorExplanation'
|
|
363
|
-
end
|
|
364
|
-
end
|
|
365
|
-
options[:object_name] ||= params.first
|
|
366
|
-
|
|
367
|
-
header_message = if options.include?(:header_message)
|
|
368
|
-
options[:header_message]
|
|
369
|
-
else
|
|
370
|
-
as_('errors.template.header', :count => count, :model => options[:object_name].to_s.gsub('_', ' '))
|
|
371
|
-
end
|
|
372
|
-
|
|
373
|
-
message = options.include?(:message) ? options[:message] : as_('errors.template.body')
|
|
374
|
-
|
|
375
|
-
error_messages = objects.sum do |object|
|
|
376
|
-
object.errors.full_messages.map do |msg|
|
|
377
|
-
options[:list_type] != :br ? content_tag(:li, msg) : msg
|
|
378
|
-
end
|
|
379
|
-
end
|
|
380
|
-
error_messages = if options[:list_type] == :br
|
|
381
|
-
error_messages.join('<br/>').html_safe
|
|
382
|
-
else
|
|
383
|
-
content_tag(options[:list_type], error_messages.join.html_safe)
|
|
384
|
-
end
|
|
385
|
-
|
|
386
|
-
contents = []
|
|
387
|
-
contents << content_tag(options[:header_tag] || :h2, header_message) unless header_message.blank?
|
|
388
|
-
contents << content_tag(:p, message) unless message.blank?
|
|
389
|
-
contents << error_messages
|
|
390
|
-
contents = contents.join.html_safe
|
|
391
|
-
options[:container_tag] ? content_tag(options[:container_tag], contents, html) : contents
|
|
392
|
-
else
|
|
393
|
-
''
|
|
394
|
-
end
|
|
395
|
-
end
|
|
396
|
-
end
|
|
397
|
-
end
|
|
398
|
-
end
|