active_scaffold 3.5.2 → 3.6.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. checksums.yaml +4 -4
  2. data/{CHANGELOG → CHANGELOG.rdoc} +66 -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 +63 -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_footer.html.erb +3 -2
  11. data/app/views/active_scaffold_overrides/_form_association_record.html.erb +6 -6
  12. data/app/views/active_scaffold_overrides/_horizontal_subform.html.erb +1 -1
  13. data/app/views/active_scaffold_overrides/_horizontal_subform_header.html.erb +1 -1
  14. data/app/views/active_scaffold_overrides/_list.html.erb +2 -1
  15. data/app/views/active_scaffold_overrides/_list_header.html.erb +5 -7
  16. data/app/views/active_scaffold_overrides/_list_messages.html.erb +1 -0
  17. data/app/views/active_scaffold_overrides/_list_record.html.erb +4 -5
  18. data/app/views/active_scaffold_overrides/_list_with_header.html.erb +1 -1
  19. data/app/views/active_scaffold_overrides/_messages.html.erb +1 -0
  20. data/app/views/active_scaffold_overrides/_refresh_list.js.erb +4 -0
  21. data/app/views/active_scaffold_overrides/_render_field.js.erb +2 -1
  22. data/app/views/active_scaffold_overrides/_show_association_horizontal.html.erb +2 -1
  23. data/app/views/active_scaffold_overrides/_show_columns.html.erb +2 -2
  24. data/app/views/active_scaffold_overrides/_show_horizontal_record.html.erb +4 -4
  25. data/app/views/active_scaffold_overrides/_update_calculations.js.erb +1 -1
  26. data/app/views/active_scaffold_overrides/_update_column.js.erb +2 -2
  27. data/app/views/active_scaffold_overrides/action_confirmation.html.erb +2 -2
  28. data/app/views/active_scaffold_overrides/delete.html.erb +2 -2
  29. data/app/views/active_scaffold_overrides/on_action_update.js.erb +16 -6
  30. data/app/views/active_scaffold_overrides/on_update.js.erb +1 -1
  31. data/app/views/active_scaffold_overrides/row.js.erb +1 -1
  32. data/app/views/active_scaffold_overrides/update_column.js.erb +1 -1
  33. data/config/locales/de.yml +2 -1
  34. data/config/locales/en.yml +1 -0
  35. data/config/locales/es.yml +1 -0
  36. data/config/locales/fr.yml +2 -1
  37. data/config/locales/hu.yml +1 -0
  38. data/config/locales/ja.yml +1 -0
  39. data/config/locales/ru.yml +1 -0
  40. data/lib/active_scaffold.rb +19 -16
  41. data/lib/active_scaffold/actions/common_search.rb +11 -8
  42. data/lib/active_scaffold/actions/core.rb +89 -71
  43. data/lib/active_scaffold/actions/create.rb +28 -28
  44. data/lib/active_scaffold/actions/delete.rb +3 -3
  45. data/lib/active_scaffold/actions/field_search.rb +53 -43
  46. data/lib/active_scaffold/actions/list.rb +111 -27
  47. data/lib/active_scaffold/actions/nested.rb +65 -48
  48. data/lib/active_scaffold/actions/search.rb +1 -1
  49. data/lib/active_scaffold/actions/show.rb +4 -4
  50. data/lib/active_scaffold/actions/subform.rb +12 -17
  51. data/lib/active_scaffold/actions/update.rb +96 -77
  52. data/lib/active_scaffold/active_record_permissions.rb +2 -11
  53. data/lib/active_scaffold/attribute_params.rb +104 -86
  54. data/lib/active_scaffold/bridges.rb +8 -8
  55. data/lib/active_scaffold/bridges/active_storage.rb +6 -0
  56. data/lib/active_scaffold/bridges/active_storage/active_storage_bridge.rb +33 -0
  57. data/lib/active_scaffold/bridges/active_storage/active_storage_helpers.rb +54 -0
  58. data/lib/active_scaffold/bridges/active_storage/form_ui.rb +22 -0
  59. data/lib/active_scaffold/bridges/active_storage/list_ui.rb +36 -0
  60. data/lib/active_scaffold/bridges/bitfields.rb +1 -0
  61. data/lib/active_scaffold/bridges/bitfields/bitfields_bridge.rb +12 -15
  62. data/lib/active_scaffold/bridges/calendar_date_select/as_cds_bridge.rb +1 -1
  63. data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +9 -12
  64. data/lib/active_scaffold/bridges/carrierwave/carrierwave_bridge.rb +1 -1
  65. data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +2 -2
  66. data/lib/active_scaffold/bridges/chosen/helpers.rb +11 -9
  67. data/lib/active_scaffold/bridges/date_picker/ext.rb +0 -13
  68. data/lib/active_scaffold/bridges/date_picker/helper.rb +49 -44
  69. data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +1 -1
  70. data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +1 -1
  71. data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +3 -3
  72. data/lib/active_scaffold/bridges/file_column/form_ui.rb +3 -3
  73. data/lib/active_scaffold/bridges/file_column/test/functional/file_column_keep_test.rb +10 -7
  74. data/lib/active_scaffold/bridges/paper_trail.rb +1 -1
  75. data/lib/active_scaffold/bridges/paperclip/list_ui.rb +1 -1
  76. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge.rb +1 -1
  77. data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +2 -2
  78. data/lib/active_scaffold/bridges/record_select/helpers.rb +12 -16
  79. data/lib/active_scaffold/bridges/shared/date_bridge.rb +20 -19
  80. data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +3 -1
  81. data/lib/active_scaffold/bridges/usa_state_select/usa_state_select_helper.rb +21 -4
  82. data/lib/active_scaffold/config/base.rb +133 -41
  83. data/lib/active_scaffold/config/core.rb +146 -18
  84. data/lib/active_scaffold/config/delete.rb +14 -1
  85. data/lib/active_scaffold/config/field_search.rb +7 -1
  86. data/lib/active_scaffold/config/form.rb +10 -1
  87. data/lib/active_scaffold/config/list.rb +39 -13
  88. data/lib/active_scaffold/config/mark.rb +4 -2
  89. data/lib/active_scaffold/config/nested.rb +16 -17
  90. data/lib/active_scaffold/config/search.rb +9 -0
  91. data/lib/active_scaffold/config/show.rb +4 -0
  92. data/lib/active_scaffold/config/update.rb +4 -0
  93. data/lib/active_scaffold/configurable.rb +14 -7
  94. data/lib/active_scaffold/constraints.rb +22 -20
  95. data/lib/active_scaffold/core.rb +68 -29
  96. data/lib/active_scaffold/data_structures/action_columns.rb +50 -59
  97. data/lib/active_scaffold/data_structures/action_link.rb +50 -20
  98. data/lib/active_scaffold/data_structures/action_links.rb +15 -13
  99. data/lib/active_scaffold/data_structures/association/abstract.rb +41 -15
  100. data/lib/active_scaffold/data_structures/association/active_mongoid.rb +2 -6
  101. data/lib/active_scaffold/data_structures/association/active_record.rb +6 -2
  102. data/lib/active_scaffold/data_structures/association/mongoid.rb +0 -3
  103. data/lib/active_scaffold/data_structures/column.rb +75 -66
  104. data/lib/active_scaffold/data_structures/columns.rb +3 -2
  105. data/lib/active_scaffold/data_structures/nested_info.rb +21 -19
  106. data/lib/active_scaffold/data_structures/set.rb +8 -0
  107. data/lib/active_scaffold/data_structures/sorting.rb +10 -2
  108. data/lib/active_scaffold/delayed_setup.rb +16 -5
  109. data/lib/active_scaffold/extensions/action_controller_rendering.rb +3 -2
  110. data/lib/active_scaffold/extensions/action_view_rendering.rb +34 -14
  111. data/lib/active_scaffold/extensions/cow_proxy.rb +91 -0
  112. data/lib/active_scaffold/extensions/ice_nine.rb +36 -0
  113. data/lib/active_scaffold/extensions/left_outer_joins.rb +8 -33
  114. data/lib/active_scaffold/extensions/localize.rb +3 -1
  115. data/lib/active_scaffold/extensions/routing_mapper.rb +6 -45
  116. data/lib/active_scaffold/extensions/to_label.rb +3 -2
  117. data/lib/active_scaffold/extensions/unsaved_record.rb +2 -4
  118. data/lib/active_scaffold/finder.rb +104 -73
  119. data/lib/active_scaffold/helpers/action_link_helpers.rb +62 -36
  120. data/lib/active_scaffold/helpers/association_helpers.rb +21 -19
  121. data/lib/active_scaffold/helpers/controller_helpers.rb +23 -10
  122. data/lib/active_scaffold/helpers/form_column_helpers.rb +157 -121
  123. data/lib/active_scaffold/helpers/human_condition_helpers.rb +1 -1
  124. data/lib/active_scaffold/helpers/id_helpers.rb +6 -2
  125. data/lib/active_scaffold/helpers/list_column_helpers.rb +82 -53
  126. data/lib/active_scaffold/helpers/pagination_helpers.rb +2 -2
  127. data/lib/active_scaffold/helpers/search_column_helpers.rb +29 -34
  128. data/lib/active_scaffold/helpers/show_column_helpers.rb +3 -5
  129. data/lib/active_scaffold/helpers/view_helpers.rb +38 -35
  130. data/lib/active_scaffold/marked_model.rb +2 -2
  131. data/lib/active_scaffold/orm_checks.rb +3 -7
  132. data/lib/active_scaffold/paginator.rb +7 -7
  133. data/lib/active_scaffold/registry.rb +33 -0
  134. data/lib/active_scaffold/responds_to_parent.rb +8 -11
  135. data/lib/active_scaffold/tableless.rb +67 -65
  136. data/lib/active_scaffold/version.rb +2 -2
  137. data/lib/generators/active_scaffold/controller_generator.rb +2 -2
  138. data/lib/generators/active_scaffold/install_generator.rb +1 -1
  139. data/lib/generators/active_scaffold/resource_generator.rb +2 -2
  140. data/shoulda_macros/macros.rb +3 -1
  141. data/test/bridges/date_picker_test.rb +1 -2
  142. data/test/bridges/paperclip_test.rb +6 -6
  143. data/test/class_with_finder.rb +2 -2
  144. data/test/company.rb +4 -4
  145. data/test/config/create_test.rb +4 -2
  146. data/test/config/nested_test.rb +1 -1
  147. data/test/config/show_test.rb +1 -1
  148. data/test/config/update_test.rb +7 -6
  149. data/test/data_structures/action_columns_test.rb +2 -2
  150. data/test/data_structures/action_links_test.rb +1 -1
  151. data/test/data_structures/column_test.rb +3 -6
  152. data/test/data_structures/columns_test.rb +2 -2
  153. data/test/data_structures/sorting_test.rb +7 -0
  154. data/test/extensions/active_record_test.rb +4 -4
  155. data/test/extensions/routing_mapper_test.rb +2 -2
  156. data/test/helpers/list_column_helpers_test.rb +3 -1
  157. data/test/misc/active_record_permissions_test.rb +3 -11
  158. data/test/misc/attribute_params_test.rb +12 -8
  159. data/test/misc/calculation_test.rb +1 -1
  160. data/test/misc/configurable_test.rb +10 -10
  161. data/test/misc/constraints_test.rb +2 -2
  162. data/test/misc/convert_numbers_format_test.rb +7 -3
  163. data/test/misc/lang_test.rb +1 -1
  164. data/test/misc/parse_datetime_test.rb +3 -4
  165. data/test/misc/tableless_test.rb +6 -0
  166. data/test/mock_app/Rakefile +1 -1
  167. data/test/mock_app/app/assets/config/manifest.js +0 -0
  168. data/test/mock_app/app/controllers/cars_controller.rb +1 -0
  169. data/test/mock_app/app/controllers/people_controller.rb +3 -1
  170. data/test/mock_app/config/application.rb +2 -1
  171. data/test/mock_app/config/boot.rb +1 -1
  172. data/test/mock_app/config/environment.rb +2 -2
  173. data/test/mock_app/config/routes.rb +4 -1
  174. data/test/mock_app/db/schema.rb +2 -0
  175. data/test/performance/list_cars_performance_test.rb +34 -0
  176. data/test/performance/list_people_performance_test.rb +31 -0
  177. data/test/performance_test_help.rb +3 -0
  178. data/test/test_helper.rb +10 -2
  179. metadata +56 -15
  180. data/app/assets/javascripts/prototype/rico_corner.js +0 -370
  181. 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: eb488c6caa26e0f29ed0a3f196978909c883a771c25d36210288b9a7f66f668c
4
- data.tar.gz: 659fee5d9563399ed060d6bec5ad1328c9bcaa9f97fdd7fa738bcaa48c541f32
3
+ metadata.gz: 6c9ea6700cdf564c8c6712df6f538251a00ab77d708a1cb6ddbaf1522f7f3c82
4
+ data.tar.gz: c71eb0579b0671fedf08104b51237f260b43ff5d6aa090c98a3ffffde943f31d
5
5
  SHA512:
6
- metadata.gz: 03028d9082279032c1798389025ab2c2f97f985c99b381e8cb85c65746a83b4cb5117a7f6d3c92ec86514ec10b0c3d772d2a2e2ebb80a00c1cd62e025772ea57
7
- data.tar.gz: 6efab3ac33378af2dbb4a7509e3fdb698e791fcf7f655a498186a90d97334cc1a1a699ab766c3f449d53a83171d61edaac96b40d75a8dcff8fa7fc3c7720b564
6
+ metadata.gz: dd0cb52f16d6a75545d491388cbde13f99db60cf0c951db73df00ce77dac5fdd09573331b510fcd2e9a2f637c539e754c8fab0838d5709e22fd8abb11128d9ae
7
+ data.tar.gz: b0b4558cf821b84701e42f730eb6699c49a82e3c1e70a6f570d6dd99abbb599f783dded394b94bd7aa96db89d4cd4a23e848480239d4256a5e3f596812ba4e17
@@ -1,3 +1,68 @@
1
+ = 3.6.0.rc1
2
+ - Cleanup: deprecate ActiveScaffold.set_defaults for ActiveScaffold.defaults, rename some setters
3
+ - Fix adding new action links on request with threadsafety enabled
4
+ - Fix iterating in config.columns with threadsafety enabled
5
+ - Fix changing pagination enabled/disabled with threadsafety enabled
6
+ - Allow create action in has_many through singular association
7
+ - Display no options in radio form_ui when no option is available, so column can be refreshed with update_columns
8
+ - Add as_main_div_data to override data attributes on main div
9
+ - Add loading indicator to embedded scaffolds, display error if fails
10
+ - Fix race condition in threadsafe mode with delayed setup
11
+ - 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)
12
+ - Display loading indicator at bottom on auto pagination
13
+ - List rendering speed up
14
+ - Remove font family from CSS, it was preventing from changing it easily in body
15
+ - Fix search for mongoid models in with threadsafety enabled
16
+ - Keep nested params after calling render_field for column in subform
17
+ - Fix nested for controllers without list action (for example, for nested create on singular assocations)
18
+ - Fix delayed setup issues with threads
19
+ - Fix render_field under nested list for polymorphic association
20
+ - Add foreign_type column to constrained columns in nested list for polymorphic association
21
+ - Add return_to to action links on nested list for singular associations, so forms would return to list
22
+ - Case insensitive search with PostGIS adapter
23
+ - Use clear_storage with around_action and ensure, so empty hash is removed from session storage when exception is raised too
24
+ - Delete search from session when search is reset
25
+ - 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
26
+ - ActiveStorage support with bridge
27
+ - Add list_row_attributes helper so more HTML attributes can be added to tr.record in list, overriding the helper
28
+ - Support column!=value param for not equal condition (column!= means column is not null)
29
+ - Don't force to use join for column's includes when sorting by method
30
+ - Add support for range conditions in url params for numeric (integer, decimal, float, bigint) columns too
31
+ - Support include_blank option in :radio form_ui
32
+ - Add add_new option for :select form_ui in singular associations, in column.options, it adds link to toggle between select and subform
33
+ - Fix subform crud in subform subgroup, when form is on nested scaffold, when record on first subform is persisted
34
+ - Add association_join_text setting to column, so it can be changed for one column only
35
+ - Use Arel.sql with sorting.clause before passing to reorder method
36
+
37
+ = 3.6.0.pre
38
+ - Added threadsafety as tech preview, enabled with ActiveScaffold.threadsafe! in initializer.
39
+ - Added active_scaffold_config.build_action_columns method to easily create action columns for custom form actions.
40
+ - Replaced each(options) with each_column(options) in ActionColumns
41
+ - Replaced collect_visible(options, &proc) with visible_columns(options).map(&proc) in ActionColumns
42
+ - Replaced names with visible_columns_names in ActionColumns
43
+ - Replaced names_without_auth_check with to_a in ActionColumns
44
+ - Support rails 5.2, drop support for 4.0 and 4.1
45
+ - Require ruby 2.3.1, drop support for 2.0, 2.1 and 2.2.
46
+ - Fix has_one/belongs_to nested for polymorphic associations, leave rails to build conditions from {assoc_name: record} hash
47
+ - Cast blank into nil for null string columns in conditions_from_params
48
+ - Support multipart with iframe in process_action_link_action default response
49
+ - Fix hidding and showing columns based on permissions with update_columns on subforms
50
+ - Fix subform crud in subform subgroup, when form is on nested scaffold
51
+ - Fix JS when rails-ujs is used instead of jquery_ujs (rails >= 5.1)
52
+ - Display flash messages only inside create form, when conf.list.always_show_create is enabled, instead of displaying twice (in form and above list).
53
+ - Fix default autocomplete value for password form_ui, new-password has to be used because off is ignored by browsers in password fields now
54
+
55
+ = 3.5.5
56
+ - Fix creating new records, when using cancan and allowing access based on id (fixes #617)
57
+
58
+ = 3.5.4
59
+ - Fix chosen form_ui for plural associations
60
+ - Eager load with includes in association options query, if includes has a hash with own association key, see #612
61
+
62
+ = 3.5.3
63
+ - Fix :text fields for rails >= 5.1
64
+ - Send empty array in collection associations with select form_ui (checkbox or draggable list) when no option is available
65
+
1
66
  = 3.5.2
2
67
  - Load chosen on turbolinks:load event
3
68
  - Fix association.blank? when associated_limit=0 and includes=nil
@@ -46,6 +111,7 @@
46
111
  - fix display of association in list when association_limit is nil
47
112
  - fix conversion of i18n date and datetime value, some abbr day and month may be equal in some languages
48
113
  - fix hidden form_ui for collection associations (has_many, habtm)
114
+ - Drop rails 3.2.x and ruby 1.9 support
49
115
 
50
116
  = 3.4.43
51
117
  - 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 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,23 @@ jQuery(document).ready(function($) {
297
323
  if (jQuery(this).prop('checked')) color_field.val('');
298
324
  });
299
325
 
326
+ jQuery(document).on('click', '.show-new-subform', function(e) {
327
+ e.preventDefault();
328
+ var $this = jQuery(this), line = $this.closest('.form-element'),
329
+ select = line.find('#' + $this.data('select-id')),
330
+ subform = line.find('#' + $this.data('subform-id'));
331
+ if (select.is(':visible')) {
332
+ select.hide().prop('disabled', true);
333
+ subform.show().find("input:disabled,select:disabled,textarea:disabled").prop('disabled', false);
334
+ $this.data('select-text', $this.html());
335
+ $this.html($this.data('subform-text'));
336
+ } else {
337
+ subform.hide().find("input:enabled,select:enabled,textarea:enabled").prop('disabled', true);
338
+ select.show().prop('disabled', false);
339
+ $this.html($this.data('select-text'));
340
+ }
341
+ });
342
+
300
343
  jQuery(document).on('turbolinks:before-visit', function() {
301
344
  if (history.state.active_scaffold) {
302
345
  history.replaceState({turbolinks: true, url: document.location.href}, '', document.location.href);
@@ -454,6 +497,7 @@ var ActiveScaffold = {
454
497
  ActiveScaffold.auto_paginate(container);
455
498
  ActiveScaffold.draggable_lists('.draggable-lists', container);
456
499
  ActiveScaffold.sliders(container);
500
+ ActiveScaffold.disable_optional_subforms(container);
457
501
  },
458
502
  setup_history_state: function() {
459
503
  var data = {}, current_search_item = jQuery('.active-scaffold .filtered-message[data-search]');
@@ -479,7 +523,9 @@ var ActiveScaffold = {
479
523
  auto_paginate: function(element) {
480
524
  var paginate_link = jQuery('.active-scaffold-pagination.auto-paginate a:first', element);
481
525
  if (paginate_link.length) {
482
- jQuery('.active-scaffold-pagination.auto-paginate', element).hide();
526
+ var pagination = paginate_link.closest('.auto-paginate');
527
+ pagination.find('.as_paginate').hide();
528
+ pagination.find('.loading-indicator').css({visibility: 'visible'});
483
529
  ActiveScaffold.auto_load_page(paginate_link.attr('href'), {auto_pagination: true});
484
530
  }
485
531
  },
@@ -489,6 +535,11 @@ var ActiveScaffold = {
489
535
  enable_js_form_buttons: function(element) {
490
536
  jQuery('.as-js-button', element).show();
491
537
  },
538
+ disable_optional_subforms: function(element) {
539
+ jQuery('.form-element select + .sub-form').each(function() {
540
+ jQuery("input:enabled,select:enabled,textarea:enabled", this).prop('disabled', true);
541
+ });
542
+ },
492
543
  sliders: function(element) {
493
544
  jQuery('.as-slider', element).each(function() {
494
545
  var opts = $(this).data('slider');
@@ -499,8 +550,13 @@ var ActiveScaffold = {
499
550
  load_embedded: function(element) {
500
551
  jQuery('.active-scaffold-component .load-embedded', element).each(function(index, item) {
501
552
  item = jQuery(item);
502
- item.closest('.active-scaffold-component').load(item.attr('href'), function() {
503
- jQuery(this).trigger('as:element_updated');
553
+ var indicator = item.closest('.active-scaffold-component').find('.loading-indicator');
554
+ indicator.css({visibility: 'visible'});
555
+ item.closest('.active-scaffold-component').load(item.attr('href'), function(response, status, xhr) {
556
+ if (status == 'error') {
557
+ indicator.css({visibility: 'hidden'});
558
+ indicator.after($('<p>').html(item.data('error-msg')).addClass("error-message message server-error"));
559
+ } else jQuery(this).trigger('as:element_updated');
504
560
  });
505
561
  });
506
562
  },
@@ -653,7 +709,7 @@ var ActiveScaffold = {
653
709
 
654
710
  disable_form: function(as_form, skip_loading_indicator) {
655
711
  if (typeof(as_form) == 'string') as_form = '#' + as_form;
656
- as_form = jQuery(as_form)
712
+ as_form = jQuery(as_form);
657
713
  var loading_indicator = jQuery('#' + as_form.attr('id').replace(/-form$/, '-loading-indicator'));
658
714
  if (!skip_loading_indicator && loading_indicator) loading_indicator.css('visibility','visible');
659
715
  jQuery('input[type=submit]', as_form).attr('disabled', 'disabled');
@@ -1023,6 +1079,7 @@ var ActiveScaffold = {
1023
1079
  url: url,
1024
1080
  data: params,
1025
1081
  type: 'post',
1082
+ dataType: 'script',
1026
1083
  beforeSend: function(xhr, settings) {
1027
1084
  element.nextAll('img.loading-indicator').css('visibility','visible');
1028
1085
  /* force to blur and save previous last_focus, because disable_form will trigger
@@ -1311,8 +1368,8 @@ ActiveScaffold.ActionLink.Record = ActiveScaffold.ActionLink.Abstract.extend({
1311
1368
  ActiveScaffold.update_row(this.target, refreshed_content_or_reload);
1312
1369
  } else if (this.refresh_url) {
1313
1370
  var target = this.target;
1314
- jQuery.get(this.refresh_url, function(e, status, response) {
1315
- ActiveScaffold.update_row(target, response.responseText);
1371
+ jQuery.get(this.refresh_url, function(e, status, xhr) {
1372
+ ActiveScaffold.update_row(target, xhr.responseText);
1316
1373
  });
1317
1374
  }
1318
1375
  }
@@ -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 select + .sub-form {
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 {