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
@@ -1,5 +0,0 @@
1
- ActiveScaffold::Bridges.bridge "Ancestry" do
2
- install do
3
- require File.join(File.dirname(__FILE__), "lib/ancestry_bridge.rb")
4
- end
5
- end
@@ -1,59 +0,0 @@
1
- module ActiveScaffold
2
- module Bridges
3
- def self.bridge(name, &block)
4
- ActiveScaffold::Bridges::Bridge.new(name, &block)
5
- end
6
-
7
- class Bridge
8
- attr_accessor :name
9
- cattr_accessor :bridges
10
- cattr_accessor :bridges_run
11
- self.bridges = []
12
-
13
- def initialize(name, &block)
14
- self.name = name
15
- @install = nil
16
- # by convention and default, use the bridge name as the required constant for installation
17
- @install_if = lambda { Object.const_defined?(name) }
18
- self.instance_eval(&block)
19
-
20
- ActiveScaffold::Bridges::Bridge.bridges << self
21
- end
22
-
23
- # Set the install block
24
- def install(&block)
25
- @install = block
26
- end
27
-
28
- # Set the install_if block (to check to see whether or not to install the block)
29
- def install?(&block)
30
- @install_if = block
31
- end
32
-
33
-
34
- def run
35
- raise(ArgumentError, "install and install? not defined for bridge #{name}" ) unless @install && @install_if
36
- @install.call if @install_if.call
37
- end
38
-
39
- def self.run_all
40
- return false if self.bridges_run
41
- ActiveScaffold::Bridges::Bridge.bridges.each{|bridge|
42
- bridge.run
43
- }
44
- self.bridges_run=true
45
- end
46
- end
47
- end
48
- end
49
-
50
- require File.join(File.dirname(__FILE__), 'shared', 'date_bridge.rb')
51
- Dir[File.join(File.dirname(__FILE__), "*/bridge.rb")].each{|bridge_require|
52
- load_bridge = true
53
- unless ActiveScaffold.exclude_bridges.empty?
54
- match = bridge_require.match('bridges\/(.*)\/bridge.rb')
55
- bridge_name = match[1] ? match[1] : nil
56
- load_bridge = ActiveScaffold.exclude_bridges.exclude?(bridge_name.to_sym) if bridge_name
57
- end
58
- require bridge_require if load_bridge == true
59
- }
@@ -1,12 +0,0 @@
1
- ActiveScaffold::Bridges.bridge "CanCan" do
2
- install do
3
- require File.join(File.dirname(__FILE__), "lib", "cancan_bridge.rb")
4
-
5
- ActiveScaffold::ClassMethods.send :include, ActiveScaffold::CancanBridge::ClassMethods
6
- ActiveScaffold::Actions::Core.send :include, ActiveScaffold::CancanBridge::Actions::Core
7
- ActiveScaffold::Actions::Nested.send :include, ActiveScaffold::CancanBridge::Actions::Core
8
- ActionController::Base.send :include, ActiveScaffold::CancanBridge::ModelUserAccess::Controller
9
- ActiveRecord::Base.send :include, ActiveScaffold::CancanBridge::ModelUserAccess::Model
10
- ActiveRecord::Base.send :include, ActiveScaffold::CancanBridge::ActiveRecord
11
- end
12
- end
@@ -1,9 +0,0 @@
1
- ActiveScaffold::Bridges.bridge "CarrierWave" do
2
- install do
3
- require File.join(File.dirname(__FILE__), "lib/form_ui")
4
- require File.join(File.dirname(__FILE__), "lib/list_ui")
5
- require File.join(File.dirname(__FILE__), "lib/carrierwave_bridge_helpers")
6
- require File.join(File.dirname(__FILE__), "lib/carrierwave_bridge")
7
- ActiveScaffold::Config::Core.send :include, ActiveScaffold::Bridges::Carrierwave::Lib::CarrierwaveBridge
8
- end
9
- end
@@ -1,33 +0,0 @@
1
- module ActiveScaffold
2
- module Bridges
3
- module Carrierwave
4
- module Lib
5
- module CarrierwaveBridge
6
- def initialize_with_carrierwave(model_id)
7
- initialize_without_carrierwave(model_id)
8
- return unless self.model.respond_to?(:uploaders) && self.model.uploaders.present?
9
-
10
- self.update.multipart = true
11
- self.create.multipart = true
12
-
13
- self.model.uploaders.keys.each do |field|
14
- configure_carrierwave_field(field.to_sym)
15
- end
16
- end
17
-
18
- def self.included(base)
19
- base.alias_method_chain :initialize, :carrierwave
20
- end
21
-
22
- private
23
- def configure_carrierwave_field(field)
24
- self.columns << field
25
- self.columns[field].form_ui ||= :carrierwave # :TODO thumbnail
26
- self.columns[field].params.add "#{field}_cache"
27
- self.columns[field].params.add "remove_#{field}"
28
- end
29
- end
30
- end
31
- end
32
- end
33
- end
@@ -1,12 +0,0 @@
1
- module ActiveScaffold
2
- module Bridges
3
- module Carrierwave
4
- module Lib
5
- module CarrierwaveBridgeHelpers
6
- mattr_accessor :thumbnail_style
7
- self.thumbnail_style = :thumbnail
8
- end
9
- end
10
- end
11
- end
12
- end
@@ -1,9 +0,0 @@
1
- ActiveScaffold::Bridges.bridge "CountryHelper" do
2
- install do
3
- require File.join(File.dirname(__FILE__), "lib/country_helper_bridge.rb")
4
- end
5
-
6
- install? do
7
- true
8
- end
9
- end
@@ -1,24 +0,0 @@
1
-
2
-
3
- ActiveScaffold::Bridges.bridge "DatePicker" do
4
- install do
5
- directory = File.dirname(__FILE__)
6
- source = File.join(directory, "public/javascripts/date_picker_bridge.js")
7
- destination = File.join(Rails.root, "public/javascripts/active_scaffold/default/")
8
-
9
- if ActiveScaffold.js_framework == :jquery
10
- require File.join(directory, "lib/datepicker_bridge.rb")
11
- unless defined?(ACTIVE_SCAFFOLD_INSTALL_ASSETS) && ACTIVE_SCAFFOLD_INSTALL_ASSETS == false
12
- FileUtils.cp(source, destination)
13
- ActiveScaffold::Bridges::DatePickerBridge.localization(File.join(destination, 'date_picker_bridge.js'))
14
- end
15
- else
16
- # make sure that jquery files are removed
17
- FileUtils.rm(File.join(destination, 'date_picker_bridge.js')) if File.exist?(File.join(destination, 'date_picker_bridge.js'))
18
- end
19
- end
20
-
21
- install? do
22
- true
23
- end
24
- end
@@ -1,234 +0,0 @@
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
-
39
- module ActiveScaffold
40
- module Bridges
41
- module DatePickerBridge
42
- DATE_FORMAT_CONVERSION = {
43
- '%a' => 'D',
44
- '%A' => 'DD',
45
- '%b' => 'M',
46
- '$B' => 'MM',
47
- '%d' => 'dd',
48
- '%e' => 'd',
49
- '%j' => 'oo',
50
- '%m' => 'mm',
51
- '%y' => 'y',
52
- '%Y' => 'yy',
53
- '%H' => 'hh', # options ampm => false
54
- '%I' => 'hh', # options ampm => true
55
- '%M' => 'mm',
56
- '%p' => 'tt',
57
- '%S' => 'ss'
58
- }
59
-
60
- def self.localization(js_file)
61
- localization = "jQuery(function($){
62
- if (typeof($.datepicker) === 'object') {
63
- $.datepicker.regional['#{I18n.locale}'] = #{date_options.to_json};
64
- $.datepicker.setDefaults($.datepicker.regional['#{I18n.locale}']);
65
- }
66
- if (typeof($.timepicker) === 'object') {
67
- $.timepicker.regional['#{I18n.locale}'] = #{datetime_options.to_json};
68
- $.timepicker.setDefaults($.timepicker.regional['#{I18n.locale}']);
69
- }
70
- });\n"
71
- prepend_js_file(js_file, localization)
72
- end
73
-
74
- def self.date_options
75
- date_options = I18n.translate! 'date'
76
- date_picker_options = { :closeText => as_(:close),
77
- :prevText => as_(:previous),
78
- :nextText => as_(:next),
79
- :currentText => as_(:today),
80
- :monthNames => date_options[:month_names][1, (date_options[:month_names].length - 1)],
81
- :monthNamesShort => date_options[:abbr_month_names][1, (date_options[:abbr_month_names].length - 1)],
82
- :dayNames => date_options[:day_names],
83
- :dayNamesShort => date_options[:abbr_day_names],
84
- :dayNamesMin => date_options[:abbr_day_names],
85
- :changeYear => true,
86
- :changeMonth => true,
87
- }
88
-
89
- begin
90
- as_date_picker_options = I18n.translate! 'active_scaffold.date_picker_options'
91
- date_picker_options.merge!(as_date_picker_options) if as_date_picker_options.is_a? Hash
92
- rescue
93
- Rails.logger.warn "ActiveScaffold: Missing date picker localization for your locale: #{I18n.locale}"
94
- end
95
-
96
- js_format = self.to_datepicker_format(date_options[:formats][:default])
97
- date_picker_options[:dateFormat] = js_format unless js_format.nil?
98
- date_picker_options
99
- end
100
-
101
- def self.datetime_options
102
- rails_time_format = I18n.translate! 'time.formats.default'
103
- datetime_options = I18n.translate! 'datetime.prompts'
104
- datetime_picker_options = {:ampm => false,
105
- :hourText => datetime_options[:hour],
106
- :minuteText => datetime_options[:minute],
107
- :secondText => datetime_options[:second],
108
- }
109
-
110
- begin
111
- as_datetime_picker_options = I18n.translate! 'active_scaffold.datetime_picker_options'
112
- datetime_picker_options.merge!(as_datetime_picker_options) if as_datetime_picker_options.is_a? Hash
113
- rescue
114
- Rails.logger.warn "ActiveScaffold: Missing datetime picker localization for your locale: #{I18n.locale}"
115
- end
116
-
117
- date_format, time_format = self.split_datetime_format(self.to_datepicker_format(rails_time_format))
118
- datetime_picker_options[:dateFormat] = date_format unless date_format.nil?
119
- unless time_format.nil?
120
- datetime_picker_options[:timeFormat] = time_format
121
- datetime_picker_options[:ampm] = true if rails_time_format.include?('%I')
122
- end
123
- datetime_picker_options
124
- end
125
-
126
- def self.prepend_js_file(js_file, prepend)
127
- content = File.binread(js_file)
128
- content.gsub!(/\A/, prepend)
129
- File.open(js_file, 'wb') { |file| file.write(content) }
130
- end
131
-
132
- def self.to_datepicker_format(rails_format)
133
- return nil if rails_format.nil?
134
- if rails_format =~ /%[cUWwxXZz]/
135
- Rails.logger.warn("AS DatePickerBridge: Can t convert rails date format: #{rails_format} to jquery datepicker format. Options %c, %U, %W, %w, %x %X, %z, %Z are not supported by datepicker]")
136
- nil
137
- else
138
- js_format = rails_format.dup
139
- DATE_FORMAT_CONVERSION.each do |key, value|
140
- js_format.gsub!(Regexp.new("#{key}"), value)
141
- end
142
- js_format
143
- end
144
- end
145
-
146
- def self.split_datetime_format(datetime_format)
147
- date_format = datetime_format
148
- time_format = nil
149
- time_start_indicators = %w{hh mm tt ss}
150
- unless datetime_format.nil?
151
- start_indicator = time_start_indicators.detect {|indicator| datetime_format.include?(indicator)}
152
- unless start_indicator.nil?
153
- pos_time_format = datetime_format.index(start_indicator)
154
- date_format = datetime_format.to(pos_time_format - 1)
155
- time_format = datetime_format.from(pos_time_format)
156
- end
157
- end
158
- return date_format, time_format
159
- end
160
-
161
- module DatepickerColumnHelpers
162
- def datepicker_split_datetime_format(datetime_format)
163
- ActiveScaffold::Bridges::DatePickerBridge.split_datetime_format(datetime_format)
164
- end
165
-
166
- def to_datepicker_format(rails_format)
167
- ActiveScaffold::Bridges::DatePickerBridge.to_datepicker_format(rails_format)
168
- end
169
-
170
- def datepicker_format_options(column, format, options)
171
- if column.form_ui == :date_picker
172
- js_format = to_datepicker_format(I18n.translate!("date.formats.#{format}"))
173
- options['date:dateFormat'] = js_format unless js_format.nil?
174
- else
175
- rails_time_format = I18n.translate!("time.formats.#{format}")
176
- date_format, time_format = datepicker_split_datetime_format(self.to_datepicker_format(rails_time_format))
177
- options['date:dateFormat'] = date_format unless date_format.nil?
178
- unless time_format.nil?
179
- options['time:timeFormat'] = time_format
180
- options['time:ampm'] = true if rails_time_format.include?('%I')
181
- end
182
- end unless format == :default
183
- end
184
- end
185
-
186
- module SearchColumnHelpers
187
- def active_scaffold_search_date_bridge_calendar_control(column, options, current_search, name)
188
- if current_search.is_a? Hash
189
- value = controller.class.condition_value_for_datetime(current_search[name], column.form_ui == :date_picker ? :to_date : :to_time)
190
- else
191
- value = current_search
192
- end
193
- options = column.options.merge(options).except!(:include_blank, :discard_time, :discard_date, :value)
194
- options = active_scaffold_input_text_options(options.merge(column.options))
195
- options[:class] << " #{column.search_ui.to_s}"
196
- options[:style] = "display:#{(options[:show].nil? || options[:show]) ? '' : 'none'}"
197
- format = options.delete(:format) || :default
198
- datepicker_format_options(column, format, options)
199
- text_field_tag("#{options[:name]}[#{name}]", value ? l(value, :format => format) : nil, options.merge(:id => "#{options[:id]}_#{name}", :name => "#{options[:name]}[#{name}]"))
200
- end
201
- end
202
-
203
- module FormColumnHelpers
204
- def active_scaffold_input_date_picker(column, options)
205
- options = active_scaffold_input_text_options(options.merge(column.options))
206
- options[:class] << " #{column.form_ui.to_s}"
207
- value = controller.class.condition_value_for_datetime(@record.send(column.name), column.form_ui == :date_picker ? :to_date : :to_time)
208
- format = options.delete(:format) || :default
209
- datepicker_format_options(column, format, options)
210
- options[:value] = (value ? l(value, :format => format) : nil)
211
- text_field(:record, column.name, options)
212
- end
213
- end
214
- end
215
- end
216
- end
217
-
218
- ActionView::Base.class_eval do
219
- include ActiveScaffold::Bridges::Shared::DateBridge::SearchColumnHelpers
220
- alias_method :active_scaffold_search_date_picker, :active_scaffold_search_date_bridge
221
- alias_method :active_scaffold_search_datetime_picker, :active_scaffold_search_date_bridge
222
- include ActiveScaffold::Bridges::Shared::DateBridge::HumanConditionHelpers
223
- alias_method :active_scaffold_human_condition_date_picker, :active_scaffold_human_condition_date_bridge
224
- alias_method :active_scaffold_human_condition_datetime_picker, :active_scaffold_human_condition_date_bridge
225
- include ActiveScaffold::Bridges::DatePickerBridge::SearchColumnHelpers
226
- include ActiveScaffold::Bridges::DatePickerBridge::FormColumnHelpers
227
- alias_method :active_scaffold_input_datetime_picker, :active_scaffold_input_date_picker
228
- include ActiveScaffold::Bridges::DatePickerBridge::DatepickerColumnHelpers
229
- end
230
- ActiveScaffold::Finder::ClassMethods.module_eval do
231
- include ActiveScaffold::Bridges::Shared::DateBridge::Finder::ClassMethods
232
- alias_method :condition_for_date_picker_type, :condition_for_date_bridge_type
233
- alias_method :condition_for_datetime_picker_type, :condition_for_date_picker_type
234
- end
@@ -1,9 +0,0 @@
1
- ActiveScaffold::Bridges.bridge "Dragonfly" do
2
- install do
3
- require File.join(File.dirname(__FILE__), "lib/form_ui")
4
- require File.join(File.dirname(__FILE__), "lib/list_ui")
5
- require File.join(File.dirname(__FILE__), "lib/dragonfly_bridge_helpers")
6
- require File.join(File.dirname(__FILE__), "lib/dragonfly_bridge")
7
- ActiveScaffold::Config::Core.send :include, ActiveScaffold::Bridges::Dragonfly::Lib::DragonflyBridge
8
- end
9
- end
@@ -1,36 +0,0 @@
1
- module ActiveScaffold
2
- module Bridges
3
- module Dragonfly
4
- module Lib
5
- module DragonflyBridge
6
- def initialize_with_dragonfly(model_id)
7
- initialize_without_dragonfly(model_id)
8
- return unless self.model.respond_to?(:dragonfly_attachment_classes) && self.model.dragonfly_attachment_classes.present?
9
-
10
- self.update.multipart = true
11
- self.create.multipart = true
12
-
13
- self.model.dragonfly_attachment_classes.each do |attachment|
14
- configure_dragonfly_field(attachment.attribute)
15
- end
16
- end
17
-
18
- def self.included(base)
19
- base.alias_method_chain :initialize, :dragonfly
20
- end
21
-
22
- private
23
- def configure_dragonfly_field(field)
24
- self.columns << field
25
- self.columns[field].form_ui ||= :dragonfly
26
- self.columns[field].params.add "remove_#{field}"
27
-
28
- [:name, :uid].each do |f|
29
- self.columns.exclude("#{field}_#{f}".to_sym)
30
- end
31
- end
32
- end
33
- end
34
- end
35
- end
36
- end