active_scaffold 3.2.17 → 3.2.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +5 -1
- metadata +17 -261
- data/app/assets/images/active_scaffold/add.png +0 -0
- data/app/assets/images/active_scaffold/arrow_down.png +0 -0
- data/app/assets/images/active_scaffold/arrow_up.png +0 -0
- data/app/assets/images/active_scaffold/close.png +0 -0
- data/app/assets/images/active_scaffold/close_touch.png +0 -0
- data/app/assets/images/active_scaffold/config.png +0 -0
- data/app/assets/images/active_scaffold/cross.png +0 -0
- data/app/assets/images/active_scaffold/gears.png +0 -0
- data/app/assets/images/active_scaffold/indicator-small.gif +0 -0
- data/app/assets/images/active_scaffold/indicator.gif +0 -0
- data/app/assets/images/active_scaffold/magnifier.png +0 -0
- data/app/assets/javascripts/active_scaffold.js.erb +0 -19
- data/app/assets/javascripts/jquery/active_scaffold.js +0 -1113
- data/app/assets/javascripts/jquery/date_picker_bridge.js.erb +0 -24
- data/app/assets/javascripts/jquery/draggable_lists.js +0 -27
- data/app/assets/javascripts/jquery/jquery.editinplace.js +0 -743
- data/app/assets/javascripts/jquery/tiny_mce_bridge.js +0 -7
- data/app/assets/javascripts/prototype/active_scaffold.js +0 -1107
- data/app/assets/javascripts/prototype/dhtml_history.js +0 -870
- data/app/assets/javascripts/prototype/form_enhancements.js +0 -117
- data/app/assets/javascripts/prototype/rico_corner.js +0 -370
- data/app/assets/javascripts/prototype/tiny_mce_bridge.js +0 -7
- data/app/assets/stylesheets/active_scaffold-ie.css.scss +0 -54
- data/app/assets/stylesheets/active_scaffold.css.scss +0 -14
- data/app/assets/stylesheets/active_scaffold_colors.css.scss +0 -395
- data/app/assets/stylesheets/active_scaffold_extensions.css.erb +0 -2
- data/app/assets/stylesheets/active_scaffold_images.css.scss +0 -40
- data/app/assets/stylesheets/active_scaffold_layout.css +0 -936
- data/app/assets/stylesheets/blue-theme.css +0 -74
- data/config/locales/de.yml +0 -125
- data/config/locales/en.yml +0 -127
- data/config/locales/es.yml +0 -128
- data/config/locales/fr.yml +0 -131
- data/config/locales/hu.yml +0 -126
- data/config/locales/ja.yml +0 -126
- data/config/locales/ru.yml +0 -135
- data/frontends/default/views/_action_group.html.erb +0 -24
- data/frontends/default/views/_add_existing_form.html.erb +0 -30
- data/frontends/default/views/_base_form.html.erb +0 -53
- data/frontends/default/views/_create_form.html.erb +0 -8
- data/frontends/default/views/_create_form_on_list.html.erb +0 -6
- data/frontends/default/views/_field_search.html.erb +0 -32
- data/frontends/default/views/_form.html.erb +0 -28
- data/frontends/default/views/_form_association.html.erb +0 -17
- data/frontends/default/views/_form_association_footer.html.erb +0 -47
- data/frontends/default/views/_form_attribute.html.erb +0 -23
- data/frontends/default/views/_form_hidden_attribute.html.erb +0 -7
- data/frontends/default/views/_form_messages.html.erb +0 -5
- data/frontends/default/views/_horizontal_subform.html.erb +0 -22
- data/frontends/default/views/_horizontal_subform_footer.html.erb +0 -0
- data/frontends/default/views/_horizontal_subform_header.html.erb +0 -11
- data/frontends/default/views/_horizontal_subform_record.html.erb +0 -43
- data/frontends/default/views/_human_conditions.html.erb +0 -1
- data/frontends/default/views/_list.html.erb +0 -18
- data/frontends/default/views/_list_actions.html.erb +0 -15
- data/frontends/default/views/_list_calculations.html.erb +0 -16
- data/frontends/default/views/_list_column_headings.html.erb +0 -12
- data/frontends/default/views/_list_header.html.erb +0 -10
- data/frontends/default/views/_list_inline_adapter.html.erb +0 -21
- data/frontends/default/views/_list_messages.html.erb +0 -28
- data/frontends/default/views/_list_pagination.html.erb +0 -11
- data/frontends/default/views/_list_pagination_links.html.erb +0 -9
- data/frontends/default/views/_list_record.html.erb +0 -13
- data/frontends/default/views/_list_record_columns.html.erb +0 -8
- data/frontends/default/views/_list_with_header.html.erb +0 -36
- data/frontends/default/views/_messages.html.erb +0 -10
- data/frontends/default/views/_refresh_list.js.erb +0 -1
- data/frontends/default/views/_render_field.js.erb +0 -20
- data/frontends/default/views/_row.html.erb +0 -1
- data/frontends/default/views/_search.html.erb +0 -34
- data/frontends/default/views/_search_attribute.html.erb +0 -10
- data/frontends/default/views/_show.html.erb +0 -8
- data/frontends/default/views/_show_columns.html.erb +0 -15
- data/frontends/default/views/_update_actions.html.erb +0 -9
- data/frontends/default/views/_update_calculations.js.erb +0 -4
- data/frontends/default/views/_update_form.html.erb +0 -6
- data/frontends/default/views/_update_messages.js.erb +0 -2
- data/frontends/default/views/_vertical_subform.html.erb +0 -12
- data/frontends/default/views/_vertical_subform_record.html.erb +0 -43
- data/frontends/default/views/action_confirmation.html.erb +0 -13
- data/frontends/default/views/add_existing.js.erb +0 -14
- data/frontends/default/views/add_existing_form.html.erb +0 -5
- data/frontends/default/views/create.html.erb +0 -5
- data/frontends/default/views/delete.html.erb +0 -13
- data/frontends/default/views/destroy.js.erb +0 -26
- data/frontends/default/views/edit_associated.js.erb +0 -12
- data/frontends/default/views/field_search.html.erb +0 -5
- data/frontends/default/views/form_messages.js.erb +0 -1
- data/frontends/default/views/list.html.erb +0 -1
- data/frontends/default/views/on_action_update.js.erb +0 -22
- data/frontends/default/views/on_create.js.erb +0 -38
- data/frontends/default/views/on_mark.js.erb +0 -6
- data/frontends/default/views/on_update.js.erb +0 -29
- data/frontends/default/views/refresh_list.js.erb +0 -2
- data/frontends/default/views/render_field.js.erb +0 -1
- data/frontends/default/views/row.js.erb +0 -2
- data/frontends/default/views/search.html.erb +0 -5
- data/frontends/default/views/show.html.erb +0 -5
- data/frontends/default/views/update.html.erb +0 -8
- data/frontends/default/views/update_column.js.erb +0 -15
- data/frontends/default/views/update_row.js.erb +0 -1
- data/lib/active_scaffold.rb +0 -373
- data/lib/active_scaffold/actions/common_search.rb +0 -22
- data/lib/active_scaffold/actions/core.rb +0 -203
- data/lib/active_scaffold/actions/create.rb +0 -139
- data/lib/active_scaffold/actions/delete.rb +0 -74
- data/lib/active_scaffold/actions/field_search.rb +0 -78
- data/lib/active_scaffold/actions/list.rb +0 -208
- data/lib/active_scaffold/actions/mark.rb +0 -89
- data/lib/active_scaffold/actions/nested.rb +0 -244
- data/lib/active_scaffold/actions/search.rb +0 -48
- data/lib/active_scaffold/actions/show.rb +0 -61
- data/lib/active_scaffold/actions/subform.rb +0 -23
- data/lib/active_scaffold/actions/update.rb +0 -156
- data/lib/active_scaffold/active_record_permissions.rb +0 -135
- data/lib/active_scaffold/attribute_params.rb +0 -200
- data/lib/active_scaffold/bridges.rb +0 -61
- data/lib/active_scaffold/bridges/ancestry.rb +0 -5
- data/lib/active_scaffold/bridges/ancestry/ancestry_bridge.rb +0 -39
- data/lib/active_scaffold/bridges/bitfields.rb +0 -6
- data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +0 -37
- data/lib/active_scaffold/bridges/calendar_date_select.rb +0 -24
- data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +0 -66
- data/lib/active_scaffold/bridges/cancan.rb +0 -15
- data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +0 -127
- data/lib/active_scaffold/bridges/carrierwave.rb +0 -12
- data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +0 -31
- data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge_helpers.rb +0 -10
- data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +0 -45
- data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +0 -17
- data/lib/active_scaffold/bridges/country_helper.rb +0 -9
- data/lib/active_scaffold/bridges/country_helper/country_helper_bridge.rb +0 -358
- data/lib/active_scaffold/bridges/date_picker.rb +0 -23
- data/lib/active_scaffold/bridges/date_picker/ext.rb +0 -63
- data/lib/active_scaffold/bridges/date_picker/helper.rb +0 -180
- data/lib/active_scaffold/bridges/dragonfly.rb +0 -9
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +0 -34
- data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge_helpers.rb +0 -10
- data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +0 -27
- data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +0 -16
- data/lib/active_scaffold/bridges/file_column.rb +0 -11
- data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +0 -46
- data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +0 -57
- data/lib/active_scaffold/bridges/file_column/form_ui.rb +0 -34
- data/lib/active_scaffold/bridges/file_column/list_ui.rb +0 -26
- data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +0 -43
- data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +0 -9
- data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +0 -15
- data/lib/active_scaffold/bridges/paperclip.rb +0 -12
- data/lib/active_scaffold/bridges/paperclip/form_ui.rb +0 -27
- data/lib/active_scaffold/bridges/paperclip/list_ui.rb +0 -16
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +0 -36
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +0 -24
- data/lib/active_scaffold/bridges/record_select.rb +0 -11
- data/lib/active_scaffold/bridges/record_select/helpers.rb +0 -92
- data/lib/active_scaffold/bridges/semantic_attributes.rb +0 -5
- data/lib/active_scaffold/bridges/semantic_attributes/column.rb +0 -20
- data/lib/active_scaffold/bridges/shared/date_bridge.rb +0 -209
- data/lib/active_scaffold/bridges/tiny_mce.rb +0 -17
- data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +0 -46
- data/lib/active_scaffold/config/base.rb +0 -75
- data/lib/active_scaffold/config/core.rb +0 -236
- data/lib/active_scaffold/config/create.rb +0 -32
- data/lib/active_scaffold/config/delete.rb +0 -32
- data/lib/active_scaffold/config/field_search.rb +0 -79
- data/lib/active_scaffold/config/form.rb +0 -64
- data/lib/active_scaffold/config/list.rb +0 -247
- data/lib/active_scaffold/config/mark.rb +0 -30
- data/lib/active_scaffold/config/nested.rb +0 -42
- data/lib/active_scaffold/config/search.rb +0 -73
- data/lib/active_scaffold/config/show.rb +0 -31
- data/lib/active_scaffold/config/subform.rb +0 -35
- data/lib/active_scaffold/config/update.rb +0 -33
- data/lib/active_scaffold/configurable.rb +0 -29
- data/lib/active_scaffold/constraints.rb +0 -171
- data/lib/active_scaffold/data_structures/action_columns.rb +0 -142
- data/lib/active_scaffold/data_structures/action_link.rb +0 -185
- data/lib/active_scaffold/data_structures/action_links.rb +0 -191
- data/lib/active_scaffold/data_structures/actions.rb +0 -45
- data/lib/active_scaffold/data_structures/bridge.rb +0 -22
- data/lib/active_scaffold/data_structures/column.rb +0 -401
- data/lib/active_scaffold/data_structures/columns.rb +0 -75
- data/lib/active_scaffold/data_structures/error_message.rb +0 -24
- data/lib/active_scaffold/data_structures/nested_info.rb +0 -171
- data/lib/active_scaffold/data_structures/set.rb +0 -61
- data/lib/active_scaffold/data_structures/sorting.rb +0 -167
- data/lib/active_scaffold/engine.rb +0 -4
- data/lib/active_scaffold/extensions/action_controller_rendering.rb +0 -20
- data/lib/active_scaffold/extensions/action_controller_rescueing.rb +0 -7
- data/lib/active_scaffold/extensions/action_view_rendering.rb +0 -115
- data/lib/active_scaffold/extensions/active_record_offset.rb +0 -12
- data/lib/active_scaffold/extensions/array.rb +0 -7
- data/lib/active_scaffold/extensions/cache_association.rb +0 -16
- data/lib/active_scaffold/extensions/localize.rb +0 -10
- data/lib/active_scaffold/extensions/name_option_for_datetime.rb +0 -12
- data/lib/active_scaffold/extensions/nil_id_in_url_params.rb +0 -7
- data/lib/active_scaffold/extensions/paginator_extensions.rb +0 -26
- data/lib/active_scaffold/extensions/reverse_associations.rb +0 -64
- data/lib/active_scaffold/extensions/routing_mapper.rb +0 -48
- data/lib/active_scaffold/extensions/to_label.rb +0 -8
- data/lib/active_scaffold/extensions/unsaved_associated.rb +0 -61
- data/lib/active_scaffold/extensions/unsaved_record.rb +0 -20
- data/lib/active_scaffold/extensions/usa_state.rb +0 -46
- data/lib/active_scaffold/finder.rb +0 -399
- data/lib/active_scaffold/helpers/association_helpers.rb +0 -42
- data/lib/active_scaffold/helpers/controller_helpers.rb +0 -94
- data/lib/active_scaffold/helpers/form_column_helpers.rb +0 -322
- data/lib/active_scaffold/helpers/human_condition_helpers.rb +0 -64
- data/lib/active_scaffold/helpers/id_helpers.rb +0 -131
- data/lib/active_scaffold/helpers/list_column_helpers.rb +0 -374
- data/lib/active_scaffold/helpers/pagination_helpers.rb +0 -62
- data/lib/active_scaffold/helpers/search_column_helpers.rb +0 -257
- data/lib/active_scaffold/helpers/show_column_helpers.rb +0 -44
- data/lib/active_scaffold/helpers/view_helpers.rb +0 -398
- data/lib/active_scaffold/marked_model.rb +0 -38
- data/lib/active_scaffold/paginator.rb +0 -136
- data/lib/active_scaffold/responds_to_parent.rb +0 -70
- data/lib/active_scaffold/tableless.rb +0 -83
- data/lib/active_scaffold/version.rb +0 -9
- data/lib/active_scaffold_env.rb +0 -13
- data/lib/generators/active_scaffold/USAGE +0 -29
- data/lib/generators/active_scaffold/active_scaffold_generator.rb +0 -21
- data/lib/generators/active_scaffold_controller/USAGE +0 -19
- data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +0 -29
- data/lib/generators/active_scaffold_controller/templates/controller.rb +0 -4
- data/lib/generators/active_scaffold_controller/templates/helper.rb +0 -2
- data/public/blank.html +0 -33
- data/shoulda_macros/macros.rb +0 -136
- data/vendor/assets/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
- data/vendor/assets/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
- data/vendor/assets/images/ui-bg_flat_10_000000_40x100.png +0 -0
- data/vendor/assets/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
- data/vendor/assets/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
- data/vendor/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/vendor/assets/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
- data/vendor/assets/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
- data/vendor/assets/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
- data/vendor/assets/images/ui-icons_222222_256x240.png +0 -0
- data/vendor/assets/images/ui-icons_228ef1_256x240.png +0 -0
- data/vendor/assets/images/ui-icons_ef8c08_256x240.png +0 -0
- data/vendor/assets/images/ui-icons_ffd27a_256x240.png +0 -0
- data/vendor/assets/images/ui-icons_ffffff_256x240.png +0 -0
- data/vendor/assets/javascripts/jquery-ui-timepicker-addon.js +0 -1276
- data/vendor/assets/stylesheets/jquery-ui.css +0 -568
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
module ActiveScaffold
|
|
2
|
-
module Helpers
|
|
3
|
-
module ControllerHelpers
|
|
4
|
-
def self.included(controller)
|
|
5
|
-
controller.class_eval { helper_method :params_for, :params_conditions, :main_path_to_return, :render_parent?, :render_parent_options, :render_parent_action, :nested_singular_association?, :build_associated}
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
include ActiveScaffold::Helpers::IdHelpers
|
|
9
|
-
|
|
10
|
-
def params_conditions
|
|
11
|
-
conditions_from_params.keys
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def params_for(options = {})
|
|
15
|
-
# :adapter and :position are one-use rendering arguments. they should not propagate.
|
|
16
|
-
# :sort, :sort_direction, and :page are arguments that stored in the session. they need not propagate.
|
|
17
|
-
# and wow. no we don't want to propagate :record.
|
|
18
|
-
# :commit is a special rails variable for form buttons
|
|
19
|
-
blacklist = [:adapter, :position, :sort, :sort_direction, :page, :record, :commit, :_method, :authenticity_token, :iframe]
|
|
20
|
-
unless @params_for
|
|
21
|
-
@params_for = {}
|
|
22
|
-
params.select { |key, value| blacklist.exclude? key.to_sym if key }.each {|key, value| @params_for[key.to_sym] = value.duplicable? ? value.clone : value}
|
|
23
|
-
@params_for[:controller] = '/' + @params_for[:controller].to_s unless @params_for[:controller].to_s.first(1) == '/' # for namespaced controllers
|
|
24
|
-
@params_for.delete(:id) if @params_for[:id].nil?
|
|
25
|
-
end
|
|
26
|
-
@params_for.merge(options)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
# Parameters to generate url to the main page (override if the ActiveScaffold is used as a component on another controllers page)
|
|
30
|
-
def main_path_to_return
|
|
31
|
-
if params[:return_to]
|
|
32
|
-
params[:return_to]
|
|
33
|
-
else
|
|
34
|
-
parameters = {}
|
|
35
|
-
if params[:parent_controller]
|
|
36
|
-
parameters[:controller] = params[:parent_controller]
|
|
37
|
-
#parameters[:eid] = params[:parent_controller] # not neeeded anymore?
|
|
38
|
-
end
|
|
39
|
-
parameters.merge! nested.to_params if nested?
|
|
40
|
-
if params[:parent_sti]
|
|
41
|
-
parameters[:controller] = params[:parent_sti]
|
|
42
|
-
#parameters[:eid] = nil # not neeeded anymore?
|
|
43
|
-
end
|
|
44
|
-
parameters[:parent_column] = nil
|
|
45
|
-
parameters[:parent_id] = nil
|
|
46
|
-
parameters[:action] = "index"
|
|
47
|
-
parameters[:id] = nil
|
|
48
|
-
parameters[:associated_id] = nil
|
|
49
|
-
parameters[:utf8] = nil
|
|
50
|
-
params_for(parameters)
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def nested_singular_association?
|
|
55
|
-
nested? && (nested.belongs_to? || nested.has_one?)
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def render_parent?
|
|
59
|
-
nested_singular_association? || params[:parent_sti]
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
def render_parent_options
|
|
63
|
-
if nested_singular_association?
|
|
64
|
-
{:controller => nested.parent_scaffold.controller_path, :action => :row, :id => nested.parent_id}
|
|
65
|
-
elsif params[:parent_sti]
|
|
66
|
-
options = params_for(:controller => params[:parent_sti], :action => render_parent_action, :parent_sti => nil)
|
|
67
|
-
options.merge(:id => @record.id) if render_parent_action == :row
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def render_parent_action
|
|
72
|
-
begin
|
|
73
|
-
@parent_action = :row
|
|
74
|
-
if params[:parent_sti]
|
|
75
|
-
parent_controller = "#{params[:parent_sti].to_s.camelize}Controller".constantize
|
|
76
|
-
@parent_action = :index if action_name == 'create' && parent_controller.active_scaffold_config.actions.include?(:create) && parent_controller.active_scaffold_config.create.refresh_list == true
|
|
77
|
-
@parent_action = :index if action_name == 'update' && parent_controller.active_scaffold_config.actions.include?(:update) && parent_controller.active_scaffold_config.update.refresh_list == true
|
|
78
|
-
@parent_action = :index if action_name == 'destroy' && parent_controller.active_scaffold_config.actions.include?(:delete) && parent_controller.active_scaffold_config.delete.refresh_list == true
|
|
79
|
-
end
|
|
80
|
-
rescue ActiveScaffold::ControllerNotFound
|
|
81
|
-
end if @parent_action.nil?
|
|
82
|
-
@parent_action
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def build_associated(column, record)
|
|
86
|
-
if column.singular_association?
|
|
87
|
-
record.send(:"build_#{column.name}")
|
|
88
|
-
else
|
|
89
|
-
record.send(column.name).build
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
module ActiveScaffold
|
|
2
|
-
module Helpers
|
|
3
|
-
# Helpers that assist with the rendering of a Form Column
|
|
4
|
-
module FormColumnHelpers
|
|
5
|
-
# This method decides which input to use for the given column.
|
|
6
|
-
# It does not do any rendering. It only decides which method is responsible for rendering.
|
|
7
|
-
def active_scaffold_input_for(column, scope = nil, options = {})
|
|
8
|
-
options = active_scaffold_input_options(column, scope, options)
|
|
9
|
-
options = update_columns_options(column, scope, options)
|
|
10
|
-
active_scaffold_render_input(column, options)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
alias form_column active_scaffold_input_for
|
|
14
|
-
|
|
15
|
-
def active_scaffold_render_input(column, options)
|
|
16
|
-
begin
|
|
17
|
-
# first, check if the dev has created an override for this specific field
|
|
18
|
-
if (method = override_form_field(column))
|
|
19
|
-
send(method, @record, options)
|
|
20
|
-
# second, check if the dev has specified a valid form_ui for this column
|
|
21
|
-
elsif column.form_ui and (method = override_input(column.form_ui))
|
|
22
|
-
send(method, column, options)
|
|
23
|
-
# fallback: we get to make the decision
|
|
24
|
-
else
|
|
25
|
-
if column.association
|
|
26
|
-
if column.form_ui.nil?
|
|
27
|
-
# its an association and nothing is specified, we will assume form_ui :select
|
|
28
|
-
active_scaffold_input_select(column, options)
|
|
29
|
-
else
|
|
30
|
-
# if we get here, it's because the column has a form_ui but not one ActiveScaffold knows about.
|
|
31
|
-
raise "Unknown form_ui `#{column.form_ui}' for column `#{column.name}'"
|
|
32
|
-
end
|
|
33
|
-
elsif column.virtual?
|
|
34
|
-
options[:value] = format_number_value(@record.send(column.name), column.options) if column.number?
|
|
35
|
-
active_scaffold_input_virtual(column, options)
|
|
36
|
-
|
|
37
|
-
else # regular model attribute column
|
|
38
|
-
# if we (or someone else) have created a custom render option for the column type, use that
|
|
39
|
-
if (method = override_input(column.column.type))
|
|
40
|
-
send(method, column, options)
|
|
41
|
-
# final ultimate fallback: use rails' generic input method
|
|
42
|
-
else
|
|
43
|
-
# for textual fields we pass different options
|
|
44
|
-
text_types = [:text, :string, :integer, :float, :decimal, :date, :time, :datetime]
|
|
45
|
-
options = active_scaffold_input_text_options(options) if text_types.include?(column.column.type)
|
|
46
|
-
if column.column.type == :string && options[:maxlength].blank?
|
|
47
|
-
options[:maxlength] = column.column.limit
|
|
48
|
-
options[:size] ||= ActionView::Helpers::InstanceTag::DEFAULT_FIELD_OPTIONS["size"]
|
|
49
|
-
end
|
|
50
|
-
options[:include_blank] = true if column.column.null and [:date, :datetime, :time].include?(column.column.type)
|
|
51
|
-
options[:value] = format_number_value(@record.send(column.name), column.options) if column.number?
|
|
52
|
-
text_field(:record, column.name, options.merge(column.options))
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
rescue Exception => e
|
|
57
|
-
logger.error Time.now.to_s + "#{e.inspect} -- on the ActiveScaffold column = :#{column.name} in #{controller.class}"
|
|
58
|
-
raise e
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
# the standard active scaffold options used for textual inputs
|
|
63
|
-
def active_scaffold_input_text_options(options = {})
|
|
64
|
-
options[:autocomplete] = 'off'
|
|
65
|
-
options[:class] = "#{options[:class]} text-input".strip
|
|
66
|
-
options
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
# the standard active scaffold options used for class, name and scope
|
|
70
|
-
def active_scaffold_input_options(column, scope = nil, options = {})
|
|
71
|
-
name = scope ? "record#{scope}[#{column.name}]" : "record[#{column.name}]"
|
|
72
|
-
|
|
73
|
-
# Fix for keeping unique IDs in subform
|
|
74
|
-
id_control = "record_#{column.name}_#{[params[:eid], params[:id]].compact.join '_'}"
|
|
75
|
-
id_control += scope_id(scope) if scope
|
|
76
|
-
|
|
77
|
-
classes = "#{column.name}-input"
|
|
78
|
-
classes += ' numeric-input' if column.number?
|
|
79
|
-
|
|
80
|
-
{ :name => name, :class => classes, :id => id_control}.merge(options)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def update_columns_options(column, scope, options)
|
|
84
|
-
if column.update_columns
|
|
85
|
-
form_action = params[:action] == 'edit' ? :update : :create
|
|
86
|
-
url_params = {:action => 'render_field', :id => params[:id], :column => column.name}
|
|
87
|
-
url_params[:eid] = params[:eid] if params[:eid]
|
|
88
|
-
url_params[:controller] = controller.class.active_scaffold_controller_for(@record.class).controller_path if scope
|
|
89
|
-
url_params[:scope] = scope if scope
|
|
90
|
-
|
|
91
|
-
options[:class] = "#{options[:class]} update_form".strip
|
|
92
|
-
options['data-update_url'] = url_for(url_params)
|
|
93
|
-
options['data-update_send_form'] = true if column.send_form_on_update_column
|
|
94
|
-
options['data-update_send_form_selector'] = column.options[:send_form_selector] if column.options[:send_form_selector]
|
|
95
|
-
end
|
|
96
|
-
options
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
##
|
|
100
|
-
## Form input methods
|
|
101
|
-
##
|
|
102
|
-
|
|
103
|
-
def active_scaffold_translate_select_options(options)
|
|
104
|
-
options[:include_blank] = as_(options[:include_blank]) if options[:include_blank].is_a? Symbol
|
|
105
|
-
options[:prompt] = as_(options[:prompt]) if options[:prompt].is_a? Symbol
|
|
106
|
-
options
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def active_scaffold_input_singular_association(column, html_options)
|
|
110
|
-
associated = @record.send(column.association.name)
|
|
111
|
-
|
|
112
|
-
select_options = options_for_association(column.association)
|
|
113
|
-
select_options.unshift([ associated.to_label, associated.id ]) unless associated.nil? or select_options.find {|label, id| id == associated.id}
|
|
114
|
-
|
|
115
|
-
method = column.name
|
|
116
|
-
#html_options[:name] += '[id]'
|
|
117
|
-
options = {:selected => associated.try(:id), :include_blank => as_(:_select_)}
|
|
118
|
-
|
|
119
|
-
html_options.update(column.options[:html_options] || {})
|
|
120
|
-
options.update(column.options)
|
|
121
|
-
html_options[:name] = "#{html_options[:name]}[]" if (html_options[:multiple] == true && !html_options[:name].to_s.ends_with?("[]"))
|
|
122
|
-
active_scaffold_translate_select_options(options)
|
|
123
|
-
select(:record, method, select_options.uniq, options, html_options)
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
def active_scaffold_input_plural_association(column, options)
|
|
127
|
-
associated_options = @record.send(column.association.name).collect {|r| [r.to_label, r.id]}
|
|
128
|
-
select_options = associated_options | options_for_association(column.association)
|
|
129
|
-
return content_tag(:span, as_(:no_options), :class => options[:class], :id => options[:id]) if select_options.empty?
|
|
130
|
-
|
|
131
|
-
active_scaffold_checkbox_list(column, select_options, associated_options.collect {|a| a[1]}, options)
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
def active_scaffold_checkbox_list(column, select_options, associated_ids, options)
|
|
135
|
-
html = content_tag :ul, :class => "#{options[:class]} checkbox-list", :id => options[:id] do
|
|
136
|
-
content = hidden_field_tag("#{options[:name]}[]", '')
|
|
137
|
-
select_options.each_with_index do |option, i|
|
|
138
|
-
label, id = option
|
|
139
|
-
this_id = "#{options[:id]}_#{i}_id"
|
|
140
|
-
content << content_tag(:li) do
|
|
141
|
-
check_box_tag("#{options[:name]}[]", id, associated_ids.include?(id), :id => this_id) <<
|
|
142
|
-
content_tag(:label, h(label), :for => this_id)
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
content
|
|
146
|
-
end
|
|
147
|
-
html << javascript_tag("ActiveScaffold.draggable_lists('#{options[:id]}')") if column.options[:draggable_lists]
|
|
148
|
-
html
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
def active_scaffold_translated_option(column, text, value = nil)
|
|
152
|
-
value = text if value.nil?
|
|
153
|
-
[(text.is_a?(Symbol) ? column.active_record_class.human_attribute_name(text) : text), value]
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
def active_scaffold_input_enum(column, html_options)
|
|
157
|
-
options = { :selected => @record.send(column.name) }
|
|
158
|
-
options_for_select = column.options[:options].collect do |text, value|
|
|
159
|
-
active_scaffold_translated_option(column, text, value)
|
|
160
|
-
end
|
|
161
|
-
html_options.update(column.options[:html_options] || {})
|
|
162
|
-
options.update(column.options)
|
|
163
|
-
active_scaffold_translate_select_options(options)
|
|
164
|
-
select(:record, column.name, options_for_select, options, html_options)
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
def active_scaffold_input_select(column, html_options)
|
|
168
|
-
if column.singular_association?
|
|
169
|
-
active_scaffold_input_singular_association(column, html_options)
|
|
170
|
-
elsif column.plural_association?
|
|
171
|
-
active_scaffold_input_plural_association(column, html_options)
|
|
172
|
-
else
|
|
173
|
-
active_scaffold_input_enum(column, html_options)
|
|
174
|
-
end
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
def active_scaffold_input_radio(column, html_options)
|
|
178
|
-
html_options.update(column.options[:html_options] || {})
|
|
179
|
-
column.options[:options].inject('') do |html, (text, value)|
|
|
180
|
-
text, value = active_scaffold_translated_option(column, text, value)
|
|
181
|
-
html << content_tag(:label, radio_button(:record, column.name, value, html_options.merge(:id => html_options[:id] + '-' + value.to_s)) + text)
|
|
182
|
-
end.html_safe
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
def active_scaffold_input_checkbox(column, options)
|
|
186
|
-
check_box(:record, column.name, options.merge(column.options))
|
|
187
|
-
end
|
|
188
|
-
|
|
189
|
-
def active_scaffold_input_password(column, options)
|
|
190
|
-
options = active_scaffold_input_text_options(options)
|
|
191
|
-
password_field :record, column.name, options.merge(column.options)
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
def active_scaffold_input_textarea(column, options)
|
|
195
|
-
text_area(:record, column.name, options.merge(:cols => column.options[:cols], :rows => column.options[:rows], :size => column.options[:size]))
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
def active_scaffold_input_virtual(column, options)
|
|
199
|
-
options = active_scaffold_input_text_options(options)
|
|
200
|
-
text_field :record, column.name, options.merge(column.options)
|
|
201
|
-
end
|
|
202
|
-
|
|
203
|
-
#
|
|
204
|
-
# Column.type-based inputs
|
|
205
|
-
#
|
|
206
|
-
|
|
207
|
-
def active_scaffold_input_boolean(column, options)
|
|
208
|
-
select_options = []
|
|
209
|
-
select_options << [as_(:_select_), nil] if !column.virtual? && column.column.null
|
|
210
|
-
select_options << [as_(:true), true]
|
|
211
|
-
select_options << [as_(:false), false]
|
|
212
|
-
|
|
213
|
-
select_tag(options[:name], options_for_select(select_options, @record.send(column.name)), options)
|
|
214
|
-
end
|
|
215
|
-
|
|
216
|
-
def onsubmit
|
|
217
|
-
end
|
|
218
|
-
|
|
219
|
-
##
|
|
220
|
-
## Form column override signatures
|
|
221
|
-
##
|
|
222
|
-
|
|
223
|
-
# add functionality for overriding subform partials from association class path
|
|
224
|
-
def override_subform_partial?(column, subform_partial)
|
|
225
|
-
template_exists?(override_subform_partial(column, subform_partial), true)
|
|
226
|
-
end
|
|
227
|
-
|
|
228
|
-
def override_subform_partial(column, subform_partial)
|
|
229
|
-
File.join(active_scaffold_controller_for(column.association.klass).controller_path, subform_partial) if column_renders_as(column) == :subform
|
|
230
|
-
end
|
|
231
|
-
|
|
232
|
-
def override_form_field_partial?(column)
|
|
233
|
-
template_exists?(override_form_field_partial(column), true)
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
# the naming convention for overriding form fields with helpers
|
|
237
|
-
def override_form_field_partial(column)
|
|
238
|
-
path = active_scaffold_controller_for(column.active_record_class).controller_path
|
|
239
|
-
File.join(path, "#{clean_column_name(column.name)}_form_column")
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
def override_form_field(column)
|
|
243
|
-
override_helper column, 'form_column'
|
|
244
|
-
end
|
|
245
|
-
alias_method :override_form_field?, :override_form_field
|
|
246
|
-
|
|
247
|
-
# the naming convention for overriding form input types with helpers
|
|
248
|
-
def override_input(form_ui)
|
|
249
|
-
method = "active_scaffold_input_#{form_ui}"
|
|
250
|
-
method if respond_to? method
|
|
251
|
-
end
|
|
252
|
-
alias_method :override_input?, :override_input
|
|
253
|
-
|
|
254
|
-
def form_partial_for_column(column, renders_as = nil)
|
|
255
|
-
renders_as ||= column_renders_as(column)
|
|
256
|
-
if override_form_field_partial?(column)
|
|
257
|
-
override_form_field_partial(column)
|
|
258
|
-
elsif renders_as == :field or override_form_field?(column)
|
|
259
|
-
"form_attribute"
|
|
260
|
-
elsif renders_as == :subform
|
|
261
|
-
"form_association"
|
|
262
|
-
elsif renders_as == :hidden
|
|
263
|
-
"form_hidden_attribute"
|
|
264
|
-
end
|
|
265
|
-
end
|
|
266
|
-
|
|
267
|
-
def subform_partial_for_column(column)
|
|
268
|
-
subform_partial = "#{active_scaffold_config_for(column.association.klass).subform.layout}_subform"
|
|
269
|
-
if override_subform_partial?(column, subform_partial)
|
|
270
|
-
override_subform_partial(column, subform_partial)
|
|
271
|
-
else
|
|
272
|
-
subform_partial
|
|
273
|
-
end
|
|
274
|
-
end
|
|
275
|
-
|
|
276
|
-
##
|
|
277
|
-
## Macro-level rendering decisions for columns
|
|
278
|
-
##
|
|
279
|
-
|
|
280
|
-
def column_renders_as(column)
|
|
281
|
-
if column.is_a? ActiveScaffold::DataStructures::ActionColumns
|
|
282
|
-
return :subsection
|
|
283
|
-
elsif column.active_record_class.locking_column.to_s == column.name.to_s or column.form_ui == :hidden
|
|
284
|
-
return :hidden
|
|
285
|
-
elsif column.association.nil? or column.form_ui or !active_scaffold_config_for(column.association.klass).actions.include?(:subform)
|
|
286
|
-
return :field
|
|
287
|
-
else
|
|
288
|
-
return :subform
|
|
289
|
-
end
|
|
290
|
-
end
|
|
291
|
-
|
|
292
|
-
def column_scope(column, scope = nil)
|
|
293
|
-
if column.plural_association?
|
|
294
|
-
"#{scope}[#{column.name}][#{@record.id || generate_temporary_id}]"
|
|
295
|
-
else
|
|
296
|
-
"#{scope}[#{column.name}]"
|
|
297
|
-
end
|
|
298
|
-
end
|
|
299
|
-
|
|
300
|
-
def active_scaffold_add_existing_input(options)
|
|
301
|
-
if ActiveScaffold.js_framework == :prototype && controller.respond_to?(:record_select_config)
|
|
302
|
-
remote_controller = active_scaffold_controller_for(record_select_config.model).controller_path
|
|
303
|
-
options.merge!(:controller => remote_controller)
|
|
304
|
-
options.merge!(active_scaffold_input_text_options)
|
|
305
|
-
record_select_field(options[:name], @record, options)
|
|
306
|
-
else
|
|
307
|
-
select_options = options_for_select(options_for_association(nested.association)) #unless column.through_association?
|
|
308
|
-
select_options ||= options_for_select(active_scaffold_config.model.all.collect {|c| [h(c.to_label), c.id]})
|
|
309
|
-
select_tag 'associated_id', ('<option value="">' + as_(:_select_) + '</option>' + select_options).html_safe unless select_options.empty?
|
|
310
|
-
end
|
|
311
|
-
end
|
|
312
|
-
|
|
313
|
-
def active_scaffold_add_existing_label
|
|
314
|
-
if controller.respond_to?(:record_select_config)
|
|
315
|
-
record_select_config.model.model_name.human
|
|
316
|
-
else
|
|
317
|
-
active_scaffold_config.model.model_name.human
|
|
318
|
-
end
|
|
319
|
-
end
|
|
320
|
-
end
|
|
321
|
-
end
|
|
322
|
-
end
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
module ActiveScaffold
|
|
2
|
-
module Helpers
|
|
3
|
-
# Helpers that assist with rendering of a human readable search statement
|
|
4
|
-
module HumanConditionHelpers
|
|
5
|
-
|
|
6
|
-
def active_scaffold_human_condition_for(column)
|
|
7
|
-
value = field_search_params[column.name]
|
|
8
|
-
search_ui = column.search_ui
|
|
9
|
-
search_ui ||= column.column.type if column.column
|
|
10
|
-
if override_human_condition_column?(column)
|
|
11
|
-
send(override_human_condition_column(column), value, {})
|
|
12
|
-
elsif search_ui and override_human_condition?(column.search_ui)
|
|
13
|
-
send(override_human_condition(column.search_ui), column, value)
|
|
14
|
-
else
|
|
15
|
-
case search_ui
|
|
16
|
-
when :integer, :decimal, :float
|
|
17
|
-
"#{column.active_record_class.human_attribute_name(column.name)} #{as_(value[:opt].downcase).downcase} #{format_number_value(controller.class.condition_value_for_numeric(column, value[:from]), column.options) if value[:from].present?} #{value[:opt] == 'BETWEEN' ? '- ' + format_number_value(controller.class.condition_value_for_numeric(column, value[:to]), column.options).to_s : ''}"
|
|
18
|
-
when :string
|
|
19
|
-
opt = ActiveScaffold::Finder::StringComparators.index(value[:opt]) || value[:opt]
|
|
20
|
-
"#{column.active_record_class.human_attribute_name(column.name)} #{as_(opt).downcase} '#{value[:from]}' #{opt == 'BETWEEN' ? '- ' + value[:to].to_s : ''}"
|
|
21
|
-
when :date, :time, :datetime, :timestamp
|
|
22
|
-
conversion = column.column.type == :date ? :to_date : :to_time
|
|
23
|
-
from = controller.condition_value_for_datetime(value[:from], conversion)
|
|
24
|
-
to = controller.condition_value_for_datetime(value[:to], conversion)
|
|
25
|
-
"#{column.active_record_class.human_attribute_name(column.name)} #{as_(value[:opt])} #{I18n.l(from)} #{value[:opt] == 'BETWEEN' ? '- ' + I18n.l(to) : ''}"
|
|
26
|
-
when :select, :multi_select, :record_select
|
|
27
|
-
associated = value
|
|
28
|
-
associated = [associated].compact unless associated.is_a? Array
|
|
29
|
-
if column.association
|
|
30
|
-
associated = column.association.klass.where(:id => associated.map(&:to_i)).collect(&:to_label)
|
|
31
|
-
elsif column.options[:options]
|
|
32
|
-
associated = associated.collect do |value|
|
|
33
|
-
text, val = column.options[:options].find {|text, val| (val.nil? ? text : val).to_s == value.to_s}
|
|
34
|
-
value = active_scaffold_translated_option(column, text, val).first if text
|
|
35
|
-
value
|
|
36
|
-
end
|
|
37
|
-
end
|
|
38
|
-
as_(:association, :scope => :human_conditions, :column => column.active_record_class.human_attribute_name(column.name), :value => associated.join(', '))
|
|
39
|
-
when :boolean, :checkbox
|
|
40
|
-
label = column.column.type_cast(value) ? as_(:true) : as_(:false)
|
|
41
|
-
as_(:boolean, :scope => :human_conditions, :column => column.active_record_class.human_attribute_name(column.name), :value => label)
|
|
42
|
-
when :null
|
|
43
|
-
"#{column.active_record_class.human_attribute_name(column.name)} #{as_(value.to_sym)}"
|
|
44
|
-
end
|
|
45
|
-
end unless value.nil?
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
# the naming convention for overriding form fields with helpers
|
|
49
|
-
def override_human_condition_column(column)
|
|
50
|
-
override_helper column, 'human_condition_column'
|
|
51
|
-
end
|
|
52
|
-
alias_method :override_human_condition_column?, :override_human_condition_column
|
|
53
|
-
|
|
54
|
-
def override_human_condition?(search_ui)
|
|
55
|
-
respond_to?(override_human_condition(search_ui))
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
# the naming convention for overriding human condition search_ui types
|
|
59
|
-
def override_human_condition(search_ui)
|
|
60
|
-
"active_scaffold_human_condition_#{search_ui}"
|
|
61
|
-
end
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|