active_scaffold 3.2.17 → 3.2.18
Sign up to get free protection for your applications and to get access to all the features.
- 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,31 +0,0 @@
|
|
1
|
-
module ActiveScaffold::Config
|
2
|
-
class Show < Base
|
3
|
-
self.crud_type = :read
|
4
|
-
|
5
|
-
def initialize(core_config)
|
6
|
-
super
|
7
|
-
# start with the ActionLink defined globally
|
8
|
-
@link = self.class.link.clone
|
9
|
-
end
|
10
|
-
|
11
|
-
# global level configuration
|
12
|
-
# --------------------------
|
13
|
-
cattr_accessor :link
|
14
|
-
@@link = ActiveScaffold::DataStructures::ActionLink.new('show', :label => :show, :type => :member, :security_method => :show_authorized?, :ignore_method => :show_ignore?)
|
15
|
-
# instance-level configuration
|
16
|
-
# ----------------------------
|
17
|
-
|
18
|
-
# the ActionLink for this action
|
19
|
-
attr_accessor :link
|
20
|
-
# the label for this action. used for the header.
|
21
|
-
attr_writer :label
|
22
|
-
|
23
|
-
# provides access to the list of columns specifically meant for this action to use
|
24
|
-
def columns
|
25
|
-
self.columns = @core.columns._inheritable unless @columns # lazy evaluation
|
26
|
-
@columns
|
27
|
-
end
|
28
|
-
|
29
|
-
public :columns=
|
30
|
-
end
|
31
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
module ActiveScaffold::Config
|
2
|
-
class Subform < Base
|
3
|
-
def initialize(core_config)
|
4
|
-
super
|
5
|
-
@layout = self.class.layout # default layout
|
6
|
-
end
|
7
|
-
|
8
|
-
# global level configuration
|
9
|
-
# --------------------------
|
10
|
-
|
11
|
-
cattr_accessor :layout
|
12
|
-
@@layout = :horizontal
|
13
|
-
|
14
|
-
# instance-level configuration
|
15
|
-
# ----------------------------
|
16
|
-
|
17
|
-
attr_accessor :layout
|
18
|
-
|
19
|
-
# provides access to the list of columns specifically meant for the Sub-Form to use
|
20
|
-
def columns
|
21
|
-
# we want to delay initializing to the @core.update.columns set for as long as possible. but we have to eventually clone, or else have a configuration "leak"
|
22
|
-
unless @columns
|
23
|
-
if @core.actions.include? :update
|
24
|
-
@columns = @core.update.columns.clone
|
25
|
-
else
|
26
|
-
self.columns = @core.columns._inheritable
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
@columns
|
31
|
-
end
|
32
|
-
|
33
|
-
public :columns=
|
34
|
-
end
|
35
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module ActiveScaffold::Config
|
2
|
-
class Update < ActiveScaffold::Config::Form
|
3
|
-
self.crud_type = :update
|
4
|
-
def initialize(core_config)
|
5
|
-
super
|
6
|
-
self.nested_links = self.class.nested_links
|
7
|
-
end
|
8
|
-
|
9
|
-
# global level configuration
|
10
|
-
# --------------------------
|
11
|
-
# the ActionLink for this action
|
12
|
-
def self.link
|
13
|
-
@@link
|
14
|
-
end
|
15
|
-
def self.link=(val)
|
16
|
-
@@link = val
|
17
|
-
end
|
18
|
-
@@link = ActiveScaffold::DataStructures::ActionLink.new('edit', :label => :edit, :type => :member, :security_method => :update_authorized?, :ignore_method => :update_ignore?)
|
19
|
-
|
20
|
-
# instance-level configuration
|
21
|
-
# ----------------------------
|
22
|
-
|
23
|
-
attr_accessor :nested_links
|
24
|
-
cattr_accessor :nested_links
|
25
|
-
@@nested_links = false
|
26
|
-
|
27
|
-
attr_writer :hide_nested_column
|
28
|
-
def hide_nested_column
|
29
|
-
@hide_nested_column.nil? ? true : @hide_nested_column
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module ActiveScaffold
|
2
|
-
# Exposes a +configure+ method that accepts a block and runs all contents of the block in two contexts, as opposed to the normal one. First, everything gets evaluated as part of the object including Configurable. Then, as a failover, missing methods and variables are evaluated in the original binding of the block.
|
3
|
-
#
|
4
|
-
# Note that this only works with "barewords". Constants, instance variables, and class variables are not currently supported in both contexts.
|
5
|
-
#
|
6
|
-
# May add the given functionality at both the class and instance level. For the former, use +extend+, and for the latter, use +include+.
|
7
|
-
module Configurable
|
8
|
-
def configure(&configuration_block)
|
9
|
-
return unless configuration_block
|
10
|
-
@configuration_binding = configuration_block.binding
|
11
|
-
ret = instance_exec self, &configuration_block
|
12
|
-
@configuration_binding = nil
|
13
|
-
return ret
|
14
|
-
end
|
15
|
-
|
16
|
-
# this method will surely need tweaking. for example, i'm not sure if it should call super before or after it tries to eval with the binding.
|
17
|
-
def method_missing(name, *args)
|
18
|
-
begin
|
19
|
-
super
|
20
|
-
rescue NoMethodError, NameError
|
21
|
-
if @configuration_binding.nil?
|
22
|
-
raise $!
|
23
|
-
else
|
24
|
-
eval("self", @configuration_binding).send(name, *args)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,171 +0,0 @@
|
|
1
|
-
module ActiveScaffold
|
2
|
-
module Constraints
|
3
|
-
|
4
|
-
protected
|
5
|
-
|
6
|
-
# Returns the current constraints
|
7
|
-
def active_scaffold_constraints
|
8
|
-
@active_scaffold_constraints ||= active_scaffold_session_storage[:constraints] || {}
|
9
|
-
end
|
10
|
-
|
11
|
-
# For each enabled action, adds the constrained columns to the ActionColumns object (if it exists).
|
12
|
-
# This lets the ActionColumns object skip constrained columns.
|
13
|
-
#
|
14
|
-
# If the constraint value is a Hash, then we assume the constraint is a multi-level association constraint (the reverse of a has_many :through) and we do NOT register the constraint column.
|
15
|
-
def register_constraints_with_action_columns(constrained_fields = nil)
|
16
|
-
constrained_fields ||= []
|
17
|
-
constrained_fields |= active_scaffold_constraints.reject{|k, v| v.is_a? Hash}.keys.collect(&:to_sym)
|
18
|
-
exclude_actions = []
|
19
|
-
[:list, :update].each do |action_name|
|
20
|
-
if active_scaffold_config.actions.include? action_name
|
21
|
-
exclude_actions << action_name unless active_scaffold_config.send(action_name).hide_nested_column
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
if self.class.uses_active_scaffold?
|
26
|
-
# we actually want to do this whether constrained_fields exist or not, so that we can reset the array when they don't
|
27
|
-
active_scaffold_config.actions.each do |action_name|
|
28
|
-
next if exclude_actions.include?(action_name)
|
29
|
-
action = active_scaffold_config.send(action_name)
|
30
|
-
next unless action.respond_to? :columns
|
31
|
-
action.columns.constraint_columns = constrained_fields
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# Returns search conditions based on the current scaffold constraints.
|
37
|
-
#
|
38
|
-
# Supports constraints based on either a column name (in which case it checks for an association
|
39
|
-
# or just uses the search_sql) or a database field name.
|
40
|
-
#
|
41
|
-
# All of this work is primarily to support nested scaffolds in a manner generally useful for other
|
42
|
-
# embedded scaffolds.
|
43
|
-
def conditions_from_constraints
|
44
|
-
hash_conditions = {}
|
45
|
-
conditions = [hash_conditions]
|
46
|
-
active_scaffold_constraints.each do |k, v|
|
47
|
-
column = active_scaffold_config.columns[k]
|
48
|
-
if column
|
49
|
-
# Assume this is a multi-level association constraint.
|
50
|
-
# example:
|
51
|
-
# data model: Park -> Den -> Bear
|
52
|
-
# constraint: :den => {:park => 5}
|
53
|
-
if v.is_a? Hash
|
54
|
-
far_association = column.association.klass.reflect_on_association(v.keys.first)
|
55
|
-
field = far_association.klass.primary_key
|
56
|
-
table = far_association.table_name
|
57
|
-
|
58
|
-
active_scaffold_includes.concat([{k => far_association.name}]) # e.g. {:den => :park}
|
59
|
-
hash_conditions.merge!("#{table}.#{field}" => v.values.first)
|
60
|
-
|
61
|
-
# association column constraint
|
62
|
-
elsif column.association
|
63
|
-
if column.association.macro == :has_and_belongs_to_many
|
64
|
-
active_scaffold_habtm_joins.concat column.includes
|
65
|
-
else
|
66
|
-
active_scaffold_includes.concat column.includes
|
67
|
-
end
|
68
|
-
hash_conditions.merge!(condition_from_association_constraint(column.association, v))
|
69
|
-
|
70
|
-
# regular column constraints
|
71
|
-
elsif column.searchable? && params[column.name] != v
|
72
|
-
active_scaffold_includes.concat column.includes
|
73
|
-
conditions << [column.search_sql.collect { |search_sql| "#{search_sql} = ?" }.join(' OR '), *([v] * column.search_sql.size)]
|
74
|
-
end
|
75
|
-
# unknown-to-activescaffold-but-real-database-column constraint
|
76
|
-
elsif active_scaffold_config.model.columns_hash[k.to_s] && params[column.name] != v
|
77
|
-
hash_conditions.merge!(k => v)
|
78
|
-
else
|
79
|
-
raise ActiveScaffold::MalformedConstraint, constraint_error(active_scaffold_config.model, k), caller
|
80
|
-
end
|
81
|
-
end
|
82
|
-
conditions
|
83
|
-
end
|
84
|
-
|
85
|
-
# We do NOT want to use .search_sql. If anything, search_sql will refer
|
86
|
-
# to a human-searchable value on the associated record.
|
87
|
-
def condition_from_association_constraint(association, value)
|
88
|
-
# when the reverse association is a :belongs_to, the id for the associated object only exists as
|
89
|
-
# the primary_key on the other table. so for :has_one and :has_many (when the reverse is :belongs_to),
|
90
|
-
# we have to use the other model's primary_key.
|
91
|
-
#
|
92
|
-
# please see the relevant tests for concrete examples.
|
93
|
-
field = if [:has_one, :has_many].include?(association.macro)
|
94
|
-
association.klass.primary_key
|
95
|
-
elsif [:has_and_belongs_to_many].include?(association.macro)
|
96
|
-
association.association_foreign_key
|
97
|
-
else
|
98
|
-
association.options[:foreign_key] || association.name.to_s.foreign_key
|
99
|
-
end
|
100
|
-
|
101
|
-
table = case association.macro
|
102
|
-
when :has_and_belongs_to_many
|
103
|
-
association.options[:join_table]
|
104
|
-
|
105
|
-
when :belongs_to
|
106
|
-
active_scaffold_config.model.table_name
|
107
|
-
|
108
|
-
else
|
109
|
-
association.table_name
|
110
|
-
end
|
111
|
-
|
112
|
-
if association.options[:primary_key]
|
113
|
-
value = association.klass.find(value).send(association.options[:primary_key])
|
114
|
-
end
|
115
|
-
|
116
|
-
condition = {"#{table}.#{field}" => value}
|
117
|
-
if association.options[:polymorphic]
|
118
|
-
raise ActiveScaffold::MalformedConstraint, polymorphic_constraint_error(association), caller unless params[:parent_model]
|
119
|
-
condition["#{table}.#{association.name}_type"] = params[:parent_model].constantize.model.to_s
|
120
|
-
end
|
121
|
-
|
122
|
-
condition
|
123
|
-
end
|
124
|
-
|
125
|
-
def polymorphic_constraint_error(association)
|
126
|
-
"Malformed constraint. You have added a constraint for #{association.name} polymorphic association but parent_model is not set."
|
127
|
-
end
|
128
|
-
|
129
|
-
def constraint_error(klass, column_name)
|
130
|
-
"Malformed constraint `#{klass}##{column_name}'. If it's a legitimate column, and you are using a nested scaffold, please specify or double-check the reverse association name."
|
131
|
-
end
|
132
|
-
|
133
|
-
# Applies constraints to the given record.
|
134
|
-
#
|
135
|
-
# Searches through the known columns for association columns. If the given constraint is an association,
|
136
|
-
# it assumes that the constraint value is an id. It then does a association.klass.find with the value
|
137
|
-
# and adds the associated object to the record.
|
138
|
-
#
|
139
|
-
# For some operations ActiveRecord will automatically update the database. That's not always ok.
|
140
|
-
# If it *is* ok (e.g. you're in a transaction), then set :allow_autosave to true.
|
141
|
-
def apply_constraints_to_record(record, options = {})
|
142
|
-
options[:allow_autosave] = false if options[:allow_autosave].nil?
|
143
|
-
|
144
|
-
active_scaffold_constraints.each do |k, v|
|
145
|
-
column = active_scaffold_config.columns[k]
|
146
|
-
if column and column.association
|
147
|
-
if column.plural_association?
|
148
|
-
record.send("#{k}").send(:<<, column.association.klass.find(v))
|
149
|
-
elsif column.association.options[:polymorphic]
|
150
|
-
raise ActiveScaffold::MalformedConstraint, polymorphic_constraint_error(column.association), caller unless params[:parent_model]
|
151
|
-
record.send("#{k}=", params[:parent_model].constantize.find(v))
|
152
|
-
else # regular singular association
|
153
|
-
record.send("#{k}=", column.association.klass.find(v))
|
154
|
-
|
155
|
-
# setting the belongs_to side of a has_one isn't safe. if the has_one was already
|
156
|
-
# specified, rails won't automatically clear out the previous associated record.
|
157
|
-
#
|
158
|
-
# note that we can't take the extra step to correct this unless we're permitted to
|
159
|
-
# run operations where activerecord auto-saves the object.
|
160
|
-
reverse = column.association.klass.reflect_on_association(column.association.reverse)
|
161
|
-
if reverse.macro == :has_one and options[:allow_autosave]
|
162
|
-
record.send(k).send("#{column.association.reverse}=", record)
|
163
|
-
end
|
164
|
-
end
|
165
|
-
else
|
166
|
-
record.send("#{k}=", v)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
@@ -1,142 +0,0 @@
|
|
1
|
-
module ActiveScaffold::DataStructures
|
2
|
-
# A set of columns. These structures can be nested for organization.
|
3
|
-
class ActionColumns < ActiveScaffold::DataStructures::Set
|
4
|
-
include ActiveScaffold::Configurable
|
5
|
-
|
6
|
-
# this lets us refer back to the action responsible for this link, if it exists.
|
7
|
-
# the immediate need here is to get the crud_type so we can dynamically filter columns from the set.
|
8
|
-
attr_accessor :action
|
9
|
-
|
10
|
-
# labels are useful for the Create/Update forms, when we display columns in a grouped fashion and want to name them separately
|
11
|
-
attr_writer :label
|
12
|
-
def label
|
13
|
-
as_(@label) if @label
|
14
|
-
end
|
15
|
-
def css_class
|
16
|
-
@label.to_s.underscore
|
17
|
-
end
|
18
|
-
|
19
|
-
# Whether this column set is collapsed by default in contexts where collapsing is supported
|
20
|
-
attr_accessor :collapsed
|
21
|
-
|
22
|
-
# nests a subgroup in the column set
|
23
|
-
def add_subgroup(label, &proc)
|
24
|
-
columns = ActiveScaffold::DataStructures::ActionColumns.new
|
25
|
-
columns.label = label
|
26
|
-
columns.action = self.action
|
27
|
-
columns.configure &proc
|
28
|
-
self.exclude columns.collect_columns
|
29
|
-
self.add columns
|
30
|
-
end
|
31
|
-
|
32
|
-
def include?(item)
|
33
|
-
@set.each do |c|
|
34
|
-
return true if !c.is_a? Symbol and c.include? item
|
35
|
-
return true if c == item.to_sym
|
36
|
-
end
|
37
|
-
return false
|
38
|
-
end
|
39
|
-
|
40
|
-
def names
|
41
|
-
if @columns
|
42
|
-
self.collect(&:name)
|
43
|
-
else
|
44
|
-
names_without_auth_check
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
def names_without_auth_check
|
49
|
-
Array(@set)
|
50
|
-
end
|
51
|
-
|
52
|
-
# A package of stuff to add after the configuration block. This is an attempt at making a certain level of functionality inaccessible during configuration, to reduce possible breakage from misuse.
|
53
|
-
# The bulk of the package is a means of connecting the referential column set (ActionColumns) with the actual column objects (Columns). This lets us iterate over the set and yield real column objects.
|
54
|
-
#module AfterConfiguration
|
55
|
-
# Redefine the each method to yield actual Column objects.
|
56
|
-
# It will skip constrained and unauthorized columns.
|
57
|
-
#
|
58
|
-
# Options:
|
59
|
-
# * :flatten - whether to recursively iterate on nested sets. default is false.
|
60
|
-
# * :for - the record (or class) being iterated over. used for column-level security. default is the class.
|
61
|
-
def each(options = {}, &proc)
|
62
|
-
options[:for] ||= @columns.active_record_class unless @columns.nil?
|
63
|
-
self.unauthorized_columns = []
|
64
|
-
@set.each do |item|
|
65
|
-
unless item.is_a?(ActiveScaffold::DataStructures::ActionColumns) || @columns.nil?
|
66
|
-
item = (@columns[item] || ActiveScaffold::DataStructures::Column.new(item.to_sym, @columns.active_record_class))
|
67
|
-
next if self.skip_column?(item, options)
|
68
|
-
end
|
69
|
-
if item.is_a? ActiveScaffold::DataStructures::ActionColumns and options.has_key?(:flatten) and options[:flatten]
|
70
|
-
item.each(options, &proc)
|
71
|
-
else
|
72
|
-
yield item
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def collect_visible(options = {}, &proc)
|
78
|
-
columns = []
|
79
|
-
options[:for] ||= @columns.active_record_class
|
80
|
-
self.unauthorized_columns = []
|
81
|
-
@set.each do |item|
|
82
|
-
unless item.is_a? ActiveScaffold::DataStructures::ActionColumns
|
83
|
-
item = (@columns[item] || ActiveScaffold::DataStructures::Column.new(item.to_sym, @columns.active_record_class))
|
84
|
-
next if self.skip_column?(item, options)
|
85
|
-
end
|
86
|
-
if item.is_a? ActiveScaffold::DataStructures::ActionColumns and options.has_key?(:flatten) and options[:flatten]
|
87
|
-
columns = columns + item.collect(options, &proc)
|
88
|
-
else
|
89
|
-
columns << item
|
90
|
-
end
|
91
|
-
end
|
92
|
-
columns
|
93
|
-
end
|
94
|
-
|
95
|
-
def skip_column?(column, options)
|
96
|
-
result = false
|
97
|
-
# skip if this matches a constrained column
|
98
|
-
result = true if constraint_columns.include?(column.name.to_sym)
|
99
|
-
# skip this field if it's not authorized
|
100
|
-
unless options[:for].authorized_for?(:action => options[:action], :crud_type => options[:crud_type] || self.action.crud_type, :column => column.name)
|
101
|
-
self.unauthorized_columns << column.name.to_sym
|
102
|
-
result = true
|
103
|
-
end
|
104
|
-
return result
|
105
|
-
end
|
106
|
-
|
107
|
-
# registers a set of column objects (recursively, for all nested ActionColumns)
|
108
|
-
def set_columns(columns)
|
109
|
-
@columns = columns
|
110
|
-
# iterate over @set instead of self to avoid dealing with security queries
|
111
|
-
@set.each do |item|
|
112
|
-
item.set_columns(columns) if item.respond_to? :set_columns
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
attr_writer :constraint_columns
|
117
|
-
def constraint_columns
|
118
|
-
@constraint_columns ||= []
|
119
|
-
end
|
120
|
-
|
121
|
-
attr_writer :unauthorized_columns
|
122
|
-
def unauthorized_columns
|
123
|
-
@unauthorized_columns ||= []
|
124
|
-
end
|
125
|
-
|
126
|
-
def length
|
127
|
-
((@set - self.constraint_columns) - self.unauthorized_columns).length
|
128
|
-
end
|
129
|
-
#end
|
130
|
-
|
131
|
-
protected
|
132
|
-
|
133
|
-
def collect_columns
|
134
|
-
@set.collect {|col| col.is_a?(ActiveScaffold::DataStructures::ActionColumns) ? col.collect_columns : col}
|
135
|
-
end
|
136
|
-
|
137
|
-
# called during clone or dup. makes the clone/dup deeper.
|
138
|
-
def initialize_copy(from)
|
139
|
-
@set = from.instance_variable_get('@set').clone
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|