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
@@ -1,5 +1,5 @@
|
|
1
1
|
class ActiveScaffold::Bridges::SemanticAttributes < ActiveScaffold::DataStructures::Bridge
|
2
2
|
def self.install
|
3
|
-
require File.join(File.dirname(__FILE__),
|
3
|
+
require File.join(File.dirname(__FILE__), 'semantic_attributes/column.rb')
|
4
4
|
end
|
5
5
|
end
|
@@ -6,7 +6,7 @@ class ActiveScaffold::Bridges::SemanticAttributes
|
|
6
6
|
|
7
7
|
def initialize_with_semantic_attributes(name, active_record_class)
|
8
8
|
initialize_without_semantic_attributes(name, active_record_class)
|
9
|
-
self.required = !active_record_class.semantic_attributes[self.name].predicates.find {|p| p.allow_empty? == false }.nil?
|
9
|
+
self.required = !active_record_class.semantic_attributes[self.name].predicates.find { |p| p.allow_empty? == false }.nil?
|
10
10
|
active_record_class.semantic_attributes[self.name].predicates.find do |p|
|
11
11
|
sem_type = p.class.to_s.split('::')[1].underscore.to_sym
|
12
12
|
next if [:required, :association].include?(sem_type)
|
@@ -12,54 +12,63 @@ module ActiveScaffold
|
|
12
12
|
tags << active_scaffold_search_date_bridge_trend_tag(column, options, current_search)
|
13
13
|
tags << active_scaffold_search_date_bridge_numeric_tag(column, options, current_search)
|
14
14
|
tags << active_scaffold_search_date_bridge_range_tag(column, options, current_search)
|
15
|
-
tags.join(
|
15
|
+
tags.join(' ').html_safe
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
def active_scaffold_search_date_bridge_comparator_options(column)
|
19
|
-
select_options = ActiveScaffold::Finder::
|
20
|
-
select_options + ActiveScaffold::Finder::
|
19
|
+
select_options = ActiveScaffold::Finder::DATE_COMPARATORS.collect { |comp| [as_(comp.downcase.to_sym), comp] }
|
20
|
+
select_options + ActiveScaffold::Finder::NUMERIC_COMPARATORS.collect { |comp| [as_(comp.downcase.to_sym), comp] }
|
21
21
|
end
|
22
|
-
|
22
|
+
|
23
23
|
def active_scaffold_search_date_bridge_comparator_tag(column, options, current_search)
|
24
|
-
select_tag("#{options[:name]}[opt]", options_for_select(active_scaffold_search_date_bridge_comparator_options(column),current_search['opt']), :id => "#{options[:id]}_opt", :class =>
|
24
|
+
select_tag("#{options[:name]}[opt]", options_for_select(active_scaffold_search_date_bridge_comparator_options(column), current_search['opt']), :id => "#{options[:id]}_opt", :class => 'as_search_range_option as_search_date_time_option')
|
25
25
|
end
|
26
|
-
|
26
|
+
|
27
27
|
def active_scaffold_search_date_bridge_numeric_tag(column, options, current_search)
|
28
|
-
numeric_controls =
|
29
|
-
|
30
|
-
|
31
|
-
:
|
32
|
-
|
28
|
+
numeric_controls =
|
29
|
+
'' <<
|
30
|
+
active_scaffold_search_date_bridge_calendar_control(column, options, current_search, 'from') <<
|
31
|
+
content_tag(:span, (' - ' + active_scaffold_search_date_bridge_calendar_control(column, options, current_search, 'to')).html_safe,
|
32
|
+
:id => "#{options[:id]}_between", :class => 'as_search_range_between',
|
33
|
+
:style => current_search['opt'] == 'BETWEEN' ? nil : 'display: none')
|
34
|
+
content_tag('span', numeric_controls.html_safe,
|
35
|
+
:id => "#{options[:id]}_numeric", :class => 'search-date-numeric',
|
36
|
+
:style => ActiveScaffold::Finder::NUMERIC_COMPARATORS.include?(current_search['opt']) ? nil : 'display: none')
|
33
37
|
end
|
34
|
-
|
38
|
+
|
35
39
|
def active_scaffold_search_date_bridge_trend_tag(column, options, current_search)
|
36
|
-
active_scaffold_date_bridge_trend_tag(column, options,
|
37
|
-
|
38
|
-
:unit_value => current_search[
|
39
|
-
:show => (current_search['opt'] == 'PAST' || current_search['opt'] == 'FUTURE')
|
40
|
+
active_scaffold_date_bridge_trend_tag(column, options,
|
41
|
+
:number_value => current_search['number'],
|
42
|
+
:unit_value => current_search['unit'],
|
43
|
+
:show => (current_search['opt'] == 'PAST' || current_search['opt'] == 'FUTURE'))
|
40
44
|
end
|
41
45
|
|
42
46
|
def active_scaffold_date_bridge_trend_tag(column, options, trend_options)
|
43
|
-
trend_controls =
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
47
|
+
trend_controls =
|
48
|
+
text_field_tag("#{options[:name]}[number]", trend_options[:number_value], :class => 'text-input', :size => 10, :autocomplete => 'off') << ' ' <<
|
49
|
+
select_tag("#{options[:name]}[unit]",
|
50
|
+
options_for_select(active_scaffold_search_date_bridge_trend_units(column), trend_options[:unit_value]),
|
51
|
+
:class => 'text-input')
|
52
|
+
content_tag('span', trend_controls.html_safe,
|
53
|
+
:id => "#{options[:id]}_trend", :class => 'search-date-trend',
|
54
|
+
:style => trend_options[:show] ? nil : 'display: none')
|
48
55
|
end
|
49
56
|
|
50
57
|
def active_scaffold_search_date_bridge_trend_units(column)
|
51
|
-
|
52
|
-
|
53
|
-
|
58
|
+
options = ActiveScaffold::Finder::DATE_UNITS.collect { |unit| [as_(unit.downcase.to_sym), unit] }
|
59
|
+
options = ActiveScaffold::Finder::TIME_UNITS.collect { |unit| [as_(unit.downcase.to_sym), unit] } + options if column_datetime?(column)
|
60
|
+
options
|
54
61
|
end
|
55
|
-
|
62
|
+
|
56
63
|
def active_scaffold_search_date_bridge_range_tag(column, options, current_search)
|
57
|
-
range_controls = select_tag("#{options[:name]}[range]",
|
58
|
-
|
59
|
-
|
60
|
-
content_tag(
|
64
|
+
range_controls = select_tag("#{options[:name]}[range]",
|
65
|
+
options_for_select(ActiveScaffold::Finder::DATE_RANGES.collect { |range| [as_(range.downcase.to_sym), range] }, current_search['range']),
|
66
|
+
:class => 'text-input', :id => nil)
|
67
|
+
content_tag('span', range_controls.html_safe,
|
68
|
+
:id => "#{options[:id]}_range", :class => 'search-date-range',
|
69
|
+
:style => (current_search['opt'] == 'RANGE') ? nil : 'display: none')
|
61
70
|
end
|
62
|
-
|
71
|
+
|
63
72
|
def column_datetime?(column)
|
64
73
|
(!column.column.nil? && [:datetime, :time].include?(column.column.type))
|
65
74
|
end
|
@@ -100,24 +109,24 @@ module ActiveScaffold
|
|
100
109
|
end
|
101
110
|
end
|
102
111
|
end
|
103
|
-
|
112
|
+
|
104
113
|
module Finder
|
105
114
|
module ClassMethods
|
106
115
|
def condition_for_date_bridge_type(column, value, like_pattern)
|
107
|
-
operator = ActiveScaffold::Finder::
|
116
|
+
operator = ActiveScaffold::Finder::NUMERIC_COMPARATORS.include?(value[:opt]) && value[:opt] != 'BETWEEN' ? value[:opt] : nil
|
108
117
|
from_value, to_value = date_bridge_from_to(column, value)
|
109
|
-
|
118
|
+
|
110
119
|
if column.search_sql.is_a? Proc
|
111
120
|
column.search_sql.call(from_value, to_value, operator)
|
112
121
|
else
|
113
|
-
|
114
|
-
[
|
122
|
+
if operator.nil?
|
123
|
+
['%{search_sql} BETWEEN ? AND ?', from_value.to_s(:db), to_value.to_s(:db)] unless from_value.nil? || to_value.nil?
|
115
124
|
else
|
116
|
-
["%{search_sql}
|
125
|
+
["%{search_sql} #{value[:opt]} ?", from_value.to_s(:db)] unless from_value.nil?
|
117
126
|
end
|
118
127
|
end
|
119
128
|
end
|
120
|
-
|
129
|
+
|
121
130
|
def date_bridge_from_to(column, value)
|
122
131
|
conversion = datetime_conversion_for_condition(column)
|
123
132
|
case value[:opt]
|
@@ -126,17 +135,17 @@ module ActiveScaffold
|
|
126
135
|
when 'PAST', 'FUTURE'
|
127
136
|
date_bridge_from_to_for_trend(column, value).collect(&conversion)
|
128
137
|
else
|
129
|
-
|
138
|
+
%w(from to).collect { |field| condition_value_for_datetime(column, value[field], conversion) }
|
130
139
|
end
|
131
140
|
end
|
132
141
|
|
133
142
|
def date_bridge_now
|
134
143
|
Time.zone.now
|
135
144
|
end
|
136
|
-
|
145
|
+
|
137
146
|
def date_bridge_from_to_for_trend(column, value)
|
138
147
|
case value['opt']
|
139
|
-
when
|
148
|
+
when 'PAST'
|
140
149
|
trend_number = [value['number'].to_i, 1].max
|
141
150
|
now = date_bridge_now
|
142
151
|
if date_bridge_column_date?(column)
|
@@ -147,7 +156,7 @@ module ActiveScaffold
|
|
147
156
|
to = now
|
148
157
|
end
|
149
158
|
return from, to
|
150
|
-
when
|
159
|
+
when 'FUTURE'
|
151
160
|
trend_number = [value['number'].to_i, 1].max
|
152
161
|
now = date_bridge_now
|
153
162
|
if date_bridge_column_date?(column)
|
@@ -160,7 +169,7 @@ module ActiveScaffold
|
|
160
169
|
return from, to
|
161
170
|
end
|
162
171
|
end
|
163
|
-
|
172
|
+
|
164
173
|
def date_bridge_from_to_for_range(column, value)
|
165
174
|
case value[:range]
|
166
175
|
when 'TODAY'
|
@@ -171,7 +180,7 @@ module ActiveScaffold
|
|
171
180
|
return date_bridge_now.in(1.day).beginning_of_day, date_bridge_now.in(1.day).end_of_day
|
172
181
|
else
|
173
182
|
range_type, range = value[:range].downcase.split('_')
|
174
|
-
raise ArgumentError unless
|
183
|
+
raise ArgumentError unless %w(week month year).include?(range)
|
175
184
|
case range_type
|
176
185
|
when 'this'
|
177
186
|
return date_bridge_now.send("beginning_of_#{range}".to_sym), date_bridge_now.send("end_of_#{range}")
|
@@ -180,7 +189,7 @@ module ActiveScaffold
|
|
180
189
|
when 'next'
|
181
190
|
return date_bridge_now.in(1.send(range.to_sym)).send("beginning_of_#{range}".to_sym), date_bridge_now.in(1.send(range.to_sym)).send("end_of_#{range}".to_sym)
|
182
191
|
else
|
183
|
-
return nil, nil
|
192
|
+
return nil, nil
|
184
193
|
end
|
185
194
|
end
|
186
195
|
end
|
@@ -199,10 +208,7 @@ module ActiveScaffold
|
|
199
208
|
end
|
200
209
|
end
|
201
210
|
|
202
|
-
ActiveScaffold::Finder.const_set('
|
203
|
-
ActiveScaffold::Finder.const_set('
|
204
|
-
ActiveScaffold::Finder.const_set('
|
205
|
-
ActiveScaffold::Finder.const_set('
|
206
|
-
"THIS_WEEK", "PREV_WEEK", "NEXT_WEEK",
|
207
|
-
"THIS_MONTH", "PREV_MONTH", "NEXT_MONTH",
|
208
|
-
"THIS_YEAR", "PREV_YEAR", "NEXT_YEAR"])
|
211
|
+
ActiveScaffold::Finder.const_set('DATE_COMPARATORS', %w(PAST FUTURE RANGE))
|
212
|
+
ActiveScaffold::Finder.const_set('DATE_UNITS', %w(DAYS WEEKS MONTHS YEARS))
|
213
|
+
ActiveScaffold::Finder.const_set('TIME_UNITS', %w(SECONDS MINUTES HOURS))
|
214
|
+
ActiveScaffold::Finder.const_set('DATE_RANGES', %w(TODAY YESTERDAY TOMORROW THIS_WEEK PREV_WEEK NEXT_WEEK THIS_MONTH PREV_MONTH NEXT_MONTH THIS_YEAR PREV_YEAR NEXT_YEAR))
|
@@ -5,9 +5,9 @@ class ActiveScaffold::Bridges::TinyMce < ActiveScaffold::DataStructures::Bridge
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.install?
|
8
|
-
Object.const_defined?
|
8
|
+
Object.const_defined? 'TinyMCE'
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def self.javascripts
|
12
12
|
case ActiveScaffold.js_framework
|
13
13
|
when :jquery
|
@@ -14,10 +14,10 @@ class ActiveScaffold::Bridges::TinyMce
|
|
14
14
|
|
15
15
|
def active_scaffold_input_text_editor(column, options)
|
16
16
|
options[:class] = "#{options[:class]} mceEditor #{column.options[:class]}".strip
|
17
|
-
|
18
|
-
|
17
|
+
|
18
|
+
settings = {:theme => 'simple'}.merge(column.options[:tinymce] || {})
|
19
19
|
settings = settings.to_json
|
20
|
-
|
20
|
+
settings = "tinyMCE.settings = #{settings};"
|
21
21
|
|
22
22
|
html = []
|
23
23
|
html << send(override_input(:textarea), column, options)
|
@@ -16,7 +16,7 @@ module ActiveScaffold::Config
|
|
16
16
|
class << subclass
|
17
17
|
# the crud type of the action. possible values are :create, :read, :update, :delete, and nil.
|
18
18
|
# this is not a setting for the developer. it's self-description for the actions.
|
19
|
-
|
19
|
+
attr_reader :crud_type
|
20
20
|
|
21
21
|
protected
|
22
22
|
|
@@ -28,13 +28,15 @@ module ActiveScaffold::Config
|
|
28
28
|
end
|
29
29
|
|
30
30
|
# delegate
|
31
|
-
def crud_type
|
31
|
+
def crud_type
|
32
|
+
self.class.crud_type
|
33
|
+
end
|
32
34
|
|
33
35
|
def label(model = nil)
|
34
36
|
model ||= @core.label(:count => 1)
|
35
37
|
@label.nil? ? model : as_(@label, :model => model)
|
36
38
|
end
|
37
|
-
|
39
|
+
|
38
40
|
# the user property gets set to the instantiation of the local UserSettings class during the automatic instantiation of this class.
|
39
41
|
attr_accessor :user
|
40
42
|
|
@@ -70,17 +72,14 @@ module ActiveScaffold::Config
|
|
70
72
|
end
|
71
73
|
end
|
72
74
|
end
|
73
|
-
|
75
|
+
|
74
76
|
def formats
|
75
77
|
@formats ||= []
|
76
78
|
end
|
77
|
-
|
78
|
-
|
79
|
-
@formats=val
|
80
|
-
end
|
81
|
-
|
79
|
+
attr_writer :formats
|
80
|
+
|
82
81
|
private
|
83
|
-
|
82
|
+
|
84
83
|
def columns=(val)
|
85
84
|
@columns.set_values(*val) if @columns
|
86
85
|
@columns ||= ActiveScaffold::DataStructures::ActionColumns.new(*val).tap do |columns|
|
@@ -94,9 +94,9 @@ module ActiveScaffold::Config
|
|
94
94
|
# provides read/write access to the local Columns DataStructure
|
95
95
|
attr_reader :columns
|
96
96
|
def columns=(val)
|
97
|
-
@columns._inheritable = val.collect
|
97
|
+
@columns._inheritable = val.collect(&:to_sym)
|
98
98
|
# Add virtual columns
|
99
|
-
@columns << val.collect {|c| c.to_sym unless @columns[c.to_sym]}.compact
|
99
|
+
@columns << val.collect { |c| c.to_sym unless @columns[c.to_sym] }.compact
|
100
100
|
end
|
101
101
|
|
102
102
|
# lets you override the global ActiveScaffold frontend for a specific controller
|
@@ -120,7 +120,7 @@ module ActiveScaffold::Config
|
|
120
120
|
# lets you specify whether add a create link for each sti child for a specific controller
|
121
121
|
attr_accessor :sti_create_links
|
122
122
|
def add_sti_create_links?
|
123
|
-
|
123
|
+
sti_create_links && !sti_children.nil?
|
124
124
|
end
|
125
125
|
|
126
126
|
# action links are used by actions to tie together. they appear as links for each record, or general links for the ActiveScaffold.
|
@@ -128,7 +128,7 @@ module ActiveScaffold::Config
|
|
128
128
|
|
129
129
|
# a generally-applicable name for this ActiveScaffold ... will be used for generating page/section headers
|
130
130
|
attr_writer :label
|
131
|
-
def label(options={})
|
131
|
+
def label(options = {})
|
132
132
|
as_(@label, options) || model.model_name.human(options.merge(options[:count].to_i == 1 ? {} : {:default => model.name.pluralize}))
|
133
133
|
end
|
134
134
|
|
@@ -153,15 +153,15 @@ module ActiveScaffold::Config
|
|
153
153
|
@actions = self.class.actions.clone
|
154
154
|
|
155
155
|
# create a new default columns datastructure, since it doesn't make sense before now
|
156
|
-
attribute_names =
|
157
|
-
association_column_names =
|
158
|
-
@columns = ActiveScaffold::DataStructures::Columns.new(
|
156
|
+
attribute_names = model.columns.collect { |c| c.name.to_sym }.sort_by(&:to_s)
|
157
|
+
association_column_names = model.reflect_on_all_associations.collect { |a| a.name.to_sym }.sort_by(&:to_s)
|
158
|
+
@columns = ActiveScaffold::DataStructures::Columns.new(model, attribute_names + association_column_names)
|
159
159
|
|
160
160
|
# and then, let's remove some columns from the inheritable set.
|
161
|
-
content_columns = Set.new(
|
161
|
+
content_columns = Set.new(model.content_columns.map(&:name))
|
162
162
|
@columns.exclude(*self.class.ignore_columns)
|
163
|
-
@columns.exclude(*@columns.find_all { |c| c.column
|
164
|
-
@columns.exclude(*
|
163
|
+
@columns.exclude(*@columns.find_all { |c| c.column && content_columns.exclude?(c.column.name) }.collect(&:name))
|
164
|
+
@columns.exclude(*model.reflect_on_all_associations.collect { |a| :"#{a.name}_type" if a.options[:polymorphic] }.compact)
|
165
165
|
|
166
166
|
# inherit the global frontend
|
167
167
|
@frontend = self.class.frontend
|
@@ -181,21 +181,21 @@ module ActiveScaffold::Config
|
|
181
181
|
# To be called after your finished configuration
|
182
182
|
def _load_action_columns
|
183
183
|
# then, register the column objects
|
184
|
-
|
185
|
-
action =
|
186
|
-
action.columns.set_columns(
|
184
|
+
actions.each do |action_name|
|
185
|
+
action = send(action_name)
|
186
|
+
action.columns.set_columns(columns) if action.respond_to?(:columns)
|
187
187
|
end
|
188
188
|
end
|
189
189
|
|
190
190
|
# To be called after your finished configuration
|
191
191
|
def _configure_sti
|
192
|
-
column =
|
192
|
+
column = model.inheritance_column
|
193
193
|
if sti_create_links
|
194
|
-
|
194
|
+
columns[column].form_ui ||= :hidden
|
195
195
|
else
|
196
|
-
|
197
|
-
|
198
|
-
|
196
|
+
columns[column].form_ui ||= :select
|
197
|
+
columns[column].options ||= {}
|
198
|
+
columns[column].options[:options] = sti_children.collect do |model_name|
|
199
199
|
[model_name.to_s.camelize.constantize.model_name.human, model_name.to_s.camelize]
|
200
200
|
end
|
201
201
|
end
|
@@ -221,17 +221,13 @@ module ActiveScaffold::Config
|
|
221
221
|
|
222
222
|
def self.method_missing(name, *args)
|
223
223
|
klass = "ActiveScaffold::Config::#{name.to_s.camelcase}".constantize rescue nil
|
224
|
-
if @@actions.include?
|
225
|
-
return eval("ActiveScaffold::Config::#{name.to_s.camelcase}")
|
226
|
-
end
|
224
|
+
return klass if @@actions.include?(name.to_s.underscore) && klass
|
227
225
|
super
|
228
226
|
end
|
229
227
|
# some utility methods
|
230
228
|
# --------------------
|
231
229
|
|
232
|
-
|
233
|
-
@model_id
|
234
|
-
end
|
230
|
+
attr_reader :model_id
|
235
231
|
|
236
232
|
def model
|
237
233
|
@model ||= @model_id.to_s.camelize.constantize
|
@@ -239,7 +235,7 @@ module ActiveScaffold::Config
|
|
239
235
|
|
240
236
|
# warning - this won't work as a per-request dynamic attribute in rails 2.0. You'll need to interact with Controller#generic_view_paths
|
241
237
|
def inherited_view_paths
|
242
|
-
@inherited_view_paths||=[]
|
238
|
+
@inherited_view_paths ||= []
|
243
239
|
end
|
244
240
|
|
245
241
|
# must be a class method so the layout doesn't depend on a controller that uses active_scaffold
|
@@ -251,14 +247,13 @@ module ActiveScaffold::Config
|
|
251
247
|
# must be a class method so the layout doesn't depend on a controller that uses active_scaffold
|
252
248
|
# note that this is unaffected by per-controller frontend configuration.
|
253
249
|
def self.javascripts(frontend = self.frontend)
|
254
|
-
javascript_dir = File.join(Rails.public_path,
|
255
|
-
Dir.entries(javascript_dir).reject { |e| !e.match(/\.js$/)
|
250
|
+
javascript_dir = File.join(Rails.public_path, 'javascripts', asset_path('', frontend))
|
251
|
+
Dir.entries(javascript_dir).reject { |e| !e.match(/\.js$/) || (!self.dhtml_history? && e.match('dhtml_history')) }
|
256
252
|
end
|
257
253
|
|
258
254
|
def self.available_frontends
|
259
|
-
frontends_dir = File.join(Rails.root,
|
255
|
+
frontends_dir = File.join(Rails.root, 'vendor', 'plugins', ActiveScaffold::Config::Core.plugin_directory, 'frontends')
|
260
256
|
Dir.entries(frontends_dir).reject { |e| e.match(/^\./) } # Get rid of files that start with .
|
261
257
|
end
|
262
258
|
end
|
263
259
|
end
|
264
|
-
|
@@ -8,7 +8,6 @@ module ActiveScaffold::Config
|
|
8
8
|
@human_conditions = self.class.human_conditions
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
11
|
# global level configuration
|
13
12
|
# --------------------------
|
14
13
|
# the ActionLink for this action
|
@@ -28,7 +27,7 @@ module ActiveScaffold::Config
|
|
28
27
|
# instead of just filtered you may show the user a humanized search condition statment
|
29
28
|
cattr_accessor :human_conditions
|
30
29
|
@@human_conditions = false
|
31
|
-
|
30
|
+
|
32
31
|
# instance-level configuration
|
33
32
|
# ----------------------------
|
34
33
|
|
@@ -37,7 +36,7 @@ module ActiveScaffold::Config
|
|
37
36
|
# we want to delay initializing to the @core.columns set for as long as possible. Too soon and .search_sql will not be available to .searchable?
|
38
37
|
unless @columns
|
39
38
|
self.columns = @core.columns._inheritable
|
40
|
-
|
39
|
+
columns.exclude @core.columns.active_record_class.locking_column.to_sym
|
41
40
|
end
|
42
41
|
@columns
|
43
42
|
end
|
@@ -51,26 +50,25 @@ module ActiveScaffold::Config
|
|
51
50
|
# * false: LIKE ?
|
52
51
|
# Default is :full
|
53
52
|
attr_accessor :text_search
|
54
|
-
|
53
|
+
|
55
54
|
# the ActionLink for this action
|
56
55
|
attr_accessor :link
|
57
|
-
|
56
|
+
|
58
57
|
# rarely searched columns may be placed in a hidden subgroup
|
59
58
|
def optional_columns=(optionals)
|
60
59
|
@optional_columns = Array(optionals)
|
61
60
|
end
|
62
|
-
|
61
|
+
|
63
62
|
def optional_columns
|
64
63
|
@optional_columns ||= []
|
65
64
|
end
|
66
|
-
|
65
|
+
|
67
66
|
# default search params
|
68
|
-
# default_params = {:title => {"from"=>"test", "to"=>"", "opt"=>"%?%"}}
|
67
|
+
# default_params = {:title => {"from"=>"test", "to"=>"", "opt"=>"%?%"}}
|
69
68
|
attr_accessor :default_params
|
70
|
-
|
69
|
+
|
71
70
|
# human conditions
|
72
71
|
# instead of just filtered you may show the user a humanized search condition statment
|
73
72
|
attr_accessor :human_conditions
|
74
|
-
|
75
73
|
end
|
76
74
|
end
|