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,131 +0,0 @@
1
- module ActiveScaffold
2
- module Helpers
3
- # A bunch of helper methods to produce the common view ids
4
- module IdHelpers
5
- def id_from_controller(controller)
6
- controller.to_s.gsub("/", "__").html_safe
7
- end
8
-
9
- def controller_id(controller = (params[:eid] || nested_id || params[:parent_controller] || params[:controller]))
10
- controller_id ||= 'as_' + id_from_controller(controller)
11
- end
12
-
13
- def nested_id
14
- "#{nested.parent_scaffold.controller_path}-#{nested.parent_id}-#{params[:controller]}" if nested?
15
- end
16
-
17
- def active_scaffold_id
18
- "#{controller_id}-active-scaffold"
19
- end
20
-
21
- def active_scaffold_content_id
22
- "#{controller_id}-content"
23
- end
24
-
25
- def active_scaffold_tbody_id
26
- "#{controller_id}-tbody"
27
- end
28
-
29
- def active_scaffold_messages_id(options = {})
30
- "#{options[:controller_id] || controller_id}-messages"
31
- end
32
-
33
- def active_scaffold_calculations_id(options = {})
34
- "#{options[:controller_id] || controller_id}-calculations#{'-' + options[:column].name.to_s if options[:column]}"
35
- end
36
-
37
- def empty_message_id
38
- "#{controller_id}-empty-message"
39
- end
40
-
41
- def before_header_id
42
- "#{controller_id}-search-container"
43
- end
44
-
45
- def search_input_id
46
- "#{controller_id}-search-input"
47
- end
48
-
49
- def action_link_id(link_action,link_id)
50
- "#{controller_id}-#{link_action}-#{link_id}-link"
51
- end
52
-
53
- def active_scaffold_column_header_id(column)
54
- name = column.respond_to?(:name) ? column.name : column.to_s
55
- clean_id "#{controller_id}-#{name}-column"
56
- end
57
-
58
- def element_row_id(options = {})
59
- options[:action] ||= params[:action]
60
- options[:id] ||= params[:id]
61
- options[:id] ||= params[:parent_id]
62
- clean_id "#{options[:controller_id] || controller_id}-#{options[:action]}-#{options[:id]}-row"
63
- end
64
-
65
- def element_cell_id(options = {})
66
- options[:action] ||= params[:action]
67
- options[:id] ||= params[:id]
68
- options[:id] ||= params[:parent_id]
69
- options[:name] ||= params[:name]
70
- clean_id "#{controller_id}-#{options[:action]}-#{options[:id]}-#{options[:name]}-cell"
71
- end
72
-
73
- def element_form_id(options = {})
74
- options[:action] ||= params[:action]
75
- options[:id] ||= params[:id]
76
- options[:id] ||= params[:parent_id]
77
- clean_id "#{controller_id}-#{options[:action]}-#{options[:id]}-form"
78
- end
79
-
80
- def association_subform_id(column)
81
- klass = column.association.klass.to_s.underscore
82
- clean_id "#{controller_id}-associated-#{klass}"
83
- end
84
-
85
- def loading_indicator_id(options = {})
86
- options[:action] ||= params[:action]
87
- clean_id "#{controller_id}-#{options[:action]}-#{options[:id]}-loading-indicator"
88
- end
89
-
90
- def sub_section_id(options = {})
91
- options[:id] ||= params[:id]
92
- options[:id] ||= params[:parent_id]
93
- clean_id "#{controller_id}-#{options[:id]}-#{options[:sub_section]}-subsection"
94
- end
95
-
96
- def sub_form_id(options = {})
97
- options[:id] ||= params[:id]
98
- options[:id] ||= params[:parent_id]
99
- clean_id "#{controller_id}-#{options[:id]}-#{options[:association]}-subform"
100
- end
101
-
102
- def sub_form_list_id(options = {})
103
- options[:id] ||= params[:id]
104
- options[:id] ||= params[:parent_id]
105
- clean_id "#{controller_id}-#{options[:id]}-#{options[:association]}-subform-list"
106
- end
107
-
108
- def element_messages_id(options = {})
109
- options[:action] ||= params[:action]
110
- options[:id] ||= params[:id]
111
- options[:id] ||= params[:parent_id]
112
- clean_id "#{controller_id}-#{options[:action]}-#{options[:id]}-messages"
113
- end
114
-
115
- def action_iframe_id(options)
116
- "#{controller_id}-#{options[:action]}-#{options[:id]}-iframe"
117
- end
118
-
119
- def scope_id(scope)
120
- scope.gsub(/(\[|\])/, '_').gsub('__', '_').gsub(/_$/, '')
121
- end
122
-
123
- private
124
-
125
- # whitelists id-safe characters
126
- def clean_id(val)
127
- val.gsub /[^-_0-9a-zA-Z]/, '-'
128
- end
129
- end
130
- end
131
- end
@@ -1,374 +0,0 @@
1
- # coding: utf-8
2
- module ActiveScaffold
3
- module Helpers
4
- # Helpers that assist with the rendering of a List Column
5
- module ListColumnHelpers
6
- def get_column_value(record, column)
7
- begin
8
- # check for an override helper
9
- value = if (method = column_override(column))
10
- # we only pass the record as the argument. we previously also passed the formatted_value,
11
- # but mike perham pointed out that prohibited the usage of overrides to improve on the
12
- # performance of our default formatting. see issue #138.
13
- if method(method).arity == 1
14
- ActiveSupport::Deprecation.warn("Add column argument to field override, signature is unified with list_ui")
15
- send(method, record)
16
- else
17
- send(method, record, column)
18
- end
19
- # second, check if the dev has specified a valid list_ui for this column
20
- elsif column.list_ui and (method = override_column_ui(column.list_ui))
21
- send(method, column, record)
22
- elsif column.column and (method = override_column_ui(column.column.type))
23
- send(method, column, record)
24
- else
25
- format_column_value(record, column)
26
- end
27
-
28
- value = ' '.html_safe if value.nil? or (value.respond_to?(:empty?) and value.empty?) # fix for IE 6
29
- return value
30
- rescue Exception => e
31
- logger.error Time.now.to_s + "#{e.inspect} -- on the ActiveScaffold column = :#{column.name} in #{controller.class}"
32
- raise e
33
- end
34
- end
35
-
36
- # TODO: move empty_field_text and   logic in here?
37
- # TODO: we need to distinguish between the automatic links *we* create and the ones that the dev specified. some logic may not apply if the dev specified the link.
38
- def render_list_column(text, column, record)
39
- if column.link
40
- link = column.link
41
- associated = record.send(column.association.name) if column.association
42
- url_options = params_for(:action => nil, :id => record.id)
43
-
44
- # setup automatic link
45
- if column.autolink? && column.singular_association? # link to inline form
46
- link = action_link_to_inline_form(column, record, associated, text)
47
- return text if link.nil?
48
- else
49
- url_options[:link] = text
50
- end
51
-
52
- if column_link_authorized?(link, column, record, associated)
53
- render_action_link(link, url_options, record)
54
- else
55
- "<a class='disabled'>#{text}</a>".html_safe
56
- end
57
- elsif inplace_edit?(record, column)
58
- active_scaffold_inplace_edit(record, column, {:formatted_column => text})
59
- elsif active_scaffold_config.list.wrap_tag
60
- content_tag active_scaffold_config.list.wrap_tag, text
61
- else
62
- text
63
- end
64
- end
65
-
66
- # setup the action link to inline form
67
- def action_link_to_inline_form(column, record, associated, text)
68
- link = column.link.clone
69
- link.label = text
70
- if column.polymorphic_association?
71
- polymorphic_controller = controller_path_for_activerecord(record.send(column.association.name).class)
72
- return link if polymorphic_controller.nil?
73
- link.controller = polymorphic_controller
74
- end
75
- configure_column_link(link, associated, column.actions_for_association_links)
76
- end
77
-
78
- def configure_column_link(link, associated, actions)
79
- if column_empty?(associated) # if association is empty, we only can link to create form
80
- if actions.include?(:new)
81
- link.action = 'new'
82
- link.crud_type = :create
83
- link.label = as_(:create_new)
84
- end
85
- elsif actions.include?(:edit)
86
- link.action = 'edit'
87
- link.crud_type = :update
88
- elsif actions.include?(:show)
89
- link.action = 'show'
90
- link.crud_type = :read
91
- elsif actions.include?(:list)
92
- link.action = 'index'
93
- link.crud_type = :read
94
- end
95
- link if link.action.present?
96
- end
97
-
98
- def column_link_authorized?(link, column, record, associated)
99
- if column.association
100
- associated_for_authorized = if column.plural_association? || (associated.respond_to?(:blank?) && associated.blank?)
101
- column.association.klass
102
- else
103
- associated
104
- end
105
- authorized = associated_for_authorized.authorized_for?(:crud_type => link.crud_type)
106
- authorized = authorized and record.authorized_for?(:crud_type => :update, :column => column.name) if link.crud_type == :create
107
- authorized
108
- else
109
- record.authorized_for?(:crud_type => link.crud_type)
110
- end
111
- end
112
-
113
- # There are two basic ways to clean a column's value: h() and sanitize(). The latter is useful
114
- # when the column contains *valid* html data, and you want to just disable any scripting. People
115
- # can always use field overrides to clean data one way or the other, but having this override
116
- # lets people decide which way it should happen by default.
117
- #
118
- # Why is it not a configuration option? Because it seems like a somewhat rare request. But it
119
- # could eventually be an option in config.list (and config.show, I guess).
120
- def clean_column_value(v)
121
- h(v)
122
- end
123
-
124
- ##
125
- ## Overrides
126
- ##
127
- def active_scaffold_column_text(column, record)
128
- clean_column_value(truncate(record.send(column.name), :length => column.options[:truncate] || 50))
129
- end
130
-
131
- def active_scaffold_column_marked(column, record)
132
- options = {:id => nil, :object => record}
133
- content_tag(:span, check_box(:record, column.name, options), :class => 'in_place_editor_field', :data => {:ie_id => record.id.to_s})
134
- end
135
-
136
- def active_scaffold_column_checkbox(column, record)
137
- options = {:disabled => true, :id => nil, :object => record}
138
- options.delete(:disabled) if inplace_edit?(record, column)
139
- check_box(:record, column.name, options)
140
- end
141
-
142
- def column_override(column)
143
- override_helper column, 'column'
144
- end
145
- alias_method :column_override?, :column_override
146
-
147
- # the naming convention for overriding column types with helpers
148
- def override_column_ui(list_ui)
149
- method = "active_scaffold_column_#{list_ui}"
150
- method if respond_to? method
151
- end
152
- alias_method :override_column_ui?, :override_column_ui
153
-
154
- ##
155
- ## Formatting
156
- ##
157
- def format_column_value(record, column, value = nil)
158
- value ||= record.send(column.name) unless record.nil?
159
- if value && column.association # cache association size before calling column_empty?
160
- associated_size = value.size if column.plural_association? and column.associated_number? # get count before cache association
161
- cache_association(value, column, associated_size) if column.plural_association?
162
- end
163
- if column.association.nil? or column_empty?(value)
164
- if column.form_ui == :select && column.options[:options]
165
- text, val = column.options[:options].find {|text, val| (val.nil? ? text : val).to_s == value.to_s}
166
- value = active_scaffold_translated_option(column, text, val).first if text
167
- end
168
- if value.is_a? Numeric
169
- format_number_value(value, column.options)
170
- else
171
- format_value(value, column.options)
172
- end
173
- else
174
- format_association_value(value, column, associated_size)
175
- end
176
- end
177
-
178
- def format_number_value(value, options = {})
179
- value = case options[:format]
180
- when :size
181
- number_to_human_size(value, options[:i18n_options] || {})
182
- when :percentage
183
- number_to_percentage(value, options[:i18n_options] || {})
184
- when :currency
185
- number_to_currency(value, options[:i18n_options] || {})
186
- when :i18n_number
187
- number_with_delimiter(value, options[:i18n_options] || {})
188
- else
189
- value
190
- end
191
- clean_column_value(value)
192
- end
193
-
194
- def format_association_value(value, column, size)
195
- format_value case column.association.macro
196
- when :has_one, :belongs_to
197
- if column.polymorphic_association?
198
- "#{value.class.model_name.human}: #{value.to_label}"
199
- else
200
- value.to_label
201
- end
202
- when :has_many, :has_and_belongs_to_many
203
- if column.associated_limit.nil?
204
- firsts = value.collect { |v| v.to_label }
205
- else
206
- firsts = value.first(column.associated_limit)
207
- firsts.collect! { |v| v.to_label }
208
- firsts[column.associated_limit] = '…' if value.size > column.associated_limit
209
- end
210
- if column.associated_limit == 0
211
- size if column.associated_number?
212
- else
213
- joined_associated = firsts.join(active_scaffold_config.list.association_join_text)
214
- joined_associated << " (#{size})" if column.associated_number? and column.associated_limit and value.size > column.associated_limit
215
- joined_associated
216
- end
217
- end
218
- end
219
-
220
- def format_value(column_value, options = {})
221
- value = if column_empty?(column_value)
222
- active_scaffold_config.list.empty_field_text
223
- elsif column_value.is_a?(Time) || column_value.is_a?(Date)
224
- l(column_value, :format => options[:format] || :default)
225
- elsif [FalseClass, TrueClass].include?(column_value.class)
226
- as_(column_value.to_s.to_sym)
227
- else
228
- column_value.to_s
229
- end
230
- clean_column_value(value)
231
- end
232
-
233
- def cache_association(value, column, size)
234
- # we are not using eager loading, cache firsts records in order not to query the database in a future
235
- unless value.loaded?
236
- # load at least one record, is needed to display '...'
237
- if column.associated_limit.nil?
238
- Rails.logger.warn "ActiveScaffold: Enable eager loading for #{column.name} association to reduce SQL queries"
239
- elsif column.associated_limit > 0
240
- value.target = value.find(:all, :limit => column.associated_limit + 1, :select => column.select_columns)
241
- elsif @cache_associations
242
- value.target = size.to_i.zero? ? [] : [nil]
243
- end
244
- end
245
- end
246
-
247
- # ==========
248
- # = Inline Edit =
249
- # ==========
250
-
251
- def inplace_edit?(record, column)
252
- if column.inplace_edit
253
- editable = controller.send(:update_authorized?, record) if controller.respond_to?(:update_authorized?)
254
- editable = record.authorized_for?(:crud_type => :update, :column => column.name) if editable.nil? || editable == true
255
- editable
256
- end
257
- end
258
-
259
- def inplace_edit_cloning?(column)
260
- column.inplace_edit != :ajax and (override_form_field?(column) or column.form_ui or (column.column and override_input?(column.column.type)))
261
- end
262
-
263
- def active_scaffold_inplace_edit(record, column, options = {})
264
- formatted_column = options[:formatted_column] || format_column_value(record, column)
265
- id_options = {:id => record.id.to_s, :action => 'update_column', :name => column.name.to_s}
266
- tag_options = {:id => element_cell_id(id_options), :class => "in_place_editor_field",
267
- :title => as_(:click_to_edit), :data => {:ie_id => record.id.to_s}}
268
-
269
- content_tag(:span, as_(:inplace_edit_handle), :class => 'handle') <<
270
- content_tag(:span, formatted_column, tag_options)
271
- end
272
-
273
- def inplace_edit_control(column)
274
- if inplace_edit?(active_scaffold_config.model, column) and inplace_edit_cloning?(column)
275
- old_record, @record = @record, new_model
276
- column = column.clone
277
- column.options = column.options.clone
278
- column.form_ui = :select if (column.association && column.form_ui.nil?)
279
- content_tag(:div, active_scaffold_input_for(column), :style => "display:none;", :class => inplace_edit_control_css_class).tap do
280
- @record = old_record
281
- end
282
- end
283
- end
284
-
285
- def inplace_edit_control_css_class
286
- "as_inplace_pattern"
287
- end
288
-
289
- def inplace_edit_data(column)
290
- data = {}
291
- data[:ie_url] = url_for({:controller => params_for[:controller], :action => "update_column", :column => column.name, :id => '__id__'})
292
- data[:ie_cancel_text] = column.options[:cancel_text] || as_(:cancel)
293
- data[:ie_loading_text] = column.options[:loading_text] || as_(:loading)
294
- data[:ie_save_text] = column.options[:save_text] || as_(:update)
295
- data[:ie_saving_text] = column.options[:saving_text] || as_(:saving)
296
- data[:ie_rows] = column.options[:rows] || 5 if column.column.try(:type) == :text
297
- data[:ie_cols] = column.options[:cols] if column.options[:cols]
298
- data[:ie_size] = column.options[:size] if column.options[:size]
299
-
300
- if column.list_ui == :checkbox
301
- data[:ie_mode] = :inline_checkbox
302
- elsif inplace_edit_cloning?(column)
303
- data[:ie_mode] = :clone
304
- elsif column.inplace_edit == :ajax
305
- url = url_for(:controller => params_for[:controller], :action => 'render_field', :id => '__id__', :column => column.name, :update_column => column.name, :in_place_editing => true)
306
- plural = column.plural_association? && !override_form_field?(column) && [:select, :record_select].include?(column.form_ui)
307
- data[:ie_render_url] = url
308
- data[:ie_mode] = :ajax
309
- data[:ie_plural] = plural
310
- end
311
- data
312
- end
313
-
314
- def all_marked?
315
- if active_scaffold_config.mark.mark_all_mode == :page
316
- all_marked = @page.items.detect { |record| !marked_records.include?(record.id) }.nil?
317
- else
318
- all_marked = (marked_records.length >= @page.pager.count)
319
- end
320
- end
321
-
322
- def mark_column_heading
323
- tag_options = {
324
- :id => "#{controller_id}_mark_heading",
325
- :class => "mark_heading in_place_editor_field",
326
- }
327
- content_tag(:span, check_box_tag("#{controller_id}_mark_heading_span_input", '1', all_marked?), tag_options)
328
- end
329
-
330
- def render_column_heading(column, sorting, sort_direction)
331
- tag_options = {:id => active_scaffold_column_header_id(column), :class => column_heading_class(column, sorting), :title => column.description}
332
- if column.name == :as_marked
333
- tag_options[:data] = {
334
- :ie_mode => :inline_checkbox,
335
- :ie_url => url_for(params_for(:action => 'mark', :id => '__id__'))
336
- }
337
- else
338
- tag_options[:data] = inplace_edit_data(column) if column.inplace_edit
339
- end
340
- content_tag(:th, column_heading_value(column, sorting, sort_direction) + inplace_edit_control(column), tag_options)
341
- end
342
-
343
-
344
- def column_heading_value(column, sorting, sort_direction)
345
- if column.name == :as_marked
346
- mark_column_heading
347
- elsif column.sortable?
348
- options = {:id => nil, :class => "as_sort",
349
- 'data-page-history' => controller_id,
350
- :remote => true, :method => :get}
351
- url_options = params_for(:action => :index, :page => 1,
352
- :sort => column.name, :sort_direction => sort_direction)
353
- link_to column.label, url_options, options
354
- else
355
- content_tag(:p, column.label)
356
- end
357
- end
358
-
359
- def render_nested_view(action_links, url_options, record)
360
- rendered = []
361
- action_links.member.each do |link|
362
- if link.nested_link? && link.column && @nested_auto_open[link.column.name] && @records.length <= @nested_auto_open[link.column.name] && controller.respond_to?(:render_component_into_view)
363
- link_url_options = {:adapter => '_list_inline_adapter', :format => :js}.merge(action_link_url_options(link, url_options, record, options = {:reuse_eid => true}))
364
- link_id = get_action_link_id(link_url_options, record, link.column)
365
- rendered << (controller.send(:render_component_into_view, link_url_options) + javascript_tag("ActiveScaffold.ActionLink.get('#{link_id}').set_opened();"))
366
- end
367
- end
368
- rendered.join(' ').html_safe
369
- end
370
-
371
- end
372
- end
373
- end
374
-