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,22 +0,0 @@
|
|
1
|
-
module ActiveScaffold::Actions
|
2
|
-
module CommonSearch
|
3
|
-
protected
|
4
|
-
def store_search_params_into_session
|
5
|
-
active_scaffold_session_storage[:search] = params.delete :search if params[:search]
|
6
|
-
end
|
7
|
-
|
8
|
-
def search_params
|
9
|
-
active_scaffold_session_storage[:search]
|
10
|
-
end
|
11
|
-
|
12
|
-
def search_ignore?
|
13
|
-
active_scaffold_config.list.always_show_search
|
14
|
-
end
|
15
|
-
|
16
|
-
# The default security delegates to ActiveRecordPermissions.
|
17
|
-
# You may override the method to customize.
|
18
|
-
def search_authorized?
|
19
|
-
authorized_for?(:crud_type => :read)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,203 +0,0 @@
|
|
1
|
-
module ActiveScaffold::Actions
|
2
|
-
module Core
|
3
|
-
def self.included(base)
|
4
|
-
base.class_eval do
|
5
|
-
prepend_before_filter :register_constraints_with_action_columns, :unless => :nested?
|
6
|
-
after_filter :clear_flashes
|
7
|
-
rescue_from ActiveScaffold::RecordNotAllowed, ActiveScaffold::ActionNotAllowed, :with => :deny_access
|
8
|
-
end
|
9
|
-
base.helper_method :nested?
|
10
|
-
base.helper_method :calculate
|
11
|
-
base.helper_method :new_model
|
12
|
-
end
|
13
|
-
def render_field
|
14
|
-
if params[:in_place_editing]
|
15
|
-
render_field_for_inplace_editing
|
16
|
-
else
|
17
|
-
render_field_for_update_columns
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
protected
|
22
|
-
def embedded?
|
23
|
-
@embedded ||= params.delete(:embedded)
|
24
|
-
end
|
25
|
-
|
26
|
-
def nested?
|
27
|
-
false
|
28
|
-
end
|
29
|
-
|
30
|
-
def render_field_for_inplace_editing
|
31
|
-
@record = find_if_allowed(params[:id], :update)
|
32
|
-
render :inline => "<%= active_scaffold_input_for(active_scaffold_config.columns[params[:update_column].to_sym]) %>"
|
33
|
-
end
|
34
|
-
|
35
|
-
def render_field_for_update_columns
|
36
|
-
column = active_scaffold_config.columns[params[:column]]
|
37
|
-
unless column.nil?
|
38
|
-
@source_id = params.delete(:source_id)
|
39
|
-
@columns = column.update_columns
|
40
|
-
@scope = params[:scope]
|
41
|
-
|
42
|
-
if column.send_form_on_update_column
|
43
|
-
if @scope
|
44
|
-
hash = @scope.gsub('[','').split(']').inject(params[:record]) do |hash, index|
|
45
|
-
hash[index]
|
46
|
-
end
|
47
|
-
id = hash[:id]
|
48
|
-
else
|
49
|
-
hash = params[:record]
|
50
|
-
id = params[:id]
|
51
|
-
end
|
52
|
-
@record = id ? find_if_allowed(id, :update) : new_model
|
53
|
-
@record = update_record_from_params(@record, active_scaffold_config.send(@scope ? :subform : (id ? :update : :create)).columns, hash)
|
54
|
-
else
|
55
|
-
@record = new_model
|
56
|
-
value = column_value_from_param_value(@record, column, params[:value])
|
57
|
-
@record.send "#{column.name}=", value
|
58
|
-
end
|
59
|
-
|
60
|
-
after_render_field(@record, column)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
# override this method if you want to do something after render_field
|
65
|
-
def after_render_field(record, column); end
|
66
|
-
|
67
|
-
def authorized_for?(options = {})
|
68
|
-
active_scaffold_config.model.authorized_for?(options)
|
69
|
-
end
|
70
|
-
|
71
|
-
def clear_flashes
|
72
|
-
if request.xhr?
|
73
|
-
flash.keys.each do |flash_key|
|
74
|
-
flash[flash_key] = nil
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def each_marked_record(&block)
|
80
|
-
active_scaffold_config.model.find(marked_records.to_a).each &block
|
81
|
-
end
|
82
|
-
|
83
|
-
def marked_records
|
84
|
-
active_scaffold_session_storage[:marked_records] ||= Set.new
|
85
|
-
end
|
86
|
-
|
87
|
-
def default_formats
|
88
|
-
[:html, :js, :json, :xml, :yaml]
|
89
|
-
end
|
90
|
-
# Returns true if the client accepts one of the MIME types passed to it
|
91
|
-
# ex: accepts? :html, :xml
|
92
|
-
def accepts?(*types)
|
93
|
-
for priority in request.accepts.compact
|
94
|
-
if priority == Mime::ALL
|
95
|
-
# Because IE always sends */* in the accepts header and we assume
|
96
|
-
# that if you really wanted XML or something else you would say so
|
97
|
-
# explicitly, we will assume */* to only ask for :html
|
98
|
-
return types.include?(:html)
|
99
|
-
elsif types.include?(priority.to_sym)
|
100
|
-
return true
|
101
|
-
end
|
102
|
-
end
|
103
|
-
false
|
104
|
-
end
|
105
|
-
|
106
|
-
def response_status
|
107
|
-
if successful?
|
108
|
-
action_name == 'create' ? 201 : 200
|
109
|
-
else
|
110
|
-
422
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
# API response object that will be converted to XML/YAML/JSON using to_xxx
|
115
|
-
def response_object
|
116
|
-
@response_object = successful? ? (@record || @records) : @record.errors
|
117
|
-
end
|
118
|
-
|
119
|
-
# Success is the existence of one or more model objects. Most actions
|
120
|
-
# circumvent this method by setting @success directly.
|
121
|
-
def successful?
|
122
|
-
if @successful.nil?
|
123
|
-
@record || @records
|
124
|
-
else
|
125
|
-
@successful
|
126
|
-
end
|
127
|
-
end
|
128
|
-
|
129
|
-
def successful=(val)
|
130
|
-
@successful = (val) ? true : false
|
131
|
-
end
|
132
|
-
|
133
|
-
# Redirect to the main page (override if the ActiveScaffold is used as a component on another controllers page) for Javascript degradation
|
134
|
-
def return_to_main
|
135
|
-
redirect_to main_path_to_return
|
136
|
-
end
|
137
|
-
|
138
|
-
# Override this method on your controller to define conditions to be used when querying a recordset (e.g. for List). The return of this method should be any format compatible with the :conditions clause of ActiveRecord::Base's find.
|
139
|
-
def conditions_for_collection
|
140
|
-
end
|
141
|
-
|
142
|
-
# Override this method on your controller to define joins to be used when querying a recordset (e.g. for List). The return of this method should be any format compatible with the :joins clause of ActiveRecord::Base's find.
|
143
|
-
def joins_for_collection
|
144
|
-
end
|
145
|
-
|
146
|
-
# Override this method on your controller to provide custom finder options to the find() call. The return of this method should be a hash.
|
147
|
-
def custom_finder_options
|
148
|
-
{}
|
149
|
-
end
|
150
|
-
|
151
|
-
#Overide this method on your controller to provide model with named scopes
|
152
|
-
def beginning_of_chain
|
153
|
-
active_scaffold_config.model
|
154
|
-
end
|
155
|
-
|
156
|
-
# Builds search conditions by search params for column names. This allows urls like "contacts/list?company_id=5".
|
157
|
-
def conditions_from_params
|
158
|
-
@conditions_from_params ||= begin
|
159
|
-
conditions = {}
|
160
|
-
params.reject {|key, value| [:controller, :action, :id, :page, :sort, :sort_direction].include?(key.to_sym)}.each do |key, value|
|
161
|
-
next unless active_scaffold_config.model.columns_hash[key.to_s]
|
162
|
-
next if active_scaffold_constraints[key.to_sym]
|
163
|
-
next if nested? and nested.constrained_fields.include? key.to_sym
|
164
|
-
conditions[key.to_sym] = value
|
165
|
-
end
|
166
|
-
conditions
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
def new_model
|
171
|
-
model = beginning_of_chain
|
172
|
-
if nested? && nested.association && nested.association.collection? && model.columns_hash[column = model.inheritance_column]
|
173
|
-
model_name = params.delete(column) # in new action inheritance_column must be in params
|
174
|
-
model_name ||= params[:record].delete(column) unless params[:record].blank? # in create action must be inside record key
|
175
|
-
model_name = model_name.camelize if model_name
|
176
|
-
model_name ||= active_scaffold_config.model.name
|
177
|
-
build_options = {column.to_sym => model_name} if model_name
|
178
|
-
end
|
179
|
-
model.respond_to?(:build) ? model.build(build_options || {}) : model.new
|
180
|
-
end
|
181
|
-
|
182
|
-
private
|
183
|
-
def respond_to_action(action)
|
184
|
-
respond_to do |type|
|
185
|
-
action_formats.each do |format|
|
186
|
-
type.send(format) do
|
187
|
-
if respond_to?(method_name = "#{action}_respond_to_#{format}")
|
188
|
-
send(method_name)
|
189
|
-
end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
def action_formats
|
196
|
-
@action_formats ||= if respond_to? "#{action_name}_formats", true
|
197
|
-
send("#{action_name}_formats")
|
198
|
-
else
|
199
|
-
(default_formats + active_scaffold_config.formats).uniq
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
@@ -1,139 +0,0 @@
|
|
1
|
-
module ActiveScaffold::Actions
|
2
|
-
module Create
|
3
|
-
def self.included(base)
|
4
|
-
base.before_filter :create_authorized_filter, :only => [:new, :create]
|
5
|
-
end
|
6
|
-
|
7
|
-
def new
|
8
|
-
do_new
|
9
|
-
respond_to_action(:new)
|
10
|
-
end
|
11
|
-
|
12
|
-
def create
|
13
|
-
do_create
|
14
|
-
respond_to_action(:create)
|
15
|
-
end
|
16
|
-
|
17
|
-
protected
|
18
|
-
def response_location
|
19
|
-
url_for(params_for(:action => "show", :id => @record.id)) if successful?
|
20
|
-
end
|
21
|
-
|
22
|
-
def new_respond_to_html
|
23
|
-
if successful?
|
24
|
-
render(:action => 'create')
|
25
|
-
else
|
26
|
-
return_to_main
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def new_respond_to_js
|
31
|
-
render(:partial => 'create_form')
|
32
|
-
end
|
33
|
-
|
34
|
-
def create_respond_to_html
|
35
|
-
if params[:iframe]=='true' # was this an iframe post ?
|
36
|
-
responds_to_parent do
|
37
|
-
render :action => 'on_create', :formats => [:js], :layout => false
|
38
|
-
end
|
39
|
-
else
|
40
|
-
if successful?
|
41
|
-
flash[:info] = as_(:created_model, :model => @record.to_label)
|
42
|
-
if action = active_scaffold_config.create.action_after_create
|
43
|
-
redirect_to params_for(:action => action, :id => @record.id)
|
44
|
-
elsif active_scaffold_config.create.persistent
|
45
|
-
redirect_to params_for(:action => "new")
|
46
|
-
else
|
47
|
-
return_to_main
|
48
|
-
end
|
49
|
-
else
|
50
|
-
if !nested? && active_scaffold_config.actions.include?(:list) && active_scaffold_config.list.always_show_create
|
51
|
-
list
|
52
|
-
else
|
53
|
-
render(:action => 'create')
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def create_respond_to_js
|
60
|
-
do_refresh_list if successful? && active_scaffold_config.create.refresh_list && !render_parent?
|
61
|
-
render :action => 'on_create'
|
62
|
-
end
|
63
|
-
|
64
|
-
def create_respond_to_xml
|
65
|
-
render :xml => response_object.to_xml(:only => active_scaffold_config.create.columns.names), :content_type => Mime::XML, :status => response_status, :location => response_location
|
66
|
-
end
|
67
|
-
|
68
|
-
def create_respond_to_json
|
69
|
-
render :text => response_object.to_json(:only => active_scaffold_config.create.columns.names), :content_type => Mime::JSON, :status => response_status, :location => response_location
|
70
|
-
end
|
71
|
-
|
72
|
-
def create_respond_to_yaml
|
73
|
-
render :text => Hash.from_xml(response_object.to_xml(:only => active_scaffold_config.create.columns.names)).to_yaml, :content_type => Mime::YAML, :status => response_status, :location => response_location
|
74
|
-
end
|
75
|
-
|
76
|
-
# A simple method to find and prepare an example new record for the form
|
77
|
-
# May be overridden to customize the behavior (add default values, for instance)
|
78
|
-
def do_new
|
79
|
-
@record = new_model
|
80
|
-
apply_constraints_to_record(@record)
|
81
|
-
create_association_with_parent(@record) if nested?
|
82
|
-
@record
|
83
|
-
end
|
84
|
-
|
85
|
-
# A somewhat complex method to actually create a new record. The complexity is from support for subforms and associated records.
|
86
|
-
# If you want to customize this behavior, consider using the +before_create_save+ and +after_create_save+ callbacks.
|
87
|
-
def do_create(options = {})
|
88
|
-
attributes = options[:attributes] || params[:record]
|
89
|
-
begin
|
90
|
-
active_scaffold_config.model.transaction do
|
91
|
-
@record = update_record_from_params(new_model, active_scaffold_config.create.columns, attributes)
|
92
|
-
apply_constraints_to_record(@record, :allow_autosave => true)
|
93
|
-
create_association_with_parent(@record) if nested?
|
94
|
-
before_create_save(@record)
|
95
|
-
self.successful = [@record.valid?, @record.associated_valid?].all? {|v| v == true} # this syntax avoids a short-circuit
|
96
|
-
create_save(@record) unless options[:skip_save]
|
97
|
-
end
|
98
|
-
rescue ActiveRecord::ActiveRecordError => ex
|
99
|
-
flash[:error] = ex.message
|
100
|
-
self.successful = false
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def create_save(record)
|
105
|
-
if successful?
|
106
|
-
record.save! and record.save_associated!
|
107
|
-
after_create_save(record)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
# override this method if you want to inject data in the record (or its associated objects) before the save
|
112
|
-
def before_create_save(record); end
|
113
|
-
|
114
|
-
# override this method if you want to do something after the save
|
115
|
-
def after_create_save(record); end
|
116
|
-
|
117
|
-
# The default security delegates to ActiveRecordPermissions.
|
118
|
-
# You may override the method to customize.
|
119
|
-
|
120
|
-
def create_ignore?
|
121
|
-
nested? && active_scaffold_config.list.always_show_create
|
122
|
-
end
|
123
|
-
|
124
|
-
def create_authorized?
|
125
|
-
(!nested? || !nested.readonly? || !nested.through?) && authorized_for?(:crud_type => :create)
|
126
|
-
end
|
127
|
-
private
|
128
|
-
def create_authorized_filter
|
129
|
-
link = active_scaffold_config.create.link || active_scaffold_config.create.class.link
|
130
|
-
raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
|
131
|
-
end
|
132
|
-
def new_formats
|
133
|
-
(default_formats + active_scaffold_config.formats).uniq
|
134
|
-
end
|
135
|
-
def create_formats
|
136
|
-
(default_formats + active_scaffold_config.formats + active_scaffold_config.create.formats).uniq
|
137
|
-
end
|
138
|
-
end
|
139
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
module ActiveScaffold::Actions
|
2
|
-
module Delete
|
3
|
-
def self.included(base)
|
4
|
-
base.before_filter :delete_authorized_filter, :only => [:destroy]
|
5
|
-
end
|
6
|
-
|
7
|
-
def destroy
|
8
|
-
params.delete :destroy_action
|
9
|
-
process_action_link_action(:destroy) do |record|
|
10
|
-
do_destroy
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
protected
|
15
|
-
def destroy_respond_to_html
|
16
|
-
if self.successful?
|
17
|
-
flash[:info] = as_(:deleted_model, :model => @record.to_label)
|
18
|
-
else
|
19
|
-
#error_message_for not available in controller...
|
20
|
-
#flash[:error] = active_scaffold_error_messages_for(@record, :object_name => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :header_message => '', :message => "#{@record.class.model_name.human.downcase}#{@record.new_record? ? '' : ": #{@record.to_label}"}", :container_tag => nil, :list_type => :br)
|
21
|
-
end
|
22
|
-
return_to_main
|
23
|
-
end
|
24
|
-
|
25
|
-
def destroy_respond_to_js
|
26
|
-
do_refresh_list if successful? && active_scaffold_config.delete.refresh_list && !render_parent?
|
27
|
-
render(:action => 'destroy')
|
28
|
-
end
|
29
|
-
|
30
|
-
def destroy_respond_to_xml
|
31
|
-
render :xml => successful? ? "" : response_object.to_xml(:only => active_scaffold_config.list.columns.names), :content_type => Mime::XML, :status => response_status
|
32
|
-
end
|
33
|
-
|
34
|
-
def destroy_respond_to_json
|
35
|
-
render :text => successful? ? "" : response_object.to_json(:only => active_scaffold_config.list.columns.names), :content_type => Mime::JSON, :status => response_status
|
36
|
-
end
|
37
|
-
|
38
|
-
def destroy_respond_to_yaml
|
39
|
-
render :text => successful? ? "" : Hash.from_xml(response_object.to_xml(:only => active_scaffold_config.list.columns.names)).to_yaml, :content_type => Mime::YAML, :status => response_status
|
40
|
-
end
|
41
|
-
|
42
|
-
def destroy_find_record
|
43
|
-
@record = find_if_allowed(params[:id], :delete)
|
44
|
-
end
|
45
|
-
|
46
|
-
# A simple method to handle the actual destroying of a record
|
47
|
-
# May be overridden to customize the behavior
|
48
|
-
def do_destroy
|
49
|
-
@record ||= destroy_find_record
|
50
|
-
begin
|
51
|
-
self.successful = @record.destroy
|
52
|
-
rescue Exception => ex
|
53
|
-
flash[:warning] = as_(:cant_destroy_record, :record => @record.to_label)
|
54
|
-
self.successful = false
|
55
|
-
logger.debug ex.message
|
56
|
-
logger.debug ex.backtrace.join("\n")
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
# The default security delegates to ActiveRecordPermissions.
|
61
|
-
# You may override the method to customize.
|
62
|
-
def delete_authorized?(record = nil)
|
63
|
-
(!nested? || !nested.readonly?) && (record || self).send(:authorized_for?, :crud_type => :delete)
|
64
|
-
end
|
65
|
-
private
|
66
|
-
def delete_authorized_filter
|
67
|
-
link = active_scaffold_config.delete.link || active_scaffold_config.delete.class.link
|
68
|
-
raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
|
69
|
-
end
|
70
|
-
def destroy_formats
|
71
|
-
(default_formats + active_scaffold_config.formats + active_scaffold_config.delete.formats).uniq
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
@@ -1,78 +0,0 @@
|
|
1
|
-
module ActiveScaffold::Actions
|
2
|
-
module FieldSearch
|
3
|
-
include ActiveScaffold::Actions::CommonSearch
|
4
|
-
def self.included(base)
|
5
|
-
base.before_filter :search_authorized_filter, :only => :show_search
|
6
|
-
base.before_filter :store_search_params_into_session, :only => [:index]
|
7
|
-
base.before_filter :do_search, :only => [:index]
|
8
|
-
base.helper_method :field_search_params
|
9
|
-
end
|
10
|
-
|
11
|
-
# FieldSearch uses params[:search] and not @record because search conditions do not always pass the Model's validations.
|
12
|
-
# This facilitates for example, textual searches against associations via .search_sql
|
13
|
-
def show_search
|
14
|
-
@record = new_model
|
15
|
-
respond_to_action(:field_search)
|
16
|
-
end
|
17
|
-
|
18
|
-
protected
|
19
|
-
|
20
|
-
def store_search_params_into_session
|
21
|
-
set_field_search_default_params(active_scaffold_config.field_search.default_params) unless active_scaffold_config.field_search.default_params.nil?
|
22
|
-
super
|
23
|
-
active_scaffold_session_storage[:search] = nil if search_params.is_a?(String)
|
24
|
-
end
|
25
|
-
|
26
|
-
def set_field_search_default_params(default_params)
|
27
|
-
if (params[:search].nil? && search_params.nil?) || (params[:search].is_a?(String) && params[:search].blank?)
|
28
|
-
params[:search] = default_params.is_a?(Proc) ? self.instance_eval(&default_params) : default_params
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
def field_search_params
|
33
|
-
search_params || {}
|
34
|
-
end
|
35
|
-
|
36
|
-
def field_search_respond_to_html
|
37
|
-
render(:action => "field_search")
|
38
|
-
end
|
39
|
-
|
40
|
-
def field_search_respond_to_js
|
41
|
-
render(:partial => "field_search")
|
42
|
-
end
|
43
|
-
|
44
|
-
def do_search
|
45
|
-
unless search_params.blank?
|
46
|
-
filtered_columns = []
|
47
|
-
text_search = active_scaffold_config.field_search.text_search
|
48
|
-
columns = active_scaffold_config.field_search.columns
|
49
|
-
search_params.each do |key, value|
|
50
|
-
next unless columns.include? key
|
51
|
-
search_condition = self.class.condition_for_column(active_scaffold_config.columns[key], value, text_search)
|
52
|
-
unless search_condition.blank?
|
53
|
-
self.active_scaffold_conditions << search_condition
|
54
|
-
filtered_columns << active_scaffold_config.columns[key]
|
55
|
-
end
|
56
|
-
end
|
57
|
-
unless filtered_columns.blank?
|
58
|
-
@filtered = active_scaffold_config.field_search.human_conditions ? filtered_columns : true
|
59
|
-
end
|
60
|
-
|
61
|
-
includes_for_search_columns = columns.collect{ |column| column.includes}.flatten.uniq.compact
|
62
|
-
self.active_scaffold_includes.concat includes_for_search_columns
|
63
|
-
|
64
|
-
active_scaffold_config.list.user.page = nil
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
private
|
69
|
-
|
70
|
-
def search_authorized_filter
|
71
|
-
link = active_scaffold_config.field_search.link || active_scaffold_config.field_search.class.link
|
72
|
-
raise ActiveScaffold::ActionNotAllowed unless self.send(link.security_method)
|
73
|
-
end
|
74
|
-
def field_search_formats
|
75
|
-
(default_formats + active_scaffold_config.formats + active_scaffold_config.field_search.formats).uniq
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|