active_scaffold 3.0.26 → 3.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (236) hide show
  1. data/CHANGELOG +1 -1
  2. data/{frontends/default → app/assets}/images/add.gif +0 -0
  3. data/{frontends/default → app/assets}/images/arrow_down.gif +0 -0
  4. data/{frontends/default → app/assets}/images/arrow_up.gif +0 -0
  5. data/{frontends/default → app/assets}/images/close.gif +0 -0
  6. data/{frontends/default → app/assets}/images/close_touch.png +0 -0
  7. data/{frontends/default → app/assets}/images/config.png +0 -0
  8. data/{frontends/default → app/assets}/images/cross.png +0 -0
  9. data/{frontends/default → app/assets}/images/gears.png +0 -0
  10. data/{frontends/default → app/assets}/images/indicator-small.gif +0 -0
  11. data/{frontends/default → app/assets}/images/indicator.gif +0 -0
  12. data/{frontends/default → app/assets}/images/magnifier.png +0 -0
  13. data/app/assets/javascripts/active_scaffold.js.erb +16 -0
  14. data/{frontends/default → app/assets}/javascripts/jquery/active_scaffold.js +16 -28
  15. data/app/assets/javascripts/jquery/active_scaffold.js~ +1036 -0
  16. data/{lib/active_scaffold/bridges/date_picker/public/javascripts/date_picker_bridge.js → app/assets/javascripts/jquery/date_picker_bridge.js.erb} +3 -1
  17. data/{frontends/default → app/assets}/javascripts/jquery/jquery.editinplace.js +0 -0
  18. data/app/assets/javascripts/prototype/active_scaffold.js +1033 -0
  19. data/{frontends/default/javascripts/prototype/active_scaffold.js → app/assets/javascripts/prototype/active_scaffold.js~} +1 -0
  20. data/{frontends/default → app/assets}/javascripts/prototype/dhtml_history.js +0 -0
  21. data/{frontends/default → app/assets}/javascripts/prototype/form_enhancements.js +0 -0
  22. data/{frontends/default → app/assets}/javascripts/prototype/rico_corner.js +0 -0
  23. data/{frontends/default/stylesheets/stylesheet-ie.css → app/assets/stylesheets/active_scaffold-ie.css} +0 -0
  24. data/{frontends/default/stylesheets/stylesheet.css → app/assets/stylesheets/active_scaffold.css.erb} +29 -24
  25. data/{lib/active_scaffold/locale → config/locales}/de.yml +3 -0
  26. data/{lib/active_scaffold/locale → config/locales}/en.yml +3 -0
  27. data/{lib/active_scaffold/locale → config/locales}/es.yml +5 -0
  28. data/{lib/active_scaffold/locale → config/locales}/fr.yml +3 -0
  29. data/{lib/active_scaffold/locale → config/locales}/hu.yml +13 -2
  30. data/{lib/active_scaffold/locale → config/locales}/ja.yml +9 -0
  31. data/{lib/active_scaffold/locale → config/locales}/ru.yml +3 -0
  32. data/frontends/default/views/_form.html.erb +1 -1
  33. data/frontends/default/views/_form_association.html.erb +1 -5
  34. data/frontends/default/views/_horizontal_subform.html.erb +7 -4
  35. data/frontends/default/views/_horizontal_subform.html.erb~ +2 -5
  36. data/frontends/default/views/_horizontal_subform_footer.html.erb +0 -0
  37. data/frontends/default/views/_horizontal_subform_header.html.erb +1 -1
  38. data/frontends/default/views/_horizontal_subform_header.html.erb~ +1 -1
  39. data/frontends/default/views/_horizontal_subform_record.html.erb~ +1 -1
  40. data/frontends/default/views/_list_actions.html.erb +1 -1
  41. data/frontends/default/views/_list_messages.html.erb +1 -3
  42. data/frontends/default/views/_render_field.js.erb +20 -0
  43. data/frontends/default/views/_row.html.erb +3 -9
  44. data/frontends/default/views/_show.html.erb +2 -2
  45. data/frontends/default/views/add_existing.js.erb +20 -0
  46. data/frontends/default/views/destroy.js.erb +24 -0
  47. data/frontends/default/views/{edit_associated.js.rjs → edit_associated.js.erb} +3 -2
  48. data/frontends/default/views/form_messages.js.erb +1 -0
  49. data/frontends/default/views/list.js.erb +1 -0
  50. data/frontends/default/views/mark.js.rjs +6 -0
  51. data/frontends/default/views/on_action_update.js.erb +13 -0
  52. data/frontends/default/views/{on_create.js.erb~ → on_create.js.erb} +0 -0
  53. data/frontends/default/views/on_mark_all.js.erb +12 -0
  54. data/frontends/default/views/{on_update.js.erb~ → on_update.js.erb} +0 -0
  55. data/frontends/default/views/render_field.js.erb +1 -0
  56. data/frontends/default/views/search.html.erb +1 -1
  57. data/frontends/default/views/{update_column.js.erb~ → update_column.js.erb} +3 -3
  58. data/frontends/default/views/update_row.js.erb +1 -0
  59. data/lib/active_scaffold.rb +22 -46
  60. data/lib/active_scaffold/actions/core.rb +14 -6
  61. data/lib/active_scaffold/actions/core.rb~ +3 -3
  62. data/lib/active_scaffold/actions/create.rb +2 -5
  63. data/lib/active_scaffold/actions/create.rb~ +3 -2
  64. data/lib/active_scaffold/actions/delete.rb +1 -0
  65. data/lib/active_scaffold/actions/field_search.rb +1 -1
  66. data/lib/active_scaffold/actions/list.rb +10 -6
  67. data/lib/active_scaffold/actions/list.rb~ +3 -3
  68. data/lib/active_scaffold/actions/mark.rb +8 -8
  69. data/lib/active_scaffold/actions/nested.rb +2 -9
  70. data/lib/active_scaffold/actions/nested.rb~ +5 -7
  71. data/lib/active_scaffold/actions/search.rb +2 -1
  72. data/lib/active_scaffold/actions/subform.rb +1 -5
  73. data/lib/active_scaffold/actions/update.rb +1 -4
  74. data/lib/active_scaffold/actions/update.rb~ +5 -5
  75. data/lib/active_scaffold/attribute_params.rb +15 -26
  76. data/lib/active_scaffold/attribute_params.rb~ +1 -2
  77. data/lib/active_scaffold/bridges.rb +61 -0
  78. data/lib/active_scaffold/bridges/ancestry.rb +5 -0
  79. data/lib/active_scaffold/bridges/ancestry/{lib/ancestry_bridge.rb → ancestry_bridge.rb} +3 -3
  80. data/lib/active_scaffold/bridges/{calendar_date_select/bridge.rb → calendar_date_select.rb} +13 -5
  81. data/lib/active_scaffold/bridges/calendar_date_select/{lib/as_cds_bridge.rb → as_cds_bridge.rb} +4 -20
  82. data/lib/active_scaffold/bridges/cancan.rb +15 -0
  83. data/lib/active_scaffold/bridges/cancan/{lib/cancan_bridge.rb → cancan_bridge.rb} +2 -2
  84. data/lib/active_scaffold/bridges/carrierwave.rb +12 -0
  85. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +31 -0
  86. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge_helpers.rb +10 -0
  87. data/lib/active_scaffold/bridges/carrierwave/{lib/form_ui.rb → form_ui.rb} +0 -0
  88. data/lib/active_scaffold/bridges/carrierwave/{lib/list_ui.rb → list_ui.rb} +1 -1
  89. data/lib/active_scaffold/bridges/country_helper.rb +9 -0
  90. data/lib/active_scaffold/bridges/country_helper/{lib/country_helper_bridge.rb → country_helper_bridge.rb} +5 -5
  91. data/lib/active_scaffold/bridges/date_picker.rb +23 -0
  92. data/lib/active_scaffold/bridges/date_picker/ext.rb +54 -0
  93. data/lib/active_scaffold/bridges/date_picker/helper.rb +188 -0
  94. data/lib/active_scaffold/bridges/dragonfly.rb +9 -0
  95. data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +34 -0
  96. data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge_helpers.rb +10 -0
  97. data/lib/active_scaffold/bridges/dragonfly/{lib/form_ui.rb → form_ui.rb} +0 -0
  98. data/lib/active_scaffold/bridges/dragonfly/{lib/list_ui.rb → list_ui.rb} +2 -2
  99. data/lib/active_scaffold/bridges/file_column.rb +11 -0
  100. data/lib/active_scaffold/bridges/file_column/{lib/as_file_column_bridge.rb → as_file_column_bridge.rb} +2 -2
  101. data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +57 -0
  102. data/lib/active_scaffold/bridges/file_column/{lib/form_ui.rb → form_ui.rb} +2 -2
  103. data/lib/active_scaffold/bridges/file_column/{lib/list_ui.rb → list_ui.rb} +0 -0
  104. data/lib/active_scaffold/bridges/paperclip.rb +12 -0
  105. data/lib/active_scaffold/bridges/paperclip/{lib/form_ui.rb → form_ui.rb} +0 -0
  106. data/lib/active_scaffold/bridges/paperclip/{lib/list_ui.rb → list_ui.rb} +3 -3
  107. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +36 -0
  108. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +24 -0
  109. data/lib/active_scaffold/bridges/record_select.rb +11 -0
  110. data/lib/active_scaffold/bridges/record_select/{lib/record_select_bridge.rb → helpers.rb} +5 -16
  111. data/lib/active_scaffold/bridges/record_select/helpers.rb~ +9 -14
  112. data/lib/active_scaffold/bridges/semantic_attributes.rb +5 -0
  113. data/lib/active_scaffold/bridges/semantic_attributes/{lib/semantic_attributes_bridge.rb → column.rb} +3 -3
  114. data/lib/active_scaffold/bridges/tiny_mce.rb +5 -0
  115. data/lib/active_scaffold/bridges/tiny_mce/{lib/tiny_mce_bridge.rb → helpers.rb} +16 -8
  116. data/lib/active_scaffold/config/base.rb +9 -1
  117. data/lib/active_scaffold/config/core.rb +1 -1
  118. data/lib/active_scaffold/config/create.rb +3 -10
  119. data/lib/active_scaffold/config/delete.rb +1 -2
  120. data/lib/active_scaffold/config/field_search.rb +1 -2
  121. data/lib/active_scaffold/config/form.rb +2 -6
  122. data/lib/active_scaffold/config/list.rb +8 -2
  123. data/lib/active_scaffold/config/nested.rb +2 -6
  124. data/lib/active_scaffold/config/search.rb +6 -2
  125. data/lib/active_scaffold/config/show.rb +1 -4
  126. data/lib/active_scaffold/config/subform.rb +1 -1
  127. data/lib/active_scaffold/config/update.rb +1 -6
  128. data/lib/active_scaffold/data_structures/action_columns.rb +3 -0
  129. data/lib/active_scaffold/data_structures/action_link.rb +14 -10
  130. data/lib/active_scaffold/data_structures/bridge.rb +22 -0
  131. data/lib/active_scaffold/data_structures/column.rb +36 -4
  132. data/lib/active_scaffold/data_structures/nested_info.rb +4 -4
  133. data/lib/active_scaffold/data_structures/set.rb +1 -6
  134. data/lib/active_scaffold/data_structures/sorting.rb +2 -2
  135. data/lib/active_scaffold/engine.rb +4 -0
  136. data/lib/active_scaffold/extensions/action_controller_rendering.rb +2 -2
  137. data/lib/active_scaffold/extensions/action_controller_rendering.rb~ +1 -1
  138. data/lib/active_scaffold/extensions/action_view_rendering.rb +90 -93
  139. data/lib/active_scaffold/extensions/action_view_rendering.rb~ +1 -13
  140. data/lib/active_scaffold/extensions/active_association_reflection.rb +16 -7
  141. data/lib/active_scaffold/extensions/cache_association.rb +16 -0
  142. data/lib/active_scaffold/extensions/reverse_associations.rb +15 -13
  143. data/lib/active_scaffold/extensions/unsaved_associated.rb +1 -1
  144. data/lib/active_scaffold/finder.rb +40 -23
  145. data/lib/active_scaffold/finder.rb~ +3 -11
  146. data/lib/active_scaffold/helpers/association_helpers.rb +1 -1
  147. data/lib/active_scaffold/helpers/controller_helpers.rb +9 -1
  148. data/lib/active_scaffold/helpers/controller_helpers.rb~ +12 -5
  149. data/lib/active_scaffold/helpers/form_column_helpers.rb +20 -21
  150. data/lib/active_scaffold/helpers/form_column_helpers.rb~ +2 -1
  151. data/lib/active_scaffold/helpers/id_helpers.rb +5 -5
  152. data/lib/active_scaffold/helpers/list_column_helpers.rb +14 -24
  153. data/lib/active_scaffold/helpers/list_column_helpers.rb~ +15 -20
  154. data/lib/active_scaffold/helpers/search_column_helpers.rb +10 -1
  155. data/lib/active_scaffold/helpers/search_column_helpers.rb~ +1 -1
  156. data/lib/active_scaffold/helpers/view_helpers.rb +14 -40
  157. data/lib/active_scaffold/helpers/view_helpers.rb~ +3 -3
  158. data/lib/active_scaffold/version.rb +2 -2
  159. data/lib/active_scaffold_env.rb +0 -2
  160. data/test/bridges/active_scaffold_dependent_protect_test.rb +34 -0
  161. data/test/bridges/bridge_test.rb +43 -0
  162. data/test/bridges/company.rb +81 -0
  163. data/test/bridges/paperclip_test.rb +68 -0
  164. data/test/bridges/tiny_mce_test.rb +27 -0
  165. data/test/bridges/unobtrusive_date_picker_test.rb +49 -0
  166. data/test/bridges/validation_reflection_test.rb +57 -0
  167. data/test/config/base_test.rb +1 -1
  168. data/test/config/core_test.rb +58 -0
  169. data/test/config/create_test.rb +8 -5
  170. data/test/config/delete_test.rb +33 -0
  171. data/test/config/field_search_test.rb +47 -0
  172. data/test/config/list_test.rb +64 -9
  173. data/test/config/nested_test.rb +62 -0
  174. data/test/config/search_test.rb +60 -0
  175. data/test/config/show_test.rb +5 -5
  176. data/test/config/subform_test.rb +17 -0
  177. data/test/config/update_test.rb +27 -4
  178. data/test/helpers/list_column_helpers_test.rb +16 -5
  179. data/test/helpers/pagination_helpers_test.rb +4 -0
  180. data/test/misc/attribute_params_test.rb +37 -1
  181. data/test/misc/finder_test.rb +0 -1
  182. data/test/misc/lang_test.rb +2 -3
  183. data/test/mock_app/public/javascripts/active_scaffold/default/active_scaffold.js +2 -2
  184. data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +13 -7
  185. metadata +137 -154
  186. data/frontends/default/views/_list_with_header.html.erb~ +0 -32
  187. data/frontends/default/views/_render_field.js.rjs +0 -14
  188. data/frontends/default/views/_show.html.erb~ +0 -8
  189. data/frontends/default/views/_update_form.html.erb~ +0 -6
  190. data/frontends/default/views/add_existing.js.erb~ +0 -18
  191. data/frontends/default/views/add_existing.js.rjs +0 -17
  192. data/frontends/default/views/destroy.js.rjs +0 -23
  193. data/frontends/default/views/form_messages.js.rjs +0 -1
  194. data/frontends/default/views/list.js.rjs +0 -1
  195. data/frontends/default/views/on_action_update.js.rjs +0 -10
  196. data/frontends/default/views/on_create.js.rjs +0 -41
  197. data/frontends/default/views/on_mark_all.js.rjs +0 -12
  198. data/frontends/default/views/on_update.js.rjs +0 -28
  199. data/frontends/default/views/render_field.js.rjs +0 -1
  200. data/frontends/default/views/update_column.js.rjs +0 -13
  201. data/frontends/default/views/update_row.js.rjs +0 -1
  202. data/lib/active_scaffold.rb~ +0 -362
  203. data/lib/active_scaffold/bridges/ancestry/bridge.rb +0 -5
  204. data/lib/active_scaffold/bridges/bridge.rb +0 -59
  205. data/lib/active_scaffold/bridges/cancan/bridge.rb +0 -12
  206. data/lib/active_scaffold/bridges/carrierwave/bridge.rb +0 -9
  207. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge.rb +0 -33
  208. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge_helpers.rb +0 -12
  209. data/lib/active_scaffold/bridges/country_helper/bridge.rb +0 -9
  210. data/lib/active_scaffold/bridges/date_picker/bridge.rb +0 -24
  211. data/lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb +0 -234
  212. data/lib/active_scaffold/bridges/dragonfly/bridge.rb +0 -9
  213. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge.rb +0 -36
  214. data/lib/active_scaffold/bridges/dragonfly/lib/dragonfly_bridge_helpers.rb +0 -12
  215. data/lib/active_scaffold/bridges/file_column/bridge.rb +0 -11
  216. data/lib/active_scaffold/bridges/file_column/lib/file_column_helpers.rb +0 -59
  217. data/lib/active_scaffold/bridges/paperclip/bridge.rb +0 -12
  218. data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge.rb +0 -38
  219. data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge_helpers.rb +0 -26
  220. data/lib/active_scaffold/bridges/record_select/bridge.rb +0 -5
  221. data/lib/active_scaffold/bridges/semantic_attributes/bridge.rb +0 -5
  222. data/lib/active_scaffold/bridges/shared/date_bridge.rb~ +0 -209
  223. data/lib/active_scaffold/bridges/tiny_mce/bridge.rb +0 -5
  224. data/lib/active_scaffold/bridges/validation_reflection/bridge.rb +0 -8
  225. data/lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb +0 -21
  226. data/lib/active_scaffold/config/base.rb~ +0 -70
  227. data/lib/active_scaffold/config/nested.rb~ +0 -41
  228. data/lib/active_scaffold/constraints.rb~ +0 -186
  229. data/lib/active_scaffold/data_structures/action_link.rb~ +0 -179
  230. data/lib/active_scaffold/data_structures/nested_info.rb~ +0 -123
  231. data/lib/active_scaffold/extensions/action_view_resolver.rb +0 -7
  232. data/lib/active_scaffold/extensions/active_association_reflection.rb~ +0 -22
  233. data/lib/active_scaffold/extensions/unsaved_associated.rb~ +0 -62
  234. data/lib/active_scaffold_assets.rb +0 -45
  235. data/lib/generators/active_scaffold_setup/USAGE +0 -10
  236. data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +0 -59
@@ -0,0 +1,15 @@
1
+ class ActiveScaffold::Bridges::Cancan < ActiveScaffold::DataStructures::Bridge
2
+ def self.install
3
+ require File.join(File.dirname(__FILE__), "cancan", "cancan_bridge.rb")
4
+
5
+ ActiveScaffold::ClassMethods.send :include, ActiveScaffold::Bridges::Cancan::ClassMethods
6
+ ActiveScaffold::Actions::Core.send :include, ActiveScaffold::Bridges::Cancan::Actions::Core
7
+ ActiveScaffold::Actions::Nested.send :include, ActiveScaffold::Bridges::Cancan::Actions::Core
8
+ ActionController::Base.send :include, ActiveScaffold::Bridges::Cancan::ModelUserAccess::Controller
9
+ ::ActiveRecord::Base.send :include, ActiveScaffold::Bridges::Cancan::ModelUserAccess::Model
10
+ ::ActiveRecord::Base.send :include, ActiveScaffold::Bridges::Cancan::ActiveRecord
11
+ end
12
+ def self.install?
13
+ Object.const_defined? 'CanCan'
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
- module ActiveScaffold
2
- module CancanBridge
1
+ module ActiveScaffold::Bridges
2
+ class Cancan
3
3
 
4
4
  # controller level authorization
5
5
  # As already has callbacks to ensure authorization at controller method via "authorization_method"
@@ -0,0 +1,12 @@
1
+ class ActiveScaffold::Bridges::Carrierwave < ActiveScaffold::DataStructures::Bridge
2
+ def self.install
3
+ require File.join(File.dirname(__FILE__), "carrierwave/form_ui")
4
+ require File.join(File.dirname(__FILE__), "carrierwave/list_ui")
5
+ require File.join(File.dirname(__FILE__), "carrierwave/carrierwave_bridge_helpers")
6
+ require File.join(File.dirname(__FILE__), "carrierwave/carrierwave_bridge")
7
+ ActiveScaffold::Config::Core.send :include, ActiveScaffold::Bridges::Carrierwave::CarrierwaveBridge
8
+ end
9
+ def self.install?
10
+ Object.const_defined? 'CarrierWave'
11
+ end
12
+ end
@@ -0,0 +1,31 @@
1
+ module ActiveScaffold
2
+ module Bridges
3
+ class Carrierwave
4
+ module CarrierwaveBridge
5
+ def initialize_with_carrierwave(model_id)
6
+ initialize_without_carrierwave(model_id)
7
+ return unless self.model.respond_to?(:uploaders) && self.model.uploaders.present?
8
+
9
+ self.update.multipart = true
10
+ self.create.multipart = true
11
+
12
+ self.model.uploaders.keys.each do |field|
13
+ configure_carrierwave_field(field.to_sym)
14
+ end
15
+ end
16
+
17
+ def self.included(base)
18
+ base.alias_method_chain :initialize, :carrierwave
19
+ end
20
+
21
+ private
22
+ def configure_carrierwave_field(field)
23
+ self.columns << field
24
+ self.columns[field].form_ui ||= :carrierwave # :TODO thumbnail
25
+ self.columns[field].params.add "#{field}_cache"
26
+ self.columns[field].params.add "remove_#{field}"
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,10 @@
1
+ module ActiveScaffold
2
+ module Bridges
3
+ class Carrierwave
4
+ module CarrierwaveBridgeHelpers
5
+ mattr_accessor :thumbnail_style
6
+ self.thumbnail_style = :thumbnail
7
+ end
8
+ end
9
+ end
10
+ end
@@ -4,7 +4,7 @@ module ActiveScaffold
4
4
  def active_scaffold_column_carrierwave(column, record)
5
5
  carrierwave = record.send("#{column.name}")
6
6
  return nil unless !carrierwave.file.blank?
7
- thumbnail_style = ActiveScaffold::Bridges::Carrierwave::Lib::CarrierwaveBridgeHelpers.thumbnail_style
7
+ thumbnail_style = ActiveScaffold::Bridges::Carrierwave::CarrierwaveBridgeHelpers.thumbnail_style
8
8
  content = if carrierwave.versions.keys.include?(thumbnail_style)
9
9
  image_tag(carrierwave.url(thumbnail_style), :border => 0).html_safe
10
10
  else
@@ -0,0 +1,9 @@
1
+ class ActiveScaffold::Bridges::CountryHelper < ActiveScaffold::DataStructures::Bridge
2
+ def self.install
3
+ require File.join(File.dirname(__FILE__), "country_helper/country_helper_bridge.rb")
4
+ end
5
+
6
+ def self.install?
7
+ true
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
- module ActiveScaffold
2
- module CountryHelperBridge
1
+ module ActiveScaffold::Bridges
2
+ class CountryHelper
3
3
  module CountryHelpers
4
4
  # Return select and option tags for the given object and method, using country_options_for_select to generate the list of option tags.
5
5
  def country_select(object, method, priority_countries = nil, options = {}, html_options = {})
@@ -352,7 +352,7 @@ module ActiveScaffold
352
352
  end
353
353
 
354
354
  ActionView::Base.class_eval do
355
- include ActiveScaffold::CountryHelperBridge::CountryHelpers
356
- include ActiveScaffold::CountryHelperBridge::FormColumnHelpers
357
- include ActiveScaffold::CountryHelperBridge::SearchColumnHelpers
355
+ include ActiveScaffold::Bridges::CountryHelper::CountryHelpers
356
+ include ActiveScaffold::Bridges::CountryHelper::FormColumnHelpers
357
+ include ActiveScaffold::Bridges::CountryHelper::SearchColumnHelpers
358
358
  end
@@ -0,0 +1,23 @@
1
+ module ActiveScaffold::Bridges
2
+ class DatePicker < ActiveScaffold::DataStructures::Bridge
3
+ autoload :Helper, 'active_scaffold/bridges/date_picker/helper'
4
+ def self.install
5
+ require File.join(File.dirname(__FILE__), "date_picker/ext.rb")
6
+ end
7
+ def self.install?
8
+ ActiveScaffold.js_framework == :jquery
9
+ end
10
+ def self.localization
11
+ "jQuery(function($){
12
+ if (typeof($.datepicker) === 'object') {
13
+ #{Helper.date_options_for_locales}
14
+ $.datepicker.setDefaults($.datepicker.regional['#{::I18n.locale}']);
15
+ }
16
+ if (typeof($.timepicker) === 'object') {
17
+ #{Helper.datetime_options_for_locales}
18
+ $.timepicker.setDefaults($.timepicker.regional['#{::I18n.locale}']);
19
+ }
20
+ });\n"
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,54 @@
1
+ class File #:nodoc:
2
+
3
+ unless File.respond_to?(:binread)
4
+ def self.binread(file)
5
+ File.open(file, 'rb') { |f| f.read }
6
+ end
7
+ end
8
+
9
+ end
10
+
11
+ ActiveScaffold::Config::Core.class_eval do
12
+ def initialize_with_date_picker(model_id)
13
+ initialize_without_date_picker(model_id)
14
+
15
+ date_picker_fields = self.model.columns.collect{|c| {:name => c.name.to_sym, :type => c.type} if [:date, :datetime].include?(c.type) }.compact
16
+ # check to see if file column was used on the model
17
+ return if date_picker_fields.empty?
18
+
19
+ # automatically set the forum_ui to a file column
20
+ date_picker_fields.each{|field|
21
+ col_config = self.columns[field[:name]]
22
+ col_config.form_ui = (field[:type] == :date ? :date_picker : :datetime_picker)
23
+ }
24
+ end
25
+
26
+ alias_method_chain :initialize, :date_picker
27
+ end
28
+
29
+ ActiveRecord::ConnectionAdapters::Column.class_eval do
30
+ class << self
31
+ def fallback_string_to_date_with_date_picker(string)
32
+ Date.strptime(string, I18n.t('date.formats.default')) rescue fallback_string_to_date_without_date_picker(string)
33
+ end
34
+ alias_method_chain :fallback_string_to_date, :date_picker
35
+ end
36
+ end
37
+
38
+ ActionView::Base.class_eval do
39
+ include ActiveScaffold::Bridges::Shared::DateBridge::SearchColumnHelpers
40
+ alias_method :active_scaffold_search_date_picker, :active_scaffold_search_date_bridge
41
+ alias_method :active_scaffold_search_datetime_picker, :active_scaffold_search_date_bridge
42
+ include ActiveScaffold::Bridges::Shared::DateBridge::HumanConditionHelpers
43
+ alias_method :active_scaffold_human_condition_date_picker, :active_scaffold_human_condition_date_bridge
44
+ alias_method :active_scaffold_human_condition_datetime_picker, :active_scaffold_human_condition_date_bridge
45
+ include ActiveScaffold::Bridges::DatePicker::Helper::SearchColumnHelpers
46
+ include ActiveScaffold::Bridges::DatePicker::Helper::FormColumnHelpers
47
+ alias_method :active_scaffold_input_datetime_picker, :active_scaffold_input_date_picker
48
+ include ActiveScaffold::Bridges::DatePicker::Helper::DatepickerColumnHelpers
49
+ end
50
+ ActiveScaffold::Finder::ClassMethods.module_eval do
51
+ include ActiveScaffold::Bridges::Shared::DateBridge::Finder::ClassMethods
52
+ alias_method :condition_for_date_picker_type, :condition_for_date_bridge_type
53
+ alias_method :condition_for_datetime_picker_type, :condition_for_date_picker_type
54
+ end
@@ -0,0 +1,188 @@
1
+ module ActiveScaffold::Bridges
2
+ class DatePicker
3
+ module Helper
4
+ DATE_FORMAT_CONVERSION = {
5
+ /%a/ => 'D',
6
+ /%A/ => 'DD',
7
+ /%b/ => 'M',
8
+ /%B/ => 'MM',
9
+ /%d/ => 'dd',
10
+ /%e/ => 'd',
11
+ /%j/ => 'oo',
12
+ /%m/ => 'mm',
13
+ /%y/ => 'y',
14
+ /%Y/ => 'yy',
15
+ /%H/ => 'hh', # options ampm => false
16
+ /%I/ => 'hh', # options ampm => true
17
+ /%M/ => 'mm',
18
+ /%p/ => 'tt',
19
+ /%S/ => 'ss',
20
+ /%[cUWwxXZz]/ => ''
21
+ }
22
+
23
+ def self.date_options_for_locales
24
+ I18n.available_locales.collect do |locale|
25
+ locale_date_options = date_options(locale)
26
+ if locale_date_options
27
+ "$.datepicker.regional['#{locale}'] = #{locale_date_options.to_json};"
28
+ else
29
+ nil
30
+ end
31
+ end.compact.join('')
32
+ end
33
+
34
+ def self.date_options(locale)
35
+ begin
36
+ date_options = I18n.translate! 'date', :locale => locale
37
+ date_picker_options = { :closeText => as_(:close),
38
+ :prevText => as_(:previous),
39
+ :nextText => as_(:next),
40
+ :currentText => as_(:today),
41
+ :monthNames => date_options[:month_names][1, (date_options[:month_names].length - 1)],
42
+ :monthNamesShort => date_options[:abbr_month_names][1, (date_options[:abbr_month_names].length - 1)],
43
+ :dayNames => date_options[:day_names],
44
+ :dayNamesShort => date_options[:abbr_day_names],
45
+ :dayNamesMin => date_options[:abbr_day_names],
46
+ :changeYear => true,
47
+ :changeMonth => true,
48
+ }
49
+
50
+ begin
51
+ as_date_picker_options = I18n.translate! 'active_scaffold.date_picker_options'
52
+ date_picker_options.merge!(as_date_picker_options) if as_date_picker_options.is_a? Hash
53
+ rescue
54
+ Rails.logger.warn "ActiveScaffold: Missing date picker localization for your locale: #{locale}"
55
+ end
56
+
57
+ js_format = self.to_datepicker_format(date_options[:formats][:default])
58
+ date_picker_options[:dateFormat] = js_format unless js_format.nil?
59
+ date_picker_options
60
+ rescue
61
+ raise if locale == I18n.locale
62
+ end
63
+ end
64
+
65
+ def self.datetime_options_for_locales
66
+ I18n.available_locales.collect do |locale|
67
+ locale_datetime_options = datetime_options(locale)
68
+ if locale_datetime_options
69
+ "$.timepicker.regional['#{locale}'] = #{locale_datetime_options.to_json};"
70
+ else
71
+ nil
72
+ end
73
+ end.compact.join('')
74
+ end
75
+
76
+ def self.datetime_options(locale)
77
+ begin
78
+ rails_time_format = I18n.translate! 'time.formats.picker', :locale => locale
79
+ datetime_options = I18n.translate! 'datetime.prompts', :locale => locale
80
+ datetime_picker_options = {:ampm => false,
81
+ :hourText => datetime_options[:hour],
82
+ :minuteText => datetime_options[:minute],
83
+ :secondText => datetime_options[:second],
84
+ }
85
+
86
+ begin
87
+ as_datetime_picker_options = I18n.translate! 'active_scaffold.datetime_picker_options'
88
+ datetime_picker_options.merge!(as_datetime_picker_options) if as_datetime_picker_options.is_a? Hash
89
+ rescue
90
+ Rails.logger.warn "ActiveScaffold: Missing datetime picker localization for your locale: #{locale}"
91
+ end
92
+
93
+ date_format, time_format = self.split_datetime_format(self.to_datepicker_format(rails_time_format))
94
+ datetime_picker_options[:dateFormat] = date_format unless date_format.nil?
95
+ unless time_format.nil?
96
+ datetime_picker_options[:timeFormat] = time_format
97
+ datetime_picker_options[:ampm] = true if rails_time_format.include?('%I')
98
+ end
99
+ datetime_picker_options
100
+ rescue
101
+ raise if locale == I18n.locale
102
+ end
103
+ end
104
+
105
+ def self.to_datepicker_format(rails_format)
106
+ return nil if rails_format.nil?
107
+ if rails_format =~ /%[cUWwxXZz]/
108
+ Rails.logger.warn("AS DatePicker::Helper: rails date format #{rails_format} includes options which can't be converted to jquery datepicker format. Options %c, %U, %W, %w, %x %X, %z, %Z are not supported by datepicker and will be removed")
109
+ nil
110
+ end
111
+ js_format = rails_format.dup
112
+ DATE_FORMAT_CONVERSION.each do |key, value|
113
+ js_format.gsub!(key, value)
114
+ end
115
+ js_format
116
+ end
117
+
118
+ def self.split_datetime_format(datetime_format)
119
+ date_format = datetime_format
120
+ time_format = nil
121
+ time_start_indicators = %w{hh mm tt ss}
122
+ unless datetime_format.nil?
123
+ start_indicator = time_start_indicators.detect {|indicator| datetime_format.include?(indicator)}
124
+ unless start_indicator.nil?
125
+ pos_time_format = datetime_format.index(start_indicator)
126
+ date_format = datetime_format.to(pos_time_format - 1)
127
+ time_format = datetime_format.from(pos_time_format)
128
+ end
129
+ end
130
+ return date_format, time_format
131
+ end
132
+
133
+ module DatepickerColumnHelpers
134
+ def datepicker_split_datetime_format(datetime_format)
135
+ ActiveScaffold::Bridges::DatePicker::Helper.split_datetime_format(datetime_format)
136
+ end
137
+
138
+ def to_datepicker_format(rails_format)
139
+ ActiveScaffold::Bridges::DatePicker::Helper.to_datepicker_format(rails_format)
140
+ end
141
+
142
+ def datepicker_format_options(column, format, options)
143
+ if column.form_ui == :date_picker
144
+ js_format = to_datepicker_format(I18n.translate!("date.formats.#{format}"))
145
+ options['date:dateFormat'] = js_format unless js_format.nil?
146
+ else
147
+ rails_time_format = I18n.translate!("time.formats.#{format}")
148
+ date_format, time_format = datepicker_split_datetime_format(self.to_datepicker_format(rails_time_format))
149
+ options['date:dateFormat'] = date_format unless date_format.nil?
150
+ unless time_format.nil?
151
+ options['time:timeFormat'] = time_format
152
+ options['time:ampm'] = true if rails_time_format.include?('%I')
153
+ end
154
+ end unless format == :default
155
+ end
156
+ end
157
+
158
+ module SearchColumnHelpers
159
+ def active_scaffold_search_date_bridge_calendar_control(column, options, current_search, name)
160
+ if current_search.is_a? Hash
161
+ value = controller.class.condition_value_for_datetime(current_search[name], column.form_ui == :date_picker ? :to_date : :to_time)
162
+ else
163
+ value = current_search
164
+ end
165
+ options = column.options.merge(options).except!(:include_blank, :discard_time, :discard_date, :value)
166
+ options = active_scaffold_input_text_options(options.merge(column.options))
167
+ options[:class] << " #{column.search_ui.to_s}"
168
+ options[:style] = "display:#{(options[:show].nil? || options[:show]) ? '' : 'none'}"
169
+ format = options.delete(:format) || :default
170
+ datepicker_format_options(column, format, options)
171
+ text_field_tag("#{options[:name]}[#{name}]", value ? l(value, :format => format) : nil, options.merge(:id => "#{options[:id]}_#{name}", :name => "#{options[:name]}[#{name}]"))
172
+ end
173
+ end
174
+
175
+ module FormColumnHelpers
176
+ def active_scaffold_input_date_picker(column, options)
177
+ options = active_scaffold_input_text_options(options.merge(column.options))
178
+ options[:class] << " #{column.form_ui.to_s}"
179
+ value = controller.class.condition_value_for_datetime(@record.send(column.name), column.form_ui == :date_picker ? :to_date : :to_time)
180
+ format = options.delete(:format) || :default
181
+ datepicker_format_options(column, format, options)
182
+ options[:value] = (value ? l(value, :format => format) : nil)
183
+ text_field(:record, column.name, options)
184
+ end
185
+ end
186
+ end
187
+ end
188
+ end
@@ -0,0 +1,9 @@
1
+ class ActiveScaffold::Bridges::Dragonfly < ActiveScaffold::DataStructures::Bridge
2
+ def self.install
3
+ require File.join(File.dirname(__FILE__), "dragonfly/form_ui")
4
+ require File.join(File.dirname(__FILE__), "dragonfly/list_ui")
5
+ require File.join(File.dirname(__FILE__), "dragonfly/dragonfly_bridge_helpers")
6
+ require File.join(File.dirname(__FILE__), "dragonfly/dragonfly_bridge")
7
+ ActiveScaffold::Config::Core.send :include, ActiveScaffold::Bridges::Dragonfly::DragonflyBridge
8
+ end
9
+ end
@@ -0,0 +1,34 @@
1
+ module ActiveScaffold
2
+ module Bridges
3
+ class Dragonfly
4
+ module DragonflyBridge
5
+ def initialize_with_dragonfly(model_id)
6
+ initialize_without_dragonfly(model_id)
7
+ return unless self.model.respond_to?(:dragonfly_attachment_classes) && self.model.dragonfly_attachment_classes.present?
8
+
9
+ self.update.multipart = true
10
+ self.create.multipart = true
11
+
12
+ self.model.dragonfly_attachment_classes.each do |attachment|
13
+ configure_dragonfly_field(attachment.attribute)
14
+ end
15
+ end
16
+
17
+ def self.included(base)
18
+ base.alias_method_chain :initialize, :dragonfly
19
+ end
20
+
21
+ private
22
+ def configure_dragonfly_field(field)
23
+ self.columns << field
24
+ self.columns[field].form_ui ||= :dragonfly
25
+ self.columns[field].params.add "remove_#{field}"
26
+
27
+ [:name, :uid].each do |f|
28
+ self.columns.exclude("#{field}_#{f}".to_sym)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,10 @@
1
+ module ActiveScaffold
2
+ module Bridges
3
+ class Dragonfly
4
+ module DragonflyBridgeHelpers
5
+ mattr_accessor :thumbnail_style
6
+ self.thumbnail_style = 'x30>'
7
+ end
8
+ end
9
+ end
10
+ end