active_scaffold 3.2.18 → 3.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. data/CHANGELOG +3 -0
  2. data/app/assets/images/active_scaffold/add.png +0 -0
  3. data/app/assets/images/active_scaffold/arrow_down.png +0 -0
  4. data/app/assets/images/active_scaffold/arrow_up.png +0 -0
  5. data/app/assets/images/active_scaffold/close.png +0 -0
  6. data/app/assets/images/active_scaffold/close_touch.png +0 -0
  7. data/app/assets/images/active_scaffold/config.png +0 -0
  8. data/app/assets/images/active_scaffold/cross.png +0 -0
  9. data/app/assets/images/active_scaffold/gears.png +0 -0
  10. data/app/assets/images/active_scaffold/indicator-small.gif +0 -0
  11. data/app/assets/images/active_scaffold/indicator.gif +0 -0
  12. data/app/assets/images/active_scaffold/magnifier.png +0 -0
  13. data/app/assets/javascripts/active_scaffold.js.erb +19 -0
  14. data/app/assets/javascripts/jquery/active_scaffold.js +1113 -0
  15. data/app/assets/javascripts/jquery/date_picker_bridge.js.erb +24 -0
  16. data/app/assets/javascripts/jquery/draggable_lists.js +27 -0
  17. data/app/assets/javascripts/jquery/jquery.editinplace.js +743 -0
  18. data/app/assets/javascripts/jquery/tiny_mce_bridge.js +7 -0
  19. data/app/assets/javascripts/prototype/active_scaffold.js +1107 -0
  20. data/app/assets/javascripts/prototype/dhtml_history.js +870 -0
  21. data/app/assets/javascripts/prototype/form_enhancements.js +117 -0
  22. data/app/assets/javascripts/prototype/rico_corner.js +370 -0
  23. data/app/assets/javascripts/prototype/tiny_mce_bridge.js +7 -0
  24. data/app/assets/stylesheets/active_scaffold-ie.css.scss +54 -0
  25. data/app/assets/stylesheets/active_scaffold.css.scss +14 -0
  26. data/app/assets/stylesheets/active_scaffold_colors.css.scss +395 -0
  27. data/app/assets/stylesheets/active_scaffold_extensions.css.erb +2 -0
  28. data/app/assets/stylesheets/active_scaffold_images.css.scss +40 -0
  29. data/app/assets/stylesheets/active_scaffold_layout.css +936 -0
  30. data/app/assets/stylesheets/blue-theme.css +74 -0
  31. data/config/locales/de.yml +125 -0
  32. data/config/locales/en.yml +127 -0
  33. data/config/locales/es.yml +128 -0
  34. data/config/locales/fr.yml +131 -0
  35. data/config/locales/hu.yml +126 -0
  36. data/config/locales/ja.yml +126 -0
  37. data/config/locales/ru.yml +135 -0
  38. data/frontends/default/views/_action_group.html.erb +24 -0
  39. data/frontends/default/views/_add_existing_form.html.erb +30 -0
  40. data/frontends/default/views/_base_form.html.erb +53 -0
  41. data/frontends/default/views/_create_form.html.erb +8 -0
  42. data/frontends/default/views/_create_form_on_list.html.erb +6 -0
  43. data/frontends/default/views/_field_search.html.erb +32 -0
  44. data/frontends/default/views/_form.html.erb +28 -0
  45. data/frontends/default/views/_form_association.html.erb +17 -0
  46. data/frontends/default/views/_form_association_footer.html.erb +47 -0
  47. data/frontends/default/views/_form_attribute.html.erb +23 -0
  48. data/frontends/default/views/_form_hidden_attribute.html.erb +7 -0
  49. data/frontends/default/views/_form_messages.html.erb +5 -0
  50. data/frontends/default/views/_horizontal_subform.html.erb +22 -0
  51. data/frontends/default/views/_horizontal_subform_footer.html.erb +0 -0
  52. data/frontends/default/views/_horizontal_subform_header.html.erb +11 -0
  53. data/frontends/default/views/_horizontal_subform_record.html.erb +43 -0
  54. data/frontends/default/views/_human_conditions.html.erb +1 -0
  55. data/frontends/default/views/_list.html.erb +18 -0
  56. data/frontends/default/views/_list_actions.html.erb +15 -0
  57. data/frontends/default/views/_list_calculations.html.erb +16 -0
  58. data/frontends/default/views/_list_column_headings.html.erb +12 -0
  59. data/frontends/default/views/_list_header.html.erb +10 -0
  60. data/frontends/default/views/_list_inline_adapter.html.erb +21 -0
  61. data/frontends/default/views/_list_messages.html.erb +28 -0
  62. data/frontends/default/views/_list_pagination.html.erb +11 -0
  63. data/frontends/default/views/_list_pagination_links.html.erb +9 -0
  64. data/frontends/default/views/_list_record.html.erb +13 -0
  65. data/frontends/default/views/_list_record_columns.html.erb +8 -0
  66. data/frontends/default/views/_list_with_header.html.erb +36 -0
  67. data/frontends/default/views/_messages.html.erb +10 -0
  68. data/frontends/default/views/_refresh_list.js.erb +1 -0
  69. data/frontends/default/views/_render_field.js.erb +20 -0
  70. data/frontends/default/views/_row.html.erb +1 -0
  71. data/frontends/default/views/_search.html.erb +34 -0
  72. data/frontends/default/views/_search_attribute.html.erb +10 -0
  73. data/frontends/default/views/_show.html.erb +8 -0
  74. data/frontends/default/views/_show_columns.html.erb +15 -0
  75. data/frontends/default/views/_update_actions.html.erb +9 -0
  76. data/frontends/default/views/_update_calculations.js.erb +4 -0
  77. data/frontends/default/views/_update_form.html.erb +6 -0
  78. data/frontends/default/views/_update_messages.js.erb +2 -0
  79. data/frontends/default/views/_vertical_subform.html.erb +12 -0
  80. data/frontends/default/views/_vertical_subform_record.html.erb +43 -0
  81. data/frontends/default/views/action_confirmation.html.erb +13 -0
  82. data/frontends/default/views/add_existing.js.erb +14 -0
  83. data/frontends/default/views/add_existing_form.html.erb +5 -0
  84. data/frontends/default/views/create.html.erb +5 -0
  85. data/frontends/default/views/delete.html.erb +13 -0
  86. data/frontends/default/views/destroy.js.erb +26 -0
  87. data/frontends/default/views/edit_associated.js.erb +12 -0
  88. data/frontends/default/views/field_search.html.erb +5 -0
  89. data/frontends/default/views/form_messages.js.erb +1 -0
  90. data/frontends/default/views/list.html.erb +1 -0
  91. data/frontends/default/views/on_action_update.js.erb +22 -0
  92. data/frontends/default/views/on_create.js.erb +38 -0
  93. data/frontends/default/views/on_mark.js.erb +6 -0
  94. data/frontends/default/views/on_update.js.erb +29 -0
  95. data/frontends/default/views/refresh_list.js.erb +2 -0
  96. data/frontends/default/views/render_field.js.erb +1 -0
  97. data/frontends/default/views/row.js.erb +2 -0
  98. data/frontends/default/views/search.html.erb +5 -0
  99. data/frontends/default/views/show.html.erb +5 -0
  100. data/frontends/default/views/update.html.erb +8 -0
  101. data/frontends/default/views/update_column.js.erb +15 -0
  102. data/frontends/default/views/update_row.js.erb +1 -0
  103. data/lib/active_scaffold/actions/common_search.rb +22 -0
  104. data/lib/active_scaffold/actions/core.rb +203 -0
  105. data/lib/active_scaffold/actions/create.rb +139 -0
  106. data/lib/active_scaffold/actions/delete.rb +74 -0
  107. data/lib/active_scaffold/actions/field_search.rb +78 -0
  108. data/lib/active_scaffold/actions/list.rb +208 -0
  109. data/lib/active_scaffold/actions/mark.rb +89 -0
  110. data/lib/active_scaffold/actions/nested.rb +244 -0
  111. data/lib/active_scaffold/actions/search.rb +48 -0
  112. data/lib/active_scaffold/actions/show.rb +61 -0
  113. data/lib/active_scaffold/actions/subform.rb +23 -0
  114. data/lib/active_scaffold/actions/update.rb +156 -0
  115. data/lib/active_scaffold/active_record_permissions.rb +135 -0
  116. data/lib/active_scaffold/attribute_params.rb +200 -0
  117. data/lib/active_scaffold/bridges/ancestry/ancestry_bridge.rb +39 -0
  118. data/lib/active_scaffold/bridges/ancestry.rb +5 -0
  119. data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +37 -0
  120. data/lib/active_scaffold/bridges/bitfields.rb +6 -0
  121. data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +66 -0
  122. data/lib/active_scaffold/bridges/calendar_date_select.rb +24 -0
  123. data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +127 -0
  124. data/lib/active_scaffold/bridges/cancan.rb +15 -0
  125. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +31 -0
  126. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge_helpers.rb +10 -0
  127. data/lib/active_scaffold/bridges/carrierwave/form_ui.rb +45 -0
  128. data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +17 -0
  129. data/lib/active_scaffold/bridges/carrierwave.rb +12 -0
  130. data/lib/active_scaffold/bridges/country_helper/country_helper_bridge.rb +358 -0
  131. data/lib/active_scaffold/bridges/country_helper.rb +9 -0
  132. data/lib/active_scaffold/bridges/date_picker/ext.rb +63 -0
  133. data/lib/active_scaffold/bridges/date_picker/helper.rb +180 -0
  134. data/lib/active_scaffold/bridges/date_picker.rb +23 -0
  135. data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge.rb +34 -0
  136. data/lib/active_scaffold/bridges/dragonfly/dragonfly_bridge_helpers.rb +10 -0
  137. data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +27 -0
  138. data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +16 -0
  139. data/lib/active_scaffold/bridges/dragonfly.rb +9 -0
  140. data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +46 -0
  141. data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +57 -0
  142. data/lib/active_scaffold/bridges/file_column/form_ui.rb +34 -0
  143. data/lib/active_scaffold/bridges/file_column/list_ui.rb +26 -0
  144. data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +43 -0
  145. data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +9 -0
  146. data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +15 -0
  147. data/lib/active_scaffold/bridges/file_column.rb +11 -0
  148. data/lib/active_scaffold/bridges/paperclip/form_ui.rb +27 -0
  149. data/lib/active_scaffold/bridges/paperclip/list_ui.rb +16 -0
  150. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +36 -0
  151. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +24 -0
  152. data/lib/active_scaffold/bridges/paperclip.rb +12 -0
  153. data/lib/active_scaffold/bridges/record_select/helpers.rb +92 -0
  154. data/lib/active_scaffold/bridges/record_select.rb +11 -0
  155. data/lib/active_scaffold/bridges/semantic_attributes/column.rb +20 -0
  156. data/lib/active_scaffold/bridges/semantic_attributes.rb +5 -0
  157. data/lib/active_scaffold/bridges/shared/date_bridge.rb +209 -0
  158. data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +46 -0
  159. data/lib/active_scaffold/bridges/tiny_mce.rb +17 -0
  160. data/lib/active_scaffold/bridges.rb +61 -0
  161. data/lib/active_scaffold/config/base.rb +75 -0
  162. data/lib/active_scaffold/config/core.rb +236 -0
  163. data/lib/active_scaffold/config/create.rb +32 -0
  164. data/lib/active_scaffold/config/delete.rb +32 -0
  165. data/lib/active_scaffold/config/field_search.rb +79 -0
  166. data/lib/active_scaffold/config/form.rb +64 -0
  167. data/lib/active_scaffold/config/list.rb +247 -0
  168. data/lib/active_scaffold/config/mark.rb +30 -0
  169. data/lib/active_scaffold/config/nested.rb +42 -0
  170. data/lib/active_scaffold/config/search.rb +73 -0
  171. data/lib/active_scaffold/config/show.rb +31 -0
  172. data/lib/active_scaffold/config/subform.rb +35 -0
  173. data/lib/active_scaffold/config/update.rb +33 -0
  174. data/lib/active_scaffold/configurable.rb +29 -0
  175. data/lib/active_scaffold/constraints.rb +171 -0
  176. data/lib/active_scaffold/data_structures/action_columns.rb +142 -0
  177. data/lib/active_scaffold/data_structures/action_link.rb +185 -0
  178. data/lib/active_scaffold/data_structures/action_links.rb +191 -0
  179. data/lib/active_scaffold/data_structures/actions.rb +45 -0
  180. data/lib/active_scaffold/data_structures/bridge.rb +22 -0
  181. data/lib/active_scaffold/data_structures/column.rb +402 -0
  182. data/lib/active_scaffold/data_structures/columns.rb +75 -0
  183. data/lib/active_scaffold/data_structures/error_message.rb +24 -0
  184. data/lib/active_scaffold/data_structures/nested_info.rb +171 -0
  185. data/lib/active_scaffold/data_structures/set.rb +61 -0
  186. data/lib/active_scaffold/data_structures/sorting.rb +167 -0
  187. data/lib/active_scaffold/engine.rb +4 -0
  188. data/lib/active_scaffold/extensions/action_controller_rendering.rb +20 -0
  189. data/lib/active_scaffold/extensions/action_controller_rescueing.rb +7 -0
  190. data/lib/active_scaffold/extensions/action_view_rendering.rb +115 -0
  191. data/lib/active_scaffold/extensions/active_record_offset.rb +12 -0
  192. data/lib/active_scaffold/extensions/array.rb +7 -0
  193. data/lib/active_scaffold/extensions/cache_association.rb +16 -0
  194. data/lib/active_scaffold/extensions/localize.rb +10 -0
  195. data/lib/active_scaffold/extensions/name_option_for_datetime.rb +12 -0
  196. data/lib/active_scaffold/extensions/nil_id_in_url_params.rb +7 -0
  197. data/lib/active_scaffold/extensions/paginator_extensions.rb +26 -0
  198. data/lib/active_scaffold/extensions/reverse_associations.rb +64 -0
  199. data/lib/active_scaffold/extensions/routing_mapper.rb +48 -0
  200. data/lib/active_scaffold/extensions/to_label.rb +8 -0
  201. data/lib/active_scaffold/extensions/unsaved_associated.rb +61 -0
  202. data/lib/active_scaffold/extensions/unsaved_record.rb +20 -0
  203. data/lib/active_scaffold/extensions/usa_state.rb +46 -0
  204. data/lib/active_scaffold/finder.rb +399 -0
  205. data/lib/active_scaffold/helpers/association_helpers.rb +42 -0
  206. data/lib/active_scaffold/helpers/controller_helpers.rb +94 -0
  207. data/lib/active_scaffold/helpers/form_column_helpers.rb +322 -0
  208. data/lib/active_scaffold/helpers/human_condition_helpers.rb +64 -0
  209. data/lib/active_scaffold/helpers/id_helpers.rb +131 -0
  210. data/lib/active_scaffold/helpers/list_column_helpers.rb +374 -0
  211. data/lib/active_scaffold/helpers/pagination_helpers.rb +62 -0
  212. data/lib/active_scaffold/helpers/search_column_helpers.rb +257 -0
  213. data/lib/active_scaffold/helpers/show_column_helpers.rb +44 -0
  214. data/lib/active_scaffold/helpers/view_helpers.rb +398 -0
  215. data/lib/active_scaffold/marked_model.rb +38 -0
  216. data/lib/active_scaffold/paginator.rb +136 -0
  217. data/lib/active_scaffold/responds_to_parent.rb +70 -0
  218. data/lib/active_scaffold/tableless.rb +83 -0
  219. data/lib/active_scaffold/version.rb +9 -0
  220. data/lib/active_scaffold.rb +373 -0
  221. data/lib/active_scaffold_env.rb +13 -0
  222. data/lib/generators/active_scaffold/USAGE +29 -0
  223. data/lib/generators/active_scaffold/active_scaffold_generator.rb +21 -0
  224. data/lib/generators/active_scaffold_controller/USAGE +19 -0
  225. data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +29 -0
  226. data/lib/generators/active_scaffold_controller/templates/controller.rb +4 -0
  227. data/lib/generators/active_scaffold_controller/templates/helper.rb +2 -0
  228. data/public/blank.html +33 -0
  229. data/shoulda_macros/macros.rb +136 -0
  230. data/vendor/assets/images/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  231. data/vendor/assets/images/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  232. data/vendor/assets/images/ui-bg_flat_10_000000_40x100.png +0 -0
  233. data/vendor/assets/images/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  234. data/vendor/assets/images/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  235. data/vendor/assets/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  236. data/vendor/assets/images/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  237. data/vendor/assets/images/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  238. data/vendor/assets/images/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  239. data/vendor/assets/images/ui-icons_222222_256x240.png +0 -0
  240. data/vendor/assets/images/ui-icons_228ef1_256x240.png +0 -0
  241. data/vendor/assets/images/ui-icons_ef8c08_256x240.png +0 -0
  242. data/vendor/assets/images/ui-icons_ffd27a_256x240.png +0 -0
  243. data/vendor/assets/images/ui-icons_ffffff_256x240.png +0 -0
  244. data/vendor/assets/javascripts/jquery-ui-timepicker-addon.js +1276 -0
  245. data/vendor/assets/stylesheets/jquery-ui.css +568 -0
  246. metadata +261 -17
@@ -0,0 +1,83 @@
1
+ class ActiveScaffold::Tableless < ActiveRecord::Base
2
+ class Relation < ActiveRecord::Relation
3
+ attr_reader :conditions
4
+ def initialize(klass, table)
5
+ super
6
+ @conditions ||= []
7
+ end
8
+
9
+ def initialize_copy(other)
10
+ @conditions = @conditions.dup
11
+ super
12
+ end
13
+
14
+ def where(opts, *rest)
15
+ unless opts.blank?
16
+ opts = opts.with_indifferent_access if opts.is_a? Hash
17
+ @conditions << (rest.empty? ? opts : [opts, *rest])
18
+ end
19
+ self
20
+ end
21
+
22
+ def merge(r)
23
+ super.tap do |merged|
24
+ merged.conditions.concat r.conditions unless r.nil? || r.is_a?(Array)
25
+ end
26
+ end
27
+
28
+ def except(*skips)
29
+ super.tap do |new_relation|
30
+ new_relation.conditions = conditions unless skips.include? :where
31
+ end
32
+ end
33
+
34
+ def to_a
35
+ @klass.find_all(self)
36
+ end
37
+
38
+ def find_one(id)
39
+ @klass.find_one(id, self)
40
+ end
41
+
42
+ def execute_simple_calculation(operation, column_name, distinct)
43
+ @klass.execute_simple_calculation(self, operation, column_name, distinct)
44
+ end
45
+ end
46
+
47
+ def self.columns; @columns ||= []; end
48
+ def self.table_name; @table_name ||= ActiveModel::Naming.plural(self); end
49
+ def self.table_exists?; true; end
50
+ self.abstract_class = true
51
+ class << self
52
+ private
53
+ def relation
54
+ @relation ||= ActiveScaffold::Tableless::Relation.new(self, arel_table)
55
+ super
56
+ end
57
+ end
58
+
59
+ def self.column(name, sql_type = nil, options = {})
60
+ column = ActiveRecord::ConnectionAdapters::Column.new(name.to_s, options[:default], sql_type.to_s, options.has_key?(:null) ? options[:null] : true)
61
+ column.tap { columns << column }
62
+ end
63
+
64
+ def self.find_all(relation)
65
+ raise 'self.find_all must be implemented in a Tableless model'
66
+ end
67
+
68
+ def self.find_one(id, relation)
69
+ raise 'self.find_one must be implemented in a Tableless model'
70
+ end
71
+
72
+ def self.execute_simple_calculation(relation, operation, column_name, distinct)
73
+ if operation == 'count' && column_name == :all && !distinct
74
+ find_all(relation).size
75
+ else
76
+ raise "self.execute_simple_calculation must be implemented in a Tableless model to support #{operation} #{column_name} #{' distinct' if distinct} columns"
77
+ end
78
+ end
79
+
80
+ def destroy
81
+ raise 'destroy must be implemented in a Tableless model'
82
+ end
83
+ end
@@ -0,0 +1,9 @@
1
+ module ActiveScaffold
2
+ module Version
3
+ MAJOR = 3
4
+ MINOR = 2
5
+ PATCH = 19
6
+
7
+ STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
+ end
9
+ end
@@ -0,0 +1,373 @@
1
+ unless Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR >= 1
2
+ raise "This version of ActiveScaffold requires Rails 3.1 or higher. Please use an earlier version."
3
+ end
4
+
5
+ begin
6
+ require 'render_component'
7
+ rescue LoadError
8
+ end
9
+
10
+ require 'active_scaffold/active_record_permissions'
11
+ require 'active_scaffold/paginator'
12
+ require 'active_scaffold/responds_to_parent'
13
+
14
+ require 'active_scaffold/version'
15
+ require 'active_scaffold/engine' unless defined? ACTIVE_SCAFFOLD_PLUGIN
16
+ require 'json' # for js_config
17
+
18
+ module ActiveScaffold
19
+ autoload :AttributeParams, 'active_scaffold/attribute_params'
20
+ autoload :Configurable, 'active_scaffold/configurable'
21
+ autoload :Constraints, 'active_scaffold/constraints'
22
+ autoload :Finder, 'active_scaffold/finder'
23
+ autoload :MarkedModel, 'active_scaffold/marked_model'
24
+ autoload :Bridges, 'active_scaffold/bridges'
25
+
26
+ mattr_accessor :stylesheets
27
+ self.stylesheets = []
28
+ mattr_accessor :javascripts
29
+ self.javascripts = []
30
+
31
+ def self.autoload_subdir(dir, mod=self, root = File.dirname(__FILE__))
32
+ Dir["#{root}/active_scaffold/#{dir}/*.rb"].each { |file|
33
+ basename = File.basename(file, ".rb")
34
+ mod.module_eval {
35
+ autoload basename.camelcase.to_sym, "active_scaffold/#{dir}/#{basename}"
36
+ }
37
+ }
38
+ end
39
+
40
+ module Actions
41
+ ActiveScaffold.autoload_subdir('actions', self)
42
+ end
43
+
44
+ module Config
45
+ ActiveScaffold.autoload_subdir('config', self)
46
+ end
47
+
48
+ module DataStructures
49
+ ActiveScaffold.autoload_subdir('data_structures', self)
50
+ end
51
+
52
+ module Helpers
53
+ ActiveScaffold.autoload_subdir('helpers', self)
54
+ end
55
+
56
+ class ControllerNotFound < RuntimeError; end
57
+ class DependencyFailure < RuntimeError; end
58
+ class MalformedConstraint < RuntimeError; end
59
+ class RecordNotAllowed < SecurityError; end
60
+ class ActionNotAllowed < SecurityError; end
61
+ class ReverseAssociationRequired < RuntimeError; end
62
+
63
+ def self.included(base)
64
+ base.extend(ClassMethods)
65
+ base.module_eval do
66
+ # TODO: these should be in actions/core
67
+ before_filter :handle_user_settings
68
+ before_filter :check_input_device
69
+ end
70
+
71
+ base.helper_method :touch_device?
72
+ base.helper_method :hover_via_click?
73
+ base.helper_method :active_scaffold_constraints
74
+ end
75
+
76
+ def self.set_defaults(&block)
77
+ ActiveScaffold::Config::Core.configure &block
78
+ end
79
+
80
+ def active_scaffold_config
81
+ self.class.active_scaffold_config
82
+ end
83
+
84
+ def active_scaffold_config_for(klass)
85
+ self.class.active_scaffold_config_for(klass)
86
+ end
87
+
88
+ def active_scaffold_session_storage(id = nil)
89
+ id ||= params[:eid] || "#{params[:controller]}#{"_#{nested.parent_id}" if nested?}"
90
+ session_index = "as:#{id}"
91
+ session[session_index] ||= {}
92
+ session[session_index]
93
+ end
94
+
95
+ # at some point we need to pass the session and params into config. we'll just take care of that before any particular action occurs by passing those hashes off to the UserSettings class of each action.
96
+ def handle_user_settings
97
+ if self.class.uses_active_scaffold?
98
+ active_scaffold_config.actions.each do |action_name|
99
+ conf_instance = active_scaffold_config.send(action_name) rescue next
100
+ next if conf_instance.class::UserSettings == ActiveScaffold::Config::Base::UserSettings # if it hasn't been extended, skip it
101
+ active_scaffold_session_storage[action_name] ||= {}
102
+ conf_instance.user = conf_instance.class::UserSettings.new(conf_instance, active_scaffold_session_storage[action_name], params)
103
+ end
104
+ end
105
+ end
106
+
107
+ def check_input_device
108
+ if request.env["HTTP_USER_AGENT"] && request.env["HTTP_USER_AGENT"][/(iPhone|iPod|iPad)/i]
109
+ session[:input_device_type] = 'TOUCH'
110
+ session[:hover_supported] = false
111
+ else
112
+ session[:input_device_type] = 'MOUSE'
113
+ session[:hover_supported] = true
114
+ end if session[:input_device_type].nil?
115
+ end
116
+
117
+ def touch_device?
118
+ session[:input_device_type] == 'TOUCH'
119
+ end
120
+
121
+ def hover_via_click?
122
+ session[:hover_supported] == false
123
+ end
124
+
125
+ def self.js_framework=(framework)
126
+ @@js_framework = framework
127
+ end
128
+
129
+ def self.js_framework
130
+ @@js_framework ||= if defined? Jquery
131
+ :jquery
132
+ elsif defined? PrototypeRails
133
+ :prototype
134
+ end
135
+ end
136
+
137
+ def self.js_config=(config)
138
+ @@js_config = config
139
+ end
140
+
141
+ def self.js_config
142
+ @@js_config ||= {:scroll_on_close => :checkInViewport}
143
+ end
144
+
145
+ # exclude bridges you do not need
146
+ # name of bridge subdir should be used to exclude it
147
+ # eg
148
+ # ActiveScaffold.exclude_bridges = [:cancan, :ancestry]
149
+ # if you are using Activescaffold as a gem add to initializer
150
+ # if you are using Activescaffold as a plugin add to active_scaffold_env.rb
151
+ def self.exclude_bridges=(bridges)
152
+ @@exclude_bridges = bridges
153
+ end
154
+
155
+ def self.exclude_bridges
156
+ @@exclude_bridges ||= []
157
+ end
158
+
159
+ def self.root
160
+ File.dirname(__FILE__) + "/.."
161
+ end
162
+
163
+ module ClassMethods
164
+ def active_scaffold(model_id = nil, &block)
165
+ # initialize bridges here
166
+ ActiveScaffold::Bridges.run_all
167
+
168
+ # converts Foo::BarController to 'bar' and FooBarsController to 'foo_bar' and AddressController to 'address'
169
+ model_id = self.to_s.split('::').last.sub(/Controller$/, '').pluralize.singularize.underscore unless model_id
170
+
171
+ # run the configuration
172
+ @active_scaffold_config = ActiveScaffold::Config::Core.new(model_id)
173
+ @active_scaffold_config_block = block
174
+ self.links_for_associations
175
+
176
+ @active_scaffold_frontends = []
177
+ if active_scaffold_config.frontend.to_sym != :default
178
+ active_scaffold_custom_frontend_path = File.join(ActiveScaffold::Config::Core.plugin_directory, 'frontends', active_scaffold_config.frontend.to_s , 'views')
179
+ @active_scaffold_frontends << active_scaffold_custom_frontend_path
180
+ end
181
+ active_scaffold_default_frontend_path = File.join(ActiveScaffold::Config::Core.plugin_directory, 'frontends', 'default' , 'views')
182
+ @active_scaffold_frontends << active_scaffold_default_frontend_path
183
+ @active_scaffold_custom_paths = []
184
+
185
+ self.active_scaffold_superclasses_blocks.each {|superblock| self.active_scaffold_config.configure &superblock}
186
+ self.active_scaffold_config.sti_children = nil # reset sti_children if set in parent block
187
+ self.active_scaffold_config.configure &block if block_given?
188
+ self.active_scaffold_config._configure_sti unless self.active_scaffold_config.sti_children.nil?
189
+ self.active_scaffold_config._load_action_columns
190
+
191
+ # defines the attribute read methods on the model, so record.send() doesn't find protected/private methods instead
192
+ klass = self.active_scaffold_config.model
193
+ klass.define_attribute_methods unless klass.attribute_methods_generated?
194
+ # include the rest of the code into the controller: the action core and the included actions
195
+ module_eval do
196
+ include ActiveScaffold::Finder
197
+ include ActiveScaffold::Constraints
198
+ include ActiveScaffold::AttributeParams
199
+ include ActiveScaffold::Actions::Core
200
+ active_scaffold_config.actions.each do |mod|
201
+ name = mod.to_s.camelize
202
+ include "ActiveScaffold::Actions::#{name}".constantize
203
+
204
+ # sneak the action links from the actions into the main set
205
+ if link = active_scaffold_config.send(mod).link rescue nil
206
+ if link.is_a? Array
207
+ link.each {|current| active_scaffold_config.action_links.add_to_group(current, active_scaffold_config.send(mod).action_group)}
208
+ elsif link.is_a? ActiveScaffold::DataStructures::ActionLink
209
+ active_scaffold_config.action_links.add_to_group(link, active_scaffold_config.send(mod).action_group)
210
+ end
211
+ end
212
+ end
213
+ end
214
+ self.append_view_path active_scaffold_paths
215
+ self._add_sti_create_links if self.active_scaffold_config.add_sti_create_links?
216
+ end
217
+
218
+ def parent_prefixes
219
+ @parent_prefixes ||= super << 'active_scaffold_overrides' << ''
220
+ end
221
+
222
+ # To be called after include action modules
223
+ def _add_sti_create_links
224
+ new_action_link = active_scaffold_config.action_links.collection['new']
225
+ unless new_action_link.nil? || active_scaffold_config.sti_children.empty?
226
+ active_scaffold_config.action_links.collection.delete('new')
227
+ active_scaffold_config.sti_children.each do |child|
228
+ new_sti_link = Marshal.load(Marshal.dump(new_action_link)) # deep clone
229
+ new_sti_link.label = child.to_s.camelize.constantize.model_name.human
230
+ new_sti_link.parameters = {:parent_sti => controller_path}
231
+ new_sti_link.controller = Proc.new { active_scaffold_controller_for(child.to_s.camelize.constantize).controller_path }
232
+ active_scaffold_config.action_links.collection.create.add(new_sti_link)
233
+ end
234
+ end
235
+ end
236
+
237
+ # Create the automatic column links. Note that this has to happen when configuration is *done*, because otherwise the Nested module could be disabled. Actually, it could still be disabled later, couldn't it?
238
+ def links_for_associations
239
+ return unless active_scaffold_config.actions.include? :list and active_scaffold_config.actions.include? :nested
240
+ active_scaffold_config.columns.each do |column|
241
+ next unless column.link.nil? and column.autolink?
242
+ #lazy load of action_link, cause it was really slowing down app in dev mode
243
+ #and might lead to trouble cause of cyclic constantization of controllers
244
+ #and might be unnecessary cause it is done before columns are configured
245
+ column.set_link(Proc.new {|col| link_for_association(col)})
246
+ end
247
+ end
248
+
249
+ def active_scaffold_controller_for_column(column, options = {})
250
+ begin
251
+ if column.polymorphic_association?
252
+ :polymorph
253
+ elsif options.include?(:controller)
254
+ "#{options[:controller].to_s.camelize}Controller".constantize
255
+ else
256
+ active_scaffold_controller_for(column.association.klass)
257
+ end
258
+ rescue ActiveScaffold::ControllerNotFound
259
+ nil
260
+ end
261
+ end
262
+
263
+ def link_for_association(column, options = {})
264
+ controller = active_scaffold_controller_for_column(column, options)
265
+
266
+ unless controller.nil?
267
+ options.reverse_merge! :label => column.label, :position => :after, :type => :member, :controller => (controller == :polymorph ? controller : controller.controller_path), :column => column
268
+ options[:parameters] ||= {}
269
+ options[:parameters].reverse_merge! :association => column.association.name
270
+ if column.plural_association?
271
+ # note: we can't create nested scaffolds on :through associations because there's no reverse association.
272
+
273
+ ActiveScaffold::DataStructures::ActionLink.new('index', options.merge(:refresh_on_close => true)) #unless column.through_association?
274
+ else
275
+ actions = controller.active_scaffold_config.actions unless controller == :polymorph
276
+ actions ||= [:create, :update, :show]
277
+ column.actions_for_association_links.delete :new unless actions.include? :create
278
+ column.actions_for_association_links.delete :edit unless actions.include? :update
279
+ column.actions_for_association_links.delete :show unless actions.include? :show
280
+ ActiveScaffold::DataStructures::ActionLink.new(nil, options.merge(:html_options => {:class => column.name}))
281
+ end
282
+ end
283
+ end
284
+
285
+ def link_for_association_as_scope(scope, options = {})
286
+ options.reverse_merge! :label => scope, :position => :after, :type => :member, :controller => controller_path
287
+ options[:parameters] ||= {}
288
+ options[:parameters].reverse_merge! :named_scope => scope
289
+ ActiveScaffold::DataStructures::ActionLink.new('index', options)
290
+ end
291
+
292
+ def add_active_scaffold_path(path)
293
+ @active_scaffold_paths = nil # Force active_scaffold_paths to rebuild
294
+ @active_scaffold_custom_paths << path
295
+ end
296
+
297
+ def active_scaffold_paths
298
+ return @active_scaffold_paths unless @active_scaffold_paths.nil?
299
+
300
+ @active_scaffold_paths = []
301
+ @active_scaffold_paths.concat @active_scaffold_custom_paths unless @active_scaffold_custom_paths.nil?
302
+ @active_scaffold_paths.concat @active_scaffold_frontends unless @active_scaffold_frontends.nil?
303
+ @active_scaffold_paths
304
+ end
305
+
306
+ def active_scaffold_config
307
+ if @active_scaffold_config.nil?
308
+ self.superclass.active_scaffold_config if self.superclass.respond_to? :active_scaffold_config
309
+ else
310
+ @active_scaffold_config
311
+ end
312
+ end
313
+
314
+ def active_scaffold_config_block
315
+ @active_scaffold_config_block
316
+ end
317
+
318
+ def active_scaffold_superclasses_blocks
319
+ blocks = []
320
+ klass = self.superclass
321
+ while klass.respond_to? :active_scaffold_superclasses_blocks
322
+ blocks << klass.active_scaffold_config_block
323
+ klass = klass.superclass
324
+ end
325
+ blocks.compact.reverse
326
+ end
327
+
328
+ def active_scaffold_config_for(klass)
329
+ begin
330
+ controller = active_scaffold_controller_for(klass)
331
+ rescue ActiveScaffold::ControllerNotFound
332
+ config = ActiveScaffold::Config::Core.new(klass)
333
+ config._load_action_columns
334
+ config
335
+ else
336
+ controller.active_scaffold_config
337
+ end
338
+ end
339
+
340
+ # Tries to find a controller for the given ActiveRecord model.
341
+ # Searches in the namespace of the current controller for singular and plural versions of the conventional "#{model}Controller" syntax.
342
+ # You may override this method to customize the search routine.
343
+ def active_scaffold_controller_for(klass)
344
+ controller_namespace = self.to_s.split('::')[0...-1].join('::') + '::'
345
+ error_message = []
346
+ [controller_namespace, ''].each do |namespace|
347
+ ["#{klass.to_s.underscore.pluralize}", "#{klass.to_s.underscore.pluralize.singularize}"].each do |controller_name|
348
+ begin
349
+ controller = "#{namespace}#{controller_name.camelize}Controller".constantize
350
+ rescue NameError => error
351
+ # Only rescue NameError associated with the controller constant not existing - not other compile errors
352
+ if error.message["uninitialized constant #{controller}"]
353
+ error_message << "#{namespace}#{controller_name.camelize}Controller"
354
+ next
355
+ else
356
+ raise
357
+ end
358
+ end
359
+ raise ActiveScaffold::ControllerNotFound, "#{controller} missing ActiveScaffold", caller unless controller.uses_active_scaffold?
360
+ raise ActiveScaffold::ControllerNotFound, "ActiveScaffold on #{controller} is not for #{klass} model.", caller unless controller.active_scaffold_config.model.to_s == klass.to_s
361
+ return controller
362
+ end
363
+ end
364
+ raise ActiveScaffold::ControllerNotFound, "Could not find " + error_message.join(" or "), caller
365
+ end
366
+
367
+ def uses_active_scaffold?
368
+ !active_scaffold_config.nil?
369
+ end
370
+ end
371
+ end
372
+
373
+ require 'active_scaffold_env'
@@ -0,0 +1,13 @@
1
+ # TODO: clean up extensions. some could be organized for autoloading, and others could be removed entirely.
2
+ Dir["#{File.dirname __FILE__}/active_scaffold/extensions/*.rb"].each { |file| require file }
3
+ module ActiveScaffold
4
+ autoload :Tableless, 'active_scaffold/tableless'
5
+ end
6
+
7
+ ActionController::Base.send(:include, ActiveScaffold)
8
+ ActionController::Base.send(:include, RespondsToParent)
9
+ ActionController::Base.send(:include, ActiveScaffold::Helpers::ControllerHelpers)
10
+ ActionView::Base.send(:include, ActiveScaffold::Helpers::ViewHelpers)
11
+
12
+ ActionController::Base.class_eval {include ActiveRecordPermissions::ModelUserAccess::Controller}
13
+ ActiveRecord::Base.class_eval {include ActiveRecordPermissions::ModelUserAccess::Model}
@@ -0,0 +1,29 @@
1
+ Description:
2
+ Scaffolds an entire resource, from model and migration to controller,
3
+ along with a full test suite and configured to use active_scaffold.
4
+ The resource is ready to use as a starting point for your RESTful,
5
+ resource-oriented application.
6
+
7
+ Pass the name of the model (in singular form), either CamelCased or
8
+ under_scored, as the first argument, and an optional list of attribute
9
+ pairs.
10
+
11
+ Attribute pairs are field:type arguments specifying the
12
+ model's attributes. Timestamps are added by default, so you don't have to
13
+ specify them by hand as 'created_at:datetime updated_at:datetime'.
14
+
15
+ You don't have to think up every attribute up front, but it helps to
16
+ sketch out a few so you can start working with the resource immediately.
17
+
18
+ For example, 'active_scaffold post title:string body:text published:boolean'
19
+ gives you a model with those three attributes, a controller configured to use active_scaffold,
20
+ as well as a resources :posts with additional active_scaffold routes
21
+ declaration in config/routes.rb.
22
+
23
+ If you want to remove all the generated files, run
24
+ 'rails destroy active_scaffold ModelName'.
25
+
26
+ Examples:
27
+ `rails generate active_scaffold post`
28
+ `rails generate active_scaffold post title:string body:text published:boolean`
29
+ `rails generate active_scaffold purchase order_id:integer amount:decimal`
@@ -0,0 +1,21 @@
1
+ require 'rails/generators/rails/resource/resource_generator'
2
+ #require 'generators/active_scaffold_controller/active_scaffold_controller_generator'
3
+
4
+ module Rails
5
+ module Generators
6
+ class ActiveScaffoldGenerator < ResourceGenerator #metagenerator
7
+ remove_hook_for :resource_controller
8
+ remove_hook_for :resource_route
9
+ remove_class_option :actions
10
+
11
+ def add_resource_route
12
+ route_config = class_path.collect{|namespace| "namespace :#{namespace} do " }.join(" ")
13
+ route_config << "resources :#{file_name.pluralize} do as_routes end"
14
+ route_config << " end" * class_path.size
15
+ route route_config
16
+ end
17
+
18
+ invoke "active_scaffold_controller"
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ Description:
2
+ Stubs out a active_scaffolded controller. Pass the model name,
3
+ either CamelCased or under_scored.
4
+ The controller name is retrieved as a pluralized version of the model
5
+ name.
6
+
7
+ To create a controller within a module, specify the model name as a
8
+ path like 'parent_module/controller_name'.
9
+
10
+ This generates a controller class in app/controllers and invokes helper,
11
+ template engine and test framework generators.
12
+
13
+ Example:
14
+ `rails generate active_scaffold_controller CreditCard`
15
+
16
+ Credit card controller with URLs like /credit_card/debit.
17
+ Controller: app/controllers/credit_cards_controller.rb
18
+ Functional Test: test/functional/credit_cards_controller_test.rb
19
+ Helper: app/helpers/credit_cards_helper.rb
@@ -0,0 +1,29 @@
1
+ #require 'rails/generators/rails/scaffold_controller/scaffold_controller_generator'
2
+
3
+ module Rails
4
+ module Generators
5
+ class ActiveScaffoldControllerGenerator < NamedBase #metagenerator
6
+ include ResourceHelpers
7
+
8
+ def self.source_root
9
+ @source_root ||= File.join(File.dirname(__FILE__), 'templates')
10
+ end
11
+
12
+ check_class_collision :suffix => "Controller"
13
+
14
+ class_option :orm, :banner => "NAME", :type => :string, :required => true,
15
+ :desc => "ORM to generate the controller for"
16
+
17
+ def create_controller_files
18
+ template 'controller.rb', File.join('app/controllers', class_path, "#{controller_file_name}_controller.rb")
19
+ template 'helper.rb', File.join('app/helpers', class_path, "#{controller_file_name}_helper.rb")
20
+ end
21
+
22
+ hook_for :test_framework, :as => :scaffold
23
+
24
+ def create_view_root_folder
25
+ empty_directory File.join("app/views", controller_file_path)
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,4 @@
1
+ class <%= controller_class_name %>Controller < ApplicationController
2
+ active_scaffold :<%= class_name.demodulize.underscore %> do |conf|
3
+ end
4
+ end
@@ -0,0 +1,2 @@
1
+ module <%= controller_class_name %>Helper
2
+ end
data/public/blank.html ADDED
@@ -0,0 +1,33 @@
1
+ <!--
2
+ Copyright (c) 2005, Brad Neuberg, bkn3@columbia.edu
3
+ http://codinginparadise.org
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the "Software"),
7
+ to deal in the Software without restriction, including without limitation
8
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
+ and/or sell copies of the Software, and to permit persons to whom the
10
+ Software is furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
20
+ OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
21
+ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ -->
23
+
24
+ <html>
25
+ <script language="JavaScript">
26
+ function pageLoaded() {
27
+ window.parent.dhtmlHistory.iframeLoaded(window.location);
28
+ }
29
+ </script>
30
+ <body onload="pageLoaded()">
31
+ <h1>blank.html - Needed for Internet Explorer's hidden IFrame</h1>
32
+ </body>
33
+ </html>