active_scaffold 3.4.17 → 3.4.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +12 -1
- data/README.md +8 -4
- data/app/assets/javascripts/jquery/active_scaffold.js +82 -67
- data/app/assets/stylesheets/active_scaffold.scss +1 -1
- data/app/assets/stylesheets/active_scaffold_colors.scss +1 -1
- data/app/assets/stylesheets/blue-theme.css +1 -1
- data/app/views/active_scaffold_overrides/_form_association.html.erb +3 -3
- data/app/views/active_scaffold_overrides/_form_association_record.html.erb +3 -3
- data/app/views/active_scaffold_overrides/_show_columns.html.erb +1 -1
- data/lib/active_scaffold.rb +16 -16
- data/lib/active_scaffold/actions/common_search.rb +13 -11
- data/lib/active_scaffold/actions/core.rb +85 -78
- data/lib/active_scaffold/actions/create.rb +29 -28
- data/lib/active_scaffold/actions/delete.rb +17 -17
- data/lib/active_scaffold/actions/field_search.rb +18 -19
- data/lib/active_scaffold/actions/list.rb +30 -22
- data/lib/active_scaffold/actions/mark.rb +1 -1
- data/lib/active_scaffold/actions/nested.rb +78 -65
- data/lib/active_scaffold/actions/search.rb +13 -10
- data/lib/active_scaffold/actions/show.rb +10 -6
- data/lib/active_scaffold/actions/subform.rb +1 -2
- data/lib/active_scaffold/actions/update.rb +39 -31
- data/lib/active_scaffold/active_record_permissions.rb +14 -15
- data/lib/active_scaffold/attribute_params.rb +42 -43
- data/lib/active_scaffold/bridges.rb +22 -12
- data/lib/active_scaffold/bridges/ancestry.rb +1 -1
- data/lib/active_scaffold/bridges/ancestry/ancestry_bridge.rb +6 -6
- data/lib/active_scaffold/bridges/bitfields.rb +1 -1
- data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +12 -13
- data/lib/active_scaffold/bridges/calendar_date_select.rb +5 -5
- data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +17 -20
- data/lib/active_scaffold/bridges/cancan.rb +1 -1
- data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +8 -9
- data/lib/active_scaffold/bridges/carrierwave.rb +4 -4
- data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +9 -8
- data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +11 -10
- data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +7 -6
- data/lib/active_scaffold/bridges/chosen.rb +1 -1
- data/lib/active_scaffold/bridges/chosen/helpers.rb +4 -4
- data/lib/active_scaffold/bridges/country_helper.rb +1 -1
- data/lib/active_scaffold/bridges/country_helper/country_helper_bridge.rb +259 -260
- data/lib/active_scaffold/bridges/date_picker.rb +2 -2
- data/lib/active_scaffold/bridges/date_picker/ext.rb +9 -11
- data/lib/active_scaffold/bridges/date_picker/helper.rb +61 -67
- data/lib/active_scaffold/bridges/dragonfly.rb +4 -4
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +9 -8
- data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +11 -10
- data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +6 -5
- data/lib/active_scaffold/bridges/file_column.rb +5 -5
- data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +20 -23
- data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +20 -23
- data/lib/active_scaffold/bridges/file_column/form_ui.rb +13 -14
- data/lib/active_scaffold/bridges/file_column/list_ui.rb +7 -8
- data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +18 -22
- data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +5 -4
- data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +2 -10
- data/lib/active_scaffold/bridges/paper_trail.rb +7 -5
- data/lib/active_scaffold/bridges/paper_trail/paper_trail_bridge.rb +4 -3
- data/lib/active_scaffold/bridges/paperclip.rb +5 -5
- data/lib/active_scaffold/bridges/paperclip/form_ui.rb +11 -10
- data/lib/active_scaffold/bridges/paperclip/list_ui.rb +6 -5
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +10 -9
- data/lib/active_scaffold/bridges/record_select.rb +1 -1
- data/lib/active_scaffold/bridges/record_select/helpers.rb +28 -28
- data/lib/active_scaffold/bridges/semantic_attributes.rb +1 -1
- data/lib/active_scaffold/bridges/semantic_attributes/column.rb +1 -1
- data/lib/active_scaffold/bridges/shared/date_bridge.rb +58 -52
- data/lib/active_scaffold/bridges/tiny_mce.rb +2 -2
- data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +3 -3
- data/lib/active_scaffold/config/base.rb +9 -10
- data/lib/active_scaffold/config/core.rb +24 -29
- data/lib/active_scaffold/config/create.rb +0 -1
- data/lib/active_scaffold/config/field_search.rb +8 -10
- data/lib/active_scaffold/config/form.rb +5 -5
- data/lib/active_scaffold/config/list.rb +21 -20
- data/lib/active_scaffold/config/mark.rb +3 -3
- data/lib/active_scaffold/config/nested.rb +11 -10
- data/lib/active_scaffold/config/search.rb +2 -3
- data/lib/active_scaffold/config/show.rb +1 -1
- data/lib/active_scaffold/config/update.rb +1 -2
- data/lib/active_scaffold/configurable.rb +9 -11
- data/lib/active_scaffold/constraints.rb +9 -8
- data/lib/active_scaffold/core.rb +72 -84
- data/lib/active_scaffold/data_structures/action_columns.rb +26 -25
- data/lib/active_scaffold/data_structures/action_link.rb +43 -43
- data/lib/active_scaffold/data_structures/action_links.rb +17 -15
- data/lib/active_scaffold/data_structures/actions.rb +5 -5
- data/lib/active_scaffold/data_structures/bridge.rb +6 -3
- data/lib/active_scaffold/data_structures/column.rb +110 -89
- data/lib/active_scaffold/data_structures/columns.rb +3 -3
- data/lib/active_scaffold/data_structures/error_message.rb +4 -6
- data/lib/active_scaffold/data_structures/nested_info.rb +43 -48
- data/lib/active_scaffold/data_structures/set.rb +7 -8
- data/lib/active_scaffold/data_structures/sorting.rb +38 -33
- data/lib/active_scaffold/delayed_setup.rb +5 -6
- data/lib/active_scaffold/engine.rb +4 -4
- data/lib/active_scaffold/extensions/action_controller_rendering.rb +3 -4
- data/lib/active_scaffold/extensions/action_controller_rescueing.rb +1 -1
- data/lib/active_scaffold/extensions/action_view_rendering.rb +5 -6
- data/lib/active_scaffold/extensions/left_outer_joins.rb +11 -11
- data/lib/active_scaffold/extensions/localize.rb +1 -1
- data/lib/active_scaffold/extensions/name_option_for_datetime.rb +1 -1
- data/lib/active_scaffold/extensions/paginator_extensions.rb +2 -5
- data/lib/active_scaffold/extensions/reverse_associations.rb +13 -13
- data/lib/active_scaffold/extensions/routing_mapper.rb +9 -9
- data/lib/active_scaffold/extensions/unsaved_associated.rb +9 -9
- data/lib/active_scaffold/finder.rb +90 -93
- data/lib/active_scaffold/helpers/association_helpers.rb +5 -5
- data/lib/active_scaffold/helpers/controller_helpers.rb +22 -19
- data/lib/active_scaffold/helpers/form_column_helpers.rb +115 -105
- data/lib/active_scaffold/helpers/human_condition_helpers.rb +62 -35
- data/lib/active_scaffold/helpers/id_helpers.rb +6 -6
- data/lib/active_scaffold/helpers/list_column_helpers.rb +89 -94
- data/lib/active_scaffold/helpers/pagination_helpers.rb +9 -9
- data/lib/active_scaffold/helpers/search_column_helpers.rb +47 -44
- data/lib/active_scaffold/helpers/show_column_helpers.rb +2 -2
- data/lib/active_scaffold/helpers/view_helpers.rb +86 -91
- data/lib/active_scaffold/marked_model.rb +10 -10
- data/lib/active_scaffold/paginator.rb +30 -34
- data/lib/active_scaffold/responds_to_parent.rb +27 -28
- data/lib/active_scaffold/tableless.rb +20 -15
- data/lib/active_scaffold/version.rb +1 -1
- data/lib/generators/active_scaffold/active_scaffold_generator.rb +8 -8
- data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +9 -9
- data/shoulda_macros/macros.rb +27 -22
- data/test/bridges/bridge_test.rb +38 -29
- data/test/bridges/date_picker_test.rb +1 -1
- data/test/bridges/paper_trail_test.rb +17 -0
- data/test/bridges/paperclip_test.rb +3 -2
- data/test/bridges/tiny_mce_test.rb +5 -2
- data/test/company.rb +25 -30
- data/test/config/base_test.rb +1 -1
- data/test/config/core_test.rb +9 -9
- data/test/config/create_test.rb +14 -8
- data/test/config/delete_test.rb +4 -4
- data/test/config/field_search_test.rb +6 -6
- data/test/config/list_test.rb +16 -16
- data/test/config/nested_test.rb +4 -4
- data/test/config/search_test.rb +8 -8
- data/test/config/show_test.rb +6 -6
- data/test/config/subform_test.rb +1 -1
- data/test/config/update_test.rb +5 -5
- data/test/const_mocker.rb +4 -4
- data/test/data_structures/action_columns_test.rb +4 -5
- data/test/data_structures/action_link_test.rb +1 -0
- data/test/data_structures/action_links_test.rb +5 -5
- data/test/data_structures/column_test.rb +9 -9
- data/test/data_structures/columns_test.rb +2 -2
- data/test/data_structures/error_message_test.rb +4 -5
- data/test/data_structures/set_test.rb +1 -2
- data/test/data_structures/sorting_test.rb +10 -10
- data/test/data_structures/validation_reflection_test.rb +8 -0
- data/test/extensions/routing_mapper_test.rb +2 -2
- data/test/helpers/list_column_helpers_test.rb +3 -2
- data/test/helpers/pagination_helpers_test.rb +5 -4
- data/test/helpers/search_column_helpers_test.rb +1 -1
- data/test/misc/active_record_permissions_test.rb +63 -50
- data/test/misc/attribute_params_test.rb +28 -26
- data/test/misc/calculation_test.rb +10 -3
- data/test/misc/configurable_test.rb +12 -13
- data/test/misc/constraints_test.rb +6 -6
- data/test/misc/convert_numbers_format_test.rb +7 -6
- data/test/misc/finder_test.rb +17 -12
- data/test/misc/lang_test.rb +3 -4
- data/test/misc/tableless_test.rb +2 -3
- data/test/mock_app/app/controllers/addresses_controller.rb +1 -1
- data/test/mock_app/app/controllers/buildings_controller.rb +1 -1
- data/test/mock_app/app/controllers/cars_controller.rb +1 -1
- data/test/mock_app/app/controllers/contacts_controller.rb +1 -1
- data/test/mock_app/app/controllers/people_controller.rb +1 -1
- data/test/mock_app/app/models/file_model.rb +2 -2
- data/test/mock_app/app/models/person.rb +1 -1
- data/test/mock_app/config/application.rb +3 -3
- data/test/mock_app/config/boot.rb +1 -1
- data/test/mock_app/config/environment.rb +1 -0
- data/test/mock_app/config/environments/development.rb +0 -1
- data/test/mock_app/config/environments/production.rb +1 -1
- data/test/mock_app/db/schema.rb +14 -15
- data/test/model_stub.rb +13 -16
- data/test/run_all.rb +5 -7
- data/test/test_helper.rb +12 -9
- metadata +19 -3
@@ -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(:page => page_number), options.merge(:class =>
|
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)
|
@@ -40,18 +40,18 @@ module ActiveScaffold
|
|
40
40
|
if current_page.pager.infinite?
|
41
41
|
offsets.reverse.each do |offset|
|
42
42
|
page = current_page.number - offset
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
next unless page < start_number && page > last_page
|
44
|
+
|
45
|
+
html << '..' if page > last_page + 1
|
46
|
+
html << pagination_ajax_link(page, url_options, options)
|
47
|
+
last_page = page
|
48
48
|
end
|
49
49
|
end
|
50
|
-
html <<
|
50
|
+
html << '..' if start_number > last_page + 1
|
51
51
|
|
52
52
|
[start_number, last_page + 1].max.upto(end_number) do |num|
|
53
53
|
if current_page.number == num
|
54
|
-
html << content_tag(:span, num.to_s,
|
54
|
+
html << content_tag(:span, num.to_s, :class => 'as_paginate current')
|
55
55
|
else
|
56
56
|
html << pagination_ajax_link(num, url_options, options)
|
57
57
|
end
|
@@ -62,7 +62,7 @@ module ActiveScaffold
|
|
62
62
|
html << '..' << pagination_ajax_link(current_page.number + offset, url_options, options)
|
63
63
|
end
|
64
64
|
else
|
65
|
-
html <<
|
65
|
+
html << '..' unless end_number >= current_page.pager.last.number - outer_window - 1
|
66
66
|
[end_number + 1, current_page.pager.last.number - outer_window].max.upto(current_page.pager.last.number) do |num|
|
67
67
|
html << pagination_ajax_link(num, url_options, options)
|
68
68
|
end
|
@@ -7,19 +7,19 @@ module ActiveScaffold
|
|
7
7
|
def active_scaffold_search_for(column, options = nil)
|
8
8
|
options ||= active_scaffold_search_options(column)
|
9
9
|
record = options[:object]
|
10
|
-
ActiveSupport::Deprecation.warn
|
11
|
-
record ||= @record # TODO Remove when relying on @record is removed
|
10
|
+
ActiveSupport::Deprecation.warn 'Relying on @record is deprecated, include :object in options with record.', caller if record.nil? # TODO: Remove when relying on @record is removed
|
11
|
+
record ||= @record # TODO: Remove when relying on @record is removed
|
12
12
|
|
13
13
|
# first, check if the dev has created an override for this specific field for search
|
14
14
|
if (method = override_search_field(column))
|
15
15
|
send(method, record, options)
|
16
16
|
|
17
17
|
# second, check if the dev has specified a valid search_ui for this column, using specific ui for searches
|
18
|
-
elsif column.search_ui
|
18
|
+
elsif column.search_ui && (method = override_search(column.search_ui))
|
19
19
|
send(method, column, options)
|
20
20
|
|
21
21
|
# third, check if the dev has specified a valid search_ui for this column, using generic ui for forms
|
22
|
-
elsif column.search_ui
|
22
|
+
elsif column.search_ui && (method = override_input(column.search_ui))
|
23
23
|
send(method, column, options)
|
24
24
|
|
25
25
|
# fourth, check if the dev has created an override for this specific field
|
@@ -28,7 +28,7 @@ module ActiveScaffold
|
|
28
28
|
|
29
29
|
# fallback: we get to make the decision
|
30
30
|
else
|
31
|
-
if column.association
|
31
|
+
if column.association || column.virtual?
|
32
32
|
active_scaffold_search_text(column, options)
|
33
33
|
|
34
34
|
else # regular model attribute column
|
@@ -47,41 +47,41 @@ module ActiveScaffold
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
50
|
-
rescue
|
50
|
+
rescue StandardError => e
|
51
51
|
logger.error "#{e.class.name}: #{e.message} -- on the ActiveScaffold column = :#{column.name} in #{controller.class}"
|
52
52
|
raise e
|
53
53
|
end
|
54
54
|
|
55
55
|
# the standard active scaffold options used for class, name and scope
|
56
56
|
def active_scaffold_search_options(column)
|
57
|
-
{
|
57
|
+
{:name => "search[#{column.name}]", :class => "#{column.name}-input", :id => "search_#{column.name}", :value => field_search_params[column.name]}
|
58
58
|
end
|
59
59
|
|
60
60
|
def search_attribute(column, record)
|
61
61
|
column_options = active_scaffold_search_options(column).merge(:object => record)
|
62
62
|
field = active_scaffold_search_for column, column_options
|
63
|
-
|
63
|
+
%(<dl><dt>#{label_tag search_label_for(column, column_options), search_column_label(column, record)}</dt><dd>#{field}</dd></dl>).html_safe
|
64
64
|
end
|
65
65
|
|
66
66
|
def search_label_for(column, options)
|
67
67
|
options[:id] unless [:range, :integer, :decimal, :float, :string, :date_picker, :datetime_picker, :calendar_date_select].include? column.search_ui
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
##
|
71
71
|
## Search input methods
|
72
72
|
##
|
73
73
|
|
74
74
|
def active_scaffold_search_multi_select(column, options)
|
75
75
|
record = options.delete(:object)
|
76
|
-
ActiveSupport::Deprecation.warn
|
77
|
-
record ||= @record # TODO Remove when relying on @record is removed
|
76
|
+
ActiveSupport::Deprecation.warn 'Relying on @record is deprecated, include :object in options with record.', caller if record.nil? # TODO: Remove when relying on @record is removed
|
77
|
+
record ||= @record # TODO: Remove when relying on @record is removed
|
78
78
|
associated = options.delete :value
|
79
79
|
associated = [associated].compact unless associated.is_a? Array
|
80
80
|
associated.collect!(&:to_i)
|
81
|
-
|
81
|
+
|
82
82
|
if column.association
|
83
83
|
method = column.options[:label_method] || :to_label
|
84
|
-
select_options = sorted_association_options_find(column.association, nil, record).collect {|r| [r.send(method), r.id]}
|
84
|
+
select_options = sorted_association_options_find(column.association, nil, record).collect { |r| [r.send(method), r.id] }
|
85
85
|
else
|
86
86
|
select_options = column.options[:options].collect do |text, value|
|
87
87
|
active_scaffold_translated_option(column, text, value)
|
@@ -94,8 +94,8 @@ module ActiveScaffold
|
|
94
94
|
|
95
95
|
def active_scaffold_search_select(column, html_options, options = {})
|
96
96
|
record = html_options.delete(:object)
|
97
|
-
ActiveSupport::Deprecation.warn
|
98
|
-
record ||= @record # TODO Remove when relying on @record is removed
|
97
|
+
ActiveSupport::Deprecation.warn 'Relying on @record is deprecated, include :object in html_options with record.', caller if record.nil? # TODO: Remove when relying on @record is removed
|
98
|
+
record ||= @record # TODO: Remove when relying on @record is removed
|
99
99
|
associated = html_options.delete :value
|
100
100
|
if column.association
|
101
101
|
associated = associated.is_a?(Array) ? associated.map(&:to_i) : associated.to_i unless associated.nil?
|
@@ -113,10 +113,10 @@ module ActiveScaffold
|
|
113
113
|
if html_options[:multiple]
|
114
114
|
html_options[:name] += '[]'
|
115
115
|
else
|
116
|
-
options[:include_blank] ||= as_(:_select_)
|
116
|
+
options[:include_blank] ||= as_(:_select_)
|
117
117
|
end
|
118
|
-
|
119
|
-
if optgroup = options.delete(:optgroup)
|
118
|
+
|
119
|
+
if (optgroup = options.delete(:optgroup))
|
120
120
|
select(:record, method, active_scaffold_grouped_options(column, select_options, optgroup), options, html_options)
|
121
121
|
elsif column.association
|
122
122
|
collection_select(:record, method, select_options, :id, column.options[:label_method] || :to_label, options, html_options)
|
@@ -141,18 +141,18 @@ module ActiveScaffold
|
|
141
141
|
end
|
142
142
|
# we can't use checkbox ui because it's not possible to decide whether search for this field or not
|
143
143
|
alias_method :active_scaffold_search_checkbox, :active_scaffold_search_boolean
|
144
|
-
|
144
|
+
|
145
145
|
def active_scaffold_search_null(column, options)
|
146
146
|
select_options = []
|
147
147
|
select_options << [as_(:_select_), nil]
|
148
|
-
select_options.concat ActiveScaffold::Finder::
|
148
|
+
select_options.concat ActiveScaffold::Finder::NULL_COMPARATORS.collect { |comp| [as_(comp), comp] }
|
149
149
|
select_tag(options[:name], options_for_select(select_options, options[:value]), :id => options[:id])
|
150
150
|
end
|
151
151
|
|
152
152
|
def field_search_params_range_values(column)
|
153
153
|
values = field_search_params[column.name]
|
154
154
|
return nil unless values.is_a? Hash
|
155
|
-
|
155
|
+
[values[:opt], (values[:from].blank? ? nil : values[:from]), (values[:to].blank? ? nil : values[:to])]
|
156
156
|
end
|
157
157
|
|
158
158
|
def active_scaffold_search_range_string?(column)
|
@@ -160,18 +160,18 @@ module ActiveScaffold
|
|
160
160
|
end
|
161
161
|
|
162
162
|
def active_scaffold_search_range_comparator_options(column)
|
163
|
-
select_options = ActiveScaffold::Finder::
|
163
|
+
select_options = ActiveScaffold::Finder::NUMERIC_COMPARATORS.collect { |comp| [as_(comp.downcase.to_sym), comp] }
|
164
164
|
if active_scaffold_search_range_string?(column)
|
165
|
-
select_options.unshift *ActiveScaffold::Finder::
|
165
|
+
select_options.unshift *ActiveScaffold::Finder::STRING_COMPARATORS.collect { |title, comp| [as_(title), comp] }
|
166
166
|
end
|
167
167
|
if include_null_comparators? column
|
168
|
-
select_options += ActiveScaffold::Finder::
|
168
|
+
select_options += ActiveScaffold::Finder::NULL_COMPARATORS.collect { |comp| [as_(comp), comp] }
|
169
169
|
end
|
170
170
|
select_options
|
171
171
|
end
|
172
172
|
|
173
173
|
def include_null_comparators?(column)
|
174
|
-
return column.options[:null_comparators] if column.options.
|
174
|
+
return column.options[:null_comparators] if column.options.key? :null_comparators
|
175
175
|
if column.association
|
176
176
|
column.association.macro != :belongs_to || active_scaffold_config.columns[column.association.foreign_key].column.try(:null)
|
177
177
|
else
|
@@ -190,20 +190,22 @@ module ActiveScaffold
|
|
190
190
|
text_field_size = 10
|
191
191
|
opt_value ||= '='
|
192
192
|
end
|
193
|
-
|
193
|
+
|
194
194
|
from_value = controller.class.condition_value_for_numeric(column, from_value)
|
195
195
|
to_value = controller.class.condition_value_for_numeric(column, to_value)
|
196
196
|
from_value = format_number_value(from_value, column.options) if from_value.is_a?(Numeric)
|
197
197
|
to_value = format_number_value(to_value, column.options) if to_value.is_a?(Numeric)
|
198
|
-
html = select_tag("#{options[:name]}[opt]",
|
199
|
-
|
200
|
-
|
201
|
-
:class => "as_search_range_option")
|
202
|
-
html << content_tag("span", :id => "#{options[:id]}_numeric", :style => ActiveScaffold::Finder::NullComparators.include?(opt_value) ? "display: none" : nil) do
|
198
|
+
html = select_tag("#{options[:name]}[opt]", options_for_select(select_options, opt_value),
|
199
|
+
:id => "#{options[:id]}_opt", :class => 'as_search_range_option')
|
200
|
+
html << content_tag('span', :id => "#{options[:id]}_numeric", :style => ActiveScaffold::Finder::NULL_COMPARATORS.include?(opt_value) ? 'display: none' : nil) do
|
203
201
|
text_field_tag("#{options[:name]}[from]", from_value, active_scaffold_input_text_options(:id => options[:id], :size => text_field_size)) <<
|
204
|
-
|
205
|
-
|
206
|
-
|
202
|
+
content_tag(
|
203
|
+
:span, (
|
204
|
+
' - ' + text_field_tag("#{options[:name]}[to]", to_value,
|
205
|
+
active_scaffold_input_text_options(:id => "#{options[:id]}_to", :size => text_field_size))
|
206
|
+
).html_safe,
|
207
|
+
:id => "#{options[:id]}_between", :class => 'as_search_range_between', :style => (opt_value == 'BETWEEN') ? nil : 'display: none'
|
208
|
+
)
|
207
209
|
end
|
208
210
|
content_tag :span, html, :class => 'search_range'
|
209
211
|
end
|
@@ -215,19 +217,20 @@ module ActiveScaffold
|
|
215
217
|
def field_search_datetime_value(value)
|
216
218
|
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?
|
217
219
|
end
|
218
|
-
|
220
|
+
|
219
221
|
def active_scaffold_search_datetime(column, options)
|
220
|
-
|
222
|
+
_, from_value, to_value = field_search_params_range_values(column)
|
221
223
|
options = column.options.merge(options)
|
222
224
|
helper = "select_#{'date' unless options[:discard_date]}#{'time' unless options[:discard_time]}"
|
223
|
-
|
224
|
-
send(helper, field_search_datetime_value(from_value), {:include_blank => true, :prefix => "#{options[:name]}[from]"}.merge(options)) <<
|
225
|
-
|
225
|
+
|
226
|
+
send(helper, field_search_datetime_value(from_value), {:include_blank => true, :prefix => "#{options[:name]}[from]"}.merge(options)) <<
|
227
|
+
' - '.html_safe << send(helper, field_search_datetime_value(to_value), {:include_blank => true, :prefix => "#{options[:name]}[to]"}.merge(options))
|
226
228
|
end
|
227
229
|
|
228
230
|
def active_scaffold_search_date(column, options)
|
229
231
|
active_scaffold_search_datetime(column, options.merge!(:discard_time => true))
|
230
232
|
end
|
233
|
+
|
231
234
|
def active_scaffold_search_time(column, options)
|
232
235
|
active_scaffold_search_datetime(column, options.merge!(:discard_date => true))
|
233
236
|
end
|
@@ -236,7 +239,7 @@ module ActiveScaffold
|
|
236
239
|
##
|
237
240
|
## Search column override signatures
|
238
241
|
##
|
239
|
-
|
242
|
+
|
240
243
|
def search_column_label(column, record)
|
241
244
|
column.label
|
242
245
|
end
|
@@ -250,9 +253,9 @@ module ActiveScaffold
|
|
250
253
|
method = "active_scaffold_search_#{form_ui}"
|
251
254
|
method if respond_to? method
|
252
255
|
end
|
253
|
-
|
256
|
+
|
254
257
|
def visibles_and_hiddens(search_config)
|
255
|
-
visibles = []
|
258
|
+
visibles = []
|
256
259
|
hiddens = []
|
257
260
|
search_config.columns.each do |column|
|
258
261
|
next unless column.search_sql
|
@@ -262,9 +265,9 @@ module ActiveScaffold
|
|
262
265
|
visibles << column
|
263
266
|
end
|
264
267
|
end
|
265
|
-
|
268
|
+
[visibles, hiddens]
|
266
269
|
end
|
267
|
-
|
270
|
+
|
268
271
|
def searched_by?(column)
|
269
272
|
value = field_search_params[column.name]
|
270
273
|
case value
|
@@ -10,10 +10,10 @@ module ActiveScaffold
|
|
10
10
|
# performance of our default formatting. see issue #138.
|
11
11
|
send(method, record, column)
|
12
12
|
# second, check if the dev has specified a valid list_ui for this column
|
13
|
-
elsif column.list_ui
|
13
|
+
elsif column.list_ui && (method = override_show_column_ui(column.list_ui))
|
14
14
|
send(method, record, column)
|
15
15
|
else
|
16
|
-
if column.column
|
16
|
+
if column.column && (method = override_show_column_ui(column.column.type))
|
17
17
|
send(method, record, column)
|
18
18
|
else
|
19
19
|
get_column_value(record, column)
|
@@ -35,12 +35,10 @@ module ActiveScaffold
|
|
35
35
|
##
|
36
36
|
|
37
37
|
def controller_path_for_activerecord(klass)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
controller = nil
|
43
|
-
end
|
38
|
+
controller = active_scaffold_controller_for(klass)
|
39
|
+
controller.controller_path
|
40
|
+
rescue ActiveScaffold::ControllerNotFound
|
41
|
+
nil
|
44
42
|
end
|
45
43
|
|
46
44
|
# This is the template finder logic, keep it updated with however we find stuff in rails
|
@@ -52,25 +50,25 @@ module ActiveScaffold
|
|
52
50
|
# Turns [[label, value]] into <option> tags
|
53
51
|
# Takes optional parameter of :include_blank
|
54
52
|
def option_tags_for(select_options, options = {})
|
55
|
-
select_options.insert(0,[as_(:_select_),nil]) if options[:include_blank]
|
53
|
+
select_options.insert(0, [as_(:_select_), nil]) if options[:include_blank]
|
56
54
|
select_options.collect do |option|
|
57
55
|
label, value = option[0], option[1]
|
58
|
-
value.nil? ?
|
56
|
+
value.nil? ? '<option value='">#{label}</option>" : "<option value=\"#{value}\">#{label}</option>"
|
59
57
|
end
|
60
58
|
end
|
61
59
|
|
62
60
|
def form_remote_upload_tag(url_for_options = {}, options = {})
|
63
61
|
options[:target] = action_iframe_id(url_for_options)
|
64
62
|
options[:multipart] ||= true
|
65
|
-
options[:class] = "#{options[:class]} as_remote_upload".strip
|
66
|
-
output=
|
63
|
+
options[:class] = "#{options[:class]} as_remote_upload".strip
|
64
|
+
output = ''
|
67
65
|
output << form_tag(url_for_options, options)
|
68
66
|
(output << "<iframe id='#{action_iframe_id(url_for_options)}' name='#{action_iframe_id(url_for_options)}' style='display:none'></iframe>").html_safe
|
69
67
|
end
|
70
68
|
|
71
69
|
# a general-use loading indicator (the "stuff is happening, please wait" feedback)
|
72
70
|
def loading_indicator_tag(options)
|
73
|
-
image_tag
|
71
|
+
image_tag 'active_scaffold/indicator.gif', :style => 'visibility:hidden;', :id => loading_indicator_id(options), :alt => 'loading indicator', :class => 'loading-indicator'
|
74
72
|
end
|
75
73
|
|
76
74
|
# Creates a javascript-based link that toggles the visibility of some element on the page.
|
@@ -78,7 +76,7 @@ module ActiveScaffold
|
|
78
76
|
# You may also flag whether the other element is visible by default or not, and the initial text will adjust accordingly.
|
79
77
|
def link_to_visibility_toggle(id, options = {})
|
80
78
|
options[:default_visible] = true if options[:default_visible].nil?
|
81
|
-
options[:hide_label] ||= as_(:hide)
|
79
|
+
options[:hide_label] ||= as_(:hide)
|
82
80
|
options[:show_label] ||= as_(:show_block)
|
83
81
|
link_to options[:default_visible] ? options[:hide_label] : options[:show_label], '#', :data => {:show => options[:show_label], :hide => options[:hide_label], :toggable => id}, :style => 'display: none;', :class => 'as-js-button visibility-toggle'
|
84
82
|
end
|
@@ -88,8 +86,7 @@ module ActiveScaffold
|
|
88
86
|
end
|
89
87
|
|
90
88
|
def action_link_authorized?(link, *args)
|
91
|
-
|
92
|
-
authorized = if security_method
|
89
|
+
if link.security_method_set? || controller.respond_to?(link.security_method, true)
|
93
90
|
controller.send(link.security_method, *args)
|
94
91
|
else
|
95
92
|
args.empty? ? true : args.first.authorized_for?(:crud_type => link.crud_type, :action => link.action)
|
@@ -160,7 +157,7 @@ module ActiveScaffold
|
|
160
157
|
options[:authorized] = false if link.action.nil? || link.controller.nil?
|
161
158
|
options.delete :link if link.crud_type == :create
|
162
159
|
end
|
163
|
-
if link.action.nil? || (link.type == :member && options.
|
160
|
+
if link.action.nil? || (link.type == :member && options.key?(:authorized) && !options[:authorized])
|
164
161
|
action_link_html(link, nil, {:link => action_link_text(link, options), :class => "disabled #{link.action}#{" #{link.html_options[:class]}" unless link.html_options[:class].blank?}"}, record)
|
165
162
|
else
|
166
163
|
url = action_link_url(link, record)
|
@@ -199,7 +196,7 @@ module ActiveScaffold
|
|
199
196
|
link.action = 'index'
|
200
197
|
link.crud_type = :read
|
201
198
|
end
|
202
|
-
|
199
|
+
|
203
200
|
unless column_link_authorized?(link, link.column, record, associated)
|
204
201
|
link.action = nil
|
205
202
|
# if action is edit and is not authorized, fallback to show if it's enabled
|
@@ -212,22 +209,23 @@ module ActiveScaffold
|
|
212
209
|
|
213
210
|
def column_link_authorized?(link, column, record, associated)
|
214
211
|
if column.association
|
215
|
-
associated_for_authorized =
|
216
|
-
column.
|
217
|
-
|
218
|
-
|
219
|
-
|
212
|
+
associated_for_authorized =
|
213
|
+
if column.plural_association? || (associated.respond_to?(:blank?) && associated.blank?)
|
214
|
+
column.association.klass
|
215
|
+
else
|
216
|
+
associated
|
217
|
+
end
|
220
218
|
authorized = associated_for_authorized.authorized_for?(:crud_type => link.crud_type)
|
221
|
-
authorized
|
219
|
+
authorized &&= record.authorized_for?(:crud_type => :update, :column => column.name) if link.crud_type == :create
|
222
220
|
authorized
|
223
|
-
else
|
221
|
+
else
|
224
222
|
action_link_authorized?(link, record)
|
225
223
|
end
|
226
224
|
end
|
227
225
|
|
228
226
|
def is_sti_record?(record)
|
229
227
|
model = active_scaffold_config.model
|
230
|
-
|
228
|
+
record && model.columns_hash.include?(model.inheritance_column) &&
|
231
229
|
record[model.inheritance_column].present? && !record.instance_of?(model)
|
232
230
|
end
|
233
231
|
|
@@ -236,9 +234,9 @@ module ActiveScaffold
|
|
236
234
|
end
|
237
235
|
|
238
236
|
def cached_action_link_url(link, record)
|
239
|
-
|
240
|
-
|
241
|
-
url_options =
|
237
|
+
@action_links_urls ||= {}
|
238
|
+
@action_links_urls[link.name_to_cache] || begin
|
239
|
+
url_options = cached_action_link_url_options(link, record)
|
242
240
|
if cache_action_link_url?(link, record)
|
243
241
|
@action_links_urls[link.name_to_cache] = url_for(url_options)
|
244
242
|
else
|
@@ -246,7 +244,7 @@ module ActiveScaffold
|
|
246
244
|
end
|
247
245
|
end
|
248
246
|
end
|
249
|
-
|
247
|
+
|
250
248
|
def replace_id_params_in_action_link_url(link, record, url)
|
251
249
|
url = record ? url.sub('--ID--', record.to_param) : url.clone
|
252
250
|
if link.column.try(:singular_association?)
|
@@ -254,7 +252,7 @@ module ActiveScaffold
|
|
254
252
|
if child_id.present?
|
255
253
|
url.sub!('--CHILD_ID--', child_id)
|
256
254
|
else
|
257
|
-
url.sub!(/\w+=--CHILD_ID--&?/,'')
|
255
|
+
url.sub!(/\w+=--CHILD_ID--&?/, '')
|
258
256
|
url.sub!(/\?$/, '')
|
259
257
|
end
|
260
258
|
elsif nested?
|
@@ -262,7 +260,7 @@ module ActiveScaffold
|
|
262
260
|
end
|
263
261
|
url
|
264
262
|
end
|
265
|
-
|
263
|
+
|
266
264
|
def add_query_string_to_cached_url(link, url)
|
267
265
|
query_string, non_nested_query_string = query_string_for_action_links(link)
|
268
266
|
nested_params = (!link.nested_link? && non_nested_query_string)
|
@@ -281,15 +279,14 @@ module ActiveScaffold
|
|
281
279
|
end
|
282
280
|
|
283
281
|
def query_string_for_action_links(link)
|
284
|
-
if defined?(@query_string) && link.parameters.none? { |k,
|
282
|
+
if defined?(@query_string) && link.parameters.none? { |k, _| @query_string_params.include? k }
|
285
283
|
return [@query_string, @non_nested_query_string]
|
286
284
|
end
|
287
285
|
keep = true
|
288
286
|
@query_string_params ||= Set.new
|
289
|
-
query_string_for_all = nil
|
290
287
|
query_string_options = {}
|
291
288
|
non_nested_query_string_options = {}
|
292
|
-
|
289
|
+
|
293
290
|
params_for.except(:controller, :action, :id).each do |key, value|
|
294
291
|
@query_string_params << key
|
295
292
|
if link.parameters.include? key
|
@@ -302,7 +299,7 @@ module ActiveScaffold
|
|
302
299
|
query_string_options[key] = value
|
303
300
|
end
|
304
301
|
end
|
305
|
-
|
302
|
+
|
306
303
|
query_string = query_string_options.to_query if query_string_options.present?
|
307
304
|
if non_nested_query_string_options.present?
|
308
305
|
non_nested_query_string = "#{'&' if query_string}#{non_nested_query_string_options.to_query}"
|
@@ -317,11 +314,11 @@ module ActiveScaffold
|
|
317
314
|
def cache_action_link_url_options?(link, record)
|
318
315
|
active_scaffold_config.cache_action_link_urls && (link.type == :collection || !link.dynamic_parameters.is_a?(Proc)) && !is_sti_record?(record)
|
319
316
|
end
|
320
|
-
|
321
|
-
def
|
322
|
-
|
323
|
-
|
324
|
-
options =
|
317
|
+
|
318
|
+
def cached_action_link_url_options(link, record)
|
319
|
+
@action_links_url_options ||= {}
|
320
|
+
@action_links_url_options[link.name_to_cache] || begin
|
321
|
+
options = action_link_url_options(link, record)
|
325
322
|
if cache_action_link_url_options?(link, record)
|
326
323
|
@action_links_url_options[link.name_to_cache] = options
|
327
324
|
end
|
@@ -329,7 +326,7 @@ module ActiveScaffold
|
|
329
326
|
end
|
330
327
|
end
|
331
328
|
|
332
|
-
def
|
329
|
+
def action_link_url_options(link, record)
|
333
330
|
url_options = {:action => link.action}
|
334
331
|
url_options[:id] = '--ID--' unless record.nil?
|
335
332
|
url_options[:controller] = link.controller.to_s if link.controller
|
@@ -350,16 +347,16 @@ module ActiveScaffold
|
|
350
347
|
url_options[:_method] = link.method if !link.confirm? && link.inline? && link.method != :get
|
351
348
|
url_options
|
352
349
|
end
|
353
|
-
|
350
|
+
|
354
351
|
def action_link_text(link, options)
|
355
352
|
text = image_tag(link.image[:name], :size => link.image[:size], :alt => options[:link] || link.label, :title => options[:link] || link.label) if link.image
|
356
353
|
text || options[:link]
|
357
354
|
end
|
358
|
-
|
355
|
+
|
359
356
|
def replaced_action_link_url_options(link, record)
|
360
|
-
url =
|
357
|
+
url = cached_action_link_url_options(link, record)
|
361
358
|
url[:controller] ||= params[:controller]
|
362
|
-
missing_options, url_options = url.partition{|
|
359
|
+
missing_options, url_options = url.partition { |_, v| v.nil? }
|
363
360
|
replacements = {}
|
364
361
|
replacements['--ID--'] = record.id.to_s if record
|
365
362
|
if link.column.try(:singular_association?)
|
@@ -367,26 +364,26 @@ module ActiveScaffold
|
|
367
364
|
elsif nested?
|
368
365
|
replacements['--CHILD_ID--'] = params[nested.param_name].to_s
|
369
366
|
end
|
370
|
-
url_options.collect! do |k,v|
|
367
|
+
url_options.collect! do |k, v|
|
371
368
|
[k.to_s, replacements[v] || v]
|
372
369
|
end
|
373
370
|
[missing_options, url_options]
|
374
371
|
end
|
375
|
-
|
372
|
+
|
376
373
|
def action_link_selected?(link, record)
|
377
374
|
missing_options, url_options = replaced_action_link_url_options(link, record)
|
378
|
-
(url_options - params.to_a).blank? && missing_options.all? {|k,
|
375
|
+
(url_options - params.to_a).blank? && missing_options.all? { |k, _| params[k].nil? }
|
379
376
|
end
|
380
|
-
|
377
|
+
|
381
378
|
def action_link_html_options(link, record, options)
|
382
379
|
link_id = get_action_link_id(link, record)
|
383
380
|
html_options = link.html_options.merge(:class => [link.html_options[:class], link.action.to_s].compact.join(' '))
|
384
381
|
html_options[:link] = action_link_text(link, options)
|
385
382
|
|
386
|
-
# Needs to be in html_options to as the adding _method to the url is no longer supported by Rails
|
383
|
+
# Needs to be in html_options to as the adding _method to the url is no longer supported by Rails
|
387
384
|
html_options[:method] = link.method if link.method != :get
|
388
385
|
|
389
|
-
html_options[:data]
|
386
|
+
html_options[:data] ||= {}
|
390
387
|
html_options[:data][:confirm] = link.confirm(record.try(:to_label)) if link.confirm?
|
391
388
|
if link.inline?
|
392
389
|
html_options[:class] << ' as_action'
|
@@ -400,7 +397,7 @@ module ActiveScaffold
|
|
400
397
|
html_options[:class] << ' toggle'
|
401
398
|
html_options[:class] << ' active' if action_link_selected?(link, record)
|
402
399
|
end
|
403
|
-
|
400
|
+
|
404
401
|
html_options[:target] = '_blank' if link.popup?
|
405
402
|
html_options[:id] = link_id
|
406
403
|
html_options[:remote] = true unless link.page? || link.popup?
|
@@ -426,11 +423,11 @@ module ActiveScaffold
|
|
426
423
|
id = "#{column.association.name}-#{record.id}" unless record.nil?
|
427
424
|
end
|
428
425
|
end
|
429
|
-
id ||= record
|
426
|
+
id ||= record.try(:id) || (nested? ? nested_parent_id : '')
|
430
427
|
action_id = "#{id_from_controller("#{link.controller}-") if params[:parent_controller] || (link.controller && link.controller != controller.controller_path)}#{link.action}"
|
431
428
|
action_link_id(action_id, id)
|
432
429
|
end
|
433
|
-
|
430
|
+
|
434
431
|
def action_link_html(link, url, html_options, record)
|
435
432
|
label = html_options.delete(:link)
|
436
433
|
label ||= link.label
|
@@ -440,7 +437,7 @@ module ActiveScaffold
|
|
440
437
|
link_to(label, url, html_options)
|
441
438
|
end
|
442
439
|
end
|
443
|
-
|
440
|
+
|
444
441
|
def url_options_for_nested_link(column, record, link, url_options)
|
445
442
|
if column && column.association
|
446
443
|
url_options[:parent_scaffold] = controller_path
|
@@ -457,18 +454,14 @@ module ActiveScaffold
|
|
457
454
|
end
|
458
455
|
|
459
456
|
def url_options_for_sti_link(column, record, link, url_options)
|
460
|
-
#need to find out controller of current record type
|
461
|
-
#
|
462
|
-
#
|
463
|
-
#
|
464
|
-
|
465
|
-
if
|
466
|
-
|
467
|
-
|
468
|
-
url_options[:controller] = sti_controller_path
|
469
|
-
url_options[:parent_sti] = controller_path
|
470
|
-
end
|
471
|
-
end
|
457
|
+
# need to find out controller of current record type and set parameters
|
458
|
+
# it's quite difficult to detect an sti link
|
459
|
+
# if link.column.nil? we are sure that it isn't a singular association inline autolink
|
460
|
+
# however that will not work if a sti parent is a singular association inline autolink
|
461
|
+
return unless link.column.nil?
|
462
|
+
return if (sti_controller_path = controller_path_for_activerecord(record.class)).nil?
|
463
|
+
url_options[:controller] = sti_controller_path
|
464
|
+
url_options[:parent_sti] = controller_path
|
472
465
|
end
|
473
466
|
|
474
467
|
def list_row_class_method(record)
|
@@ -498,14 +491,14 @@ module ActiveScaffold
|
|
498
491
|
end
|
499
492
|
classes = "#{@_column_classes[column.name]} "
|
500
493
|
classes << 'empty ' if column_empty? column_value
|
501
|
-
classes << 'in_place_editor_field ' if inplace_edit?(record, column)
|
494
|
+
classes << 'in_place_editor_field ' if inplace_edit?(record, column) || column.list_ui == :marked
|
502
495
|
if column.css_class.is_a?(Proc)
|
503
496
|
css_class = column.css_class.call(column_value, record)
|
504
497
|
classes << css_class unless css_class.nil?
|
505
498
|
end
|
506
499
|
classes
|
507
500
|
end
|
508
|
-
|
501
|
+
|
509
502
|
def column_heading_class(column, sorting)
|
510
503
|
classes = "#{column.name}-column_heading "
|
511
504
|
classes << "sorted #{sorting.direction_of(column).downcase} " if sorting.sorts_on? column
|
@@ -515,26 +508,26 @@ module ActiveScaffold
|
|
515
508
|
|
516
509
|
def as_main_div_class
|
517
510
|
classes = "active-scaffold active-scaffold-#{controller_id} #{id_from_controller params[:controller]}-view #{active_scaffold_config.theme}-theme"
|
518
|
-
classes <<
|
511
|
+
classes << ' as_touch' if touch_device?
|
519
512
|
classes
|
520
513
|
end
|
521
514
|
|
522
515
|
def column_empty?(column_value)
|
523
516
|
empty = column_value.nil?
|
524
517
|
empty ||= false != column_value && column_value.blank?
|
525
|
-
empty ||= [' ', empty_field_text].include? column_value if String
|
526
|
-
|
518
|
+
empty ||= [' ', empty_field_text].include? column_value if column_value.is_a? String
|
519
|
+
empty
|
527
520
|
end
|
528
|
-
|
521
|
+
|
529
522
|
def empty_field_text
|
530
523
|
active_scaffold_config.list.empty_field_text if active_scaffold_config.actions.include?(:list)
|
531
524
|
end
|
532
525
|
|
533
526
|
def column_calculation(column)
|
534
|
-
|
535
|
-
calculate_query.calculate(column.calculate, column.name)
|
536
|
-
else
|
527
|
+
if column.calculate.instance_of? Proc
|
537
528
|
column.calculate.call(@records)
|
529
|
+
else
|
530
|
+
calculate_query.calculate(column.calculate, column.name)
|
538
531
|
end
|
539
532
|
end
|
540
533
|
|
@@ -548,7 +541,7 @@ module ActiveScaffold
|
|
548
541
|
def format_column_calculation(column, calculation)
|
549
542
|
"#{"#{as_(column.calculate)}: " unless column.calculate.is_a? Proc}#{format_column_value nil, column, calculation}"
|
550
543
|
end
|
551
|
-
|
544
|
+
|
552
545
|
def clean_column_name(name)
|
553
546
|
name.to_s.gsub('?', '')
|
554
547
|
end
|
@@ -556,7 +549,7 @@ module ActiveScaffold
|
|
556
549
|
def clean_class_name(name)
|
557
550
|
name.underscore.gsub('/', '_')
|
558
551
|
end
|
559
|
-
|
552
|
+
|
560
553
|
# the naming convention for overriding with helpers
|
561
554
|
def override_helper_name(column, suffix, class_prefix = false)
|
562
555
|
"#{clean_class_name(column.active_record_class.name) + '_' if class_prefix}#{clean_column_name(column.name)}_#{suffix}"
|
@@ -607,9 +600,11 @@ module ActiveScaffold
|
|
607
600
|
end
|
608
601
|
|
609
602
|
objects.compact!
|
610
|
-
count = objects.inject(0) {|sum, object| sum + object.errors.count }
|
603
|
+
count = objects.inject(0) { |sum, object| sum + object.errors.count }
|
611
604
|
|
612
|
-
|
605
|
+
if count.zero?
|
606
|
+
''
|
607
|
+
else
|
613
608
|
html = {}
|
614
609
|
[:id, :class].each do |key|
|
615
610
|
if options.include?(key)
|
@@ -621,11 +616,12 @@ module ActiveScaffold
|
|
621
616
|
end
|
622
617
|
options[:object_name] ||= params.first
|
623
618
|
|
624
|
-
header_message =
|
625
|
-
options
|
626
|
-
|
627
|
-
|
628
|
-
|
619
|
+
header_message =
|
620
|
+
if options.include?(:header_message)
|
621
|
+
options[:header_message]
|
622
|
+
else
|
623
|
+
as_('errors.template.header', :count => count, :model => options[:object_name].to_s.gsub('_', ' '))
|
624
|
+
end
|
629
625
|
|
630
626
|
message = options.include?(:message) ? options[:message] : as_('errors.template.body')
|
631
627
|
|
@@ -634,11 +630,12 @@ module ActiveScaffold
|
|
634
630
|
options[:list_type] != :br ? content_tag(:li, msg) : msg
|
635
631
|
end
|
636
632
|
end
|
637
|
-
error_messages =
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
633
|
+
error_messages =
|
634
|
+
if options[:list_type] == :br
|
635
|
+
error_messages.join('<br/>').html_safe
|
636
|
+
else
|
637
|
+
content_tag(options[:list_type], error_messages.join.html_safe)
|
638
|
+
end
|
642
639
|
|
643
640
|
contents = []
|
644
641
|
contents << content_tag(options[:header_tag] || :h2, header_message) unless header_message.blank?
|
@@ -646,8 +643,6 @@ module ActiveScaffold
|
|
646
643
|
contents << error_messages
|
647
644
|
contents = contents.join.html_safe
|
648
645
|
options[:container_tag] ? content_tag(options[:container_tag], contents, html) : contents
|
649
|
-
else
|
650
|
-
''
|
651
646
|
end
|
652
647
|
end
|
653
648
|
end
|