active_scaffold_san 3.0.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (284) hide show
  1. data/.autotest +27 -0
  2. data/.document +5 -0
  3. data/CHANGELOG +179 -0
  4. data/Gemfile +13 -0
  5. data/Gemfile.lock +20 -0
  6. data/MIT-LICENSE +20 -0
  7. data/README +69 -0
  8. data/Rakefile +53 -0
  9. data/active_scaffold_vho.gemspec +388 -0
  10. data/frontends/default/images/add.gif +0 -0
  11. data/frontends/default/images/arrow_down.gif +0 -0
  12. data/frontends/default/images/arrow_up.gif +0 -0
  13. data/frontends/default/images/close.gif +0 -0
  14. data/frontends/default/images/config.png +0 -0
  15. data/frontends/default/images/cross.png +0 -0
  16. data/frontends/default/images/gears.png +0 -0
  17. data/frontends/default/images/indicator-small.gif +0 -0
  18. data/frontends/default/images/indicator.gif +0 -0
  19. data/frontends/default/images/magnifier.png +0 -0
  20. data/frontends/default/javascripts/jquery/active_scaffold.js +1004 -0
  21. data/frontends/default/javascripts/jquery/jquery.editinplace.js +743 -0
  22. data/frontends/default/javascripts/prototype/active_scaffold.js +1003 -0
  23. data/frontends/default/javascripts/prototype/dhtml_history.js +867 -0
  24. data/frontends/default/javascripts/prototype/form_enhancements.js +117 -0
  25. data/frontends/default/javascripts/prototype/rico_corner.js +370 -0
  26. data/frontends/default/stylesheets/stylesheet-ie.css +35 -0
  27. data/frontends/default/stylesheets/stylesheet.css +973 -0
  28. data/frontends/default/views/_action_group.html.erb +20 -0
  29. data/frontends/default/views/_add_existing_form.html.erb +30 -0
  30. data/frontends/default/views/_base_form.html.erb +51 -0
  31. data/frontends/default/views/_create_form.html.erb +8 -0
  32. data/frontends/default/views/_create_form_on_list.html.erb +6 -0
  33. data/frontends/default/views/_field_search.html.erb +32 -0
  34. data/frontends/default/views/_form.html.erb +24 -0
  35. data/frontends/default/views/_form_association.html.erb +19 -0
  36. data/frontends/default/views/_form_association_footer.html.erb +40 -0
  37. data/frontends/default/views/_form_attribute.html.erb +15 -0
  38. data/frontends/default/views/_form_hidden_attribute.html.erb +2 -0
  39. data/frontends/default/views/_form_messages.html.erb +5 -0
  40. data/frontends/default/views/_horizontal_subform.html.erb +29 -0
  41. data/frontends/default/views/_horizontal_subform_header.html.erb +10 -0
  42. data/frontends/default/views/_horizontal_subform_record.html.erb +37 -0
  43. data/frontends/default/views/_human_conditions.html.erb +1 -0
  44. data/frontends/default/views/_list.html.erb +18 -0
  45. data/frontends/default/views/_list_actions.html.erb +15 -0
  46. data/frontends/default/views/_list_calculations.html.erb +16 -0
  47. data/frontends/default/views/_list_column_headings.html.erb +12 -0
  48. data/frontends/default/views/_list_header.html.erb +10 -0
  49. data/frontends/default/views/_list_inline_adapter.html.erb +10 -0
  50. data/frontends/default/views/_list_messages.html.erb +32 -0
  51. data/frontends/default/views/_list_pagination.html.erb +11 -0
  52. data/frontends/default/views/_list_pagination_links.html.erb +9 -0
  53. data/frontends/default/views/_list_record.html.erb +14 -0
  54. data/frontends/default/views/_list_record_columns.html.erb +8 -0
  55. data/frontends/default/views/_list_with_header.html.erb +32 -0
  56. data/frontends/default/views/_messages.html.erb +10 -0
  57. data/frontends/default/views/_render_field.js.rjs +10 -0
  58. data/frontends/default/views/_row.html.erb +12 -0
  59. data/frontends/default/views/_search.html.erb +34 -0
  60. data/frontends/default/views/_search_attribute.html.erb +10 -0
  61. data/frontends/default/views/_show.html.erb +8 -0
  62. data/frontends/default/views/_show_columns.html.erb +15 -0
  63. data/frontends/default/views/_update_actions.html.erb +9 -0
  64. data/frontends/default/views/_update_form.html.erb +6 -0
  65. data/frontends/default/views/_vertical_subform.html.erb +12 -0
  66. data/frontends/default/views/_vertical_subform_record.html.erb +38 -0
  67. data/frontends/default/views/action_confirmation.html.erb +13 -0
  68. data/frontends/default/views/add_existing.js.rjs +17 -0
  69. data/frontends/default/views/add_existing_form.html.erb +5 -0
  70. data/frontends/default/views/create.html.erb +5 -0
  71. data/frontends/default/views/delete.html.erb +13 -0
  72. data/frontends/default/views/destroy.js.rjs +23 -0
  73. data/frontends/default/views/edit_associated.js.rjs +11 -0
  74. data/frontends/default/views/field_search.html.erb +5 -0
  75. data/frontends/default/views/form_messages.js.rjs +1 -0
  76. data/frontends/default/views/list.html.erb +1 -0
  77. data/frontends/default/views/list.js.rjs +1 -0
  78. data/frontends/default/views/on_action_update.js.rjs +8 -0
  79. data/frontends/default/views/on_create.js.rjs +41 -0
  80. data/frontends/default/views/on_mark_all.js.rjs +4 -0
  81. data/frontends/default/views/on_update.js.rjs +28 -0
  82. data/frontends/default/views/search.html.erb +5 -0
  83. data/frontends/default/views/show.html.erb +5 -0
  84. data/frontends/default/views/update.html.erb +8 -0
  85. data/frontends/default/views/update_column.js.rjs +13 -0
  86. data/frontends/default/views/update_row.js.rjs +1 -0
  87. data/init.rb +8 -0
  88. data/lib/active_scaffold.rb +360 -0
  89. data/lib/active_scaffold/actions/common_search.rb +22 -0
  90. data/lib/active_scaffold/actions/core.rb +180 -0
  91. data/lib/active_scaffold/actions/create.rb +149 -0
  92. data/lib/active_scaffold/actions/delete.rb +75 -0
  93. data/lib/active_scaffold/actions/field_search.rb +82 -0
  94. data/lib/active_scaffold/actions/list.rb +184 -0
  95. data/lib/active_scaffold/actions/mark.rb +63 -0
  96. data/lib/active_scaffold/actions/nested.rb +250 -0
  97. data/lib/active_scaffold/actions/search.rb +47 -0
  98. data/lib/active_scaffold/actions/show.rb +61 -0
  99. data/lib/active_scaffold/actions/subform.rb +27 -0
  100. data/lib/active_scaffold/actions/update.rb +151 -0
  101. data/lib/active_scaffold/active_record_permissions.rb +134 -0
  102. data/lib/active_scaffold/attribute_params.rb +211 -0
  103. data/lib/active_scaffold/bridges/ancestry/bridge.rb +5 -0
  104. data/lib/active_scaffold/bridges/ancestry/lib/ancestry_bridge.rb +39 -0
  105. data/lib/active_scaffold/bridges/bridge.rb +59 -0
  106. data/lib/active_scaffold/bridges/calendar_date_select/bridge.rb +16 -0
  107. data/lib/active_scaffold/bridges/calendar_date_select/lib/as_cds_bridge.rb +83 -0
  108. data/lib/active_scaffold/bridges/cancan/bridge.rb +12 -0
  109. data/lib/active_scaffold/bridges/cancan/lib/cancan_bridge.rb +107 -0
  110. data/lib/active_scaffold/bridges/carrierwave/bridge.rb +9 -0
  111. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge.rb +33 -0
  112. data/lib/active_scaffold/bridges/carrierwave/lib/carrierwave_bridge_helpers.rb +12 -0
  113. data/lib/active_scaffold/bridges/carrierwave/lib/form_ui.rb +45 -0
  114. data/lib/active_scaffold/bridges/carrierwave/lib/list_ui.rb +17 -0
  115. data/lib/active_scaffold/bridges/date_picker/bridge.rb +24 -0
  116. data/lib/active_scaffold/bridges/date_picker/lib/datepicker_bridge.rb +225 -0
  117. data/lib/active_scaffold/bridges/date_picker/public/javascripts/date_picker_bridge.js +22 -0
  118. data/lib/active_scaffold/bridges/file_column/bridge.rb +11 -0
  119. data/lib/active_scaffold/bridges/file_column/lib/as_file_column_bridge.rb +46 -0
  120. data/lib/active_scaffold/bridges/file_column/lib/file_column_helpers.rb +59 -0
  121. data/lib/active_scaffold/bridges/file_column/lib/form_ui.rb +37 -0
  122. data/lib/active_scaffold/bridges/file_column/lib/list_ui.rb +26 -0
  123. data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +43 -0
  124. data/lib/active_scaffold/bridges/file_column/test/mock_model.rb +9 -0
  125. data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +15 -0
  126. data/lib/active_scaffold/bridges/paperclip/bridge.rb +12 -0
  127. data/lib/active_scaffold/bridges/paperclip/lib/form_ui.rb +27 -0
  128. data/lib/active_scaffold/bridges/paperclip/lib/list_ui.rb +16 -0
  129. data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge.rb +38 -0
  130. data/lib/active_scaffold/bridges/paperclip/lib/paperclip_bridge_helpers.rb +26 -0
  131. data/lib/active_scaffold/bridges/semantic_attributes/bridge.rb +5 -0
  132. data/lib/active_scaffold/bridges/semantic_attributes/lib/semantic_attributes_bridge.rb +20 -0
  133. data/lib/active_scaffold/bridges/shared/date_bridge.rb +209 -0
  134. data/lib/active_scaffold/bridges/tiny_mce/bridge.rb +5 -0
  135. data/lib/active_scaffold/bridges/tiny_mce/lib/tiny_mce_bridge.rb +61 -0
  136. data/lib/active_scaffold/bridges/validation_reflection/bridge.rb +8 -0
  137. data/lib/active_scaffold/bridges/validation_reflection/lib/validation_reflection_bridge.rb +21 -0
  138. data/lib/active_scaffold/config/base.rb +62 -0
  139. data/lib/active_scaffold/config/core.rb +220 -0
  140. data/lib/active_scaffold/config/create.rb +51 -0
  141. data/lib/active_scaffold/config/delete.rb +34 -0
  142. data/lib/active_scaffold/config/field_search.rb +75 -0
  143. data/lib/active_scaffold/config/form.rb +47 -0
  144. data/lib/active_scaffold/config/list.rb +174 -0
  145. data/lib/active_scaffold/config/mark.rb +22 -0
  146. data/lib/active_scaffold/config/nested.rb +44 -0
  147. data/lib/active_scaffold/config/search.rb +69 -0
  148. data/lib/active_scaffold/config/show.rb +35 -0
  149. data/lib/active_scaffold/config/subform.rb +35 -0
  150. data/lib/active_scaffold/config/update.rb +46 -0
  151. data/lib/active_scaffold/configurable.rb +29 -0
  152. data/lib/active_scaffold/constraints.rb +184 -0
  153. data/lib/active_scaffold/data_structures/action_columns.rb +137 -0
  154. data/lib/active_scaffold/data_structures/action_link.rb +175 -0
  155. data/lib/active_scaffold/data_structures/action_links.rb +185 -0
  156. data/lib/active_scaffold/data_structures/actions.rb +45 -0
  157. data/lib/active_scaffold/data_structures/column.rb +355 -0
  158. data/lib/active_scaffold/data_structures/columns.rb +75 -0
  159. data/lib/active_scaffold/data_structures/error_message.rb +24 -0
  160. data/lib/active_scaffold/data_structures/nested_info.rb +123 -0
  161. data/lib/active_scaffold/data_structures/set.rb +62 -0
  162. data/lib/active_scaffold/data_structures/sorting.rb +168 -0
  163. data/lib/active_scaffold/extensions/action_controller_rendering.rb +20 -0
  164. data/lib/active_scaffold/extensions/action_view_rendering.rb +123 -0
  165. data/lib/active_scaffold/extensions/action_view_resolver.rb +7 -0
  166. data/lib/active_scaffold/extensions/active_association_reflection.rb +13 -0
  167. data/lib/active_scaffold/extensions/active_record_offset.rb +12 -0
  168. data/lib/active_scaffold/extensions/array.rb +7 -0
  169. data/lib/active_scaffold/extensions/localize.rb +10 -0
  170. data/lib/active_scaffold/extensions/name_option_for_datetime.rb +12 -0
  171. data/lib/active_scaffold/extensions/nil_id_in_url_params.rb +7 -0
  172. data/lib/active_scaffold/extensions/paginator_extensions.rb +26 -0
  173. data/lib/active_scaffold/extensions/reverse_associations.rb +62 -0
  174. data/lib/active_scaffold/extensions/routing_mapper.rb +34 -0
  175. data/lib/active_scaffold/extensions/to_label.rb +8 -0
  176. data/lib/active_scaffold/extensions/unsaved_associated.rb +61 -0
  177. data/lib/active_scaffold/extensions/unsaved_record.rb +20 -0
  178. data/lib/active_scaffold/extensions/usa_state.rb +46 -0
  179. data/lib/active_scaffold/finder.rb +343 -0
  180. data/lib/active_scaffold/helpers/association_helpers.rb +40 -0
  181. data/lib/active_scaffold/helpers/controller_helpers.rb +87 -0
  182. data/lib/active_scaffold/helpers/country_helpers.rb +352 -0
  183. data/lib/active_scaffold/helpers/form_column_helpers.rb +350 -0
  184. data/lib/active_scaffold/helpers/human_condition_helpers.rb +59 -0
  185. data/lib/active_scaffold/helpers/id_helpers.rb +127 -0
  186. data/lib/active_scaffold/helpers/list_column_helpers.rb +361 -0
  187. data/lib/active_scaffold/helpers/pagination_helpers.rb +55 -0
  188. data/lib/active_scaffold/helpers/search_column_helpers.rb +249 -0
  189. data/lib/active_scaffold/helpers/show_column_helpers.rb +46 -0
  190. data/lib/active_scaffold/helpers/view_helpers.rb +360 -0
  191. data/lib/active_scaffold/locale/de.rb +120 -0
  192. data/lib/active_scaffold/locale/en.rb +119 -0
  193. data/lib/active_scaffold/locale/es.yml +115 -0
  194. data/lib/active_scaffold/locale/fr.rb +122 -0
  195. data/lib/active_scaffold/locale/hu.yml +63 -0
  196. data/lib/active_scaffold/locale/ja.yml +64 -0
  197. data/lib/active_scaffold/locale/ru.yml +119 -0
  198. data/lib/active_scaffold/marked_model.rb +38 -0
  199. data/lib/active_scaffold/paginator.rb +136 -0
  200. data/lib/active_scaffold/responds_to_parent.rb +70 -0
  201. data/lib/active_scaffold/version.rb +9 -0
  202. data/lib/active_scaffold_assets.rb +45 -0
  203. data/lib/active_scaffold_env.rb +14 -0
  204. data/lib/active_scaffold_vho.rb +2 -0
  205. data/lib/generators/active_scaffold/USAGE +29 -0
  206. data/lib/generators/active_scaffold/active_scaffold_generator.rb +20 -0
  207. data/lib/generators/active_scaffold_controller/USAGE +19 -0
  208. data/lib/generators/active_scaffold_controller/active_scaffold_controller_generator.rb +29 -0
  209. data/lib/generators/active_scaffold_controller/templates/controller.rb +4 -0
  210. data/lib/generators/active_scaffold_controller/templates/helper.rb +2 -0
  211. data/lib/generators/active_scaffold_setup/USAGE +10 -0
  212. data/lib/generators/active_scaffold_setup/active_scaffold_setup_generator.rb +61 -0
  213. data/public/blank.html +33 -0
  214. data/shoulda_macros/macros.rb +136 -0
  215. data/test/bridges/bridge_test.rb +47 -0
  216. data/test/config/base_test.rb +15 -0
  217. data/test/config/create_test.rb +55 -0
  218. data/test/config/list_test.rb +74 -0
  219. data/test/config/show_test.rb +43 -0
  220. data/test/config/update_test.rb +17 -0
  221. data/test/const_mocker.rb +36 -0
  222. data/test/data_structures/action_columns_test.rb +113 -0
  223. data/test/data_structures/action_link_test.rb +78 -0
  224. data/test/data_structures/action_links_test.rb +78 -0
  225. data/test/data_structures/actions_test.rb +25 -0
  226. data/test/data_structures/association_column_test.rb +42 -0
  227. data/test/data_structures/column_test.rb +185 -0
  228. data/test/data_structures/columns_test.rb +69 -0
  229. data/test/data_structures/error_message_test.rb +28 -0
  230. data/test/data_structures/set_test.rb +86 -0
  231. data/test/data_structures/sorting_test.rb +126 -0
  232. data/test/data_structures/standard_column_test.rb +24 -0
  233. data/test/data_structures/virtual_column_test.rb +23 -0
  234. data/test/extensions/active_record_test.rb +45 -0
  235. data/test/extensions/array_test.rb +12 -0
  236. data/test/helpers/form_column_helpers_test.rb +31 -0
  237. data/test/helpers/list_column_helpers_test.rb +31 -0
  238. data/test/helpers/pagination_helpers_test.rb +55 -0
  239. data/test/misc/active_record_permissions_test.rb +154 -0
  240. data/test/misc/attribute_params_test.rb +110 -0
  241. data/test/misc/configurable_test.rb +96 -0
  242. data/test/misc/constraints_test.rb +193 -0
  243. data/test/misc/finder_test.rb +93 -0
  244. data/test/misc/lang_test.rb +12 -0
  245. data/test/mock_app/.gitignore +2 -0
  246. data/test/mock_app/app/controllers/application_controller.rb +10 -0
  247. data/test/mock_app/app/helpers/application_helper.rb +3 -0
  248. data/test/mock_app/config/boot.rb +110 -0
  249. data/test/mock_app/config/database.yml +16 -0
  250. data/test/mock_app/config/environment.rb +43 -0
  251. data/test/mock_app/config/environments/development.rb +17 -0
  252. data/test/mock_app/config/environments/production.rb +28 -0
  253. data/test/mock_app/config/environments/test.rb +28 -0
  254. data/test/mock_app/config/initializers/backtrace_silencers.rb +7 -0
  255. data/test/mock_app/config/initializers/inflections.rb +10 -0
  256. data/test/mock_app/config/initializers/mime_types.rb +5 -0
  257. data/test/mock_app/config/initializers/new_rails_defaults.rb +19 -0
  258. data/test/mock_app/config/initializers/session_store.rb +15 -0
  259. data/test/mock_app/config/locales/en.yml +5 -0
  260. data/test/mock_app/config/routes.rb +43 -0
  261. data/test/mock_app/db/test.sqlite3 +1 -0
  262. data/test/mock_app/public/blank.html +33 -0
  263. data/test/mock_app/public/images/active_scaffold/DO_NOT_EDIT +2 -0
  264. data/test/mock_app/public/images/active_scaffold/default/add.gif +0 -0
  265. data/test/mock_app/public/images/active_scaffold/default/arrow_down.gif +0 -0
  266. data/test/mock_app/public/images/active_scaffold/default/arrow_up.gif +0 -0
  267. data/test/mock_app/public/images/active_scaffold/default/close.gif +0 -0
  268. data/test/mock_app/public/images/active_scaffold/default/cross.png +0 -0
  269. data/test/mock_app/public/images/active_scaffold/default/indicator-small.gif +0 -0
  270. data/test/mock_app/public/images/active_scaffold/default/indicator.gif +0 -0
  271. data/test/mock_app/public/images/active_scaffold/default/magnifier.png +0 -0
  272. data/test/mock_app/public/javascripts/active_scaffold/DO_NOT_EDIT +2 -0
  273. data/test/mock_app/public/javascripts/active_scaffold/default/active_scaffold.js +532 -0
  274. data/test/mock_app/public/javascripts/active_scaffold/default/dhtml_history.js +867 -0
  275. data/test/mock_app/public/javascripts/active_scaffold/default/form_enhancements.js +117 -0
  276. data/test/mock_app/public/javascripts/active_scaffold/default/rico_corner.js +370 -0
  277. data/test/mock_app/public/stylesheets/active_scaffold/DO_NOT_EDIT +2 -0
  278. data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet-ie.css +35 -0
  279. data/test/mock_app/public/stylesheets/active_scaffold/default/stylesheet.css +842 -0
  280. data/test/model_stub.rb +55 -0
  281. data/test/run_all.rb +8 -0
  282. data/test/test_helper.rb +39 -0
  283. data/uninstall.rb +13 -0
  284. metadata +497 -0
@@ -0,0 +1,47 @@
1
+ module ActiveScaffold::Config
2
+ class Form < Base
3
+ def initialize(core_config)
4
+ @core = core_config
5
+
6
+ # start with the ActionLink defined globally
7
+ @link = self.class.link.clone unless self.class.link.nil?
8
+ @action_group = self.class.action_group.clone if self.class.action_group
9
+
10
+ # no global setting here because multipart should only be set for specific forms
11
+ @multipart = false
12
+ end
13
+
14
+ # global level configuration
15
+ # --------------------------
16
+
17
+ # instance-level configuration
18
+ # ----------------------------
19
+
20
+ # the ActionLink for this action
21
+ attr_accessor :link
22
+
23
+ # the label for this Form action. used for the header.
24
+ attr_writer :label
25
+ def label
26
+ as_(@label)
27
+ end
28
+
29
+ # provides access to the list of columns specifically meant for the Form to use
30
+ def columns
31
+ unless @columns # lazy evaluation
32
+ self.columns = @core.columns._inheritable
33
+ self.columns.exclude :created_on, :created_at, :updated_on, :updated_at, :marked
34
+ self.columns.exclude *@core.columns.collect{|c| c.name if c.polymorphic_association?}.compact
35
+ end
36
+ @columns
37
+ end
38
+
39
+ public :columns=
40
+
41
+ # whether the form should be multipart
42
+ attr_writer :multipart
43
+ def multipart?
44
+ @multipart ? true : false
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,174 @@
1
+ module ActiveScaffold::Config
2
+ class List < Base
3
+ self.crud_type = :read
4
+
5
+ def initialize(core_config)
6
+ @core = core_config
7
+
8
+ # inherit from global scope
9
+ # full configuration path is: defaults => global table => local table
10
+ @per_page = self.class.per_page
11
+ @page_links_window = self.class.page_links_window
12
+
13
+ # originates here
14
+ @sorting = ActiveScaffold::DataStructures::Sorting.new(@core.columns)
15
+ @sorting.set_default_sorting(@core.model)
16
+
17
+ # inherit from global scope
18
+ @empty_field_text = self.class.empty_field_text
19
+ @pagination = self.class.pagination
20
+ @show_search_reset = true
21
+ end
22
+
23
+ # global level configuration
24
+ # --------------------------
25
+ # how many records to show per page
26
+ cattr_accessor :per_page
27
+ @@per_page = 15
28
+
29
+ # how many page links around current page to show
30
+ cattr_accessor :page_links_window
31
+ @@page_links_window = 2
32
+
33
+ # what string to use when a field is empty
34
+ cattr_accessor :empty_field_text
35
+ @@empty_field_text = '-'
36
+
37
+ # What kind of pagination to use:
38
+ # * true: The usual pagination
39
+ # * :infinite: Treat the source as having an infinite number of pages (i.e. don't count the records; useful for large tables where counting is slow and we don't really care anyway)
40
+ # * false: Disable pagination
41
+ cattr_accessor :pagination
42
+ @@pagination = true
43
+
44
+ # instance-level configuration
45
+ # ----------------------------
46
+
47
+ # provides access to the list of columns specifically meant for the Table to use
48
+ def columns
49
+ self.columns = @core.columns._inheritable unless @columns # lazy evaluation
50
+ @columns
51
+ end
52
+
53
+ public :columns=
54
+
55
+ # how many rows to show at once
56
+ attr_accessor :per_page
57
+
58
+ # how many page links around current page to show
59
+ attr_accessor :page_links_window
60
+
61
+ # What kind of pagination to use:
62
+ # * true: The usual pagination
63
+ # * :infinite: Treat the source as having an infinite number of pages (i.e. don't count the records; useful for large tables where counting is slow and we don't really care anyway)
64
+ # * false: Disable pagination
65
+ attr_accessor :pagination
66
+
67
+ # what string to use when a field is empty
68
+ attr_accessor :empty_field_text
69
+
70
+ # show a link to reset the search next to filtered message
71
+ attr_accessor :show_search_reset
72
+
73
+ # 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'}.
74
+ def sorting=(val)
75
+ val = [val] if val.is_a? Hash
76
+ sorting.clear
77
+ val.each { |clause| sorting.add *Array(clause).first }
78
+ end
79
+ def sorting
80
+ @sorting ||= ActiveScaffold::DataStructures::Sorting.new(@core.columns)
81
+ end
82
+
83
+ # overwrite the includes used for the count sql query
84
+ attr_accessor :count_includes
85
+
86
+ # the label for this List action. used for the header.
87
+ attr_writer :label
88
+ def label
89
+ @label ? as_(@label, :count => 2) : @core.label(:count => 2)
90
+ end
91
+
92
+ attr_writer :no_entries_message
93
+ def no_entries_message
94
+ @no_entries_message ? @no_entries_message : :no_entries
95
+ end
96
+
97
+ attr_writer :filtered_message
98
+ def filtered_message
99
+ @filtered_message ? @filtered_message : :filtered
100
+ end
101
+
102
+ attr_writer :always_show_search
103
+ def always_show_search
104
+ @always_show_search && !search_partial.blank?
105
+ end
106
+
107
+ def search_partial
108
+ return "search" if @core.actions.include?(:search)
109
+ return "field_search" if @core.actions.include?(:field_search)
110
+ end
111
+
112
+ # always show create
113
+ attr_writer :always_show_create
114
+ def always_show_create
115
+ @always_show_create && @core.actions.include?(:create)
116
+ end
117
+
118
+ # might be set to open nested_link automatically in view
119
+ # conf.nested.add_link(:players)
120
+ # conf.list.nested_auto_open = {:players => 2}
121
+ # will open nested players view if there are 2 or less records in parent
122
+ attr_accessor :nested_auto_open
123
+
124
+ class UserSettings < UserSettings
125
+ # This label has alread been localized.
126
+ def label
127
+ @session[:label] ? @session[:label] : @conf.label
128
+ end
129
+
130
+ def per_page
131
+ @session['per_page'] = @params['limit'].to_i if @params.has_key? 'limit'
132
+ @session['per_page'] || @conf.per_page
133
+ end
134
+
135
+ def page
136
+ @session['page'] = @params['page'] if @params.has_key? 'page'
137
+ @session['page'] || 1
138
+ end
139
+
140
+ def page=(value = nil)
141
+ @session['page'] = value
142
+ end
143
+
144
+ attr_reader :nested_default_sorting
145
+
146
+ def nested_default_sorting=(options)
147
+ @nested_default_sorting ||= @conf.sorting.clone
148
+ @nested_default_sorting.set_nested_sorting(options[:table_name], options[:default_sorting])
149
+ end
150
+
151
+ def default_sorting
152
+ nested_default_sorting.nil? ? @conf.sorting : nested_default_sorting
153
+ end
154
+
155
+ def sorting
156
+ # we want to store as little as possible in the session, but we want to return a Sorting data structure. so we recreate it each page load based on session data.
157
+ @session['sort'] = [@params['sort'], @params['sort_direction']] if @params['sort'] and @params['sort_direction']
158
+ @session['sort'] = nil if @params['sort_direction'] == 'reset'
159
+
160
+ if @session['sort']
161
+ sorting = @conf.sorting.clone
162
+ sorting.set(*@session['sort'])
163
+ return sorting
164
+ else
165
+ return default_sorting
166
+ end
167
+ end
168
+
169
+ def count_includes
170
+ @conf.count_includes
171
+ end
172
+ end
173
+ end
174
+ end
@@ -0,0 +1,22 @@
1
+ module ActiveScaffold::Config
2
+ class Mark < Base
3
+ self.crud_type = :read
4
+
5
+ def initialize(core_config)
6
+ @core = core_config
7
+ @core.model.send(:include, ActiveScaffold::MarkedModel) unless @core.model.ancestors.include?(ActiveScaffold::MarkedModel)
8
+ add_mark_column
9
+ end
10
+
11
+ protected
12
+
13
+ def add_mark_column
14
+ @core.columns.add :marked
15
+ @core.columns[:marked].label = 'M'
16
+ @core.columns[:marked].form_ui = :checkbox
17
+ @core.columns[:marked].inplace_edit = true
18
+ @core.columns[:marked].sort = false
19
+ @core.list.columns = [:marked] + @core.list.columns.names_without_auth_check unless @core.list.columns.include? :marked
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,44 @@
1
+ module ActiveScaffold::Config
2
+ class Nested < Base
3
+ self.crud_type = :read
4
+
5
+ def initialize(core_config)
6
+ @core = core_config
7
+ self.shallow_delete = self.class.shallow_delete
8
+ @action_group = self.class.action_group.clone if self.class.action_group
9
+ end
10
+
11
+ # global level configuration
12
+ # --------------------------
13
+ cattr_accessor :shallow_delete
14
+ @@shallow_delete = true
15
+
16
+ # instance-level configuration
17
+ # ----------------------------
18
+ attr_accessor :shallow_delete
19
+
20
+ # Add a nested ActionLink
21
+ def add_link(attribute, options = {})
22
+ column = @core.columns[attribute.to_sym]
23
+ unless column.nil? || column.association.nil?
24
+ options.reverse_merge! :security_method => :nested_authorized?, :label => column.association.klass.model_name.human({:count => 2, :default => column.association.klass.name.pluralize})
25
+ action_link = @core.link_for_association(column, options)
26
+ @core.action_links.add_to_group(action_link, action_group) unless action_link.nil?
27
+ else
28
+
29
+ end
30
+ end
31
+
32
+ def add_scoped_link(named_scope, options = {})
33
+ action_link = @core.link_for_association_as_scope(named_scope.to_sym, options)
34
+ @core.action_links.add_to_group(action_link, action_group) unless action_link.nil?
35
+ end
36
+
37
+ # the label for this Nested action. used for the header.
38
+ attr_writer :label
39
+ def label
40
+ @label ? as_(@label) : as_(:add_existing_model, :model => @core.label)
41
+ end
42
+
43
+ end
44
+ end
@@ -0,0 +1,69 @@
1
+ module ActiveScaffold::Config
2
+ class Search < Base
3
+ self.crud_type = :read
4
+
5
+ def initialize(core_config)
6
+ @core = core_config
7
+
8
+ @text_search = self.class.text_search
9
+ @live = self.class.live?
10
+
11
+ # start with the ActionLink defined globally
12
+ @link = self.class.link.clone
13
+ @action_group = self.class.action_group.clone if self.class.action_group
14
+ end
15
+
16
+
17
+ # global level configuration
18
+ # --------------------------
19
+ # the ActionLink for this action
20
+ cattr_accessor :link
21
+ @@link = ActiveScaffold::DataStructures::ActionLink.new('show_search', :label => :search, :type => :collection, :security_method => :search_authorized?, :ignore_method => :search_ignore?)
22
+
23
+ # A flag for how the search should do full-text searching in the database:
24
+ # * :full: LIKE %?%
25
+ # * :start: LIKE ?%
26
+ # * :end: LIKE %?
27
+ # * false: LIKE ?
28
+ # Default is :full
29
+ cattr_accessor :text_search
30
+ @@text_search = :full
31
+
32
+ # whether submits the search as you type
33
+ cattr_writer :live
34
+ def self.live?
35
+ @@live
36
+ end
37
+
38
+ # instance-level configuration
39
+ # ----------------------------
40
+
41
+ # provides access to the list of columns specifically meant for the Search to use
42
+ def columns
43
+ # we want to delay initializing to the @core.columns set for as long as possible. Too soon and .search_sql will not be available to .searchable?
44
+ unless @columns
45
+ self.columns = @core.columns.collect{|c| c.name if c.searchable? and c.column and c.column.text?}.compact
46
+ end
47
+ @columns
48
+ end
49
+
50
+ public :columns=
51
+
52
+ # A flag for how the search should do full-text searching in the database:
53
+ # * :full: LIKE %?%
54
+ # * :start: LIKE ?%
55
+ # * :end: LIKE %?
56
+ # * false: LIKE ?
57
+ # Default is :full
58
+ attr_accessor :text_search
59
+
60
+ # the ActionLink for this action
61
+ attr_accessor :link
62
+
63
+ # whether submits the search as you type
64
+ attr_writer :live
65
+ def live?
66
+ @live
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,35 @@
1
+ module ActiveScaffold::Config
2
+ class Show < Base
3
+ self.crud_type = :read
4
+
5
+ def initialize(core_config)
6
+ @core = core_config
7
+ # start with the ActionLink defined globally
8
+ @link = self.class.link.clone
9
+ @action_group = self.class.action_group.clone if self.class.action_group
10
+ end
11
+
12
+ # global level configuration
13
+ # --------------------------
14
+ cattr_accessor :link
15
+ @@link = ActiveScaffold::DataStructures::ActionLink.new('show', :label => :show, :type => :member, :security_method => :show_authorized?)
16
+ # instance-level configuration
17
+ # ----------------------------
18
+
19
+ # the ActionLink for this action
20
+ attr_accessor :link
21
+ # the label for this action. used for the header.
22
+ attr_writer :label
23
+ def label
24
+ @label ? as_(@label) : as_(:show_model, :model => @core.label(:count => 1))
25
+ end
26
+
27
+ # provides access to the list of columns specifically meant for this action to use
28
+ def columns
29
+ self.columns = @core.columns._inheritable unless @columns # lazy evaluation
30
+ @columns
31
+ end
32
+
33
+ public :columns=
34
+ end
35
+ end
@@ -0,0 +1,35 @@
1
+ module ActiveScaffold::Config
2
+ class Subform < Base
3
+ def initialize(core_config)
4
+ @core = core_config
5
+ @layout = self.class.layout # default layout
6
+ end
7
+
8
+ # global level configuration
9
+ # --------------------------
10
+
11
+ cattr_accessor :layout
12
+ @@layout = :horizontal
13
+
14
+ # instance-level configuration
15
+ # ----------------------------
16
+
17
+ attr_accessor :layout
18
+
19
+ # provides access to the list of columns specifically meant for the Sub-Form to use
20
+ def columns
21
+ # we want to delay initializing to the @core.update.columns set for as long as possible. but we have to eventually clone, or else have a configuration "leak"
22
+ unless @columns
23
+ if @core.actions.include? :update
24
+ @columns = @core.update.columns.clone
25
+ else
26
+ self.columns = @core.columns._inheritable
27
+ end
28
+ end
29
+
30
+ @columns
31
+ end
32
+
33
+ public :columns=
34
+ end
35
+ end
@@ -0,0 +1,46 @@
1
+ module ActiveScaffold::Config
2
+ class Update < ActiveScaffold::Config::Form
3
+ self.crud_type = :update
4
+ def initialize(*args)
5
+ super
6
+ self.nested_links = self.class.nested_links
7
+ self.refresh_list = self.class.refresh_list
8
+ end
9
+
10
+ # global level configuration
11
+ # --------------------------
12
+ # the ActionLink for this action
13
+ def self.link
14
+ @@link
15
+ end
16
+ def self.link=(val)
17
+ @@link = val
18
+ end
19
+ @@link = ActiveScaffold::DataStructures::ActionLink.new('edit', :label => :edit, :type => :member, :security_method => :update_authorized?)
20
+
21
+ # whether we should refresh list after update or not
22
+ cattr_accessor :refresh_list
23
+ @@refresh_list = false
24
+
25
+ # instance-level configuration
26
+ # ----------------------------
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
+ attr_accessor :nested_links
34
+ cattr_accessor :nested_links
35
+ @@nested_links = false
36
+
37
+ attr_writer :hide_nested_column
38
+ def hide_nested_column
39
+ @hide_nested_column.nil? ? true : @hide_nested_column
40
+ end
41
+
42
+ # whether we should refresh list after update or not
43
+ attr_accessor :refresh_list
44
+
45
+ end
46
+ end