active_scaffold 3.2.18 → 3.2.19
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 +3 -0
- 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 +19 -0
- data/app/assets/javascripts/jquery/active_scaffold.js +1113 -0
- data/app/assets/javascripts/jquery/date_picker_bridge.js.erb +24 -0
- data/app/assets/javascripts/jquery/draggable_lists.js +27 -0
- data/app/assets/javascripts/jquery/jquery.editinplace.js +743 -0
- data/app/assets/javascripts/jquery/tiny_mce_bridge.js +7 -0
- data/app/assets/javascripts/prototype/active_scaffold.js +1107 -0
- data/app/assets/javascripts/prototype/dhtml_history.js +870 -0
- data/app/assets/javascripts/prototype/form_enhancements.js +117 -0
- data/app/assets/javascripts/prototype/rico_corner.js +370 -0
- data/app/assets/javascripts/prototype/tiny_mce_bridge.js +7 -0
- data/app/assets/stylesheets/active_scaffold-ie.css.scss +54 -0
- data/app/assets/stylesheets/active_scaffold.css.scss +14 -0
- data/app/assets/stylesheets/active_scaffold_colors.css.scss +395 -0
- data/app/assets/stylesheets/active_scaffold_extensions.css.erb +2 -0
- data/app/assets/stylesheets/active_scaffold_images.css.scss +40 -0
- data/app/assets/stylesheets/active_scaffold_layout.css +936 -0
- data/app/assets/stylesheets/blue-theme.css +74 -0
- data/config/locales/de.yml +125 -0
- data/config/locales/en.yml +127 -0
- data/config/locales/es.yml +128 -0
- data/config/locales/fr.yml +131 -0
- data/config/locales/hu.yml +126 -0
- data/config/locales/ja.yml +126 -0
- data/config/locales/ru.yml +135 -0
- data/frontends/default/views/_action_group.html.erb +24 -0
- data/frontends/default/views/_add_existing_form.html.erb +30 -0
- data/frontends/default/views/_base_form.html.erb +53 -0
- data/frontends/default/views/_create_form.html.erb +8 -0
- data/frontends/default/views/_create_form_on_list.html.erb +6 -0
- data/frontends/default/views/_field_search.html.erb +32 -0
- data/frontends/default/views/_form.html.erb +28 -0
- data/frontends/default/views/_form_association.html.erb +17 -0
- data/frontends/default/views/_form_association_footer.html.erb +47 -0
- data/frontends/default/views/_form_attribute.html.erb +23 -0
- data/frontends/default/views/_form_hidden_attribute.html.erb +7 -0
- data/frontends/default/views/_form_messages.html.erb +5 -0
- data/frontends/default/views/_horizontal_subform.html.erb +22 -0
- data/frontends/default/views/_horizontal_subform_footer.html.erb +0 -0
- data/frontends/default/views/_horizontal_subform_header.html.erb +11 -0
- data/frontends/default/views/_horizontal_subform_record.html.erb +43 -0
- data/frontends/default/views/_human_conditions.html.erb +1 -0
- data/frontends/default/views/_list.html.erb +18 -0
- data/frontends/default/views/_list_actions.html.erb +15 -0
- data/frontends/default/views/_list_calculations.html.erb +16 -0
- data/frontends/default/views/_list_column_headings.html.erb +12 -0
- data/frontends/default/views/_list_header.html.erb +10 -0
- data/frontends/default/views/_list_inline_adapter.html.erb +21 -0
- data/frontends/default/views/_list_messages.html.erb +28 -0
- data/frontends/default/views/_list_pagination.html.erb +11 -0
- data/frontends/default/views/_list_pagination_links.html.erb +9 -0
- data/frontends/default/views/_list_record.html.erb +13 -0
- data/frontends/default/views/_list_record_columns.html.erb +8 -0
- data/frontends/default/views/_list_with_header.html.erb +36 -0
- data/frontends/default/views/_messages.html.erb +10 -0
- data/frontends/default/views/_refresh_list.js.erb +1 -0
- data/frontends/default/views/_render_field.js.erb +20 -0
- data/frontends/default/views/_row.html.erb +1 -0
- data/frontends/default/views/_search.html.erb +34 -0
- data/frontends/default/views/_search_attribute.html.erb +10 -0
- data/frontends/default/views/_show.html.erb +8 -0
- data/frontends/default/views/_show_columns.html.erb +15 -0
- data/frontends/default/views/_update_actions.html.erb +9 -0
- data/frontends/default/views/_update_calculations.js.erb +4 -0
- data/frontends/default/views/_update_form.html.erb +6 -0
- data/frontends/default/views/_update_messages.js.erb +2 -0
- data/frontends/default/views/_vertical_subform.html.erb +12 -0
- data/frontends/default/views/_vertical_subform_record.html.erb +43 -0
- data/frontends/default/views/action_confirmation.html.erb +13 -0
- data/frontends/default/views/add_existing.js.erb +14 -0
- data/frontends/default/views/add_existing_form.html.erb +5 -0
- data/frontends/default/views/create.html.erb +5 -0
- data/frontends/default/views/delete.html.erb +13 -0
- data/frontends/default/views/destroy.js.erb +26 -0
- data/frontends/default/views/edit_associated.js.erb +12 -0
- data/frontends/default/views/field_search.html.erb +5 -0
- data/frontends/default/views/form_messages.js.erb +1 -0
- data/frontends/default/views/list.html.erb +1 -0
- data/frontends/default/views/on_action_update.js.erb +22 -0
- data/frontends/default/views/on_create.js.erb +38 -0
- data/frontends/default/views/on_mark.js.erb +6 -0
- data/frontends/default/views/on_update.js.erb +29 -0
- data/frontends/default/views/refresh_list.js.erb +2 -0
- data/frontends/default/views/render_field.js.erb +1 -0
- data/frontends/default/views/row.js.erb +2 -0
- data/frontends/default/views/search.html.erb +5 -0
- data/frontends/default/views/show.html.erb +5 -0
- data/frontends/default/views/update.html.erb +8 -0
- data/frontends/default/views/update_column.js.erb +15 -0
- data/frontends/default/views/update_row.js.erb +1 -0
- data/lib/active_scaffold/actions/common_search.rb +22 -0
- data/lib/active_scaffold/actions/core.rb +203 -0
- data/lib/active_scaffold/actions/create.rb +139 -0
- data/lib/active_scaffold/actions/delete.rb +74 -0
- data/lib/active_scaffold/actions/field_search.rb +78 -0
- data/lib/active_scaffold/actions/list.rb +208 -0
- data/lib/active_scaffold/actions/mark.rb +89 -0
- data/lib/active_scaffold/actions/nested.rb +244 -0
- data/lib/active_scaffold/actions/search.rb +48 -0
- data/lib/active_scaffold/actions/show.rb +61 -0
- data/lib/active_scaffold/actions/subform.rb +23 -0
- data/lib/active_scaffold/actions/update.rb +156 -0
- data/lib/active_scaffold/active_record_permissions.rb +135 -0
- data/lib/active_scaffold/attribute_params.rb +200 -0
- data/lib/active_scaffold/bridges/ancestry/ancestry_bridge.rb +39 -0
- data/lib/active_scaffold/bridges/ancestry.rb +5 -0
- data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +37 -0
- data/lib/active_scaffold/bridges/bitfields.rb +6 -0
- data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +66 -0
- data/lib/active_scaffold/bridges/calendar_date_select.rb +24 -0
- data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +127 -0
- data/lib/active_scaffold/bridges/cancan.rb +15 -0
- data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +31 -0
- data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge_helpers.rb +10 -0
- data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +45 -0
- data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +17 -0
- data/lib/active_scaffold/bridges/carrierwave.rb +12 -0
- data/lib/active_scaffold/bridges/country_helper/country_helper_bridge.rb +358 -0
- data/lib/active_scaffold/bridges/country_helper.rb +9 -0
- data/lib/active_scaffold/bridges/date_picker/ext.rb +63 -0
- data/lib/active_scaffold/bridges/date_picker/helper.rb +180 -0
- data/lib/active_scaffold/bridges/date_picker.rb +23 -0
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +34 -0
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge_helpers.rb +10 -0
- data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +27 -0
- data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +16 -0
- data/lib/active_scaffold/bridges/dragonfly.rb +9 -0
- data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +46 -0
- data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +57 -0
- data/lib/active_scaffold/bridges/file_column/form_ui.rb +34 -0
- data/lib/active_scaffold/bridges/file_column/list_ui.rb +26 -0
- data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +43 -0
- data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +9 -0
- data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +15 -0
- data/lib/active_scaffold/bridges/file_column.rb +11 -0
- data/lib/active_scaffold/bridges/paperclip/form_ui.rb +27 -0
- data/lib/active_scaffold/bridges/paperclip/list_ui.rb +16 -0
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +36 -0
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +24 -0
- data/lib/active_scaffold/bridges/paperclip.rb +12 -0
- data/lib/active_scaffold/bridges/record_select/helpers.rb +92 -0
- data/lib/active_scaffold/bridges/record_select.rb +11 -0
- data/lib/active_scaffold/bridges/semantic_attributes/column.rb +20 -0
- data/lib/active_scaffold/bridges/semantic_attributes.rb +5 -0
- data/lib/active_scaffold/bridges/shared/date_bridge.rb +209 -0
- data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +46 -0
- data/lib/active_scaffold/bridges/tiny_mce.rb +17 -0
- data/lib/active_scaffold/bridges.rb +61 -0
- data/lib/active_scaffold/config/base.rb +75 -0
- data/lib/active_scaffold/config/core.rb +236 -0
- data/lib/active_scaffold/config/create.rb +32 -0
- data/lib/active_scaffold/config/delete.rb +32 -0
- data/lib/active_scaffold/config/field_search.rb +79 -0
- data/lib/active_scaffold/config/form.rb +64 -0
- data/lib/active_scaffold/config/list.rb +247 -0
- data/lib/active_scaffold/config/mark.rb +30 -0
- data/lib/active_scaffold/config/nested.rb +42 -0
- data/lib/active_scaffold/config/search.rb +73 -0
- data/lib/active_scaffold/config/show.rb +31 -0
- data/lib/active_scaffold/config/subform.rb +35 -0
- data/lib/active_scaffold/config/update.rb +33 -0
- data/lib/active_scaffold/configurable.rb +29 -0
- data/lib/active_scaffold/constraints.rb +171 -0
- data/lib/active_scaffold/data_structures/action_columns.rb +142 -0
- data/lib/active_scaffold/data_structures/action_link.rb +185 -0
- data/lib/active_scaffold/data_structures/action_links.rb +191 -0
- data/lib/active_scaffold/data_structures/actions.rb +45 -0
- data/lib/active_scaffold/data_structures/bridge.rb +22 -0
- data/lib/active_scaffold/data_structures/column.rb +402 -0
- data/lib/active_scaffold/data_structures/columns.rb +75 -0
- data/lib/active_scaffold/data_structures/error_message.rb +24 -0
- data/lib/active_scaffold/data_structures/nested_info.rb +171 -0
- data/lib/active_scaffold/data_structures/set.rb +61 -0
- data/lib/active_scaffold/data_structures/sorting.rb +167 -0
- data/lib/active_scaffold/engine.rb +4 -0
- data/lib/active_scaffold/extensions/action_controller_rendering.rb +20 -0
- data/lib/active_scaffold/extensions/action_controller_rescueing.rb +7 -0
- data/lib/active_scaffold/extensions/action_view_rendering.rb +115 -0
- data/lib/active_scaffold/extensions/active_record_offset.rb +12 -0
- data/lib/active_scaffold/extensions/array.rb +7 -0
- data/lib/active_scaffold/extensions/cache_association.rb +16 -0
- data/lib/active_scaffold/extensions/localize.rb +10 -0
- data/lib/active_scaffold/extensions/name_option_for_datetime.rb +12 -0
- data/lib/active_scaffold/extensions/nil_id_in_url_params.rb +7 -0
- data/lib/active_scaffold/extensions/paginator_extensions.rb +26 -0
- data/lib/active_scaffold/extensions/reverse_associations.rb +64 -0
- data/lib/active_scaffold/extensions/routing_mapper.rb +48 -0
- data/lib/active_scaffold/extensions/to_label.rb +8 -0
- data/lib/active_scaffold/extensions/unsaved_associated.rb +61 -0
- data/lib/active_scaffold/extensions/unsaved_record.rb +20 -0
- data/lib/active_scaffold/extensions/usa_state.rb +46 -0
- data/lib/active_scaffold/finder.rb +399 -0
- data/lib/active_scaffold/helpers/association_helpers.rb +42 -0
- data/lib/active_scaffold/helpers/controller_helpers.rb +94 -0
- data/lib/active_scaffold/helpers/form_column_helpers.rb +322 -0
- data/lib/active_scaffold/helpers/human_condition_helpers.rb +64 -0
- data/lib/active_scaffold/helpers/id_helpers.rb +131 -0
- data/lib/active_scaffold/helpers/list_column_helpers.rb +374 -0
- data/lib/active_scaffold/helpers/pagination_helpers.rb +62 -0
- data/lib/active_scaffold/helpers/search_column_helpers.rb +257 -0
- data/lib/active_scaffold/helpers/show_column_helpers.rb +44 -0
- data/lib/active_scaffold/helpers/view_helpers.rb +398 -0
- data/lib/active_scaffold/marked_model.rb +38 -0
- data/lib/active_scaffold/paginator.rb +136 -0
- data/lib/active_scaffold/responds_to_parent.rb +70 -0
- data/lib/active_scaffold/tableless.rb +83 -0
- data/lib/active_scaffold/version.rb +9 -0
- data/lib/active_scaffold.rb +373 -0
- data/lib/active_scaffold_env.rb +13 -0
- data/lib/generators/active_scaffold/USAGE +29 -0
- data/lib/generators/active_scaffold/active_scaffold_generator.rb +21 -0
- data/lib/generators/active_scaffold_controller/USAGE +19 -0
- data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +29 -0
- data/lib/generators/active_scaffold_controller/templates/controller.rb +4 -0
- data/lib/generators/active_scaffold_controller/templates/helper.rb +2 -0
- data/public/blank.html +33 -0
- data/shoulda_macros/macros.rb +136 -0
- 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 +1276 -0
- data/vendor/assets/stylesheets/jquery-ui.css +568 -0
- metadata +261 -17
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
module ActiveScaffold
|
|
2
|
+
module Bridges
|
|
3
|
+
module Shared
|
|
4
|
+
module DateBridge
|
|
5
|
+
module SearchColumnHelpers
|
|
6
|
+
def active_scaffold_search_date_bridge(column, options)
|
|
7
|
+
current_search = {'from' => nil, 'to' => nil, 'opt' => 'BETWEEN',
|
|
8
|
+
'number' => 1, 'unit' => 'DAYS', 'range' => nil}
|
|
9
|
+
current_search.merge!(options[:value]) unless options[:value].nil?
|
|
10
|
+
tags = []
|
|
11
|
+
tags << active_scaffold_search_date_bridge_comparator_tag(column, options, current_search)
|
|
12
|
+
tags << active_scaffold_search_date_bridge_trend_tag(column, options, current_search)
|
|
13
|
+
tags << active_scaffold_search_date_bridge_numeric_tag(column, options, current_search)
|
|
14
|
+
tags << active_scaffold_search_date_bridge_range_tag(column, options, current_search)
|
|
15
|
+
tags.join(" ").html_safe
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def active_scaffold_search_date_bridge_comparator_options(column)
|
|
19
|
+
select_options = ActiveScaffold::Finder::DateComparators.collect {|comp| [as_(comp.downcase.to_sym), comp]}
|
|
20
|
+
select_options + ActiveScaffold::Finder::NumericComparators.collect {|comp| [as_(comp.downcase.to_sym), comp]}
|
|
21
|
+
end
|
|
22
|
+
|
|
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 => "as_search_range_option as_search_date_time_option")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def active_scaffold_search_date_bridge_numeric_tag(column, options, current_search)
|
|
28
|
+
numeric_controls = "" <<
|
|
29
|
+
active_scaffold_search_date_bridge_calendar_control(column, options, current_search, 'from') <<
|
|
30
|
+
content_tag(:span, (" - " + active_scaffold_search_date_bridge_calendar_control(column, options, current_search, 'to')).html_safe,
|
|
31
|
+
:id => "#{options[:id]}_between", :class => "as_search_range_between", :style => current_search['opt'] == 'BETWEEN' ? nil : "display: none")
|
|
32
|
+
content_tag("span", numeric_controls.html_safe, :id => "#{options[:id]}_numeric", :style => ActiveScaffold::Finder::NumericComparators.include?(current_search['opt']) ? nil : "display: none")
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def active_scaffold_search_date_bridge_trend_tag(column, options, current_search)
|
|
36
|
+
active_scaffold_date_bridge_trend_tag(column, options,
|
|
37
|
+
{:name_prefix => 'search',
|
|
38
|
+
:number_value => current_search['number'],
|
|
39
|
+
:unit_value => current_search["unit"],
|
|
40
|
+
:show => (current_search['opt'] == 'PAST' || current_search['opt'] == 'FUTURE')})
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def active_scaffold_date_bridge_trend_tag(column, options, trend_options)
|
|
44
|
+
trend_controls = text_field_tag("#{trend_options[:name_prefix]}[#{column.name}][number]", trend_options[:number_value], :class => 'text-input', :size => 10, :autocomplete => 'off') << " " <<
|
|
45
|
+
select_tag("#{trend_options[:name_prefix]}[#{column.name}][unit]",
|
|
46
|
+
options_for_select(active_scaffold_search_date_bridge_trend_units(column), trend_options[:unit_value]),
|
|
47
|
+
:class => 'text-input')
|
|
48
|
+
content_tag("span", trend_controls.html_safe, :id => "#{options[:id]}_trend", :style => trend_options[:show] ? nil : "display: none")
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def active_scaffold_search_date_bridge_trend_units(column)
|
|
52
|
+
options = ActiveScaffold::Finder::DateUnits.collect{|unit| [as_(unit.downcase.to_sym), unit]}
|
|
53
|
+
options = ActiveScaffold::Finder::TimeUnits.collect{|unit| [as_(unit.downcase.to_sym), unit]} + options if column_datetime?(column)
|
|
54
|
+
options
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def active_scaffold_search_date_bridge_range_tag(column, options, current_search)
|
|
58
|
+
range_controls = select_tag("search[#{column.name}][range]",
|
|
59
|
+
options_for_select( ActiveScaffold::Finder::DateRanges.collect{|range| [as_(range.downcase.to_sym), range]}, current_search["range"]),
|
|
60
|
+
:class => 'text-input')
|
|
61
|
+
content_tag("span", range_controls.html_safe, :id => "#{options[:id]}_range", :style => (current_search['opt'] == 'RANGE') ? nil : "display: none")
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def column_datetime?(column)
|
|
65
|
+
(!column.column.nil? && [:datetime, :time].include?(column.column.type))
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
module HumanConditionHelpers
|
|
70
|
+
def active_scaffold_human_condition_date_bridge(column, value)
|
|
71
|
+
case value[:opt]
|
|
72
|
+
when 'RANGE'
|
|
73
|
+
range_type, range = value[:range].downcase.split('_')
|
|
74
|
+
format = active_scaffold_human_condition_date_bridge_range_format(range_type, range)
|
|
75
|
+
from, to = controller.class.date_bridge_from_to(column, value)
|
|
76
|
+
"#{column.active_record_class.human_attribute_name(column.name)} = #{as_(value[:range].downcase).downcase} (#{I18n.l(from, :format => format)})"
|
|
77
|
+
when 'PAST', 'FUTURE'
|
|
78
|
+
from, to = controller.class.date_bridge_from_to(column, value)
|
|
79
|
+
"#{column.active_record_class.human_attribute_name(column.name)} #{as_('BETWEEN'.downcase).downcase} #{I18n.l(from)} - #{I18n.l(to)}"
|
|
80
|
+
else
|
|
81
|
+
from, to = controller.class.date_bridge_from_to(column, value)
|
|
82
|
+
"#{column.active_record_class.human_attribute_name(column.name)} #{as_(value[:opt].downcase).downcase} #{I18n.l(from)} #{value[:opt] == 'BETWEEN' ? '- ' + I18n.l(to) : ''}"
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def active_scaffold_human_condition_date_bridge_range_format(range_type, range)
|
|
87
|
+
case range
|
|
88
|
+
when 'week'
|
|
89
|
+
first_day_of_week = I18n.translate 'active_scaffold.date_picker_options.firstDay'
|
|
90
|
+
if first_day_of_week == 1
|
|
91
|
+
'%W %Y'
|
|
92
|
+
else
|
|
93
|
+
'%U %Y'
|
|
94
|
+
end
|
|
95
|
+
when 'month'
|
|
96
|
+
'%b %Y'
|
|
97
|
+
when 'year'
|
|
98
|
+
'%Y'
|
|
99
|
+
else
|
|
100
|
+
I18n.translate 'date.formats.default'
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
module Finder
|
|
106
|
+
module ClassMethods
|
|
107
|
+
def condition_for_date_bridge_type(column, value, like_pattern)
|
|
108
|
+
operator = ActiveScaffold::Finder::NumericComparators.include?(value[:opt]) && value[:opt] != 'BETWEEN' ? value[:opt] : nil
|
|
109
|
+
from_value, to_value = date_bridge_from_to(column, value)
|
|
110
|
+
|
|
111
|
+
if column.search_sql.is_a? Proc
|
|
112
|
+
column.search_sql.call(from_value, to_value, operator)
|
|
113
|
+
else
|
|
114
|
+
unless operator.nil?
|
|
115
|
+
["%{search_sql} #{value[:opt]} ?", from_value.to_s(:db)] unless from_value.nil?
|
|
116
|
+
else
|
|
117
|
+
["%{search_sql} BETWEEN ? AND ?", from_value.to_s(:db), to_value.to_s(:db)] unless from_value.nil? || to_value.nil?
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def date_bridge_from_to(column, value)
|
|
123
|
+
conversion = datetime_conversion_for_condition(column)
|
|
124
|
+
case value[:opt]
|
|
125
|
+
when 'RANGE'
|
|
126
|
+
date_bridge_from_to_for_range(column, value).collect(&conversion)
|
|
127
|
+
when 'PAST', 'FUTURE'
|
|
128
|
+
date_bridge_from_to_for_trend(column, value).collect(&conversion)
|
|
129
|
+
else
|
|
130
|
+
['from', 'to'].collect { |field| condition_value_for_datetime(value[field], conversion)}
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def date_bridge_now
|
|
135
|
+
Time.zone.now
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
def date_bridge_from_to_for_trend(column, value)
|
|
139
|
+
case value['opt']
|
|
140
|
+
when "PAST"
|
|
141
|
+
trend_number = [value['number'].to_i, 1].max
|
|
142
|
+
now = date_bridge_now
|
|
143
|
+
if date_bridge_column_date?(column)
|
|
144
|
+
from = now.beginning_of_day.ago((trend_number).send(value['unit'].downcase.singularize.to_sym))
|
|
145
|
+
to = now.end_of_day
|
|
146
|
+
else
|
|
147
|
+
from = now.ago((trend_number).send(value['unit'].downcase.singularize.to_sym))
|
|
148
|
+
to = now
|
|
149
|
+
end
|
|
150
|
+
return from, to
|
|
151
|
+
when "FUTURE"
|
|
152
|
+
trend_number = [value['number'].to_i, 1].max
|
|
153
|
+
now = date_bridge_now
|
|
154
|
+
if date_bridge_column_date?(column)
|
|
155
|
+
from = now.beginning_of_day
|
|
156
|
+
to = now.end_of_day.in((trend_number).send(value['unit'].downcase.singularize.to_sym))
|
|
157
|
+
else
|
|
158
|
+
from = now
|
|
159
|
+
to = now.in((trend_number).send(value['unit'].downcase.singularize.to_sym))
|
|
160
|
+
end
|
|
161
|
+
return from, to
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def date_bridge_from_to_for_range(column, value)
|
|
166
|
+
case value[:range]
|
|
167
|
+
when 'TODAY'
|
|
168
|
+
return date_bridge_now.beginning_of_day, date_bridge_now.end_of_day
|
|
169
|
+
when 'YESTERDAY'
|
|
170
|
+
return date_bridge_now.ago(1.day).beginning_of_day, date_bridge_now.ago(1.day).end_of_day
|
|
171
|
+
when 'TOMORROW'
|
|
172
|
+
return date_bridge_now.in(1.day).beginning_of_day, date_bridge_now.in(1.day).end_of_day
|
|
173
|
+
else
|
|
174
|
+
range_type, range = value[:range].downcase.split('_')
|
|
175
|
+
raise ArgumentError unless ['week', 'month', 'year'].include?(range)
|
|
176
|
+
case range_type
|
|
177
|
+
when 'this'
|
|
178
|
+
return date_bridge_now.send("beginning_of_#{range}".to_sym), date_bridge_now.send("end_of_#{range}")
|
|
179
|
+
when 'prev'
|
|
180
|
+
return date_bridge_now.ago(1.send(range.to_sym)).send("beginning_of_#{range}".to_sym), date_bridge_now.ago(1.send(range.to_sym)).send("end_of_#{range}".to_sym)
|
|
181
|
+
when 'next'
|
|
182
|
+
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)
|
|
183
|
+
else
|
|
184
|
+
return nil, nil
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def date_bridge_column_date?(column)
|
|
190
|
+
if [:date_picker, :datetime_picker].include? column.form_ui
|
|
191
|
+
column.form_ui == :date_picker
|
|
192
|
+
else
|
|
193
|
+
(!column.column.nil? && [:date].include?(column.column.type))
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
end
|
|
197
|
+
end
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
ActiveScaffold::Finder.const_set('DateComparators', ["PAST", "FUTURE", "RANGE"])
|
|
204
|
+
ActiveScaffold::Finder.const_set('DateUnits', ["DAYS", "WEEKS", "MONTHS", "YEARS"])
|
|
205
|
+
ActiveScaffold::Finder.const_set('TimeUnits', ["SECONDS", "MINUTES", "HOURS"])
|
|
206
|
+
ActiveScaffold::Finder.const_set('DateRanges', ["TODAY", "YESTERDAY", "TOMORROW",
|
|
207
|
+
"THIS_WEEK", "PREV_WEEK", "NEXT_WEEK",
|
|
208
|
+
"THIS_MONTH", "PREV_MONTH", "NEXT_MONTH",
|
|
209
|
+
"THIS_YEAR", "PREV_YEAR", "NEXT_YEAR"])
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
class ActiveScaffold::Bridges::TinyMce
|
|
2
|
+
module Helpers
|
|
3
|
+
def self.included(base)
|
|
4
|
+
base.class_eval do
|
|
5
|
+
include FormColumnHelpers
|
|
6
|
+
include SearchColumnHelpers
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
module FormColumnHelpers
|
|
11
|
+
def self.included(base)
|
|
12
|
+
base.alias_method_chain :onsubmit, :tiny_mce
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def active_scaffold_input_text_editor(column, options)
|
|
16
|
+
options[:class] = "#{options[:class]} mceEditor #{column.options[:class]}".strip
|
|
17
|
+
|
|
18
|
+
settings = { :theme => 'simple' }.merge(column.options[:tinymce] || {})
|
|
19
|
+
settings = settings.to_s.gsub(/:(.+?)\=\>/, '\1:')
|
|
20
|
+
settings = "tinyMCE.settings = #{settings};"
|
|
21
|
+
|
|
22
|
+
html = []
|
|
23
|
+
html << send(override_input(:textarea), column, options)
|
|
24
|
+
html << javascript_tag(settings + "tinyMCE.execCommand('mceAddControl', false, '#{options[:id]}');") if request.xhr? || params[:iframe]
|
|
25
|
+
html.join "\n"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def onsubmit_with_tiny_mce
|
|
29
|
+
if ActiveScaffold.js_framework == :jquery
|
|
30
|
+
submit_js = 'tinyMCE.triggerSave();$(\'textarea.mceEditor\').each(function(index, elem) { tinyMCE.execCommand(\'mceRemoveControl\', false, $(elem).attr(\'id\')); });'
|
|
31
|
+
else
|
|
32
|
+
submit_js = 'tinyMCE.triggerSave();this.select(\'textarea.mceEditor\').each(function(elem) { tinyMCE.execCommand(\'mceRemoveControl\', false, elem.id); });'
|
|
33
|
+
end
|
|
34
|
+
[onsubmit_without_tiny_mce, submit_js].compact.join ';'
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
module SearchColumnHelpers
|
|
39
|
+
def self.included(base)
|
|
40
|
+
base.class_eval { alias_method :active_scaffold_search_text_editor, :active_scaffold_search_text }
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
ActionView::Base.class_eval { include ActiveScaffold::Bridges::TinyMce::Helpers }
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
class ActiveScaffold::Bridges::TinyMce < ActiveScaffold::DataStructures::Bridge
|
|
2
|
+
def self.install
|
|
3
|
+
require File.join(File.dirname(__FILE__), "tiny_mce/helpers.rb")
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
def self.install?
|
|
7
|
+
Object.const_defined? "TinyMCE"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.javascripts
|
|
11
|
+
if ActiveScaffold.js_framework == :jquery
|
|
12
|
+
['tinymce-jquery', 'jquery/tiny_mce_bridge']
|
|
13
|
+
else
|
|
14
|
+
['tinymce', 'prototype/tiny_mce_bridge']
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
module ActiveScaffold
|
|
2
|
+
module Bridges
|
|
3
|
+
ActiveScaffold.autoload_subdir('bridges', self)
|
|
4
|
+
module Shared
|
|
5
|
+
autoload :DateBridge, 'active_scaffold/bridges/shared/date_bridge'
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
mattr_accessor :bridges
|
|
9
|
+
mattr_accessor :bridges_run
|
|
10
|
+
self.bridges = {}
|
|
11
|
+
|
|
12
|
+
def self.register(file)
|
|
13
|
+
match = file.match(/(active_scaffold\/bridges\/(.*))\.rb\Z/)
|
|
14
|
+
self.bridges[match[2].to_sym] = match[1] if match
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.load(bridge_name)
|
|
18
|
+
bridge = self.bridges[bridge_name.to_sym]
|
|
19
|
+
if bridge.is_a? String
|
|
20
|
+
if ActiveScaffold.exclude_bridges.exclude? bridge_name.to_sym
|
|
21
|
+
bridge = bridge.camelize.constantize
|
|
22
|
+
self.bridges[bridge_name.to_sym] = bridge
|
|
23
|
+
else
|
|
24
|
+
self.bridges.delete bridge_name
|
|
25
|
+
bridge = nil
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
bridge
|
|
29
|
+
end
|
|
30
|
+
class << self
|
|
31
|
+
alias_method :[], :load
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def self.run_all
|
|
35
|
+
return false if self.bridges_run
|
|
36
|
+
self.bridges.keys.each do |bridge_name|
|
|
37
|
+
bridge = self[bridge_name]
|
|
38
|
+
bridge.run if bridge
|
|
39
|
+
end
|
|
40
|
+
self.bridges_run = true
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.all_stylesheets
|
|
44
|
+
self.bridges.keys.collect do |bridge_name|
|
|
45
|
+
bridge = self[bridge_name]
|
|
46
|
+
bridge.stylesheets if bridge and bridge.install?
|
|
47
|
+
end.compact.flatten
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.all_javascripts
|
|
51
|
+
self.bridges.keys.collect do |bridge_name|
|
|
52
|
+
bridge = self[bridge_name]
|
|
53
|
+
bridge.javascripts if bridge and bridge.install?
|
|
54
|
+
end.compact.flatten
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
(Dir[File.join(File.dirname(__FILE__), "bridges/*.rb")] - [__FILE__]).each{|bridge_require|
|
|
60
|
+
ActiveScaffold::Bridges.register bridge_require
|
|
61
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
module ActiveScaffold::Config
|
|
2
|
+
class Base
|
|
3
|
+
include ActiveScaffold::Configurable
|
|
4
|
+
extend ActiveScaffold::Configurable
|
|
5
|
+
|
|
6
|
+
def initialize(core_config)
|
|
7
|
+
@core = core_config
|
|
8
|
+
@action_group = self.class.action_group.clone if self.class.action_group
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.inherited(subclass)
|
|
12
|
+
class << subclass
|
|
13
|
+
# the crud type of the action. possible values are :create, :read, :update, :delete, and nil.
|
|
14
|
+
# this is not a setting for the developer. it's self-description for the actions.
|
|
15
|
+
def crud_type; @crud_type; end
|
|
16
|
+
|
|
17
|
+
protected
|
|
18
|
+
|
|
19
|
+
def crud_type=(val)
|
|
20
|
+
raise ArgumentError, "unknown CRUD type #{val}" unless [:create, :read, :update, :delete].include?(val.to_sym)
|
|
21
|
+
@crud_type = val.to_sym
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
# delegate
|
|
27
|
+
def crud_type; self.class.crud_type end
|
|
28
|
+
|
|
29
|
+
def label(model = nil)
|
|
30
|
+
model ||= @core.label(:count => 1)
|
|
31
|
+
@label.nil? ? model : as_(@label, :model => model)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# the user property gets set to the instantiation of the local UserSettings class during the automatic instantiation of this class.
|
|
35
|
+
attr_accessor :user
|
|
36
|
+
|
|
37
|
+
# define a default action_group for this action
|
|
38
|
+
# e.g. 'members.crud'
|
|
39
|
+
class_attribute :action_group
|
|
40
|
+
|
|
41
|
+
# action_group this action should belong to
|
|
42
|
+
attr_accessor :action_group
|
|
43
|
+
|
|
44
|
+
class UserSettings
|
|
45
|
+
def initialize(conf, storage, params)
|
|
46
|
+
# the session hash relevant to this action
|
|
47
|
+
@session = storage
|
|
48
|
+
# all the request params
|
|
49
|
+
@params = params
|
|
50
|
+
# the configuration object for this action
|
|
51
|
+
@conf = conf
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def formats
|
|
56
|
+
@formats ||= []
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def formats=(val)
|
|
60
|
+
@formats=val
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
private
|
|
64
|
+
|
|
65
|
+
def columns=(val)
|
|
66
|
+
@columns.set_values(*val) if @columns
|
|
67
|
+
@columns ||= ActiveScaffold::DataStructures::ActionColumns.new(*val).tap do |columns|
|
|
68
|
+
columns.action = self
|
|
69
|
+
columns.set_columns(@core.columns) if @columns.respond_to?(:set_columns)
|
|
70
|
+
columns
|
|
71
|
+
end
|
|
72
|
+
@columns
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
module ActiveScaffold::Config
|
|
2
|
+
# to fix the ckeditor bridge problem
|
|
3
|
+
class Core < ActiveScaffold::Config::Base
|
|
4
|
+
# code commented out (see above)
|
|
5
|
+
#class Core < Base
|
|
6
|
+
# global level configuration
|
|
7
|
+
# --------------------------
|
|
8
|
+
|
|
9
|
+
# provides read/write access to the global Actions DataStructure
|
|
10
|
+
cattr_reader :actions
|
|
11
|
+
def self.actions=(val)
|
|
12
|
+
@@actions = ActiveScaffold::DataStructures::Actions.new(*val)
|
|
13
|
+
end
|
|
14
|
+
self.actions = [:create, :list, :search, :update, :delete, :show, :nested, :subform]
|
|
15
|
+
|
|
16
|
+
# configures where the ActiveScaffold plugin itself is located. there is no instance version of this.
|
|
17
|
+
cattr_accessor :plugin_directory
|
|
18
|
+
@@plugin_directory = File.expand_path(__FILE__).match(%{(^.*)/lib/active_scaffold/config/core.rb})[1]
|
|
19
|
+
|
|
20
|
+
# lets you specify a global ActiveScaffold frontend.
|
|
21
|
+
cattr_accessor :frontend
|
|
22
|
+
@@frontend = :default
|
|
23
|
+
|
|
24
|
+
# lets you specify a global ActiveScaffold theme for your frontend.
|
|
25
|
+
cattr_accessor :theme
|
|
26
|
+
@@theme = :default
|
|
27
|
+
|
|
28
|
+
# lets you disable the DHTML history
|
|
29
|
+
def self.dhtml_history=(val)
|
|
30
|
+
@@dhtml_history = val
|
|
31
|
+
end
|
|
32
|
+
def self.dhtml_history?
|
|
33
|
+
@@dhtml_history ? true : false
|
|
34
|
+
end
|
|
35
|
+
@@dhtml_history = true
|
|
36
|
+
|
|
37
|
+
# action links are used by actions to tie together. you can use them, too! this is a collection of ActiveScaffold::DataStructures::ActionLink objects.
|
|
38
|
+
cattr_reader :action_links
|
|
39
|
+
@@action_links = ActiveScaffold::DataStructures::ActionLinks.new
|
|
40
|
+
|
|
41
|
+
# access to the permissions configuration.
|
|
42
|
+
# configuration options include:
|
|
43
|
+
# * current_user_method - what method on the controller returns the current user. default: :current_user
|
|
44
|
+
# * default_permission - what the default permission is. default: true
|
|
45
|
+
def self.security
|
|
46
|
+
ActiveRecordPermissions
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# columns that should be ignored for every model. these should be metadata columns like change dates, versions, etc.
|
|
50
|
+
# values in this array may be symbols or strings.
|
|
51
|
+
def self.ignore_columns
|
|
52
|
+
@@ignore_columns
|
|
53
|
+
end
|
|
54
|
+
def self.ignore_columns=(val)
|
|
55
|
+
@@ignore_columns = ActiveScaffold::DataStructures::Set.new(*val)
|
|
56
|
+
end
|
|
57
|
+
@@ignore_columns = ActiveScaffold::DataStructures::Set.new
|
|
58
|
+
|
|
59
|
+
# lets you specify whether add a create link for each sti child
|
|
60
|
+
cattr_accessor :sti_create_links
|
|
61
|
+
@@sti_create_links = true
|
|
62
|
+
|
|
63
|
+
# prefix messages with current timestamp, set the format to display (you can use I18n keys) or true and :short will be used
|
|
64
|
+
cattr_accessor :timestamped_messages
|
|
65
|
+
@@timestamped_messages = false
|
|
66
|
+
|
|
67
|
+
# a hash of string (or array of strings) and highlighter string to highlight words in messages. It will use highlight rails helper
|
|
68
|
+
cattr_accessor :highlight_messages
|
|
69
|
+
@@highlight_messages = nil
|
|
70
|
+
|
|
71
|
+
# instance-level configuration
|
|
72
|
+
# ----------------------------
|
|
73
|
+
|
|
74
|
+
# provides read/write access to the local Actions DataStructure
|
|
75
|
+
attr_reader :actions
|
|
76
|
+
def actions=(args)
|
|
77
|
+
@actions = ActiveScaffold::DataStructures::Actions.new(*args)
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# provides read/write access to the local Columns DataStructure
|
|
81
|
+
attr_reader :columns
|
|
82
|
+
def columns=(val)
|
|
83
|
+
@columns._inheritable = val.collect {|c| c.to_sym}
|
|
84
|
+
# Add virtual columns
|
|
85
|
+
@columns << val.collect {|c| c.to_sym unless @columns[c.to_sym]}.compact
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# lets you override the global ActiveScaffold frontend for a specific controller
|
|
89
|
+
attr_accessor :frontend
|
|
90
|
+
|
|
91
|
+
# lets you override the global ActiveScaffold theme for a specific controller
|
|
92
|
+
attr_accessor :theme
|
|
93
|
+
|
|
94
|
+
# lets you specify whether add a create link for each sti child for a specific controller
|
|
95
|
+
attr_accessor :sti_create_links
|
|
96
|
+
def add_sti_create_links?
|
|
97
|
+
self.sti_create_links and not self.sti_children.nil?
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# action links are used by actions to tie together. they appear as links for each record, or general links for the ActiveScaffold.
|
|
101
|
+
attr_reader :action_links
|
|
102
|
+
|
|
103
|
+
# a generally-applicable name for this ActiveScaffold ... will be used for generating page/section headers
|
|
104
|
+
attr_writer :label
|
|
105
|
+
def label(options={})
|
|
106
|
+
as_(@label, options) || model.model_name.human(options.merge(options[:count].to_i == 1 ? {} : {:default => model.name.pluralize}))
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# STI children models, use an array of model names
|
|
110
|
+
attr_accessor :sti_children
|
|
111
|
+
|
|
112
|
+
# prefix messages with current timestamp, set the format to display (you can use I18n keys) or true and :short will be used
|
|
113
|
+
attr_accessor :timestamped_messages
|
|
114
|
+
|
|
115
|
+
# a hash of string (or array of strings) and highlighter string to highlight words in messages. It will use highlight rails helper
|
|
116
|
+
attr_accessor :highlight_messages
|
|
117
|
+
|
|
118
|
+
##
|
|
119
|
+
## internal usage only below this point
|
|
120
|
+
## ------------------------------------
|
|
121
|
+
|
|
122
|
+
def initialize(model_id)
|
|
123
|
+
# model_id is the only absolutely required configuration value. it is also not publicly accessible.
|
|
124
|
+
@model_id = model_id
|
|
125
|
+
|
|
126
|
+
# inherit the actions list directly from the global level
|
|
127
|
+
@actions = self.class.actions.clone
|
|
128
|
+
|
|
129
|
+
# create a new default columns datastructure, since it doesn't make sense before now
|
|
130
|
+
attribute_names = self.model.columns.collect{ |c| c.name.to_sym }.sort_by { |c| c.to_s }
|
|
131
|
+
association_column_names = self.model.reflect_on_all_associations.collect{ |a| a.name.to_sym }.sort_by { |c| c.to_s }
|
|
132
|
+
@columns = ActiveScaffold::DataStructures::Columns.new(self.model, attribute_names + association_column_names)
|
|
133
|
+
|
|
134
|
+
# and then, let's remove some columns from the inheritable set.
|
|
135
|
+
@columns.exclude(*self.class.ignore_columns)
|
|
136
|
+
@columns.exclude(*@columns.find_all { |c| c.column and (c.column.primary or c.column.name =~ /(_id|_count)$/) }.collect {|c| c.name})
|
|
137
|
+
@columns.exclude(*self.model.reflect_on_all_associations.collect{|a| :"#{a.name}_type" if a.options[:polymorphic]}.compact)
|
|
138
|
+
|
|
139
|
+
# inherit the global frontend
|
|
140
|
+
@frontend = self.class.frontend
|
|
141
|
+
@theme = self.class.theme
|
|
142
|
+
@sti_create_links = self.class.sti_create_links
|
|
143
|
+
|
|
144
|
+
# inherit from the global set of action links
|
|
145
|
+
@action_links = self.class.action_links.clone
|
|
146
|
+
@timestamped_messages = self.class.timestamped_messages
|
|
147
|
+
@highlight_messages = self.class.highlight_messages
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# To be called after your finished configuration
|
|
151
|
+
def _load_action_columns
|
|
152
|
+
#ActiveScaffold::DataStructures::ActionColumns.class_eval {include ActiveScaffold::DataStructures::ActionColumns::AfterConfiguration}
|
|
153
|
+
|
|
154
|
+
# then, register the column objects
|
|
155
|
+
self.actions.each do |action_name|
|
|
156
|
+
action = self.send(action_name)
|
|
157
|
+
next unless action.respond_to? :columns
|
|
158
|
+
action.columns.set_columns(self.columns)
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# To be called after your finished configuration
|
|
163
|
+
def _configure_sti
|
|
164
|
+
column = self.model.inheritance_column
|
|
165
|
+
if sti_create_links
|
|
166
|
+
self.columns[column].form_ui ||= :hidden
|
|
167
|
+
else
|
|
168
|
+
self.columns[column].form_ui ||= :select
|
|
169
|
+
self.columns[column].options ||= {}
|
|
170
|
+
self.columns[column].options[:options] = self.sti_children.collect do |model_name|
|
|
171
|
+
[model_name.to_s.camelize.constantize.model_name.human, model_name.to_s.camelize]
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# configuration routing.
|
|
177
|
+
# we want to route calls named like an activated action to that action's global or local Config class.
|
|
178
|
+
# ---------------------------
|
|
179
|
+
def method_missing(name, *args)
|
|
180
|
+
@action_configs ||= {}
|
|
181
|
+
titled_name = name.to_s.camelcase
|
|
182
|
+
underscored_name = name.to_s.underscore.to_sym
|
|
183
|
+
klass = "ActiveScaffold::Config::#{titled_name}".constantize rescue nil
|
|
184
|
+
if klass
|
|
185
|
+
if @actions.include? underscored_name
|
|
186
|
+
return @action_configs[underscored_name] ||= klass.new(self)
|
|
187
|
+
else
|
|
188
|
+
raise "#{titled_name} is not enabled. Please enable it or remove any references in your configuration (e.g. config.#{underscored_name}.columns = [...])."
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
super
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
def self.method_missing(name, *args)
|
|
195
|
+
klass = "ActiveScaffold::Config::#{name.to_s.camelcase}".constantize rescue nil
|
|
196
|
+
if @@actions.include? name.to_s.underscore and klass
|
|
197
|
+
return eval("ActiveScaffold::Config::#{name.to_s.camelcase}")
|
|
198
|
+
end
|
|
199
|
+
super
|
|
200
|
+
end
|
|
201
|
+
# some utility methods
|
|
202
|
+
# --------------------
|
|
203
|
+
|
|
204
|
+
def model_id
|
|
205
|
+
@model_id
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
def model
|
|
209
|
+
@model ||= @model_id.to_s.camelize.constantize
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
# 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
|
|
213
|
+
def inherited_view_paths
|
|
214
|
+
@inherited_view_paths||=[]
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
# must be a class method so the layout doesn't depend on a controller that uses active_scaffold
|
|
218
|
+
# note that this is unaffected by per-controller frontend configuration.
|
|
219
|
+
def self.asset_path(filename, frontend = self.frontend)
|
|
220
|
+
"active_scaffold/#{frontend}/#{filename}"
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# must be a class method so the layout doesn't depend on a controller that uses active_scaffold
|
|
224
|
+
# note that this is unaffected by per-controller frontend configuration.
|
|
225
|
+
def self.javascripts(frontend = self.frontend)
|
|
226
|
+
javascript_dir = File.join(Rails.public_path, "javascripts", asset_path('', frontend))
|
|
227
|
+
Dir.entries(javascript_dir).reject { |e| !e.match(/\.js$/) or (!self.dhtml_history? and e.match('dhtml_history')) }
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
def self.available_frontends
|
|
231
|
+
frontends_dir = File.join(Rails.root, "vendor", "plugins", ActiveScaffold::Config::Core.plugin_directory, "frontends")
|
|
232
|
+
Dir.entries(frontends_dir).reject { |e| e.match(/^\./) } # Get rid of files that start with .
|
|
233
|
+
end
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module ActiveScaffold::Config
|
|
2
|
+
class Create < ActiveScaffold::Config::Form
|
|
3
|
+
self.crud_type = :create
|
|
4
|
+
def initialize(core_config)
|
|
5
|
+
super
|
|
6
|
+
@label = :create_model
|
|
7
|
+
self.action_after_create = self.class.action_after_create
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# global level configuration
|
|
11
|
+
# --------------------------
|
|
12
|
+
# the ActionLink for this action
|
|
13
|
+
def self.link
|
|
14
|
+
@@link
|
|
15
|
+
end
|
|
16
|
+
def self.link=(val)
|
|
17
|
+
@@link = val
|
|
18
|
+
end
|
|
19
|
+
@@link = ActiveScaffold::DataStructures::ActionLink.new('new', :label => :create_new, :type => :collection, :security_method => :create_authorized?, :ignore_method => :create_ignore?)
|
|
20
|
+
|
|
21
|
+
# whether update form is opened after a create or not
|
|
22
|
+
cattr_accessor :action_after_create
|
|
23
|
+
@@action_after_create = nil
|
|
24
|
+
|
|
25
|
+
# instance-level configuration
|
|
26
|
+
# ----------------------------
|
|
27
|
+
|
|
28
|
+
# whether the form stays open after a create or not
|
|
29
|
+
attr_accessor :action_after_create
|
|
30
|
+
|
|
31
|
+
end
|
|
32
|
+
end
|