active_scaffold 3.5.3 → 3.6.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/{CHANGELOG → CHANGELOG.rdoc} +73 -0
  3. data/README.md +17 -7
  4. data/app/assets/javascripts/active_scaffold.js.erb +0 -1
  5. data/app/assets/javascripts/jquery/active_scaffold.js +97 -6
  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 +1 -0
  63. data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +12 -15
  64. data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +1 -1
  65. data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +9 -12
  66. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +1 -1
  67. data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +2 -2
  68. data/lib/active_scaffold/bridges/chosen/helpers.rb +11 -9
  69. data/lib/active_scaffold/bridges/date_picker/ext.rb +0 -13
  70. data/lib/active_scaffold/bridges/date_picker/helper.rb +49 -44
  71. data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +1 -1
  72. data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +1 -1
  73. data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +3 -3
  74. data/lib/active_scaffold/bridges/file_column/form_ui.rb +3 -3
  75. data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +10 -7
  76. data/lib/active_scaffold/bridges/paper_trail.rb +1 -1
  77. data/lib/active_scaffold/bridges/paper_trail/actions.rb +3 -1
  78. data/lib/active_scaffold/bridges/paperclip/list_ui.rb +1 -1
  79. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +1 -1
  80. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +2 -2
  81. data/lib/active_scaffold/bridges/record_select/helpers.rb +15 -17
  82. data/lib/active_scaffold/bridges/shared/date_bridge.rb +20 -19
  83. data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +3 -1
  84. data/lib/active_scaffold/bridges/usa_state_select/usa_state_select_helper.rb +21 -4
  85. data/lib/active_scaffold/config/base.rb +133 -41
  86. data/lib/active_scaffold/config/core.rb +146 -18
  87. data/lib/active_scaffold/config/delete.rb +14 -1
  88. data/lib/active_scaffold/config/field_search.rb +7 -1
  89. data/lib/active_scaffold/config/form.rb +10 -1
  90. data/lib/active_scaffold/config/list.rb +39 -13
  91. data/lib/active_scaffold/config/mark.rb +4 -2
  92. data/lib/active_scaffold/config/nested.rb +16 -17
  93. data/lib/active_scaffold/config/search.rb +9 -0
  94. data/lib/active_scaffold/config/show.rb +4 -0
  95. data/lib/active_scaffold/config/update.rb +4 -0
  96. data/lib/active_scaffold/configurable.rb +14 -7
  97. data/lib/active_scaffold/constraints.rb +22 -20
  98. data/lib/active_scaffold/core.rb +67 -28
  99. data/lib/active_scaffold/data_structures/action_columns.rb +50 -59
  100. data/lib/active_scaffold/data_structures/action_link.rb +50 -20
  101. data/lib/active_scaffold/data_structures/action_links.rb +15 -13
  102. data/lib/active_scaffold/data_structures/association/abstract.rb +38 -15
  103. data/lib/active_scaffold/data_structures/association/active_mongoid.rb +2 -6
  104. data/lib/active_scaffold/data_structures/association/active_record.rb +6 -2
  105. data/lib/active_scaffold/data_structures/association/mongoid.rb +0 -3
  106. data/lib/active_scaffold/data_structures/column.rb +75 -66
  107. data/lib/active_scaffold/data_structures/columns.rb +3 -2
  108. data/lib/active_scaffold/data_structures/nested_info.rb +33 -19
  109. data/lib/active_scaffold/data_structures/set.rb +8 -0
  110. data/lib/active_scaffold/data_structures/sorting.rb +10 -2
  111. data/lib/active_scaffold/delayed_setup.rb +16 -5
  112. data/lib/active_scaffold/extensions/action_controller_rendering.rb +3 -2
  113. data/lib/active_scaffold/extensions/action_view_rendering.rb +34 -14
  114. data/lib/active_scaffold/extensions/cow_proxy.rb +95 -0
  115. data/lib/active_scaffold/extensions/ice_nine.rb +36 -0
  116. data/lib/active_scaffold/extensions/left_outer_joins.rb +8 -33
  117. data/lib/active_scaffold/extensions/localize.rb +3 -1
  118. data/lib/active_scaffold/extensions/routing_mapper.rb +6 -45
  119. data/lib/active_scaffold/extensions/to_label.rb +3 -2
  120. data/lib/active_scaffold/extensions/unsaved_record.rb +2 -4
  121. data/lib/active_scaffold/finder.rb +110 -77
  122. data/lib/active_scaffold/helpers/action_link_helpers.rb +62 -36
  123. data/lib/active_scaffold/helpers/association_helpers.rb +21 -19
  124. data/lib/active_scaffold/helpers/controller_helpers.rb +34 -10
  125. data/lib/active_scaffold/helpers/form_column_helpers.rb +196 -124
  126. data/lib/active_scaffold/helpers/human_condition_helpers.rb +1 -1
  127. data/lib/active_scaffold/helpers/id_helpers.rb +6 -2
  128. data/lib/active_scaffold/helpers/list_column_helpers.rb +86 -57
  129. data/lib/active_scaffold/helpers/pagination_helpers.rb +2 -2
  130. data/lib/active_scaffold/helpers/search_column_helpers.rb +29 -34
  131. data/lib/active_scaffold/helpers/show_column_helpers.rb +3 -5
  132. data/lib/active_scaffold/helpers/view_helpers.rb +38 -35
  133. data/lib/active_scaffold/marked_model.rb +2 -2
  134. data/lib/active_scaffold/orm_checks.rb +3 -7
  135. data/lib/active_scaffold/paginator.rb +7 -7
  136. data/lib/active_scaffold/registry.rb +33 -0
  137. data/lib/active_scaffold/responds_to_parent.rb +8 -11
  138. data/lib/active_scaffold/tableless.rb +67 -65
  139. data/lib/active_scaffold/version.rb +2 -2
  140. data/lib/generators/active_scaffold/controller_generator.rb +2 -2
  141. data/lib/generators/active_scaffold/install_generator.rb +1 -1
  142. data/lib/generators/active_scaffold/resource_generator.rb +2 -2
  143. data/shoulda_macros/macros.rb +3 -1
  144. data/test/bridges/date_picker_test.rb +1 -2
  145. data/test/bridges/paperclip_test.rb +6 -6
  146. data/test/class_with_finder.rb +2 -2
  147. data/test/company.rb +4 -4
  148. data/test/config/create_test.rb +4 -2
  149. data/test/config/nested_test.rb +1 -1
  150. data/test/config/show_test.rb +1 -1
  151. data/test/config/update_test.rb +7 -6
  152. data/test/data_structures/action_columns_test.rb +2 -2
  153. data/test/data_structures/action_links_test.rb +1 -1
  154. data/test/data_structures/column_test.rb +3 -6
  155. data/test/data_structures/columns_test.rb +2 -2
  156. data/test/data_structures/sorting_test.rb +7 -0
  157. data/test/extensions/active_record_test.rb +4 -4
  158. data/test/extensions/routing_mapper_test.rb +2 -2
  159. data/test/helpers/list_column_helpers_test.rb +3 -1
  160. data/test/misc/active_record_permissions_test.rb +3 -11
  161. data/test/misc/attribute_params_test.rb +12 -8
  162. data/test/misc/calculation_test.rb +1 -1
  163. data/test/misc/configurable_test.rb +10 -10
  164. data/test/misc/constraints_test.rb +2 -2
  165. data/test/misc/convert_numbers_format_test.rb +7 -3
  166. data/test/misc/lang_test.rb +1 -1
  167. data/test/misc/parse_datetime_test.rb +3 -4
  168. data/test/misc/tableless_test.rb +6 -0
  169. data/test/mock_app/Rakefile +1 -1
  170. data/test/mock_app/app/assets/config/manifest.js +0 -0
  171. data/test/mock_app/app/controllers/cars_controller.rb +1 -0
  172. data/test/mock_app/app/controllers/people_controller.rb +3 -1
  173. data/test/mock_app/config/application.rb +2 -1
  174. data/test/mock_app/config/boot.rb +1 -1
  175. data/test/mock_app/config/environment.rb +2 -2
  176. data/test/mock_app/config/routes.rb +4 -1
  177. data/test/mock_app/db/schema.rb +2 -0
  178. data/test/performance/list_cars_performance_test.rb +34 -0
  179. data/test/performance/list_people_performance_test.rb +31 -0
  180. data/test/performance_test_help.rb +3 -0
  181. data/test/test_helper.rb +10 -2
  182. metadata +55 -20
  183. data/app/assets/javascripts/prototype/rico_corner.js +0 -370
  184. 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: 177c474fcde86642099ba380b09ad4b3042a09c8e29b0ab400190628b426e92e
4
- data.tar.gz: f38ba6290d4887a33d376bf03ba5ba0ea0e9fe19488e783543be999948614646
3
+ metadata.gz: 482104397cc4bcba59938371add5a7d584a23c3f42aa4b8f3f4ba44f0ffa6114
4
+ data.tar.gz: a140af6343b7a3002740fa8a5af20ddd5da09a0c7a3f384ef31c85a697918cb4
5
5
  SHA512:
6
- metadata.gz: 5592eef658ad06e1a564d085c2db7501057cf49b3782c9e7da7d13a18d375ae7e812a3e400b3fc14cf6ddb15703bce206e7da9c81a397b8035eed2d3cc470c46
7
- data.tar.gz: 54d1fdd3df68b78ad89595e0350d04a91b75b79d203ed478c4b638136b108d2d39834dabbd64971609641de621011cb761d8bafd3a22fbab3327cd880252b7ff
6
+ metadata.gz: 89556a2bbb6664fb22291e21bba6108d21c0195788cf5e3fdb6b5d471aab24e7bdef1d40d764f68bb9ecb6e94dfc5c728ac4742b3034a7e74d7e11688933d835
7
+ data.tar.gz: 2606b28e771d97eb6600fb380c34cace3adfbce11cc7baa470de3821dd2bd82e3acec4e66b1bcef14ff7fa17755e2255d7b977a43e85aea893d70d83c2d0f133
@@ -1,3 +1,75 @@
1
+ = 3.6.0.rc2
2
+ - Fix subform crud in subform subgroup when controller is embedded
3
+ - Fix sorting for mongoid models, broken in 3.6.0.rc1
4
+ - Improve add_new option, allow to change subform columns (with helper override calling super and add columns to locals argument)
5
+ - Support add_new option for record_select or radio form_ui
6
+ - 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)
7
+ - Support description for columns displayed as subform
8
+ - Don't mess with history if current page is not using activescaffold when is loaded
9
+ - Fix changing sort_by per request when threadsafe is enabled
10
+
11
+ = 3.6.0.rc1
12
+ - Cleanup: deprecate ActiveScaffold.set_defaults for ActiveScaffold.defaults, rename some setters
13
+ - Fix adding new action links on request with threadsafety enabled
14
+ - Fix iterating in config.columns with threadsafety enabled
15
+ - Fix changing pagination enabled/disabled with threadsafety enabled
16
+ - Allow create action in has_many through singular association
17
+ - Display no options in radio form_ui when no option is available, so column can be refreshed with update_columns
18
+ - Add as_main_div_data to override data attributes on main div
19
+ - Add loading indicator to embedded scaffolds, display error if fails
20
+ - Fix race condition in threadsafe mode with delayed setup
21
+ - 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)
22
+ - Display loading indicator at bottom on auto pagination
23
+ - List rendering speed up
24
+ - Remove font family from CSS, it was preventing from changing it easily in body
25
+ - Fix search for mongoid models in with threadsafety enabled
26
+ - Keep nested params after calling render_field for column in subform
27
+ - Fix nested for controllers without list action (for example, for nested create on singular assocations)
28
+ - Fix delayed setup issues with threads
29
+ - Fix render_field under nested list for polymorphic association
30
+ - Add foreign_type column to constrained columns in nested list for polymorphic association
31
+ - Add return_to to action links on nested list for singular associations, so forms would return to list
32
+ - Case insensitive search with PostGIS adapter
33
+ - Use clear_storage with around_action and ensure, so empty hash is removed from session storage when exception is raised too
34
+ - Delete search from session when search is reset
35
+ - 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
36
+ - ActiveStorage support with bridge
37
+ - Add list_row_attributes helper so more HTML attributes can be added to tr.record in list, overriding the helper
38
+ - Support column!=value param for not equal condition (column!= means column is not null)
39
+ - Don't force to use join for column's includes when sorting by method
40
+ - Add support for range conditions in url params for numeric (integer, decimal, float, bigint) columns too
41
+ - Support include_blank option in :radio form_ui
42
+ - Add add_new option for :select form_ui in singular associations, in column.options, it adds link to toggle between select and subform
43
+ - Fix subform crud in subform subgroup, when form is on nested scaffold, when record on first subform is persisted
44
+ - Add association_join_text setting to column, so it can be changed for one column only
45
+ - Use Arel.sql with sorting.clause before passing to reorder method
46
+
47
+ = 3.6.0.pre
48
+ - Added threadsafety as tech preview, enabled with ActiveScaffold.threadsafe! in initializer.
49
+ - Added active_scaffold_config.build_action_columns method to easily create action columns for custom form actions.
50
+ - Replaced each(options) with each_column(options) in ActionColumns
51
+ - Replaced collect_visible(options, &proc) with visible_columns(options).map(&proc) in ActionColumns
52
+ - Replaced names with visible_columns_names in ActionColumns
53
+ - Replaced names_without_auth_check with to_a in ActionColumns
54
+ - Support rails 5.2, drop support for 4.0 and 4.1
55
+ - Require ruby 2.3.1, drop support for 2.0, 2.1 and 2.2.
56
+ - Fix has_one/belongs_to nested for polymorphic associations, leave rails to build conditions from {assoc_name: record} hash
57
+ - Cast blank into nil for null string columns in conditions_from_params
58
+ - Support multipart with iframe in process_action_link_action default response
59
+ - Fix hidding and showing columns based on permissions with update_columns on subforms
60
+ - Fix subform crud in subform subgroup, when form is on nested scaffold
61
+ - Fix JS when rails-ujs is used instead of jquery_ujs (rails >= 5.1)
62
+ - Display flash messages only inside create form, when conf.list.always_show_create is enabled, instead of displaying twice (in form and above list).
63
+ - Fix default autocomplete value for password form_ui, new-password has to be used because off is ignored by browsers in password fields now
64
+
65
+ = 3.5.5
66
+ - Fix creating new records, when using cancan and allowing access based on id (fixes #617)
67
+
68
+ = 3.5.4
69
+ - Fix chosen form_ui for plural associations
70
+ - Eager load with includes in association options query, if includes has a hash with own association key, see #612
71
+
72
+ = 3.5.3
1
73
  - Fix :text fields for rails >= 5.1
2
74
  - Send empty array in collection associations with select form_ui (checkbox or draggable list) when no option is available
3
75
 
@@ -49,6 +121,7 @@
49
121
  - fix display of association in list when association_limit is nil
50
122
  - fix conversion of i18n date and datetime value, some abbr day and month may be equal in some languages
51
123
  - fix hidden form_ui for collection associations (has_many, habtm)
124
+ - Drop rails 3.2.x and ruby 1.9 support
52
125
 
53
126
  = 3.4.43
54
127
  - Fix human conditions for date and datetime columns, not using date picker
data/README.md CHANGED
@@ -8,10 +8,11 @@ Overview
8
8
  [![Inline docs](https://inch-ci.org/github/activescaffold/active_scaffold.svg?branch=master)](https://inch-ci.org/github/activescaffold/active_scaffold)
9
9
  [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
10
10
 
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.
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.2.0 is supported, ruby >= 2.3 required.
12
12
 
13
13
  Branch Details
14
14
  --------------
15
+ 3-5-stable supports rails >= 4.0.x and ruby >= 2.0.0
15
16
  3-4-stable supports rails >= 3.2.x and ruby >= 1.9.3
16
17
  3-3-stable supports rails >= 3.2.x and ruby >= 1.8
17
18
  rails-3.2 supports Rails 3.1 & 3.2, and is the current source of the 3.2.x line of gems.
@@ -24,28 +25,37 @@ Added to Gemfile
24
25
 
25
26
  gem 'active_scaffold'
26
27
 
27
- For rails >= 5.1, add
28
+ For rails >= 5.1, add jquery to application.js before rails-ujs (with jquery-rails), or 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).
29
+
30
+ //= require jquery
28
31
 
29
32
  gem 'jquery-rails'
30
33
 
31
- Run the following commands
34
+ Run the following commands, for rails 4.2
32
35
 
33
36
  bundle install
34
37
  rails g active_scaffold:install
35
38
  bundle exec rake db:create
36
- rails g active_scaffold:resource User name:string
39
+ rails g active_scaffold:resource Model [attrs]
37
40
  bundle exec rake db:migrate
38
41
 
39
- Commands for Rails 5
42
+ Or run the following commands, for rails 5
40
43
 
41
44
  bundle install
42
45
  rails g active_scaffold:install
43
46
  rails db:create
44
- rails g active_scaffold:resource User name:string
47
+ rails g active_scaffold:resource Model [attrs]
45
48
  rails db:migrate
46
49
 
47
50
 
48
- Run the app and visit localhost:3000/users
51
+ Run the app and visit localhost:3000/<plural_model>
52
+
53
+ Threadsafe
54
+ ----------
55
+
56
+ Threadsafe can be enabled calling ActiveScaffold.threadsafe! in an initializer.
57
+ It should be enabled on app start and it can't be disabled. Threadsafety is a
58
+ new feature and not well tested yet.
49
59
 
50
60
  Configuration
51
61
  -------------
@@ -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
  }
@@ -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 {