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
@@ -3,8 +3,7 @@ module ActiveScaffold::Config
3
3
  self.crud_type = :delete
4
4
 
5
5
  def initialize(core_config)
6
- @core = core_config
7
-
6
+ super
8
7
  # start with the ActionLink defined globally
9
8
  @link = self.class.link.clone
10
9
  @action_group = self.class.action_group.clone if self.class.action_group
@@ -3,8 +3,7 @@ module ActiveScaffold::Config
3
3
  self.crud_type = :read
4
4
 
5
5
  def initialize(core_config)
6
- @core = core_config
7
-
6
+ super
8
7
  @text_search = self.class.text_search
9
8
 
10
9
  # start with the ActionLink defined globally
@@ -1,8 +1,7 @@
1
1
  module ActiveScaffold::Config
2
2
  class Form < Base
3
3
  def initialize(core_config)
4
- @core = core_config
5
-
4
+ super
6
5
  # start with the ActionLink defined globally
7
6
  @link = self.class.link.clone unless self.class.link.nil?
8
7
  @action_group = self.class.action_group.clone if self.class.action_group
@@ -15,7 +14,7 @@ module ActiveScaffold::Config
15
14
  # global level configuration
16
15
  # --------------------------
17
16
  # show value of unauthorized columns instead of skip them
18
- class_inheritable_accessor :show_unauthorized_columns
17
+ class_attribute :show_unauthorized_columns
19
18
 
20
19
  # instance-level configuration
21
20
  # ----------------------------
@@ -28,9 +27,6 @@ module ActiveScaffold::Config
28
27
 
29
28
  # the label for this Form action. used for the header.
30
29
  attr_writer :label
31
- def label
32
- as_(@label)
33
- end
34
30
 
35
31
  # provides access to the list of columns specifically meant for the Form to use
36
32
  def columns
@@ -3,8 +3,7 @@ module ActiveScaffold::Config
3
3
  self.crud_type = :read
4
4
 
5
5
  def initialize(core_config)
6
- @core = core_config
7
-
6
+ super
8
7
  # inherit from global scope
9
8
  # full configuration path is: defaults => global table => local table
10
9
  @per_page = self.class.per_page
@@ -19,6 +18,7 @@ module ActiveScaffold::Config
19
18
  @association_join_text = self.class.association_join_text
20
19
  @pagination = self.class.pagination
21
20
  @show_search_reset = true
21
+ @mark_records = self.class.mark_records
22
22
  end
23
23
 
24
24
  # global level configuration
@@ -46,6 +46,9 @@ module ActiveScaffold::Config
46
46
  cattr_accessor :pagination
47
47
  @@pagination = true
48
48
 
49
+ # Add a checkbox in front of each record to mark them and use them with a batch action later
50
+ cattr_accessor :mark_records
51
+
49
52
  # instance-level configuration
50
53
  # ----------------------------
51
54
 
@@ -78,6 +81,9 @@ module ActiveScaffold::Config
78
81
  # show a link to reset the search next to filtered message
79
82
  attr_accessor :show_search_reset
80
83
 
84
+ # Add a checkbox in front of each record to mark them and use them with a batch action later
85
+ attr_accessor :mark_records
86
+
81
87
  # the default sorting. should be an array of hashes of {column_name => direction}, e.g. [{:a => 'desc'}, {:b => 'asc'}]. to just sort on one column, you can simply provide a hash, though, e.g. {:a => 'desc'}.
82
88
  def sorting=(val)
83
89
  val = [val] if val.is_a? Hash
@@ -3,7 +3,8 @@ module ActiveScaffold::Config
3
3
  self.crud_type = :read
4
4
 
5
5
  def initialize(core_config)
6
- @core = core_config
6
+ super
7
+ @label = :add_existing_model
7
8
  self.shallow_delete = self.class.shallow_delete
8
9
  @action_group = self.class.action_group.clone if self.class.action_group
9
10
  end
@@ -23,7 +24,6 @@ module ActiveScaffold::Config
23
24
  unless column.nil? || column.association.nil?
24
25
  options.reverse_merge! :security_method => :nested_authorized?, :label => column.association.klass.model_name.human({:count => 2, :default => column.association.klass.name.pluralize})
25
26
  action_link = @core.link_for_association(column, options)
26
- action_link.action ||= :index
27
27
  @core.action_links.add_to_group(action_link, action_group) unless action_link.nil?
28
28
  else
29
29
 
@@ -37,9 +37,5 @@ module ActiveScaffold::Config
37
37
 
38
38
  # the label for this Nested action. used for the header.
39
39
  attr_writer :label
40
- def label
41
- @label ? as_(@label) : as_(:add_existing_model, :model => @core.label)
42
- end
43
-
44
40
  end
45
41
  end
@@ -3,10 +3,10 @@ module ActiveScaffold::Config
3
3
  self.crud_type = :read
4
4
 
5
5
  def initialize(core_config)
6
- @core = core_config
7
-
6
+ super
8
7
  @text_search = self.class.text_search
9
8
  @live = self.class.live?
9
+ @split_terms = self.class.split_terms
10
10
 
11
11
  # start with the ActionLink defined globally
12
12
  @link = self.class.link.clone
@@ -57,6 +57,10 @@ module ActiveScaffold::Config
57
57
  # Default is :full
58
58
  attr_accessor :text_search
59
59
 
60
+ @@split_terms = " "
61
+ cattr_accessor :split_terms
62
+ attr_accessor :split_terms
63
+
60
64
  # the ActionLink for this action
61
65
  attr_accessor :link
62
66
 
@@ -3,7 +3,7 @@ module ActiveScaffold::Config
3
3
  self.crud_type = :read
4
4
 
5
5
  def initialize(core_config)
6
- @core = core_config
6
+ super
7
7
  # start with the ActionLink defined globally
8
8
  @link = self.class.link.clone
9
9
  @action_group = self.class.action_group.clone if self.class.action_group
@@ -20,9 +20,6 @@ module ActiveScaffold::Config
20
20
  attr_accessor :link
21
21
  # the label for this action. used for the header.
22
22
  attr_writer :label
23
- def label
24
- @label ? as_(@label) : as_(:show_model, :model => @core.label(:count => 1))
25
- end
26
23
 
27
24
  # provides access to the list of columns specifically meant for this action to use
28
25
  def columns
@@ -1,7 +1,7 @@
1
1
  module ActiveScaffold::Config
2
2
  class Subform < Base
3
3
  def initialize(core_config)
4
- @core = core_config
4
+ super
5
5
  @layout = self.class.layout # default layout
6
6
  end
7
7
 
@@ -1,7 +1,7 @@
1
1
  module ActiveScaffold::Config
2
2
  class Update < ActiveScaffold::Config::Form
3
3
  self.crud_type = :update
4
- def initialize(*args)
4
+ def initialize(core_config)
5
5
  super
6
6
  self.nested_links = self.class.nested_links
7
7
  self.refresh_list = self.class.refresh_list
@@ -25,11 +25,6 @@ module ActiveScaffold::Config
25
25
  # instance-level configuration
26
26
  # ----------------------------
27
27
 
28
- # the label= method already exists in the Form base class
29
- def label
30
- @label ? as_(@label) : as_(:update_model, :model => @core.label(:count => 1))
31
- end
32
-
33
28
  attr_accessor :nested_links
34
29
  cattr_accessor :nested_links
35
30
  @@nested_links = false
@@ -12,6 +12,9 @@ module ActiveScaffold::DataStructures
12
12
  def label
13
13
  as_(@label) if @label
14
14
  end
15
+ def css_class
16
+ @label.to_s.underscore
17
+ end
15
18
 
16
19
  # Whether this column set is collapsed by default in contexts where collapsing is supported
17
20
  attr_accessor :collapsed
@@ -3,15 +3,15 @@ module ActiveScaffold::DataStructures
3
3
  # provides a quick way to set any property of the object from a hash
4
4
  def initialize(action, options = {})
5
5
  # set defaults
6
- self.action = action
6
+ self.action = action.to_s
7
7
  self.label = action
8
8
  self.confirm = false
9
9
  self.type = :collection
10
10
  self.inline = true
11
11
  self.method = :get
12
- self.crud_type = :delete if [:destroy].include?(action.try(:to_sym))
13
- self.crud_type = :create if [:create, :new].include?(action.try(:to_sym))
14
- self.crud_type = :update if [:edit, :update].include?(action.try(:to_sym))
12
+ self.crud_type = :delete if [:destroy].include?(action.to_sym)
13
+ self.crud_type = :create if [:create, :new].include?(action.to_sym)
14
+ self.crud_type = :update if [:edit, :update].include?(action.to_sym)
15
15
  self.crud_type ||= :read
16
16
  self.parameters = {}
17
17
  self.html_options = {}
@@ -60,21 +60,25 @@ module ActiveScaffold::DataStructures
60
60
  attr_accessor :image
61
61
 
62
62
  # if the action requires confirmation
63
- attr_writer :confirm
63
+ def confirm=(value)
64
+ @dhtml_confirm = nil if value
65
+ @confirm = value
66
+ end
64
67
  def confirm(label = '')
65
68
  @confirm.is_a?(String) ? @confirm : as_(@confirm, :label => label)
66
69
  end
67
70
  def confirm?
68
- @confirm ? true : false
71
+ !!@confirm
69
72
  end
70
73
 
71
74
  # if the action uses a DHTML based (i.e. 2-phase) confirmation
72
- attr_writer :dhtml_confirm
73
- def dhtml_confirm
74
- @dhtml_confirm
75
+ attr_accessor :dhtml_confirm
76
+ def dhtml_confirm=(value)
77
+ @confirm = nil if value
78
+ @dhtml_confirm = value
75
79
  end
76
80
  def dhtml_confirm?
77
- @dhtml_confirm
81
+ !!@dhtml_confirm
78
82
  end
79
83
 
80
84
  # what method to call on the controller to see if this action_link should be visible
@@ -0,0 +1,22 @@
1
+ module ActiveScaffold::DataStructures
2
+ class Bridge
3
+ def self.install
4
+ raise(RunTimeError, "install not defined for bridge #{name}")
5
+ end
6
+
7
+ # by convention and default, use the bridge name as the required constant for installation
8
+ def self.install?
9
+ Object.const_defined? name.demodulize
10
+ end
11
+
12
+ def self.run
13
+ install if install?
14
+ end
15
+
16
+ def self.stylesheets
17
+ end
18
+
19
+ def self.javascripts
20
+ end
21
+ end
22
+ end
@@ -66,6 +66,13 @@ module ActiveScaffold::DataStructures
66
66
  cattr_accessor :send_form_on_update_column
67
67
  attr_accessor :send_form_on_update_column
68
68
 
69
+ # column to be updated in a form when this column changes
70
+ attr_accessor :update_column
71
+
72
+ # send all the form instead of only new value when this column change
73
+ cattr_accessor :send_form_on_update_column
74
+ attr_accessor :send_form_on_update_column
75
+
69
76
  # sorting on a column can be configured four ways:
70
77
  # sort = true default, uses intelligent sorting sql default
71
78
  # sort = false sometimes sorting doesn't make sense
@@ -201,7 +208,7 @@ module ActiveScaffold::DataStructures
201
208
  def show_blank_record?(associated)
202
209
  if @show_blank_record
203
210
  return false unless self.association.klass.authorized_for?(:crud_type => :create)
204
- self.plural_association? or (self.singular_association? and associated.empty?)
211
+ self.plural_association? or (self.singular_association? and associated.blank?)
205
212
  end
206
213
  end
207
214
 
@@ -279,6 +286,7 @@ module ActiveScaffold::DataStructures
279
286
  @associated_limit = self.class.associated_limit
280
287
  @associated_number = self.class.associated_number
281
288
  @show_blank_record = self.class.show_blank_record
289
+ @send_form_on_update_column = self.class.send_form_on_update_column
282
290
  @actions_for_association_links = self.class.actions_for_association_links.clone if @association
283
291
 
284
292
  self.number = @column.try(:number?)
@@ -290,7 +298,11 @@ module ActiveScaffold::DataStructures
290
298
 
291
299
  # default all the configurable variables
292
300
  self.css_class = ''
293
- self.required = active_record_class.validators_on(self.name).map(&:class).include? ActiveModel::Validations::PresenceValidator
301
+ self.required = active_record_class.validators_on(self.name).any? do |val|
302
+ ActiveModel::Validations::PresenceValidator === val or (
303
+ ActiveModel::Validations::InclusionValidator === val and not val.options[:allow_nil] and not val.options[:allow_blank]
304
+ )
305
+ end
294
306
  self.sort = true
295
307
  self.search_sql = true
296
308
 
@@ -302,7 +314,7 @@ module ActiveScaffold::DataStructures
302
314
  # just the field (not table.field)
303
315
  def field_name
304
316
  return nil if virtual?
305
- column ? @active_record_class.connection.quote_column_name(column.name) : association.primary_key_name
317
+ column ? @active_record_class.connection.quote_column_name(column.name) : association.foreign_key
306
318
  end
307
319
 
308
320
  def <=>(other_column)
@@ -310,6 +322,26 @@ module ActiveScaffold::DataStructures
310
322
  order_weight != 0 ? order_weight : self.name.to_s <=> other_column.name.to_s
311
323
  end
312
324
 
325
+ def number_to_native(value)
326
+ return value if value.blank? || !value.is_a?(String)
327
+ native = '.' # native ruby separator
328
+ format = {:separator => '', :delimiter => ''}.merge! I18n.t('number.format', :default => {})
329
+ specific = case self.options[:format]
330
+ when :currency
331
+ I18n.t('number.currency.format', :default => nil)
332
+ when :size
333
+ I18n.t('number.human.format', :default => nil)
334
+ when :percentage
335
+ I18n.t('number.percentage.format', :default => nil)
336
+ end
337
+ format.merge! specific unless specific.nil?
338
+ unless format[:separator].blank? || !value.include?(format[:separator]) && value.include?(native) && (format[:delimiter] != native || value !~ /\.\d{3}$/)
339
+ value.gsub(/[^0-9\-#{format[:separator]}]/, '').gsub(format[:separator], native)
340
+ else
341
+ value
342
+ end
343
+ end
344
+
313
345
  protected
314
346
 
315
347
  def initialize_sort
@@ -344,7 +376,7 @@ module ActiveScaffold::DataStructures
344
376
 
345
377
  # the table.field name for this column, if applicable
346
378
  def field
347
- @field ||= [@active_record_class.connection.quote_column_name(@table), field_name].join('.')
379
+ @field ||= [@active_record_class.connection.quote_table_name(@table), field_name].join('.')
348
380
  end
349
381
 
350
382
  def estimate_weight
@@ -98,16 +98,16 @@ module ActiveScaffold::DataStructures
98
98
 
99
99
  def iterate_model_associations(model)
100
100
  @constrained_fields = []
101
- @constrained_fields << association.primary_key_name.to_sym unless association.belongs_to?
101
+ @constrained_fields << association.foreign_key.to_sym unless association.belongs_to?
102
102
  model.reflect_on_all_associations.each do |current|
103
- if !current.belongs_to? && association.primary_key_name == current.association_foreign_key
103
+ if !current.belongs_to? && association.foreign_key == current.association_foreign_key
104
104
  constrained_fields << current.name.to_sym
105
105
  @child_association = current if current.klass == @parent_model
106
106
  end
107
- if association.primary_key_name == current.primary_key_name
107
+ if association.foreign_key == current.foreign_key
108
108
  # show columns for has_many and has_one child associationes
109
109
  constrained_fields << current.name.to_sym if current.belongs_to?
110
- @child_association = current if current.klass == @parent_model
110
+ @child_association = current
111
111
  end
112
112
  end
113
113
  end
@@ -3,11 +3,6 @@ module ActiveScaffold::DataStructures
3
3
  include Enumerable
4
4
  include ActiveScaffold::Configurable
5
5
 
6
- attr_writer :label
7
- def label
8
- as_(@label)
9
- end
10
-
11
6
  def initialize(*args)
12
7
  @set = []
13
8
  self.add *args
@@ -59,4 +54,4 @@ module ActiveScaffold::DataStructures
59
54
  end
60
55
 
61
56
  end
62
- end
57
+ end
@@ -9,7 +9,7 @@ module ActiveScaffold::DataStructures
9
9
  end
10
10
 
11
11
  def set_default_sorting(model)
12
- model_scope = model.send(:current_scoped_methods)
12
+ model_scope = model.send(:build_default_scope)
13
13
  order_clause = model_scope.arel.order_clauses.join(",") if model_scope
14
14
 
15
15
  # If an ORDER BY clause is found set default sorting according to it, else
@@ -34,7 +34,7 @@ module ActiveScaffold::DataStructures
34
34
  column = get_column(column_name)
35
35
  raise ArgumentError, "Could not find column #{column_name}" if column.nil?
36
36
  raise ArgumentError, "Sorting direction unknown" unless [:ASC, :DESC].include? direction.to_sym
37
- @clauses << [column, direction] if column.sortable?
37
+ @clauses << [column, direction.untaint] if column.sortable?
38
38
  raise ArgumentError, "Can't mix :method- and :sql-based sorting" if mixed_sorting?
39
39
  end
40
40
 
@@ -0,0 +1,4 @@
1
+ module ActiveScaffold
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -7,8 +7,8 @@ module ActionController #:nodoc:
7
7
  # if we need an adapter, then we render the actual stuff to a string and insert it into the adapter template
8
8
  opts = args.blank? ? Hash.new : args.first
9
9
  render :partial => params[:adapter][1..-1],
10
- :locals => {:payload => render_to_string(opts.merge(:layout => false), &block)},
11
- :use_full_path => true, :layout => false
10
+ :locals => {:payload => render_to_string(opts.merge(:layout => false), &block).html_safe},
11
+ :use_full_path => true, :layout => false, :content_type => :html
12
12
  @rendering_adapter = nil # recursion control
13
13
  else
14
14
  render_without_active_scaffold(*args, &block)
@@ -8,7 +8,7 @@ module ActionController #:nodoc:
8
8
  opts = args.blank? ? Hash.new : args.first
9
9
  render :partial => params[:adapter][1..-1],
10
10
  :locals => {:payload => render_to_string(opts.merge(:layout => false), &block).html_safe},
11
- :use_full_path => true, :layout => false, :content_type => :html
11
+ :use_full_path => true, :layout => false
12
12
  @rendering_adapter = nil # recursion control
13
13
  else
14
14
  render_without_active_scaffold(*args, &block)