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.
Files changed (246) hide show
  1. data/CHANGELOG +5 -1
  2. metadata +17 -261
  3. data/app/assets/images/active_scaffold/add.png +0 -0
  4. data/app/assets/images/active_scaffold/arrow_down.png +0 -0
  5. data/app/assets/images/active_scaffold/arrow_up.png +0 -0
  6. data/app/assets/images/active_scaffold/close.png +0 -0
  7. data/app/assets/images/active_scaffold/close_touch.png +0 -0
  8. data/app/assets/images/active_scaffold/config.png +0 -0
  9. data/app/assets/images/active_scaffold/cross.png +0 -0
  10. data/app/assets/images/active_scaffold/gears.png +0 -0
  11. data/app/assets/images/active_scaffold/indicator-small.gif +0 -0
  12. data/app/assets/images/active_scaffold/indicator.gif +0 -0
  13. data/app/assets/images/active_scaffold/magnifier.png +0 -0
  14. data/app/assets/javascripts/active_scaffold.js.erb +0 -19
  15. data/app/assets/javascripts/jquery/active_scaffold.js +0 -1113
  16. data/app/assets/javascripts/jquery/date_picker_bridge.js.erb +0 -24
  17. data/app/assets/javascripts/jquery/draggable_lists.js +0 -27
  18. data/app/assets/javascripts/jquery/jquery.editinplace.js +0 -743
  19. data/app/assets/javascripts/jquery/tiny_mce_bridge.js +0 -7
  20. data/app/assets/javascripts/prototype/active_scaffold.js +0 -1107
  21. data/app/assets/javascripts/prototype/dhtml_history.js +0 -870
  22. data/app/assets/javascripts/prototype/form_enhancements.js +0 -117
  23. data/app/assets/javascripts/prototype/rico_corner.js +0 -370
  24. data/app/assets/javascripts/prototype/tiny_mce_bridge.js +0 -7
  25. data/app/assets/stylesheets/active_scaffold-ie.css.scss +0 -54
  26. data/app/assets/stylesheets/active_scaffold.css.scss +0 -14
  27. data/app/assets/stylesheets/active_scaffold_colors.css.scss +0 -395
  28. data/app/assets/stylesheets/active_scaffold_extensions.css.erb +0 -2
  29. data/app/assets/stylesheets/active_scaffold_images.css.scss +0 -40
  30. data/app/assets/stylesheets/active_scaffold_layout.css +0 -936
  31. data/app/assets/stylesheets/blue-theme.css +0 -74
  32. data/config/locales/de.yml +0 -125
  33. data/config/locales/en.yml +0 -127
  34. data/config/locales/es.yml +0 -128
  35. data/config/locales/fr.yml +0 -131
  36. data/config/locales/hu.yml +0 -126
  37. data/config/locales/ja.yml +0 -126
  38. data/config/locales/ru.yml +0 -135
  39. data/frontends/default/views/_action_group.html.erb +0 -24
  40. data/frontends/default/views/_add_existing_form.html.erb +0 -30
  41. data/frontends/default/views/_base_form.html.erb +0 -53
  42. data/frontends/default/views/_create_form.html.erb +0 -8
  43. data/frontends/default/views/_create_form_on_list.html.erb +0 -6
  44. data/frontends/default/views/_field_search.html.erb +0 -32
  45. data/frontends/default/views/_form.html.erb +0 -28
  46. data/frontends/default/views/_form_association.html.erb +0 -17
  47. data/frontends/default/views/_form_association_footer.html.erb +0 -47
  48. data/frontends/default/views/_form_attribute.html.erb +0 -23
  49. data/frontends/default/views/_form_hidden_attribute.html.erb +0 -7
  50. data/frontends/default/views/_form_messages.html.erb +0 -5
  51. data/frontends/default/views/_horizontal_subform.html.erb +0 -22
  52. data/frontends/default/views/_horizontal_subform_footer.html.erb +0 -0
  53. data/frontends/default/views/_horizontal_subform_header.html.erb +0 -11
  54. data/frontends/default/views/_horizontal_subform_record.html.erb +0 -43
  55. data/frontends/default/views/_human_conditions.html.erb +0 -1
  56. data/frontends/default/views/_list.html.erb +0 -18
  57. data/frontends/default/views/_list_actions.html.erb +0 -15
  58. data/frontends/default/views/_list_calculations.html.erb +0 -16
  59. data/frontends/default/views/_list_column_headings.html.erb +0 -12
  60. data/frontends/default/views/_list_header.html.erb +0 -10
  61. data/frontends/default/views/_list_inline_adapter.html.erb +0 -21
  62. data/frontends/default/views/_list_messages.html.erb +0 -28
  63. data/frontends/default/views/_list_pagination.html.erb +0 -11
  64. data/frontends/default/views/_list_pagination_links.html.erb +0 -9
  65. data/frontends/default/views/_list_record.html.erb +0 -13
  66. data/frontends/default/views/_list_record_columns.html.erb +0 -8
  67. data/frontends/default/views/_list_with_header.html.erb +0 -36
  68. data/frontends/default/views/_messages.html.erb +0 -10
  69. data/frontends/default/views/_refresh_list.js.erb +0 -1
  70. data/frontends/default/views/_render_field.js.erb +0 -20
  71. data/frontends/default/views/_row.html.erb +0 -1
  72. data/frontends/default/views/_search.html.erb +0 -34
  73. data/frontends/default/views/_search_attribute.html.erb +0 -10
  74. data/frontends/default/views/_show.html.erb +0 -8
  75. data/frontends/default/views/_show_columns.html.erb +0 -15
  76. data/frontends/default/views/_update_actions.html.erb +0 -9
  77. data/frontends/default/views/_update_calculations.js.erb +0 -4
  78. data/frontends/default/views/_update_form.html.erb +0 -6
  79. data/frontends/default/views/_update_messages.js.erb +0 -2
  80. data/frontends/default/views/_vertical_subform.html.erb +0 -12
  81. data/frontends/default/views/_vertical_subform_record.html.erb +0 -43
  82. data/frontends/default/views/action_confirmation.html.erb +0 -13
  83. data/frontends/default/views/add_existing.js.erb +0 -14
  84. data/frontends/default/views/add_existing_form.html.erb +0 -5
  85. data/frontends/default/views/create.html.erb +0 -5
  86. data/frontends/default/views/delete.html.erb +0 -13
  87. data/frontends/default/views/destroy.js.erb +0 -26
  88. data/frontends/default/views/edit_associated.js.erb +0 -12
  89. data/frontends/default/views/field_search.html.erb +0 -5
  90. data/frontends/default/views/form_messages.js.erb +0 -1
  91. data/frontends/default/views/list.html.erb +0 -1
  92. data/frontends/default/views/on_action_update.js.erb +0 -22
  93. data/frontends/default/views/on_create.js.erb +0 -38
  94. data/frontends/default/views/on_mark.js.erb +0 -6
  95. data/frontends/default/views/on_update.js.erb +0 -29
  96. data/frontends/default/views/refresh_list.js.erb +0 -2
  97. data/frontends/default/views/render_field.js.erb +0 -1
  98. data/frontends/default/views/row.js.erb +0 -2
  99. data/frontends/default/views/search.html.erb +0 -5
  100. data/frontends/default/views/show.html.erb +0 -5
  101. data/frontends/default/views/update.html.erb +0 -8
  102. data/frontends/default/views/update_column.js.erb +0 -15
  103. data/frontends/default/views/update_row.js.erb +0 -1
  104. data/lib/active_scaffold.rb +0 -373
  105. data/lib/active_scaffold/actions/common_search.rb +0 -22
  106. data/lib/active_scaffold/actions/core.rb +0 -203
  107. data/lib/active_scaffold/actions/create.rb +0 -139
  108. data/lib/active_scaffold/actions/delete.rb +0 -74
  109. data/lib/active_scaffold/actions/field_search.rb +0 -78
  110. data/lib/active_scaffold/actions/list.rb +0 -208
  111. data/lib/active_scaffold/actions/mark.rb +0 -89
  112. data/lib/active_scaffold/actions/nested.rb +0 -244
  113. data/lib/active_scaffold/actions/search.rb +0 -48
  114. data/lib/active_scaffold/actions/show.rb +0 -61
  115. data/lib/active_scaffold/actions/subform.rb +0 -23
  116. data/lib/active_scaffold/actions/update.rb +0 -156
  117. data/lib/active_scaffold/active_record_permissions.rb +0 -135
  118. data/lib/active_scaffold/attribute_params.rb +0 -200
  119. data/lib/active_scaffold/bridges.rb +0 -61
  120. data/lib/active_scaffold/bridges/ancestry.rb +0 -5
  121. data/lib/active_scaffold/bridges/ancestry/ancestry_bridge.rb +0 -39
  122. data/lib/active_scaffold/bridges/bitfields.rb +0 -6
  123. data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +0 -37
  124. data/lib/active_scaffold/bridges/calendar_date_select.rb +0 -24
  125. data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +0 -66
  126. data/lib/active_scaffold/bridges/cancan.rb +0 -15
  127. data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +0 -127
  128. data/lib/active_scaffold/bridges/carrierwave.rb +0 -12
  129. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +0 -31
  130. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge_helpers.rb +0 -10
  131. data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +0 -45
  132. data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +0 -17
  133. data/lib/active_scaffold/bridges/country_helper.rb +0 -9
  134. data/lib/active_scaffold/bridges/country_helper/country_helper_bridge.rb +0 -358
  135. data/lib/active_scaffold/bridges/date_picker.rb +0 -23
  136. data/lib/active_scaffold/bridges/date_picker/ext.rb +0 -63
  137. data/lib/active_scaffold/bridges/date_picker/helper.rb +0 -180
  138. data/lib/active_scaffold/bridges/dragonfly.rb +0 -9
  139. data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +0 -34
  140. data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge_helpers.rb +0 -10
  141. data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +0 -27
  142. data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +0 -16
  143. data/lib/active_scaffold/bridges/file_column.rb +0 -11
  144. data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +0 -46
  145. data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +0 -57
  146. data/lib/active_scaffold/bridges/file_column/form_ui.rb +0 -34
  147. data/lib/active_scaffold/bridges/file_column/list_ui.rb +0 -26
  148. data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +0 -43
  149. data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +0 -9
  150. data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +0 -15
  151. data/lib/active_scaffold/bridges/paperclip.rb +0 -12
  152. data/lib/active_scaffold/bridges/paperclip/form_ui.rb +0 -27
  153. data/lib/active_scaffold/bridges/paperclip/list_ui.rb +0 -16
  154. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +0 -36
  155. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +0 -24
  156. data/lib/active_scaffold/bridges/record_select.rb +0 -11
  157. data/lib/active_scaffold/bridges/record_select/helpers.rb +0 -92
  158. data/lib/active_scaffold/bridges/semantic_attributes.rb +0 -5
  159. data/lib/active_scaffold/bridges/semantic_attributes/column.rb +0 -20
  160. data/lib/active_scaffold/bridges/shared/date_bridge.rb +0 -209
  161. data/lib/active_scaffold/bridges/tiny_mce.rb +0 -17
  162. data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +0 -46
  163. data/lib/active_scaffold/config/base.rb +0 -75
  164. data/lib/active_scaffold/config/core.rb +0 -236
  165. data/lib/active_scaffold/config/create.rb +0 -32
  166. data/lib/active_scaffold/config/delete.rb +0 -32
  167. data/lib/active_scaffold/config/field_search.rb +0 -79
  168. data/lib/active_scaffold/config/form.rb +0 -64
  169. data/lib/active_scaffold/config/list.rb +0 -247
  170. data/lib/active_scaffold/config/mark.rb +0 -30
  171. data/lib/active_scaffold/config/nested.rb +0 -42
  172. data/lib/active_scaffold/config/search.rb +0 -73
  173. data/lib/active_scaffold/config/show.rb +0 -31
  174. data/lib/active_scaffold/config/subform.rb +0 -35
  175. data/lib/active_scaffold/config/update.rb +0 -33
  176. data/lib/active_scaffold/configurable.rb +0 -29
  177. data/lib/active_scaffold/constraints.rb +0 -171
  178. data/lib/active_scaffold/data_structures/action_columns.rb +0 -142
  179. data/lib/active_scaffold/data_structures/action_link.rb +0 -185
  180. data/lib/active_scaffold/data_structures/action_links.rb +0 -191
  181. data/lib/active_scaffold/data_structures/actions.rb +0 -45
  182. data/lib/active_scaffold/data_structures/bridge.rb +0 -22
  183. data/lib/active_scaffold/data_structures/column.rb +0 -401
  184. data/lib/active_scaffold/data_structures/columns.rb +0 -75
  185. data/lib/active_scaffold/data_structures/error_message.rb +0 -24
  186. data/lib/active_scaffold/data_structures/nested_info.rb +0 -171
  187. data/lib/active_scaffold/data_structures/set.rb +0 -61
  188. data/lib/active_scaffold/data_structures/sorting.rb +0 -167
  189. data/lib/active_scaffold/engine.rb +0 -4
  190. data/lib/active_scaffold/extensions/action_controller_rendering.rb +0 -20
  191. data/lib/active_scaffold/extensions/action_controller_rescueing.rb +0 -7
  192. data/lib/active_scaffold/extensions/action_view_rendering.rb +0 -115
  193. data/lib/active_scaffold/extensions/active_record_offset.rb +0 -12
  194. data/lib/active_scaffold/extensions/array.rb +0 -7
  195. data/lib/active_scaffold/extensions/cache_association.rb +0 -16
  196. data/lib/active_scaffold/extensions/localize.rb +0 -10
  197. data/lib/active_scaffold/extensions/name_option_for_datetime.rb +0 -12
  198. data/lib/active_scaffold/extensions/nil_id_in_url_params.rb +0 -7
  199. data/lib/active_scaffold/extensions/paginator_extensions.rb +0 -26
  200. data/lib/active_scaffold/extensions/reverse_associations.rb +0 -64
  201. data/lib/active_scaffold/extensions/routing_mapper.rb +0 -48
  202. data/lib/active_scaffold/extensions/to_label.rb +0 -8
  203. data/lib/active_scaffold/extensions/unsaved_associated.rb +0 -61
  204. data/lib/active_scaffold/extensions/unsaved_record.rb +0 -20
  205. data/lib/active_scaffold/extensions/usa_state.rb +0 -46
  206. data/lib/active_scaffold/finder.rb +0 -399
  207. data/lib/active_scaffold/helpers/association_helpers.rb +0 -42
  208. data/lib/active_scaffold/helpers/controller_helpers.rb +0 -94
  209. data/lib/active_scaffold/helpers/form_column_helpers.rb +0 -322
  210. data/lib/active_scaffold/helpers/human_condition_helpers.rb +0 -64
  211. data/lib/active_scaffold/helpers/id_helpers.rb +0 -131
  212. data/lib/active_scaffold/helpers/list_column_helpers.rb +0 -374
  213. data/lib/active_scaffold/helpers/pagination_helpers.rb +0 -62
  214. data/lib/active_scaffold/helpers/search_column_helpers.rb +0 -257
  215. data/lib/active_scaffold/helpers/show_column_helpers.rb +0 -44
  216. data/lib/active_scaffold/helpers/view_helpers.rb +0 -398
  217. data/lib/active_scaffold/marked_model.rb +0 -38
  218. data/lib/active_scaffold/paginator.rb +0 -136
  219. data/lib/active_scaffold/responds_to_parent.rb +0 -70
  220. data/lib/active_scaffold/tableless.rb +0 -83
  221. data/lib/active_scaffold/version.rb +0 -9
  222. data/lib/active_scaffold_env.rb +0 -13
  223. data/lib/generators/active_scaffold/USAGE +0 -29
  224. data/lib/generators/active_scaffold/active_scaffold_generator.rb +0 -21
  225. data/lib/generators/active_scaffold_controller/USAGE +0 -19
  226. data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +0 -29
  227. data/lib/generators/active_scaffold_controller/templates/controller.rb +0 -4
  228. data/lib/generators/active_scaffold_controller/templates/helper.rb +0 -2
  229. data/public/blank.html +0 -33
  230. data/shoulda_macros/macros.rb +0 -136
  231. data/vendor/assets/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  232. data/vendor/assets/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  233. data/vendor/assets/images/ui-bg_flat_10_000000_40x100.png +0 -0
  234. data/vendor/assets/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  235. data/vendor/assets/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  236. data/vendor/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  237. data/vendor/assets/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  238. data/vendor/assets/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  239. data/vendor/assets/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  240. data/vendor/assets/images/ui-icons_222222_256x240.png +0 -0
  241. data/vendor/assets/images/ui-icons_228ef1_256x240.png +0 -0
  242. data/vendor/assets/images/ui-icons_ef8c08_256x240.png +0 -0
  243. data/vendor/assets/images/ui-icons_ffd27a_256x240.png +0 -0
  244. data/vendor/assets/images/ui-icons_ffffff_256x240.png +0 -0
  245. data/vendor/assets/javascripts/jquery-ui-timepicker-addon.js +0 -1276
  246. data/vendor/assets/stylesheets/jquery-ui.css +0 -568
@@ -1,208 +0,0 @@
1
- module ActiveScaffold::Actions
2
- module List
3
- def self.included(base)
4
- base.before_filter :list_authorized_filter, :only => [:index, :row]
5
- base.helper_method :list_columns
6
- end
7
-
8
- def index
9
- list
10
- end
11
-
12
- # get just a single row
13
- def row
14
- get_row
15
- respond_to_action(:row)
16
- end
17
-
18
- def list
19
- if %w(index list).include? action_name
20
- do_list
21
- else
22
- do_refresh_list
23
- end
24
- @nested_auto_open = active_scaffold_config.list.nested_auto_open
25
- respond_to_action(:list)
26
- end
27
-
28
- protected
29
- def list_respond_to_html
30
- if embedded?
31
- render :action => 'list', :layout => false
32
- else
33
- render :action => 'list'
34
- end
35
- end
36
- def list_respond_to_js
37
- if params[:adapter] || embedded?
38
- render(:partial => 'list_with_header')
39
- else
40
- render :partial => 'refresh_list', :formats => [:js]
41
- end
42
- end
43
- def list_respond_to_xml
44
- render :xml => response_object.to_xml(:only => list_columns_names), :content_type => Mime::XML, :status => response_status
45
- end
46
- def list_respond_to_json
47
- render :text => response_object.to_json(:only => list_columns_names), :content_type => Mime::JSON, :status => response_status
48
- end
49
- def list_respond_to_yaml
50
- render :text => Hash.from_xml(response_object.to_xml(:only => list_columns_names)).to_yaml, :content_type => Mime::YAML, :status => response_status
51
- end
52
-
53
- def row_respond_to_html
54
- render(:partial => 'row', :locals => {:record => @record})
55
- end
56
-
57
- def row_respond_to_js
58
- render
59
- end
60
-
61
- # The actual algorithm to prepare for the list view
62
- def set_includes_for_list_columns
63
- @cache_associations = true
64
- includes_for_list_columns = active_scaffold_config.list.columns.collect{ |c| c.includes }.flatten.uniq.compact
65
- self.active_scaffold_includes.concat includes_for_list_columns
66
- end
67
-
68
- def get_row
69
- set_includes_for_list_columns
70
- klass = beginning_of_chain.includes(active_scaffold_includes)
71
- @record = find_if_allowed(params[:id], :read, klass)
72
- end
73
-
74
- # The actual algorithm to prepare for the list view
75
- def do_list
76
- set_includes_for_list_columns
77
-
78
- options = { :sorting => active_scaffold_config.list.user.sorting,
79
- :count_includes => active_scaffold_config.list.user.count_includes }
80
- paginate = (params[:format].nil?) ? (accepts? :html, :js) : ['html', 'js'].include?(params[:format])
81
- if paginate
82
- options.merge!({
83
- :per_page => active_scaffold_config.list.user.per_page,
84
- :page => active_scaffold_config.list.user.page,
85
- :pagination => active_scaffold_config.list.pagination
86
- })
87
- end
88
-
89
- page = find_page(options)
90
- total_pages = page.pager.number_of_pages
91
- if !page.pager.infinite? && !total_pages.zero? && page.number > total_pages
92
- page = page.pager.last
93
- active_scaffold_config.list.user.page = page.number
94
- end
95
- @page, @records = page, page.items
96
- end
97
-
98
- def do_refresh_list
99
- do_search if respond_to? :do_search
100
- do_list
101
- end
102
-
103
- def each_record_in_page
104
- _page = active_scaffold_config.list.user.page
105
- do_search if respond_to? :do_search
106
- active_scaffold_config.list.user.page = _page
107
- do_list
108
- @page.items.each {|record| yield record}
109
- end
110
-
111
- def each_record_in_scope
112
- do_search if respond_to? :do_search
113
- append_to_query(beginning_of_chain, finder_options).all.each {|record| yield record}
114
- end
115
-
116
- # The default security delegates to ActiveRecordPermissions.
117
- # You may override the method to customize.
118
- def list_authorized?
119
- authorized_for?(:crud_type => :read)
120
- end
121
-
122
- # call this method in your action_link action to simplify processing of actions
123
- # eg for member action_link :fire
124
- # process_action_link_action do |record|
125
- # record.update_attributes(:fired => true)
126
- # self.successful = true
127
- # flash[:info] = 'Player fired'
128
- # end
129
- def process_action_link_action(render_action = :action_update, crud_type = nil)
130
- if request.get?
131
- # someone has disabled javascript, we have to show confirmation form first
132
- @record = find_if_allowed(params[:id], :read) if params[:id] && params[:id] && params[:id].to_i > 0
133
- respond_to_action(:action_confirmation)
134
- else
135
- @action_link = active_scaffold_config.action_links[action_name]
136
- if params[:id] && params[:id] && params[:id].to_i > 0
137
- crud_type ||= (request.post? || request.put?) ? :update : :delete
138
- @record = find_if_allowed(params[:id], crud_type)
139
- unless @record.nil?
140
- yield @record
141
- else
142
- self.successful = false
143
- flash[:error] = as_(:no_authorization_for_action, :action => action_name)
144
- end
145
- else
146
- yield
147
- end
148
- respond_to_action(render_action)
149
- end
150
- end
151
-
152
- def action_confirmation_respond_to_html(confirm_action = action_name.to_sym)
153
- link = active_scaffold_config.action_links[confirm_action]
154
- render :action => 'action_confirmation', :locals => {:record => @record, :link => link}
155
- end
156
-
157
- def action_update_respond_to_html
158
- redirect_to :action => 'index'
159
- end
160
-
161
- def action_update_respond_to_js
162
- do_refresh_list unless @record.present?
163
- render(:action => 'on_action_update')
164
- end
165
-
166
- def action_update_respond_to_xml
167
- render :xml => successful? ? "" : response_object.to_xml(:only => list_columns_names), :content_type => Mime::XML, :status => response_status
168
- end
169
-
170
- def action_update_respond_to_json
171
- render :text => successful? ? "" : response_object.to_json(:only => list_columns_names), :content_type => Mime::JSON, :status => response_status
172
- end
173
-
174
- def action_update_respond_to_yaml
175
- render :text => successful? ? "" : Hash.from_xml(response_object.to_xml(:only => list_columns_names)).to_yaml, :content_type => Mime::YAML, :status => response_status
176
- end
177
-
178
- private
179
- def list_authorized_filter
180
- raise ActiveScaffold::ActionNotAllowed unless list_authorized?
181
- end
182
-
183
- def list_formats
184
- (default_formats + active_scaffold_config.formats + active_scaffold_config.list.formats).uniq
185
- end
186
- alias_method :index_formats, :list_formats
187
-
188
- def row_formats
189
- ([:html, :js] + active_scaffold_config.formats + active_scaffold_config.list.formats).uniq
190
- end
191
-
192
- def action_update_formats
193
- (default_formats + active_scaffold_config.formats).uniq
194
- end
195
-
196
- def action_confirmation_formats
197
- (default_formats + active_scaffold_config.formats).uniq
198
- end
199
-
200
- def list_columns
201
- active_scaffold_config.list.columns.collect_visible
202
- end
203
-
204
- def list_columns_names
205
- list_columns.collect(&:name)
206
- end
207
- end
208
- end
@@ -1,89 +0,0 @@
1
- module ActiveScaffold::Actions
2
- module Mark
3
-
4
- def self.included(base)
5
- base.before_filter :mark_authorized?, :only => :mark
6
- base.before_filter :assign_marked_records_to_model
7
- base.helper_method :marked_records
8
- end
9
-
10
- def mark
11
- if mark? || mark_all_scope_forced?
12
- do_mark
13
- else
14
- do_demark
15
- end
16
- if marked_records.length > 0
17
- count = marked_records.length
18
- flash[:info] = as_(:records_marked, :count => count, :model => active_scaffold_config.label(:count => count))
19
- end
20
- respond_to_action(:mark)
21
- end
22
- protected
23
-
24
- def mark_respond_to_html
25
- do_list
26
- list_respond_to_html
27
- end
28
-
29
- def mark_respond_to_js
30
- if params[:id]
31
- do_search if respond_to? :do_search
32
- set_includes_for_list_columns
33
- @page = find_page(:pagination => active_scaffold_config.mark.mark_all_mode != :page)
34
- render :action => 'on_mark'
35
- else
36
- render :action => 'on_mark', :locals => {:checked => mark?}
37
- end
38
- end
39
-
40
- # We need to give the ActiveRecord classes a handle to currently marked records. We don't want to just pass the object,
41
- # because the object may change. So we give ActiveRecord a proc that ties to the marked_records_method on this ApplicationController.
42
- def assign_marked_records_to_model
43
- active_scaffold_config.model.marked_records = marked_records
44
- end
45
-
46
- def mark?
47
- @mark ||= [true, 'true', 1, '1', 'T', 't'].include?(params[:value].class == String ? params[:value].downcase : params[:value])
48
- end
49
-
50
- def mark_all_scope_forced?
51
- params[:mark_target] == 'scope' unless params[:id]
52
- end
53
-
54
- def do_mark
55
- if params[:id]
56
- find_if_allowed(params[:id], :read).as_marked = true
57
- elsif active_scaffold_config.mark.mark_all_mode == :page && !mark_all_scope_forced?
58
- each_record_in_page { |record| record.as_marked = true }
59
- else
60
- each_record_in_scope { |record| record.as_marked = true }
61
- end
62
- end
63
-
64
- def do_demark
65
- if params[:id]
66
- find_if_allowed(params[:id], :read).as_marked = false
67
- elsif active_scaffold_config.mark.mark_all_mode == :page
68
- each_record_in_page { |record| record.as_marked = false }
69
- else
70
- each_record_in_scope { |record| record.as_marked = false }
71
- end
72
- end
73
-
74
- def do_destroy
75
- super
76
- @record.as_marked = false if successful?
77
- end
78
-
79
- # The default security delegates to ActiveRecordPermissions.
80
- # You may override the method to customize.
81
- def mark_authorized?
82
- authorized_for?(:crud_type => :read)
83
- end
84
-
85
- def mark_formats
86
- (default_formats + active_scaffold_config.formats).uniq
87
- end
88
- end
89
- end
@@ -1,244 +0,0 @@
1
- module ActiveScaffold::Actions
2
- # The Nested module basically handles automatically linking controllers together. It does this by creating column links with the right parameters, and by providing any supporting systems (like a /:controller/nested action for returning associated scaffolds).
3
- module Nested
4
-
5
- def self.included(base)
6
- super
7
- base.module_eval do
8
- prepend_before_filter :set_nested
9
- before_filter :configure_nested
10
- include ActiveScaffold::Actions::Nested::ChildMethods if active_scaffold_config.model.reflect_on_all_associations.any? {|a| a.macro == :has_and_belongs_to_many}
11
- end
12
- base.before_filter :include_habtm_actions
13
- base.helper_method :nested
14
- base.helper_method :nested_parent_record
15
- end
16
-
17
- protected
18
- def nested
19
- @nested
20
- end
21
-
22
- def nested?
23
- !nested.nil?
24
- end
25
-
26
- def set_nested
27
- if params[:parent_scaffold] && (params[:association] || params[:named_scope])
28
- @nested = ActiveScaffold::DataStructures::NestedInfo.get(active_scaffold_config.model, params)
29
- register_constraints_with_action_columns(@nested.constrained_fields) unless @nested.nil?
30
- end
31
- end
32
-
33
- def configure_nested
34
- if nested?
35
- active_scaffold_session_storage[:list][:label] = if nested.belongs_to?
36
- as_(:nested_of_model, :nested_model => active_scaffold_config.model.model_name.human, :parent_model => nested_parent_record.to_label)
37
- else
38
- as_(:nested_for_model, :nested_model => active_scaffold_config.list.label, :parent_model => nested_parent_record.to_label)
39
- end
40
- if nested.sorted?
41
- active_scaffold_config.list.user.nested_default_sorting = {:table_name => active_scaffold_config.model.model_name, :default_sorting => nested.default_sorting}
42
- end
43
- end
44
- end
45
-
46
- def nested_authorized?(record = nil)
47
- true
48
- end
49
-
50
- def include_habtm_actions
51
- if nested?
52
- if nested.habtm?
53
- # Production mode is ok with adding a link everytime the scaffold is nested - we ar not ok with that.
54
- active_scaffold_config.action_links.add('new_existing', :label => :add_existing, :type => :collection, :security_method => :add_existing_authorized?) unless active_scaffold_config.action_links['new_existing']
55
- if active_scaffold_config.nested.shallow_delete
56
- active_scaffold_config.action_links.add('destroy_existing', :label => :remove, :type => :member, :confirm => :are_you_sure_to_delete, :method => :delete, :position => false, :security_method => :delete_existing_authorized?) unless active_scaffold_config.action_links['destroy_existing']
57
- if active_scaffold_config.actions.include?(:delete)
58
- active_scaffold_config.action_links.delete("delete") if active_scaffold_config.action_links['delete']
59
- end
60
- end
61
- else
62
- # Production mode is caching this link into a non nested scaffold
63
- active_scaffold_config.action_links.delete('new_existing') if active_scaffold_config.action_links['new_existing']
64
-
65
- if active_scaffold_config.nested.shallow_delete
66
- active_scaffold_config.action_links.delete("destroy_existing") if active_scaffold_config.action_links['destroy_existing']
67
- if active_scaffold_config.actions.include?(:delete)
68
- active_scaffold_config.action_links.add(ActiveScaffold::Config::Delete.link) unless active_scaffold_config.action_links['delete']
69
- end
70
- end
71
- end
72
- end
73
- end
74
-
75
- def beginning_of_chain
76
- if nested? && nested.association && !nested.association.belongs_to?
77
- if nested.association.collection?
78
- nested.parent_scope.send(nested.association.name)
79
- elsif nested.association.options[:through] # has_one :through doesn't need conditions
80
- active_scaffold_config.model
81
- elsif nested.child_association.belongs_to?
82
- active_scaffold_config.model.where(nested.child_association.foreign_key => nested.parent_scope)
83
- end
84
- elsif nested? && nested.scope
85
- nested.parent_scope.send(nested.scope)
86
- else
87
- active_scaffold_config.model
88
- end
89
- end
90
-
91
- def nested_parent_record(crud = :read)
92
- @nested_parent_record ||= find_if_allowed(nested.parent_id, crud, nested.parent_model)
93
- end
94
-
95
- def create_association_with_parent(record)
96
- if nested?
97
- if (nested.belongs_to? || nested.has_one? || nested.habtm?) && nested.child_association
98
- parent = nested_parent_record(:read)
99
- case nested.child_association.macro
100
- when :has_one
101
- record.send("#{nested.child_association.name}=", parent)
102
- when :belongs_to
103
- record.send("#{nested.child_association.name}=", parent)
104
- when :has_many, :has_and_belongs_to_many
105
- record.send("#{nested.child_association.name}").send(:<<, parent)
106
- end unless parent.nil?
107
- end
108
- end
109
- end
110
-
111
- private
112
- def nested_formats
113
- (default_formats + active_scaffold_config.formats + active_scaffold_config.nested.formats).uniq
114
- end
115
- end
116
- end
117
-
118
- module ActiveScaffold::Actions::Nested
119
- module ChildMethods
120
-
121
- def self.included(base)
122
- super
123
- end
124
-
125
- def new_existing
126
- do_new
127
- respond_to_action(:new_existing)
128
- end
129
-
130
- def add_existing
131
- do_add_existing
132
- respond_to_action(:add_existing)
133
- end
134
-
135
- def destroy_existing
136
- return redirect_to(params.merge(:action => :delete)) if request.get?
137
- do_destroy_existing
138
- respond_to_action(:destroy_existing)
139
- end
140
-
141
- protected
142
- def new_existing_respond_to_html
143
- if successful?
144
- render(:action => 'add_existing_form')
145
- else
146
- return_to_main
147
- end
148
- end
149
- def new_existing_respond_to_js
150
- render(:partial => 'add_existing_form')
151
- end
152
- def add_existing_respond_to_html
153
- if successful?
154
- flash[:info] = as_(:created_model, :model => @record.to_label)
155
- return_to_main
156
- else
157
- render(:action => 'add_existing_form')
158
- end
159
- end
160
- def add_existing_respond_to_js
161
- if successful?
162
- render :action => 'add_existing'
163
- else
164
- render :action => 'form_messages'
165
- end
166
- end
167
- def add_existing_respond_to_xml
168
- render :xml => response_object.to_xml(:only => active_scaffold_config.list.columns.names), :content_type => Mime::XML, :status => response_status
169
- end
170
- def add_existing_respond_to_json
171
- render :text => response_object.to_json(:only => active_scaffold_config.list.columns.names), :content_type => Mime::JSON, :status => response_status
172
- end
173
- def add_existing_respond_to_yaml
174
- render :text => Hash.from_xml(response_object.to_xml(:only => active_scaffold_config.list.columns.names)).to_yaml, :content_type => Mime::YAML, :status => response_status
175
- end
176
- def destroy_existing_respond_to_html
177
- flash[:info] = as_(:deleted_model, :model => @record.to_label)
178
- return_to_main
179
- end
180
-
181
- def destroy_existing_respond_to_js
182
- render(:action => 'destroy')
183
- end
184
-
185
- def destroy_existing_respond_to_xml
186
- render :xml => successful? ? "" : response_object.to_xml(:only => active_scaffold_config.list.columns.names), :content_type => Mime::XML, :status => response_status
187
- end
188
-
189
- def destroy_existing_respond_to_json
190
- render :text => successful? ? "" : response_object.to_json(:only => active_scaffold_config.list.columns.names), :content_type => Mime::JSON, :status => response_status
191
- end
192
-
193
- def destroy_existing_respond_to_yaml
194
- 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
195
- end
196
-
197
- def add_existing_authorized?(record = nil)
198
- true
199
- end
200
- def delete_existing_authorized?(record = nil)
201
- true
202
- end
203
-
204
- def after_create_save(record)
205
- if params[:association_macro] == :has_and_belongs_to_many
206
- params[:associated_id] = record
207
- do_add_existing
208
- end
209
- end
210
-
211
- # The actual "add_existing" algorithm
212
- def do_add_existing
213
- parent_record = nested_parent_record(:update)
214
- @record = active_scaffold_config.model.find(params[:associated_id])
215
- if parent_record && @record
216
- parent_record.send(nested.association.name) << @record
217
- parent_record.save
218
- else
219
- false
220
- end
221
- end
222
-
223
- def do_destroy_existing
224
- if active_scaffold_config.nested.shallow_delete
225
- @record = nested_parent_record(:update)
226
- collection = @record.send(nested.association.name)
227
- assoc_record = collection.find(params[:id])
228
- collection.delete(assoc_record)
229
- else
230
- do_destroy
231
- end
232
- end
233
- private
234
- def new_existing_formats
235
- (default_formats + active_scaffold_config.formats).uniq
236
- end
237
- def add_existing_formats
238
- (default_formats + active_scaffold_config.formats).uniq
239
- end
240
- def destroy_existing_formats
241
- (default_formats + active_scaffold_config.formats).uniq
242
- end
243
- end
244
- end