active_scaffold 3.5.4 → 3.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. checksums.yaml +4 -4
  2. data/{CHANGELOG → CHANGELOG.rdoc} +72 -0
  3. data/README.md +20 -8
  4. data/app/assets/javascripts/active_scaffold.js.erb +0 -1
  5. data/app/assets/javascripts/jquery/active_scaffold.js +98 -7
  6. data/app/assets/stylesheets/active_scaffold_colors.scss +1 -1
  7. data/app/assets/stylesheets/active_scaffold_layout.css +52 -29
  8. data/app/views/active_scaffold_overrides/_base_form.html.erb +2 -2
  9. data/app/views/active_scaffold_overrides/_form.html.erb +1 -1
  10. data/app/views/active_scaffold_overrides/_form_association.html.erb +2 -1
  11. data/app/views/active_scaffold_overrides/_form_association_footer.html.erb +3 -2
  12. data/app/views/active_scaffold_overrides/_form_association_record.html.erb +9 -7
  13. data/app/views/active_scaffold_overrides/_horizontal_subform.html.erb +4 -4
  14. data/app/views/active_scaffold_overrides/_horizontal_subform_header.html.erb +2 -1
  15. data/app/views/active_scaffold_overrides/_list.html.erb +2 -1
  16. data/app/views/active_scaffold_overrides/_list_header.html.erb +5 -7
  17. data/app/views/active_scaffold_overrides/_list_messages.html.erb +1 -0
  18. data/app/views/active_scaffold_overrides/_list_record.html.erb +4 -5
  19. data/app/views/active_scaffold_overrides/_list_with_header.html.erb +1 -1
  20. data/app/views/active_scaffold_overrides/_messages.html.erb +1 -0
  21. data/app/views/active_scaffold_overrides/_refresh_list.js.erb +4 -0
  22. data/app/views/active_scaffold_overrides/_render_field.js.erb +2 -1
  23. data/app/views/active_scaffold_overrides/_show_association_horizontal.html.erb +2 -1
  24. data/app/views/active_scaffold_overrides/_show_columns.html.erb +2 -2
  25. data/app/views/active_scaffold_overrides/_show_horizontal_record.html.erb +4 -4
  26. data/app/views/active_scaffold_overrides/_update_calculations.js.erb +1 -1
  27. data/app/views/active_scaffold_overrides/_update_column.js.erb +2 -2
  28. data/app/views/active_scaffold_overrides/_vertical_subform.html.erb +2 -2
  29. data/app/views/active_scaffold_overrides/action_confirmation.html.erb +2 -2
  30. data/app/views/active_scaffold_overrides/delete.html.erb +2 -2
  31. data/app/views/active_scaffold_overrides/on_action_update.js.erb +16 -6
  32. data/app/views/active_scaffold_overrides/on_update.js.erb +1 -1
  33. data/app/views/active_scaffold_overrides/row.js.erb +1 -1
  34. data/app/views/active_scaffold_overrides/update_column.js.erb +2 -2
  35. data/config/locales/de.yml +2 -1
  36. data/config/locales/en.yml +1 -0
  37. data/config/locales/es.yml +1 -0
  38. data/config/locales/fr.yml +2 -1
  39. data/config/locales/hu.yml +1 -0
  40. data/config/locales/ja.yml +1 -0
  41. data/config/locales/ru.yml +1 -0
  42. data/lib/active_scaffold.rb +19 -16
  43. data/lib/active_scaffold/actions/common_search.rb +11 -8
  44. data/lib/active_scaffold/actions/core.rb +91 -70
  45. data/lib/active_scaffold/actions/create.rb +28 -28
  46. data/lib/active_scaffold/actions/delete.rb +3 -3
  47. data/lib/active_scaffold/actions/field_search.rb +53 -43
  48. data/lib/active_scaffold/actions/list.rb +111 -27
  49. data/lib/active_scaffold/actions/nested.rb +65 -48
  50. data/lib/active_scaffold/actions/search.rb +1 -1
  51. data/lib/active_scaffold/actions/show.rb +4 -4
  52. data/lib/active_scaffold/actions/subform.rb +23 -22
  53. data/lib/active_scaffold/actions/update.rb +96 -77
  54. data/lib/active_scaffold/active_record_permissions.rb +2 -11
  55. data/lib/active_scaffold/attribute_params.rb +102 -94
  56. data/lib/active_scaffold/bridges.rb +8 -8
  57. data/lib/active_scaffold/bridges/active_storage.rb +6 -0
  58. data/lib/active_scaffold/bridges/active_storage/active_storage_bridge.rb +34 -0
  59. data/lib/active_scaffold/bridges/active_storage/active_storage_helpers.rb +54 -0
  60. data/lib/active_scaffold/bridges/active_storage/form_ui.rb +22 -0
  61. data/lib/active_scaffold/bridges/active_storage/list_ui.rb +36 -0
  62. data/lib/active_scaffold/bridges/bitfields.rb +2 -1
  63. data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +12 -15
  64. data/lib/active_scaffold/bridges/bitfields/list_ui.rb +19 -0
  65. data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +1 -1
  66. data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +9 -12
  67. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +1 -1
  68. data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +2 -2
  69. data/lib/active_scaffold/bridges/chosen/helpers.rb +7 -6
  70. data/lib/active_scaffold/bridges/date_picker/ext.rb +0 -13
  71. data/lib/active_scaffold/bridges/date_picker/helper.rb +49 -44
  72. data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +1 -1
  73. data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +1 -1
  74. data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +3 -3
  75. data/lib/active_scaffold/bridges/file_column/form_ui.rb +3 -3
  76. data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +10 -7
  77. data/lib/active_scaffold/bridges/paper_trail.rb +1 -1
  78. data/lib/active_scaffold/bridges/paper_trail/actions.rb +3 -1
  79. data/lib/active_scaffold/bridges/paperclip/list_ui.rb +1 -1
  80. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +1 -1
  81. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +2 -2
  82. data/lib/active_scaffold/bridges/record_select/helpers.rb +15 -17
  83. data/lib/active_scaffold/bridges/shared/date_bridge.rb +20 -19
  84. data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +3 -1
  85. data/lib/active_scaffold/bridges/usa_state_select/usa_state_select_helper.rb +21 -4
  86. data/lib/active_scaffold/config/base.rb +133 -41
  87. data/lib/active_scaffold/config/core.rb +146 -18
  88. data/lib/active_scaffold/config/delete.rb +14 -1
  89. data/lib/active_scaffold/config/field_search.rb +7 -1
  90. data/lib/active_scaffold/config/form.rb +10 -1
  91. data/lib/active_scaffold/config/list.rb +39 -13
  92. data/lib/active_scaffold/config/mark.rb +4 -2
  93. data/lib/active_scaffold/config/nested.rb +16 -17
  94. data/lib/active_scaffold/config/search.rb +9 -0
  95. data/lib/active_scaffold/config/show.rb +4 -0
  96. data/lib/active_scaffold/config/update.rb +4 -0
  97. data/lib/active_scaffold/configurable.rb +14 -7
  98. data/lib/active_scaffold/constraints.rb +22 -20
  99. data/lib/active_scaffold/core.rb +67 -28
  100. data/lib/active_scaffold/data_structures/action_columns.rb +50 -59
  101. data/lib/active_scaffold/data_structures/action_link.rb +50 -20
  102. data/lib/active_scaffold/data_structures/action_links.rb +15 -13
  103. data/lib/active_scaffold/data_structures/association/abstract.rb +38 -15
  104. data/lib/active_scaffold/data_structures/association/active_mongoid.rb +2 -6
  105. data/lib/active_scaffold/data_structures/association/active_record.rb +6 -2
  106. data/lib/active_scaffold/data_structures/association/mongoid.rb +0 -3
  107. data/lib/active_scaffold/data_structures/column.rb +75 -66
  108. data/lib/active_scaffold/data_structures/columns.rb +3 -2
  109. data/lib/active_scaffold/data_structures/nested_info.rb +33 -19
  110. data/lib/active_scaffold/data_structures/set.rb +8 -0
  111. data/lib/active_scaffold/data_structures/sorting.rb +10 -2
  112. data/lib/active_scaffold/delayed_setup.rb +16 -5
  113. data/lib/active_scaffold/extensions/action_controller_rendering.rb +3 -2
  114. data/lib/active_scaffold/extensions/action_view_rendering.rb +93 -32
  115. data/lib/active_scaffold/extensions/cow_proxy.rb +95 -0
  116. data/lib/active_scaffold/extensions/ice_nine.rb +36 -0
  117. data/lib/active_scaffold/extensions/left_outer_joins.rb +8 -33
  118. data/lib/active_scaffold/extensions/localize.rb +3 -1
  119. data/lib/active_scaffold/extensions/routing_mapper.rb +6 -45
  120. data/lib/active_scaffold/extensions/to_label.rb +3 -2
  121. data/lib/active_scaffold/extensions/unsaved_record.rb +2 -4
  122. data/lib/active_scaffold/finder.rb +110 -77
  123. data/lib/active_scaffold/helpers/action_link_helpers.rb +62 -36
  124. data/lib/active_scaffold/helpers/association_helpers.rb +18 -16
  125. data/lib/active_scaffold/helpers/controller_helpers.rb +34 -10
  126. data/lib/active_scaffold/helpers/form_column_helpers.rb +196 -124
  127. data/lib/active_scaffold/helpers/human_condition_helpers.rb +1 -1
  128. data/lib/active_scaffold/helpers/id_helpers.rb +6 -2
  129. data/lib/active_scaffold/helpers/list_column_helpers.rb +90 -57
  130. data/lib/active_scaffold/helpers/pagination_helpers.rb +2 -2
  131. data/lib/active_scaffold/helpers/search_column_helpers.rb +29 -34
  132. data/lib/active_scaffold/helpers/show_column_helpers.rb +3 -5
  133. data/lib/active_scaffold/helpers/view_helpers.rb +39 -36
  134. data/lib/active_scaffold/marked_model.rb +2 -2
  135. data/lib/active_scaffold/orm_checks.rb +3 -7
  136. data/lib/active_scaffold/paginator.rb +7 -7
  137. data/lib/active_scaffold/registry.rb +33 -0
  138. data/lib/active_scaffold/responds_to_parent.rb +8 -11
  139. data/lib/active_scaffold/tableless.rb +82 -66
  140. data/lib/active_scaffold/version.rb +2 -2
  141. data/lib/generators/active_scaffold/controller_generator.rb +2 -2
  142. data/lib/generators/active_scaffold/install_generator.rb +52 -4
  143. data/lib/generators/active_scaffold/resource_generator.rb +2 -2
  144. data/shoulda_macros/macros.rb +3 -1
  145. data/test/bridges/date_picker_test.rb +1 -2
  146. data/test/bridges/paperclip_test.rb +6 -6
  147. data/test/class_with_finder.rb +2 -2
  148. data/test/company.rb +4 -4
  149. data/test/config/create_test.rb +4 -2
  150. data/test/config/nested_test.rb +1 -1
  151. data/test/config/show_test.rb +1 -1
  152. data/test/config/update_test.rb +7 -6
  153. data/test/data_structures/action_columns_test.rb +2 -2
  154. data/test/data_structures/action_links_test.rb +1 -1
  155. data/test/data_structures/column_test.rb +3 -6
  156. data/test/data_structures/columns_test.rb +2 -2
  157. data/test/data_structures/sorting_test.rb +7 -0
  158. data/test/extensions/action_view_rendering_test.rb +20 -0
  159. data/test/extensions/active_record_test.rb +4 -4
  160. data/test/extensions/routing_mapper_test.rb +2 -2
  161. data/test/helpers/list_column_helpers_test.rb +3 -1
  162. data/test/misc/active_record_permissions_test.rb +3 -11
  163. data/test/misc/attribute_params_test.rb +12 -8
  164. data/test/misc/calculation_test.rb +1 -1
  165. data/test/misc/configurable_test.rb +10 -10
  166. data/test/misc/constraints_test.rb +2 -2
  167. data/test/misc/convert_numbers_format_test.rb +7 -3
  168. data/test/misc/lang_test.rb +1 -1
  169. data/test/misc/parse_datetime_test.rb +3 -4
  170. data/test/misc/tableless_test.rb +14 -0
  171. data/test/mock_app/Rakefile +1 -1
  172. data/test/mock_app/app/assets/config/manifest.js +0 -0
  173. data/test/mock_app/app/controllers/cars_controller.rb +1 -0
  174. data/test/mock_app/app/controllers/people_controller.rb +5 -1
  175. data/test/mock_app/app/controllers/roles_controller.rb +4 -0
  176. data/test/mock_app/app/views/active_scaffold_overrides/_form.html.erb +2 -0
  177. data/test/mock_app/app/views/active_scaffold_overrides/list.html.erb +2 -0
  178. data/test/mock_app/app/views/people/_first_name_form_column.html.erb +2 -0
  179. data/test/mock_app/app/views/people/_form.html.erb +2 -0
  180. data/test/mock_app/app/views/people/list.html.erb +2 -0
  181. data/test/mock_app/config/application.rb +2 -1
  182. data/test/mock_app/config/boot.rb +1 -1
  183. data/test/mock_app/config/environment.rb +2 -2
  184. data/test/mock_app/config/routes.rb +4 -1
  185. data/test/mock_app/db/schema.rb +2 -0
  186. data/test/performance/list_cars_performance_test.rb +34 -0
  187. data/test/performance/list_people_performance_test.rb +31 -0
  188. data/test/performance_test_help.rb +3 -0
  189. data/test/test_helper.rb +12 -4
  190. metadata +69 -18
  191. data/app/assets/javascripts/prototype/rico_corner.js +0 -370
  192. data/lib/active_scaffold/bridges/file_column/test/test_helper.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0a92ddd6c1b3401de801feb8488ec0e4a74d02eb91a7be59a9b28fe723c26f4
4
- data.tar.gz: 832e014bbebf915d82c126ef5d552cf8f241461ca780dced5ec9df59771ae711
3
+ metadata.gz: 0c98847307a3be61b8137eba789a6e1779c2c9dccc9190b8c4d50428d6dffd33
4
+ data.tar.gz: f82b68052234f72ac8bc715eb88f7aabaed422e8ef8b929b63244e9d3cf5500d
5
5
  SHA512:
6
- metadata.gz: 597fc2f0187a6c59e0f52f7a9a187ef85810f716334ee32fd37c362a21201c7b39111c39f8a5b29e9f4b38eb9702991e1a269e05062442f5157a2a0a9de1a815
7
- data.tar.gz: dfad5b57b1bb177eaa1c8cc829a06fe85e1f4463605336fa5d67c1e3ad12c65cb285c15dbfcf2de04e9e0191c4fb172868dd2130f20a8a69b609fcf6790695d0
6
+ metadata.gz: a60af5b75baee4785e3ad1bc3353a59db2e2677aa14f82eabac52dd5d732486185731e1f2e66cb35f3bf3ebac14322ea3038bdca39c497bd163a600566d13198
7
+ data.tar.gz: 59bddf1ef940582d370591bd4003408505733abd2c45f7cac115f3033d8925266f92339c1deb6aae2c484a73ebe27e137d6b518b3199064fea187f5726f35ba4
@@ -1,3 +1,74 @@
1
+ - Fix i18n at ruby 3.0.0
2
+ - Add list helper for bitfield column, so it display labels of selected checkboxes in list
3
+ - Support rails 6.0
4
+
5
+ = 3.6.0.rc2
6
+ - Fix subform crud in subform subgroup when controller is embedded
7
+ - Fix sorting for mongoid models, broken in 3.6.0.rc1
8
+ - Improve add_new option, allow to change subform columns (with helper override calling super and add columns to locals argument)
9
+ - Support add_new option for record_select or radio form_ui
10
+ - Support add_new option for polymorphic associations (add_new may be array with class names to allow add new, or true to allow add new for any model)
11
+ - Support description for columns displayed as subform
12
+ - Don't mess with history if current page is not using activescaffold when is loaded
13
+ - Fix changing sort_by per request when threadsafe is enabled
14
+
15
+ = 3.6.0.rc1
16
+ - Cleanup: deprecate ActiveScaffold.set_defaults for ActiveScaffold.defaults, rename some setters
17
+ - Fix adding new action links on request with threadsafety enabled
18
+ - Fix iterating in config.columns with threadsafety enabled
19
+ - Fix changing pagination enabled/disabled with threadsafety enabled
20
+ - Allow create action in has_many through singular association
21
+ - Display no options in radio form_ui when no option is available, so column can be refreshed with update_columns
22
+ - Add as_main_div_data to override data attributes on main div
23
+ - Add loading indicator to embedded scaffolds, display error if fails
24
+ - Fix race condition in threadsafe mode with delayed setup
25
+ - Add ActiveScaffold::Config::Core.after_config_callbacks, so custom methods or procs can be added to be called after active_scaffold config block (used by bitfields bridge)
26
+ - Display loading indicator at bottom on auto pagination
27
+ - List rendering speed up
28
+ - Remove font family from CSS, it was preventing from changing it easily in body
29
+ - Fix search for mongoid models in with threadsafety enabled
30
+ - Keep nested params after calling render_field for column in subform
31
+ - Fix nested for controllers without list action (for example, for nested create on singular assocations)
32
+ - Fix delayed setup issues with threads
33
+ - Fix render_field under nested list for polymorphic association
34
+ - Add foreign_type column to constrained columns in nested list for polymorphic association
35
+ - Add return_to to action links on nested list for singular associations, so forms would return to list
36
+ - Case insensitive search with PostGIS adapter
37
+ - Use clear_storage with around_action and ensure, so empty hash is removed from session storage when exception is raised too
38
+ - Delete search from session when search is reset
39
+ - Add cache_column_counts method to get counts with one query for associations which are not preloaded, query per column is overridable with count_query_for_column
40
+ - ActiveStorage support with bridge
41
+ - Add list_row_attributes helper so more HTML attributes can be added to tr.record in list, overriding the helper
42
+ - Support column!=value param for not equal condition (column!= means column is not null)
43
+ - Don't force to use join for column's includes when sorting by method
44
+ - Add support for range conditions in url params for numeric (integer, decimal, float, bigint) columns too
45
+ - Support include_blank option in :radio form_ui
46
+ - Add add_new option for :select form_ui in singular associations, in column.options, it adds link to toggle between select and subform
47
+ - Fix subform crud in subform subgroup, when form is on nested scaffold, when record on first subform is persisted
48
+ - Add association_join_text setting to column, so it can be changed for one column only
49
+ - Use Arel.sql with sorting.clause before passing to reorder method
50
+
51
+ = 3.6.0.pre
52
+ - Added threadsafety as tech preview, enabled with ActiveScaffold.threadsafe! in initializer.
53
+ - Added active_scaffold_config.build_action_columns method to easily create action columns for custom form actions.
54
+ - Replaced each(options) with each_column(options) in ActionColumns
55
+ - Replaced collect_visible(options, &proc) with visible_columns(options).map(&proc) in ActionColumns
56
+ - Replaced names with visible_columns_names in ActionColumns
57
+ - Replaced names_without_auth_check with to_a in ActionColumns
58
+ - Support rails 5.2, drop support for 4.0 and 4.1
59
+ - Require ruby 2.3.1, drop support for 2.0, 2.1 and 2.2.
60
+ - Fix has_one/belongs_to nested for polymorphic associations, leave rails to build conditions from {assoc_name: record} hash
61
+ - Cast blank into nil for null string columns in conditions_from_params
62
+ - Support multipart with iframe in process_action_link_action default response
63
+ - Fix hidding and showing columns based on permissions with update_columns on subforms
64
+ - Fix subform crud in subform subgroup, when form is on nested scaffold
65
+ - Fix JS when rails-ujs is used instead of jquery_ujs (rails >= 5.1)
66
+ - Display flash messages only inside create form, when conf.list.always_show_create is enabled, instead of displaying twice (in form and above list).
67
+ - Fix default autocomplete value for password form_ui, new-password has to be used because off is ignored by browsers in password fields now
68
+
69
+ = 3.5.5
70
+ - Fix creating new records, when using cancan and allowing access based on id (fixes #617)
71
+
1
72
  = 3.5.4
2
73
  - Fix chosen form_ui for plural associations
3
74
  - Eager load with includes in association options query, if includes has a hash with own association key, see #612
@@ -54,6 +125,7 @@
54
125
  - fix display of association in list when association_limit is nil
55
126
  - fix conversion of i18n date and datetime value, some abbr day and month may be equal in some languages
56
127
  - fix hidden form_ui for collection associations (has_many, habtm)
128
+ - Drop rails 3.2.x and ruby 1.9 support
57
129
 
58
130
  = 3.4.43
59
131
  - Fix human conditions for date and datetime columns, not using date picker
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
+
1
2
  Overview
2
3
  ========
3
- [![Build status](https://travis-ci.org/activescaffold/active_scaffold.svg?branch=master)](https://travis-ci.org/activescaffold/active_scaffold)
4
+ [![Build status](https://travis-ci.com/activescaffold/active_scaffold.svg?branch=master)](https://travis-ci.com/activescaffold/active_scaffold)
4
5
  [![Code Climate](https://codeclimate.com/github/activescaffold/active_scaffold/badges/gpa.svg)](https://codeclimate.com/github/activescaffold/active_scaffold)
5
6
  [![Test Coverage](https://codeclimate.com/github/activescaffold/active_scaffold/badges/coverage.svg)](https://codeclimate.com/github/activescaffold/active_scaffold)
6
7
  [![Dependency Status](https://gemnasium.com/activescaffold/active_scaffold.svg)](https://gemnasium.com/activescaffold/active_scaffold)
@@ -8,10 +9,12 @@ Overview
8
9
  [![Inline docs](https://inch-ci.org/github/activescaffold/active_scaffold.svg?branch=master)](https://inch-ci.org/github/activescaffold/active_scaffold)
9
10
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
10
11
 
11
- ActiveScaffold provides a quick and powerful user interfaces for CRUD (create, read, update, delete) operations for Rails applications. It offers additonal features including searching, pagination & layout control. Rails >= 4.0.5 and < 5.2 is supported, ruby >= 2.1 supported, although it should work with ruby >= 2.0.0, it's too old and not tested. Ruby < 2.0.0 won't work.
12
+ ActiveScaffold provides a quick and powerful user interfaces for CRUD (create, read, update, delete) operations for Rails applications. It offers additonal features including searching, pagination & layout control. Rails >= 4.2.0 and Rails < 6.1 is supported, ruby >= 2.3 required.
12
13
 
13
14
  Branch Details
14
15
  --------------
16
+ 3-6-stable supports rails >= 4.2.x and ruby >= 2.3.0
17
+ 3-5-stable supports rails >= 4.0.x and ruby >= 2.0.0
15
18
  3-4-stable supports rails >= 3.2.x and ruby >= 1.9.3
16
19
  3-3-stable supports rails >= 3.2.x and ruby >= 1.8
17
20
  rails-3.2 supports Rails 3.1 & 3.2, and is the current source of the 3.2.x line of gems.
@@ -24,28 +27,37 @@ Added to Gemfile
24
27
 
25
28
  gem 'active_scaffold'
26
29
 
27
- For rails >= 5.1, add
30
+ For rails >= 5.1, add jquery-rails to Gemfile, and install generator will jquery to application.js before rails-ujs. Also it's possible to load jquery in your layout before application.js using CDN (e.g. jquery-rails-cdn). You can replace rails-ujs with jquery_ujs, although rails-ujs should work (never load both).
28
31
 
29
32
  gem 'jquery-rails'
30
33
 
31
- Run the following commands
34
+ For rails >= 6.0, installer generator will create app/assets/javascripts/application.js, add it to assets.precompile array and add javascript_include_tag in layout, as ActiveScaffold doesn't work with webpack yet. Jquery may be loaded by packs or assets pipeline.
35
+
36
+ Run the following commands, for rails 4.2
32
37
 
33
38
  bundle install
34
39
  rails g active_scaffold:install
35
40
  bundle exec rake db:create
36
- rails g active_scaffold:resource User name:string
41
+ rails g active_scaffold:resource Model [attrs]
37
42
  bundle exec rake db:migrate
38
43
 
39
- Commands for Rails 5
44
+ Or run the following commands, for rails >= 5
40
45
 
41
46
  bundle install
42
47
  rails g active_scaffold:install
43
48
  rails db:create
44
- rails g active_scaffold:resource User name:string
49
+ rails g active_scaffold:resource Model [attrs]
45
50
  rails db:migrate
46
51
 
47
52
 
48
- Run the app and visit localhost:3000/users
53
+ Run the app and visit localhost:3000/<plural_model>
54
+
55
+ Threadsafe
56
+ ----------
57
+
58
+ Threadsafe can be enabled calling ActiveScaffold.threadsafe! in an initializer.
59
+ It should be enabled on app start and it can't be disabled. Threadsafety is a
60
+ new feature and not well tested yet.
49
61
 
50
62
  Configuration
51
63
  -------------
@@ -32,7 +32,6 @@
32
32
  require_asset "prototype/active_scaffold"
33
33
  require_asset "prototype/dhtml_history"
34
34
  require_asset "prototype/form_enhancements"
35
- require_asset "prototype/rico_corner"
36
35
  end
37
36
  %>
38
37
  ActiveScaffold.config = <%= ActiveScaffold.js_config.to_json %>;
@@ -61,6 +61,11 @@ jQuery(document).ready(function($) {
61
61
  if (e.keyCode == 13) e.preventDefault();
62
62
  });
63
63
  jQuery(document).on('ajax:error', 'form.as_form', function(event, xhr, status, error) {
64
+ if (event.detail && !xhr) {
65
+ error = event.detail[0];
66
+ status = event.detail[1];
67
+ xhr = event.detail[2];
68
+ }
64
69
  var as_div = jQuery(this).closest("div.active-scaffold");
65
70
  if (as_div.length) {
66
71
  ActiveScaffold.report_500_response(as_div, xhr);
@@ -86,6 +91,7 @@ jQuery(document).ready(function($) {
86
91
  return true;
87
92
  });
88
93
  jQuery(document).on('ajax:success', 'a.as_action', function(event, response) {
94
+ if (event.detail && !response) response = event.detail[0];
89
95
  var action_link = ActiveScaffold.ActionLink.get(jQuery(this));
90
96
  if (action_link) {
91
97
  if (action_link.position) {
@@ -105,6 +111,11 @@ jQuery(document).ready(function($) {
105
111
  return true;
106
112
  });
107
113
  jQuery(document).on('ajax:error', 'a.as_action', function(event, xhr, status, error) {
114
+ if (event.detail && !xhr) {
115
+ error = event.detail[0];
116
+ status = event.detail[1];
117
+ xhr = event.detail[2];
118
+ }
108
119
  var action_link = ActiveScaffold.ActionLink.get(jQuery(this));
109
120
  if (action_link) {
110
121
  ActiveScaffold.report_500_response(action_link.scaffold_id(), xhr);
@@ -139,6 +150,11 @@ jQuery(document).ready(function($) {
139
150
  return true;
140
151
  });
141
152
  jQuery(document).on('ajax:error', 'a.as_cancel', function(event, xhr, status, error) {
153
+ if (event.detail && !xhr) {
154
+ error = event.detail[0];
155
+ status = event.detail[1];
156
+ xhr = event.detail[2];
157
+ }
142
158
  var action_link = ActiveScaffold.find_action_link(jQuery(this));
143
159
  if (action_link) {
144
160
  ActiveScaffold.report_500_response(action_link.scaffold_id(), xhr);
@@ -151,6 +167,11 @@ jQuery(document).ready(function($) {
151
167
  return true;
152
168
  });
153
169
  jQuery(document).on('ajax:error', 'a.as_sort', function(event, xhr, status, error) {
170
+ if (event.detail && !xhr) {
171
+ error = event.detail[0];
172
+ status = event.detail[1];
173
+ xhr = event.detail[2];
174
+ }
154
175
  var as_scaffold = jQuery(this).closest('.active-scaffold');
155
176
  ActiveScaffold.report_500_response(as_scaffold, xhr);
156
177
  jQuery(this).closest('th').removeClass('loading');
@@ -179,6 +200,11 @@ jQuery(document).ready(function($) {
179
200
  return true;
180
201
  });
181
202
  jQuery(document).on('ajax:error', 'a.as_paginate', function(event, xhr, status, error) {
203
+ if (event.detail && !xhr) {
204
+ error = event.detail[0];
205
+ status = event.detail[1];
206
+ xhr = event.detail[2];
207
+ }
182
208
  var as_scaffold = jQuery(this).closest('.active-scaffold');
183
209
  ActiveScaffold.report_500_response(as_scaffold, xhr);
184
210
  return true;
@@ -297,6 +323,37 @@ jQuery(document).ready(function($) {
297
323
  if (jQuery(this).prop('checked')) color_field.val('');
298
324
  });
299
325
 
326
+ jQuery(document).on('click', '.hide-new-subform, .show-new-subform', function(e) {
327
+ var $this = jQuery(this), line = $this.closest('.form-element'),
328
+ subform = line.find('#' + $this.data('subform-id')), radio = false, hide, select;
329
+ if ($this.is('[type=radio]')) {
330
+ radio = true;
331
+ hide = $this.is('.hide-new-subform');
332
+ } else {
333
+ e.preventDefault();
334
+ hide = subform.is(':visible');
335
+ }
336
+ if ($this.data('select-id')) {
337
+ select = line.find('#' + $this.data('select-id'));
338
+ if (select.hasClass('recordselect') || select.is('.no-options')) select = select.next(':hidden').andSelf();
339
+ }
340
+ if (hide) {
341
+ subform.hide().find("input:enabled,select:enabled,textarea:enabled").prop('disabled', true);
342
+ if (select) select.show().prop('disabled', false);
343
+ if (radio) {
344
+ $this.closest('.form-element').find('[name="' + $this.attr('name') + '"].show-new-subform').prop('disabled', false);
345
+ } else $this.html($this.data('select-text'));
346
+ } else {
347
+ if (select) select.hide().prop('disabled', true);
348
+ subform.show().find("input:disabled,select:disabled,textarea:disabled").prop('disabled', false);
349
+ if (radio) $this.prop('disabled', true);
350
+ else {
351
+ $this.data('select-text', $this.html());
352
+ $this.html($this.data('subform-text'));
353
+ }
354
+ }
355
+ });
356
+
300
357
  jQuery(document).on('turbolinks:before-visit', function() {
301
358
  if (history.state.active_scaffold) {
302
359
  history.replaceState({turbolinks: true, url: document.location.href}, '', document.location.href);
@@ -454,8 +511,10 @@ var ActiveScaffold = {
454
511
  ActiveScaffold.auto_paginate(container);
455
512
  ActiveScaffold.draggable_lists('.draggable-lists', container);
456
513
  ActiveScaffold.sliders(container);
514
+ ActiveScaffold.disable_optional_subforms(container);
457
515
  },
458
516
  setup_history_state: function() {
517
+ if (!jQuery('.active-scaffold').length) return;
459
518
  var data = {}, current_search_item = jQuery('.active-scaffold .filtered-message[data-search]');
460
519
  if (current_search_item.length) {
461
520
  // store user settings enabled, update state with current page, search and sorting
@@ -479,7 +538,9 @@ var ActiveScaffold = {
479
538
  auto_paginate: function(element) {
480
539
  var paginate_link = jQuery('.active-scaffold-pagination.auto-paginate a:first', element);
481
540
  if (paginate_link.length) {
482
- jQuery('.active-scaffold-pagination.auto-paginate', element).hide();
541
+ var pagination = paginate_link.closest('.auto-paginate');
542
+ pagination.find('.as_paginate').hide();
543
+ pagination.find('.loading-indicator').css({visibility: 'visible'});
483
544
  ActiveScaffold.auto_load_page(paginate_link.attr('href'), {auto_pagination: true});
484
545
  }
485
546
  },
@@ -489,6 +550,30 @@ var ActiveScaffold = {
489
550
  enable_js_form_buttons: function(element) {
490
551
  jQuery('.as-js-button', element).show();
491
552
  },
553
+ disable_optional_subforms: function(element) {
554
+ jQuery('.sub-form.optional', element).each(function () {
555
+ var $this = jQuery(this), toggle = $this.find('>.visibility-toggle');
556
+ if (toggle.length) {
557
+ var hide = toggle.text() == toggle.data('show');
558
+ $this.find('> [id] > .sub-form-record > .associated-record dl:first').each(function (i) {
559
+ var parent = jQuery(this).parent(), div_id = toggle.data('toggable') + i;
560
+ parent.children().wrapAll('<div id="' + div_id + '">');
561
+ if (hide) parent.find('> div').hide();
562
+ parent.prepend(toggle.clone().data('toggable', div_id));
563
+ });
564
+ toggle.remove();
565
+ }
566
+ if ($this.is(':visible')) {
567
+ var line = $this.closest('.form-element'), toggle = line.find('.show-new-subform[data-subform-id="' + $this.attr('id') + '"]').first();
568
+ if (toggle.is('[type=radio]')) toggle.prop('disabled', true);
569
+ else if (toggle.data('select-id')) {
570
+ select = line.find('#' + toggle.data('select-id'));
571
+ if (select.hasClass('recordselect') || select.is('.no-options')) select = select.next(':hidden').andSelf();
572
+ select.hide().prop('disabled', true);
573
+ }
574
+ } else $this.find("input:enabled,select:enabled,textarea:enabled").prop('disabled', true);
575
+ });
576
+ },
492
577
  sliders: function(element) {
493
578
  jQuery('.as-slider', element).each(function() {
494
579
  var opts = $(this).data('slider');
@@ -499,8 +584,13 @@ var ActiveScaffold = {
499
584
  load_embedded: function(element) {
500
585
  jQuery('.active-scaffold-component .load-embedded', element).each(function(index, item) {
501
586
  item = jQuery(item);
502
- item.closest('.active-scaffold-component').load(item.attr('href'), function() {
503
- jQuery(this).trigger('as:element_updated');
587
+ var indicator = item.closest('.active-scaffold-component').find('.loading-indicator');
588
+ indicator.css({visibility: 'visible'});
589
+ item.closest('.active-scaffold-component').load(item.attr('href'), function(response, status, xhr) {
590
+ if (status == 'error') {
591
+ indicator.css({visibility: 'hidden'});
592
+ indicator.after($('<p>').html(item.data('error-msg')).addClass("error-message message server-error"));
593
+ } else jQuery(this).trigger('as:element_updated');
504
594
  });
505
595
  });
506
596
  },
@@ -653,7 +743,7 @@ var ActiveScaffold = {
653
743
 
654
744
  disable_form: function(as_form, skip_loading_indicator) {
655
745
  if (typeof(as_form) == 'string') as_form = '#' + as_form;
656
- as_form = jQuery(as_form)
746
+ as_form = jQuery(as_form);
657
747
  var loading_indicator = jQuery('#' + as_form.attr('id').replace(/-form$/, '-loading-indicator'));
658
748
  if (!skip_loading_indicator && loading_indicator) loading_indicator.css('visibility','visible');
659
749
  jQuery('input[type=submit]', as_form).attr('disabled', 'disabled');
@@ -1023,6 +1113,7 @@ var ActiveScaffold = {
1023
1113
  url: url,
1024
1114
  data: params,
1025
1115
  type: 'post',
1116
+ dataType: 'script',
1026
1117
  beforeSend: function(xhr, settings) {
1027
1118
  element.nextAll('img.loading-indicator').css('visibility','visible');
1028
1119
  /* force to blur and save previous last_focus, because disable_form will trigger
@@ -1311,8 +1402,8 @@ ActiveScaffold.ActionLink.Record = ActiveScaffold.ActionLink.Abstract.extend({
1311
1402
  ActiveScaffold.update_row(this.target, refreshed_content_or_reload);
1312
1403
  } else if (this.refresh_url) {
1313
1404
  var target = this.target;
1314
- jQuery.get(this.refresh_url, function(e, status, response) {
1315
- ActiveScaffold.update_row(target, response.responseText);
1405
+ jQuery.get(this.refresh_url, function(e, status, xhr) {
1406
+ ActiveScaffold.update_row(target, xhr.responseText);
1316
1407
  });
1317
1408
  }
1318
1409
  }
@@ -1373,7 +1464,7 @@ ActiveScaffold.ActionLink.Table = ActiveScaffold.ActionLink.Abstract.extend({
1373
1464
  else {
1374
1465
  throw 'Unknown position "' + this.position + '"'
1375
1466
  }
1376
- ActiveScaffold.highlight(this.adapter.find('td').first().children());
1467
+ ActiveScaffold.highlight(this.adapter.find('td').first().children().not('script'));
1377
1468
  ActiveScaffold.focus_first_element_of_form(this.adapter);
1378
1469
  }
1379
1470
  });
@@ -278,7 +278,7 @@ color: $msg_filtered_color;
278
278
  color: $msg_color;
279
279
  }
280
280
 
281
- .active-scaffold .error-message {
281
+ .active-scaffold .error-message, .active-scaffold-component .error-message {
282
282
  border-color: $msg_error_border_color;
283
283
  background-color: $msg_error_bg;
284
284
  }
@@ -58,13 +58,15 @@ position: relative;
58
58
  .active-scaffold-header h2 {
59
59
  padding: 2px 0px;
60
60
  margin: 0;
61
- font: bold 160% arial, sans-serif;
61
+ font-weight: bold;
62
+ font-size: 160%;
62
63
  }
63
64
 
64
65
  .active-scaffold div.actions a,
65
66
  .active-scaffold div.actions {
66
67
  float: right;
67
- font: bold 14px arial;
68
+ font-weight: bold;
69
+ font-size: 14px;
68
70
  letter-spacing: -1px;
69
71
  text-decoration: none;
70
72
  padding: 1px 2px;
@@ -150,7 +152,8 @@ text-align: left;
150
152
  .active-scaffold th a,
151
153
  .active-scaffold th p,
152
154
  .active-scaffold .show-view th {
153
- font: bold 11px arial, sans-serif;
155
+ font-weight: bold;
156
+ font-size: 11px;
154
157
  }
155
158
  .active-scaffold th a,
156
159
  .active-scaffold th p {
@@ -192,7 +195,6 @@ display: none;
192
195
  padding: 5px 4px;
193
196
  }
194
197
  .active-scaffold tr.record td {
195
- font-family: Verdana, sans-serif;
196
198
  font-size: 11px;
197
199
  border: solid 1px;
198
200
  border-width: 0 0 1px 1px;
@@ -251,7 +253,8 @@ padding: 0 2px;
251
253
 
252
254
  .active-scaffold tr.record td.actions a,
253
255
  .active-scaffold tr.record td.actions div {
254
- font: bold 11px verdana, sans-serif;
256
+ font-weight: bold;
257
+ font-size: 11px;
255
258
  letter-spacing: -1px;
256
259
  padding: 2px;
257
260
  margin: 0 2px;
@@ -378,7 +381,8 @@ right: 0px;
378
381
 
379
382
  .active-scaffold .active-scaffold .active-scaffold-header div.actions a,
380
383
  .active-scaffold .active-scaffold .active-scaffold-header div.actions div {
381
- font: bold 11px verdana, sans-serif;
384
+ font-weight: bold;
385
+ font-size: 11px;
382
386
  }
383
387
 
384
388
  .active-scaffold .active-scaffold .view {
@@ -413,13 +417,15 @@ font-size: 11px;
413
417
 
414
418
  .active-scaffold-calculations td {
415
419
  border-top: 2px solid;
416
- font: bold 12px arial, sans-serif;
420
+ font-weight: bold;
421
+ font-size: 12px;
417
422
  }
418
423
 
419
424
  .active-scaffold .active-scaffold-footer {
420
425
  padding: 3px 0px 2px 0px;
421
426
  border-bottom: none;
422
- font: bold 12px arial, sans-serif;
427
+ font-weight: bold;
428
+ font-size: 12px;
423
429
  }
424
430
  .active-scaffold .active-scaffold-footer > br {
425
431
  clear: both;
@@ -430,13 +436,17 @@ float: right;
430
436
  white-space: nowrap;
431
437
  margin-right: 5px;
432
438
  }
439
+ .active-scaffold-footer .active-scaffold-pagination.auto-paginate {
440
+ float: left;
441
+ }
433
442
 
434
443
  .active-scaffold-footer a {
435
444
  text-decoration: none;
436
445
  letter-spacing: 0;
437
446
  padding: 0 2px;
438
447
  margin: 0 -2px;
439
- font: bold 12px arial, sans-serif;
448
+ font-weight: bold;
449
+ font-size: 12px;
440
450
  }
441
451
 
442
452
  .active-scaffold-footer .next {
@@ -467,7 +477,7 @@ text-align: center;
467
477
  position: relative;
468
478
  }
469
479
 
470
- .active-scaffold .message {
480
+ .active-scaffold .message, .active-scaffold-component .message {
471
481
  font-size: 11px;
472
482
  font-weight: bold;
473
483
  padding: 5px 20px 5px 5px;
@@ -493,15 +503,16 @@ position: absolute;
493
503
  right: 10px;
494
504
  top: 4px;
495
505
  padding: 0;
496
- font: bold 11px verdana, sans-serif;
506
+ font-weight: bold;
507
+ font-size: 11px;
497
508
  letter-spacing: -1px;
498
509
  }
499
510
 
500
- .active-scaffold .messages-container .message {
511
+ .active-scaffold .messages-container .message, .active-scaffold-component .message {
501
512
  margin: 0;
502
513
  }
503
514
 
504
- .active-scaffold .error-message {
515
+ .active-scaffold .error-message, .active-scaffold-component .error-message {
505
516
  border-left: solid 5px;
506
517
  }
507
518
 
@@ -529,7 +540,6 @@ padding: 2px 5px;
529
540
  font-size: 11px;
530
541
  margin: 0;
531
542
  letter-spacing: 0;
532
- font-family: Verdana;
533
543
  }
534
544
 
535
545
  .active-scaffold .errorExplanation ul {
@@ -541,12 +551,12 @@ list-style: disc;
541
551
  .active-scaffold .errorExplanation p {
542
552
  font-size: 11px;
543
553
  padding: 2px 5px;
544
- font-family: Verdana;
545
554
  margin: 0;
546
555
  }
547
556
 
548
557
  .active-scaffold .errorExplanation ul li {
549
- font: bold 11px verdana;
558
+ font-weight: bold;
559
+ font-size: 11px;
550
560
  letter-spacing: -1px;
551
561
  margin: 0;
552
562
  padding: 0;
@@ -590,13 +600,15 @@ clear: both;
590
600
  width: 12em;
591
601
  float: left;
592
602
  clear: left;
593
- font: normal 11px verdana, sans-serif;
603
+ font-weight: normal;
604
+ font-size: 11px;
594
605
  line-height: 16px;
595
606
  }
596
607
 
597
608
  .active-scaffold .show-view dd {
598
609
  float: left;
599
- font: bold 14px arial;
610
+ font-weight: bold;
611
+ font-size: 14px;
600
612
  padding-left: 5px;
601
613
  margin-bottom: 5px;
602
614
  }
@@ -611,7 +623,6 @@ margin: 0;
611
623
  .active-scaffold .submit {
612
624
  font-weight: bold;
613
625
  font-size: 14px;
614
- font-family: Arial, sans-serif;
615
626
  letter-spacing: 0;
616
627
  margin: 0;
617
628
  margin-top: 5px;
@@ -631,7 +642,8 @@ padding: 2px;
631
642
  margin: 0;
632
643
  text-transform: none;
633
644
  letter-spacing: -1px;
634
- font: bold 16px arial;
645
+ font-weight: bold;
646
+ font-size: 16px;
635
647
  }
636
648
 
637
649
  .active-scaffold h5 {
@@ -663,7 +675,8 @@ clear: both;
663
675
 
664
676
  .active-scaffold a.as_cancel,
665
677
  .active-scaffold p.form-footer a {
666
- font: bold 14px arial, sans-serif;
678
+ font-weight: bold;
679
+ font-size: 14px;
667
680
  letter-spacing: 0;
668
681
  }
669
682
 
@@ -682,7 +695,8 @@ clear: both;
682
695
  }
683
696
 
684
697
  .active-scaffold label {
685
- font: normal 11px verdana, sans-serif;
698
+ font-weight: normal;
699
+ font-size: 11px;
686
700
  }
687
701
 
688
702
  .active-scaffold li.form-element dt {
@@ -717,12 +731,12 @@ font-weight: bold;
717
731
 
718
732
  .active-scaffold label.example {
719
733
  font-size: 11px;
720
- font-family: arial;
721
734
  }
722
735
 
723
736
  .active-scaffold input.text-input,
724
737
  .active-scaffold select {
725
- font: bold 16px arial;
738
+ font-weight: bold;
739
+ font-size: 16px;
726
740
  letter-spacing: -1px;
727
741
  border: solid 1px;
728
742
  }
@@ -746,7 +760,6 @@ padding: 1px;
746
760
 
747
761
 
748
762
  .active-scaffold textarea {
749
- font-family: Arial, sans-serif;
750
763
  font-size: 12px;
751
764
  padding: 1px;
752
765
  border: solid 1px;
@@ -828,6 +841,12 @@ clear: left;
828
841
  padding: 5px 0;
829
842
  padding-left: 5px;
830
843
  }
844
+ .active-scaffold .form-element .sub-form.optional {
845
+ float: none;
846
+ }
847
+ .active-scaffold .form-element .show-new-subform {
848
+ margin-left: 5px;
849
+ }
831
850
 
832
851
  .active-scaffold .sub-form h5 {
833
852
  margin-left: -5px;
@@ -840,7 +859,8 @@ background: none;
840
859
  }
841
860
 
842
861
  .active-scaffold .sub-form table th {
843
- font: normal 10px verdana, sans-serif;
862
+ font-weight: normal;
863
+ font-size: 10px;
844
864
  padding: 0 5px 0 1px;
845
865
  background: none;
846
866
  }
@@ -891,13 +911,15 @@ display: none;
891
911
  }
892
912
 
893
913
  .active-scaffold .sub-form .association-record a {
894
- font: bold 12px arial;
914
+ font-weight: bold;
915
+ font-size: 12px;
895
916
  }
896
917
 
897
918
  .active-scaffold .sub-form input.text-input,
898
919
  .active-scaffold .sub-form select {
899
920
  letter-spacing: 0;
900
- font: bold 12px arial;
921
+ font-weight: bold;
922
+ font-size: 12px;
901
923
  }
902
924
 
903
925
  .active-scaffold .sub-form .footer-wrapper {
@@ -983,7 +1005,8 @@ padding: 4px 0px;
983
1005
 
984
1006
  .as_touch .active-scaffold div.actions a,
985
1007
  .as_touch .active-scaffold div.actions div {
986
- font: bold 14px arial;
1008
+ font-weight: bold;
1009
+ font-size: 14px;
987
1010
  }
988
1011
 
989
1012
  .as_touch .active-scaffold div.actions {