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,34 +0,0 @@
1
- module ActiveScaffold
2
- module Helpers
3
- # Helpers that assist with the rendering of a Form Column
4
- module FormColumnHelpers
5
- def active_scaffold_input_file_column(column, options)
6
- if @record.send(column.name)
7
- # we already have a value? display the form for deletion.
8
- if ActiveScaffold.js_framework == :jquery
9
- remove_file_js = "$(this).prev().val('true'); $(this).parent().hide().next().show(); return false;";
10
- else
11
- remove_file_js = "$(this).previous().value='true'; p=$(this).up(); p.hide(); p.next().show(); return false;";
12
- end
13
-
14
- hidden_options = options.dup
15
- hidden_options[:id] += '_delete'
16
- hidden_options[:name].sub!("[#{column.name}]", "[delete_#{column.name}]")
17
- hidden_options[:value] = 'false'
18
- custom_hidden_field_tag = hidden_field(:record, column.name, hidden_options)
19
-
20
- content_tag(:div) do
21
- content_tag(:div) do
22
- content = get_column_value(@record, column) + " #{custom_hidden_field_tag} | ".html_safe
23
- content += content_tag(:a, as_(:remove_file), {:href => '#', :onclick => remove_file_js})
24
- content += content_tag(:div, file_column_field("record", column.name, options), :style => "display: none")
25
- end
26
- end
27
- else
28
- file_column_field("record", column.name, options)
29
- end
30
- end
31
-
32
- end
33
- end
34
- end
@@ -1,26 +0,0 @@
1
- module ActiveScaffold
2
- module Helpers
3
- # Helpers that assist with the rendering of a List Column
4
- module ListColumnHelpers
5
- def active_scaffold_column_download_link_with_filename(column, record)
6
- return nil if record.send(column.name).nil?
7
- active_scaffold_column_download_link(column, record, File.basename(record.send(column.name)))
8
- end
9
-
10
- def active_scaffold_column_download_link(column, record, label = nil)
11
- return nil if record.send(column.name).nil?
12
- label||=as_(:download)
13
- link_to( label, url_for_file_column(record, column.name.to_s), :popup => true)
14
- end
15
-
16
- def active_scaffold_column_thumbnail(column, record)
17
- return nil if record.send(column.name).nil?
18
- link_to(
19
- image_tag(url_for_file_column(record, column.name.to_s, "thumb"), :border => 0),
20
- url_for_file_column(record, column.name.to_s),
21
- :popup => true)
22
- end
23
-
24
- end
25
- end
26
- end
@@ -1,43 +0,0 @@
1
- require File.join(File.dirname(__FILE__), "../test_helper.rb")
2
-
3
- class DeleteFileColumnTest < Test::Unit::TestCase
4
- def setup
5
- DeleteFileColumn.generate_delete_helpers(MockModel)
6
- @model = MockModel.new
7
- @model.band_image = "coolio.jpg"
8
- end
9
-
10
- def test__file_column_fields
11
- assert_equal(1, @model.file_column_fields.length)
12
- end
13
-
14
- def test__delete_band_image__boolean__should_delete
15
- @model.delete_band_image = true
16
- assert_nil @model.band_image
17
- end
18
-
19
- def test__delete_band_image__string__should_delete
20
- @model.delete_band_image = "true"
21
- assert_nil @model.band_image
22
- end
23
-
24
-
25
- def test__delete_band_image__boolean_false__shouldnt_delete
26
- @model.delete_band_image = false
27
- assert_not_nil @model.band_image
28
- end
29
-
30
- def test__delete_band_image__string_false__shouldnt_delete
31
- @model.delete_band_image = "false"
32
- assert_not_nil @model.band_image
33
- end
34
-
35
-
36
- def test__just_uploaded__shouldnt_delete
37
- @model.band_image_just_uploaded = true
38
- @model.delete_band_image = "true"
39
- assert_not_nil(@model.band_image)
40
- end
41
-
42
-
43
- end
@@ -1,9 +0,0 @@
1
- class MockModel
2
- attr_accessor :name
3
- attr_accessor :bio
4
-
5
- attr_accessor :band_image
6
- attr_accessor :band_image_just_uploaded
7
- def band_image_just_uploaded?; self.band_image_just_uploaded ? true : false; end
8
-
9
- end
@@ -1,15 +0,0 @@
1
- require 'test/unit'
2
- require "rubygems"
3
- require 'active_support'
4
-
5
- for file in ["../lib/delete_file_column.rb", "mock_model.rb"]
6
- require File.expand_path(File.join(File.dirname(__FILE__), file))
7
- end
8
-
9
-
10
-
11
- def dbg
12
- require 'ruby-debug'
13
- Debugger.start
14
- debugger
15
- end
@@ -1,12 +0,0 @@
1
- class ActiveScaffold::Bridges::Paperclip < ActiveScaffold::DataStructures::Bridge
2
- def self.install
3
- if ActiveScaffold::Config::Core.instance_methods.include?("initialize_with_paperclip")
4
- raise RuntimeError, "We've detected that you have active_scaffold_paperclip_bridge installed. This plugin has been moved to core. Please remove active_scaffold_paperclip_bridge to prevent any conflicts"
5
- end
6
- require File.join(File.dirname(__FILE__), "paperclip/form_ui")
7
- require File.join(File.dirname(__FILE__), "paperclip/list_ui")
8
- require File.join(File.dirname(__FILE__), "paperclip/paperclip_bridge_helpers")
9
- require File.join(File.dirname(__FILE__), "paperclip/paperclip_bridge")
10
- ActiveScaffold::Config::Core.send :include, ActiveScaffold::Bridges::Paperclip::PaperclipBridge
11
- end
12
- end
@@ -1,27 +0,0 @@
1
- module ActiveScaffold
2
- module Helpers
3
- module FormColumnHelpers
4
- def active_scaffold_input_paperclip(column, options)
5
- options = active_scaffold_input_text_options(options)
6
- input = file_field(:record, column.name, options)
7
- paperclip = @record.send("#{column.name}")
8
- if paperclip.file?
9
- if ActiveScaffold.js_framework == :jquery
10
- js_remove_file_code = "$(this).prev().val('true'); $(this).parent().hide().next().show(); return false;";
11
- else
12
- js_remove_file_code = "$(this).previous().value='true'; $(this).up().hide().next().show(); return false;";
13
- end
14
-
15
- content = active_scaffold_column_paperclip(column, @record)
16
- content_tag(:div,
17
- content + " | " +
18
- hidden_field(:record, "delete_#{column.name}", :value => "false") +
19
- content_tag(:a, as_(:remove_file), {:href => '#', :onclick => js_remove_file_code})
20
- ) + content_tag(:div, input, :style => "display: none")
21
- else
22
- input
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,16 +0,0 @@
1
- module ActiveScaffold
2
- module Helpers
3
- module ListColumnHelpers
4
- def active_scaffold_column_paperclip(column, record)
5
- paperclip = record.send("#{column.name}")
6
- return nil unless paperclip.file?
7
- content = if paperclip.styles.include?(ActiveScaffold::Bridges::Paperclip::PaperclipBridgeHelpers.thumbnail_style)
8
- image_tag(paperclip.url(ActiveScaffold::Bridges::Paperclip::PaperclipBridgeHelpers.thumbnail_style), :border => 0)
9
- else
10
- paperclip.original_filename
11
- end
12
- link_to(content, paperclip.url, {'data-popup' => true, :target => '_blank'})
13
- end
14
- end
15
- end
16
- end
@@ -1,36 +0,0 @@
1
- module ActiveScaffold
2
- module Bridges
3
- class Paperclip
4
- module PaperclipBridge
5
- def initialize_with_paperclip(model_id)
6
- initialize_without_paperclip(model_id)
7
- return unless self.model.respond_to?(:attachment_definitions) && !self.model.attachment_definitions.nil?
8
-
9
- self.update.multipart = true
10
- self.create.multipart = true
11
-
12
- self.model.attachment_definitions.keys.each do |field|
13
- configure_paperclip_field(field.to_sym)
14
- # define the "delete" helper for use with active scaffold, unless it's already defined
15
- ActiveScaffold::Bridges::Paperclip::PaperclipBridgeHelpers.generate_delete_helper(self.model, field)
16
- end
17
- end
18
-
19
- def self.included(base)
20
- base.alias_method_chain :initialize, :paperclip
21
- end
22
-
23
- private
24
- def configure_paperclip_field(field)
25
- self.columns << field
26
- self.columns[field].form_ui ||= :paperclip
27
- self.columns[field].params.add "delete_#{field}"
28
-
29
- [:file_name, :content_type, :file_size, :updated_at].each do |f|
30
- self.columns.exclude("#{field}_#{f}".to_sym)
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,24 +0,0 @@
1
- module ActiveScaffold
2
- module Bridges
3
- class Paperclip
4
- module PaperclipBridgeHelpers
5
- mattr_accessor :thumbnail_style
6
- self.thumbnail_style = :thumbnail
7
-
8
- def self.generate_delete_helper(klass, field)
9
- klass.class_eval <<-EOF, __FILE__, __LINE__ + 1 unless klass.instance_methods.include?("delete_#{field}=")
10
- attr_reader :delete_#{field}
11
-
12
- def delete_#{field}=(value)
13
- value = (value == "true") if String === value
14
- return unless value
15
-
16
- # passing nil to the file column causes the file to be deleted. Don't delete if we just uploaded a file!
17
- self.#{field} = nil unless self.#{field}.dirty?
18
- end
19
- EOF
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,11 +0,0 @@
1
- class ActiveScaffold::Bridges::RecordSelect < ActiveScaffold::DataStructures::Bridge
2
- def self.install
3
- require File.join(File.dirname(__FILE__), "record_select/helpers.rb")
4
- end
5
- def self.stylesheets
6
- 'record_select'
7
- end
8
- def self.javascripts
9
- 'record_select'
10
- end
11
- end
@@ -1,92 +0,0 @@
1
- class ActiveScaffold::Bridges::RecordSelect
2
- module Helpers
3
- def self.included(base)
4
- base.class_eval do
5
- include FormColumnHelpers
6
- include SearchColumnHelpers
7
- end
8
- end
9
-
10
- module FormColumnHelpers
11
- # requires RecordSelect plugin to be installed and configured.
12
- def active_scaffold_input_record_select(column, options)
13
- if column.singular_association?
14
- multiple = false
15
- multiple = column.options[:html_options][:multiple] if column.options[:html_options] && column.options[:html_options][:multiple]
16
- active_scaffold_record_select(column, options, @record.send(column.name), multiple)
17
- elsif column.plural_association?
18
- active_scaffold_record_select(column, options, @record.send(column.name), true)
19
- else
20
- active_scaffold_record_select_autocomplete(column, options)
21
- end
22
- end
23
-
24
- def active_scaffold_record_select(column, options, value, multiple)
25
- unless column.association
26
- raise ArgumentError, "record_select can only work against associations (and #{column.name} is not). A common mistake is to specify the foreign key field (like :user_id), instead of the association (:user)."
27
- end
28
- klass = if column.polymorphic_association?
29
- @record.send(column.association.foreign_type).constantize rescue nil
30
- else
31
- column.association.klass
32
- end
33
- return content_tag :span, '', :class => options[:class] unless klass
34
-
35
- remote_controller = active_scaffold_controller_for(klass).controller_path
36
-
37
- # if the opposite association is a :belongs_to (in that case association in this class must be has_one or has_many)
38
- # then only show records that have not been associated yet
39
- if [:has_one, :has_many].include?(column.association.macro)
40
- params.merge!({column.association.foreign_key => ''})
41
- end
42
-
43
- record_select_options = active_scaffold_input_text_options(options).merge(
44
- :controller => remote_controller
45
- )
46
- record_select_options.merge!(column.options)
47
-
48
- html = if multiple
49
- record_multi_select_field(options[:name], value || [], record_select_options)
50
- else
51
- record_select_field(options[:name], value || klass.new, record_select_options)
52
- end
53
- html = self.class.field_error_proc.call(html, self) if @record.errors[column.name].any?
54
- html
55
- end
56
-
57
- def active_scaffold_record_select_autocomplete(column, options)
58
- record_select_options = active_scaffold_input_text_options(options).merge(
59
- :controller => active_scaffold_controller_for(@record.class).controller_path
60
- )
61
- html = record_select_autocomplete(options[:name], @record, record_select_options)
62
- html = self.class.field_error_proc.call(html, self) if @record.errors[column.name].any?
63
- html
64
- end
65
- end
66
-
67
- module SearchColumnHelpers
68
- def active_scaffold_search_record_select(column, options)
69
- value = field_search_record_select_value(column)
70
- active_scaffold_record_select(column, options, value, column.options[:multiple])
71
- end
72
-
73
- def field_search_record_select_value(column)
74
- begin
75
- value = field_search_params[column.name]
76
- unless value.blank?
77
- if column.options[:multiple]
78
- column.association.klass.find value.collect!(&:to_i)
79
- else
80
- column.association.klass.find(value.to_i)
81
- end
82
- end
83
- rescue Exception => e
84
- logger.error Time.now.to_s + "Sorry, we are not that smart yet. Attempted to restore search values to search fields but instead got -- #{e.inspect} -- on the ActiveScaffold column = :#{column.name} in #{@controller.class}"
85
- raise e
86
- end
87
- end
88
- end
89
- end
90
- end
91
-
92
- ActionView::Base.class_eval { include ActiveScaffold::Bridges::RecordSelect::Helpers }
@@ -1,5 +0,0 @@
1
- class ActiveScaffold::Bridges::SemanticAttributes < ActiveScaffold::DataStructures::Bridge
2
- def self.install
3
- require File.join(File.dirname(__FILE__), "semantic_attributes/column.rb")
4
- end
5
- end
@@ -1,20 +0,0 @@
1
- class ActiveScaffold::Bridges::SemanticAttributes
2
- module Column
3
- def self.included(base)
4
- base.class_eval { alias_method_chain :initialize, :semantic_attributes }
5
- end
6
-
7
- def initialize_with_semantic_attributes(name, active_record_class)
8
- initialize_without_semantic_attributes(name, active_record_class)
9
- self.required = !active_record_class.semantic_attributes[self.name].predicates.find {|p| p.allow_empty? == false }.nil?
10
- active_record_class.semantic_attributes[self.name].predicates.find do |p|
11
- sem_type = p.class.to_s.split('::')[1].underscore.to_sym
12
- next if [:required, :association].include?(sem_type)
13
- @form_ui = sem_type
14
- end
15
- end
16
- end
17
- end
18
- ActiveScaffold::DataStructures::Column.class_eval do
19
- include ActiveScaffold::Bridges::SemanticAttributes::Column
20
- end
@@ -1,209 +0,0 @@
1
- module ActiveScaffold
2
- module Bridges
3
- module Shared
4
- module DateBridge
5
- module SearchColumnHelpers
6
- def active_scaffold_search_date_bridge(column, options)
7
- current_search = {'from' => nil, 'to' => nil, 'opt' => 'BETWEEN',
8
- 'number' => 1, 'unit' => 'DAYS', 'range' => nil}
9
- current_search.merge!(options[:value]) unless options[:value].nil?
10
- tags = []
11
- tags << active_scaffold_search_date_bridge_comparator_tag(column, options, current_search)
12
- tags << active_scaffold_search_date_bridge_trend_tag(column, options, current_search)
13
- tags << active_scaffold_search_date_bridge_numeric_tag(column, options, current_search)
14
- tags << active_scaffold_search_date_bridge_range_tag(column, options, current_search)
15
- tags.join("&nbsp;").html_safe
16
- end
17
-
18
- def active_scaffold_search_date_bridge_comparator_options(column)
19
- select_options = ActiveScaffold::Finder::DateComparators.collect {|comp| [as_(comp.downcase.to_sym), comp]}
20
- select_options + ActiveScaffold::Finder::NumericComparators.collect {|comp| [as_(comp.downcase.to_sym), comp]}
21
- end
22
-
23
- def active_scaffold_search_date_bridge_comparator_tag(column, options, current_search)
24
- select_tag("#{options[:name]}[opt]", options_for_select(active_scaffold_search_date_bridge_comparator_options(column),current_search['opt']), :id => "#{options[:id]}_opt", :class => "as_search_range_option as_search_date_time_option")
25
- end
26
-
27
- def active_scaffold_search_date_bridge_numeric_tag(column, options, current_search)
28
- numeric_controls = "" <<
29
- active_scaffold_search_date_bridge_calendar_control(column, options, current_search, 'from') <<
30
- content_tag(:span, (" - " + active_scaffold_search_date_bridge_calendar_control(column, options, current_search, 'to')).html_safe,
31
- :id => "#{options[:id]}_between", :class => "as_search_range_between", :style => current_search['opt'] == 'BETWEEN' ? nil : "display: none")
32
- content_tag("span", numeric_controls.html_safe, :id => "#{options[:id]}_numeric", :style => ActiveScaffold::Finder::NumericComparators.include?(current_search['opt']) ? nil : "display: none")
33
- end
34
-
35
- def active_scaffold_search_date_bridge_trend_tag(column, options, current_search)
36
- active_scaffold_date_bridge_trend_tag(column, options,
37
- {:name_prefix => 'search',
38
- :number_value => current_search['number'],
39
- :unit_value => current_search["unit"],
40
- :show => (current_search['opt'] == 'PAST' || current_search['opt'] == 'FUTURE')})
41
- end
42
-
43
- def active_scaffold_date_bridge_trend_tag(column, options, trend_options)
44
- trend_controls = text_field_tag("#{trend_options[:name_prefix]}[#{column.name}][number]", trend_options[:number_value], :class => 'text-input', :size => 10, :autocomplete => 'off') << " " <<
45
- select_tag("#{trend_options[:name_prefix]}[#{column.name}][unit]",
46
- options_for_select(active_scaffold_search_date_bridge_trend_units(column), trend_options[:unit_value]),
47
- :class => 'text-input')
48
- content_tag("span", trend_controls.html_safe, :id => "#{options[:id]}_trend", :style => trend_options[:show] ? nil : "display: none")
49
- end
50
-
51
- def active_scaffold_search_date_bridge_trend_units(column)
52
- options = ActiveScaffold::Finder::DateUnits.collect{|unit| [as_(unit.downcase.to_sym), unit]}
53
- options = ActiveScaffold::Finder::TimeUnits.collect{|unit| [as_(unit.downcase.to_sym), unit]} + options if column_datetime?(column)
54
- options
55
- end
56
-
57
- def active_scaffold_search_date_bridge_range_tag(column, options, current_search)
58
- range_controls = select_tag("search[#{column.name}][range]",
59
- options_for_select( ActiveScaffold::Finder::DateRanges.collect{|range| [as_(range.downcase.to_sym), range]}, current_search["range"]),
60
- :class => 'text-input')
61
- content_tag("span", range_controls.html_safe, :id => "#{options[:id]}_range", :style => (current_search['opt'] == 'RANGE') ? nil : "display: none")
62
- end
63
-
64
- def column_datetime?(column)
65
- (!column.column.nil? && [:datetime, :time].include?(column.column.type))
66
- end
67
- end
68
-
69
- module HumanConditionHelpers
70
- def active_scaffold_human_condition_date_bridge(column, value)
71
- case value[:opt]
72
- when 'RANGE'
73
- range_type, range = value[:range].downcase.split('_')
74
- format = active_scaffold_human_condition_date_bridge_range_format(range_type, range)
75
- from, to = controller.class.date_bridge_from_to(column, value)
76
- "#{column.active_record_class.human_attribute_name(column.name)} = #{as_(value[:range].downcase).downcase} (#{I18n.l(from, :format => format)})"
77
- when 'PAST', 'FUTURE'
78
- from, to = controller.class.date_bridge_from_to(column, value)
79
- "#{column.active_record_class.human_attribute_name(column.name)} #{as_('BETWEEN'.downcase).downcase} #{I18n.l(from)} - #{I18n.l(to)}"
80
- else
81
- from, to = controller.class.date_bridge_from_to(column, value)
82
- "#{column.active_record_class.human_attribute_name(column.name)} #{as_(value[:opt].downcase).downcase} #{I18n.l(from)} #{value[:opt] == 'BETWEEN' ? '- ' + I18n.l(to) : ''}"
83
- end
84
- end
85
-
86
- def active_scaffold_human_condition_date_bridge_range_format(range_type, range)
87
- case range
88
- when 'week'
89
- first_day_of_week = I18n.translate 'active_scaffold.date_picker_options.firstDay'
90
- if first_day_of_week == 1
91
- '%W %Y'
92
- else
93
- '%U %Y'
94
- end
95
- when 'month'
96
- '%b %Y'
97
- when 'year'
98
- '%Y'
99
- else
100
- I18n.translate 'date.formats.default'
101
- end
102
- end
103
- end
104
-
105
- module Finder
106
- module ClassMethods
107
- def condition_for_date_bridge_type(column, value, like_pattern)
108
- operator = ActiveScaffold::Finder::NumericComparators.include?(value[:opt]) && value[:opt] != 'BETWEEN' ? value[:opt] : nil
109
- from_value, to_value = date_bridge_from_to(column, value)
110
-
111
- if column.search_sql.is_a? Proc
112
- column.search_sql.call(from_value, to_value, operator)
113
- else
114
- unless operator.nil?
115
- ["%{search_sql} #{value[:opt]} ?", from_value.to_s(:db)] unless from_value.nil?
116
- else
117
- ["%{search_sql} BETWEEN ? AND ?", from_value.to_s(:db), to_value.to_s(:db)] unless from_value.nil? && to_value.nil?
118
- end
119
- end
120
- end
121
-
122
- def date_bridge_from_to(column, value)
123
- conversion = datetime_conversion_for_condition(column)
124
- case value[:opt]
125
- when 'RANGE'
126
- date_bridge_from_to_for_range(column, value).collect(&conversion)
127
- when 'PAST', 'FUTURE'
128
- date_bridge_from_to_for_trend(column, value).collect(&conversion)
129
- else
130
- ['from', 'to'].collect { |field| condition_value_for_datetime(value[field], conversion)}
131
- end
132
- end
133
-
134
- def date_bridge_now
135
- Time.zone.now
136
- end
137
-
138
- def date_bridge_from_to_for_trend(column, value)
139
- case value['opt']
140
- when "PAST"
141
- trend_number = [value['number'].to_i, 1].max
142
- now = date_bridge_now
143
- if date_bridge_column_date?(column)
144
- from = now.beginning_of_day.ago((trend_number).send(value['unit'].downcase.singularize.to_sym))
145
- to = now.end_of_day
146
- else
147
- from = now.ago((trend_number).send(value['unit'].downcase.singularize.to_sym))
148
- to = now
149
- end
150
- return from, to
151
- when "FUTURE"
152
- trend_number = [value['number'].to_i, 1].max
153
- now = date_bridge_now
154
- if date_bridge_column_date?(column)
155
- from = now.beginning_of_day
156
- to = now.end_of_day.in((trend_number).send(value['unit'].downcase.singularize.to_sym))
157
- else
158
- from = now
159
- to = now.in((trend_number).send(value['unit'].downcase.singularize.to_sym))
160
- end
161
- return from, to
162
- end
163
- end
164
-
165
- def date_bridge_from_to_for_range(column, value)
166
- case value[:range]
167
- when 'TODAY'
168
- return date_bridge_now.beginning_of_day, date_bridge_now.end_of_day
169
- when 'YESTERDAY'
170
- return date_bridge_now.ago(1.day).beginning_of_day, date_bridge_now.ago(1.day).end_of_day
171
- when 'TOMORROW'
172
- return date_bridge_now.in(1.day).beginning_of_day, date_bridge_now.in(1.day).end_of_day
173
- else
174
- range_type, range = value[:range].downcase.split('_')
175
- raise ArgumentError unless ['week', 'month', 'year'].include?(range)
176
- case range_type
177
- when 'this'
178
- return date_bridge_now.send("beginning_of_#{range}".to_sym), date_bridge_now.send("end_of_#{range}")
179
- when 'prev'
180
- return date_bridge_now.ago(1.send(range.to_sym)).send("beginning_of_#{range}".to_sym), date_bridge_now.ago(1.send(range.to_sym)).send("end_of_#{range}".to_sym)
181
- when 'next'
182
- return date_bridge_now.in(1.send(range.to_sym)).send("beginning_of_#{range}".to_sym), date_bridge_now.in(1.send(range.to_sym)).send("end_of_#{range}".to_sym)
183
- else
184
- return nil, nil
185
- end
186
- end
187
- end
188
-
189
- def date_bridge_column_date?(column)
190
- if [:date_picker, :datetime_picker].include? column.form_ui
191
- column.form_ui == :date_picker
192
- else
193
- (!column.column.nil? && [:date].include?(column.column.type))
194
- end
195
- end
196
- end
197
- end
198
- end
199
- end
200
- end
201
- end
202
-
203
- ActiveScaffold::Finder.const_set('DateComparators', ["PAST", "FUTURE", "RANGE"])
204
- ActiveScaffold::Finder.const_set('DateUnits', ["DAYS", "WEEKS", "MONTHS", "YEARS"])
205
- ActiveScaffold::Finder.const_set('TimeUnits', ["SECONDS", "MINUTES", "HOURS"])
206
- ActiveScaffold::Finder.const_set('DateRanges', ["TODAY", "YESTERDAY", "TOMORROW",
207
- "THIS_WEEK", "PREV_WEEK", "NEXT_WEEK",
208
- "THIS_MONTH", "PREV_MONTH", "NEXT_MONTH",
209
- "THIS_YEAR", "PREV_YEAR", "NEXT_YEAR"])