active_scaffold 3.2.20 → 3.3.0.rc
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.
- data/CHANGELOG +19 -13
- data/README +66 -0
- data/app/assets/javascripts/jquery/active_scaffold.js +156 -113
- data/app/assets/javascripts/jquery/active_scaffold_chosen.js +11 -0
- data/app/assets/javascripts/jquery/date_picker_bridge.js.erb +0 -1
- data/app/assets/javascripts/jquery/jquery.editinplace.js +132 -128
- data/app/assets/javascripts/prototype/active_scaffold.js +68 -25
- data/{frontends/default/views/_horizontal_subform_footer.html.erb → app/assets/javascripts/prototype/active_scaffold_chosen.js} +0 -0
- data/app/assets/stylesheets/active_scaffold_colors.css.scss +8 -1
- data/app/assets/stylesheets/active_scaffold_layout.css +14 -8
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_add_existing_form.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_base_form.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_create_form.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_create_form_on_list.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_field_search.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_form.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_form_association.html.erb +8 -3
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_form_association_footer.html.erb +5 -4
- data/app/views/active_scaffold_overrides/_form_association_record.html.erb +85 -0
- data/app/views/active_scaffold_overrides/_form_attribute.html.erb +23 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_form_hidden_attribute.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_form_messages.html.erb +0 -0
- data/app/views/active_scaffold_overrides/_horizontal_subform.html.erb +12 -0
- data/app/views/active_scaffold_overrides/_horizontal_subform_footer.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_horizontal_subform_header.html.erb +3 -2
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_human_conditions.html.erb +0 -0
- data/app/views/active_scaffold_overrides/_list.html.erb +35 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_list_calculations.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_list_column_headings.html.erb +0 -0
- data/app/views/active_scaffold_overrides/_list_header.html.erb +8 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_list_inline_adapter.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_list_messages.html.erb +4 -4
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_list_pagination.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_list_pagination_links.html.erb +0 -0
- data/app/views/active_scaffold_overrides/_list_record.html.erb +30 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_list_with_header.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_messages.html.erb +0 -0
- data/app/views/active_scaffold_overrides/_refresh_list.js.erb +1 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_render_field.js.erb +9 -1
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_row.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_search.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_search_attribute.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_show.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_show_columns.html.erb +0 -0
- data/app/views/active_scaffold_overrides/_update_actions.html.erb +9 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_update_calculations.js.erb +0 -0
- data/app/views/active_scaffold_overrides/_update_column.js.erb +16 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_update_form.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/_update_messages.js.erb +0 -0
- data/app/views/active_scaffold_overrides/_vertical_subform.html.erb +8 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/action_confirmation.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/add_existing.js.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/add_existing_form.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/create.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/delete.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/destroy.js.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/edit_associated.js.erb +1 -1
- data/{frontends/default/views → app/views/active_scaffold_overrides}/field_search.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/form_messages.js.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/list.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/on_action_update.js.erb +3 -3
- data/{frontends/default/views → app/views/active_scaffold_overrides}/on_create.js.erb +1 -1
- data/{frontends/default/views → app/views/active_scaffold_overrides}/on_mark.js.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/on_update.js.erb +4 -4
- data/{frontends/default/views → app/views/active_scaffold_overrides}/render_field.js.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/row.js.erb +1 -1
- data/{frontends/default/views → app/views/active_scaffold_overrides}/search.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/show.html.erb +0 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/update.html.erb +1 -1
- data/app/views/active_scaffold_overrides/update_column.js.erb +26 -0
- data/{frontends/default/views → app/views/active_scaffold_overrides}/update_row.js.erb +0 -0
- data/config/locales/de.yml +1 -0
- data/config/locales/en.yml +1 -0
- data/config/locales/es.yml +1 -0
- data/config/locales/fr.yml +1 -0
- data/config/locales/hu.yml +1 -0
- data/config/locales/ja.yml +1 -0
- data/config/locales/ru.yml +1 -0
- data/lib/active_scaffold.rb +14 -26
- data/lib/active_scaffold/actions/core.rb +14 -11
- data/lib/active_scaffold/actions/create.rb +3 -3
- data/lib/active_scaffold/actions/delete.rb +3 -0
- data/lib/active_scaffold/actions/list.rb +9 -6
- data/lib/active_scaffold/actions/mark.rb +1 -1
- data/lib/active_scaffold/actions/nested.rb +8 -6
- data/lib/active_scaffold/actions/show.rb +6 -1
- data/lib/active_scaffold/actions/update.rb +39 -19
- data/lib/active_scaffold/active_record_permissions.rb +29 -12
- data/lib/active_scaffold/attribute_params.rb +14 -7
- data/lib/active_scaffold/bridges/calendar_date_select.rb +1 -1
- data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +1 -2
- data/lib/active_scaffold/bridges/carrierwave/list_ui.rb +1 -1
- data/lib/active_scaffold/bridges/chosen.rb +14 -0
- data/lib/active_scaffold/bridges/chosen/helpers.rb +48 -0
- data/lib/active_scaffold/bridges/date_picker/helper.rb +7 -6
- data/lib/active_scaffold/bridges/dragonfly/form_ui.rb +1 -1
- data/lib/active_scaffold/bridges/dragonfly/list_ui.rb +1 -1
- data/lib/active_scaffold/bridges/file_column.rb +1 -1
- data/lib/active_scaffold/bridges/file_column/as_file_column_bridge.rb +1 -1
- data/lib/active_scaffold/bridges/file_column/file_column_helpers.rb +2 -2
- data/lib/active_scaffold/bridges/file_column/list_ui.rb +4 -4
- data/lib/active_scaffold/bridges/paperclip.rb +1 -1
- data/lib/active_scaffold/bridges/paperclip/form_ui.rb +1 -1
- data/lib/active_scaffold/bridges/paperclip/list_ui.rb +1 -1
- data/lib/active_scaffold/bridges/paperclip/paperclip_bridge_helpers.rb +1 -1
- data/lib/active_scaffold/bridges/shared/date_bridge.rb +1 -1
- data/lib/active_scaffold/bridges/tiny_mce/helpers.rb +1 -1
- data/lib/active_scaffold/config/core.rb +9 -2
- data/lib/active_scaffold/config/list.rb +9 -13
- data/lib/active_scaffold/config/nested.rb +11 -2
- data/lib/active_scaffold/data_structures/action_columns.rb +19 -5
- data/lib/active_scaffold/data_structures/action_link.rb +9 -2
- data/lib/active_scaffold/data_structures/action_links.rb +5 -36
- data/lib/active_scaffold/data_structures/column.rb +21 -21
- data/lib/active_scaffold/data_structures/nested_info.rb +31 -44
- data/lib/active_scaffold/extensions/action_controller_rescueing.rb +1 -0
- data/lib/active_scaffold/extensions/action_view_rendering.rb +30 -36
- data/lib/active_scaffold/extensions/reverse_associations.rb +10 -6
- data/lib/active_scaffold/extensions/routing_mapper.rb +6 -5
- data/lib/active_scaffold/extensions/unsaved_associated.rb +1 -1
- data/lib/active_scaffold/finder.rb +18 -10
- data/lib/active_scaffold/helpers/association_helpers.rb +21 -2
- data/lib/active_scaffold/helpers/controller_helpers.rb +14 -16
- data/lib/active_scaffold/helpers/form_column_helpers.rb +161 -21
- data/lib/active_scaffold/helpers/id_helpers.rb +7 -7
- data/lib/active_scaffold/helpers/list_column_helpers.rb +42 -92
- data/lib/active_scaffold/helpers/search_column_helpers.rb +10 -3
- data/lib/active_scaffold/helpers/show_column_helpers.rb +4 -9
- data/lib/active_scaffold/helpers/view_helpers.rb +278 -78
- data/lib/active_scaffold/version.rb +2 -2
- data/lib/generators/active_scaffold_controller/templates/controller.rb +1 -1
- data/test/bridges/paperclip_test.rb +2 -2
- data/vendor/assets/javascripts/jquery-ui-timepicker-addon.js +1882 -1276
- metadata +79 -80
- data/README.md +0 -67
- data/frontends/default/views/_action_group.html.erb +0 -24
- data/frontends/default/views/_form_attribute.html.erb +0 -23
- data/frontends/default/views/_horizontal_subform.html.erb +0 -22
- data/frontends/default/views/_horizontal_subform_record.html.erb +0 -43
- data/frontends/default/views/_list.html.erb +0 -18
- data/frontends/default/views/_list_actions.html.erb +0 -15
- data/frontends/default/views/_list_header.html.erb +0 -10
- data/frontends/default/views/_list_record.html.erb +0 -13
- data/frontends/default/views/_list_record_columns.html.erb +0 -8
- data/frontends/default/views/_refresh_list.js.erb +0 -1
- data/frontends/default/views/_update_actions.html.erb +0 -9
- data/frontends/default/views/_vertical_subform.html.erb +0 -12
- data/frontends/default/views/_vertical_subform_record.html.erb +0 -43
- data/frontends/default/views/refresh_list.js.erb +0 -2
- data/frontends/default/views/update_column.js.erb +0 -15
- data/lib/active_scaffold/extensions/active_record_offset.rb +0 -12
- data/lib/active_scaffold/extensions/nil_id_in_url_params.rb +0 -7
data/CHANGELOG
CHANGED
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
=
|
|
2
|
-
-
|
|
3
|
-
-
|
|
4
|
-
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
= master
|
|
2
|
+
- Unify field overrides and list_ui method signatures
|
|
3
|
+
- Improve performance removing some partials and adding some caching for helper overrides and UIs, and caching url generation for lists (optional)
|
|
4
|
+
- Drop support for rails 3.1
|
|
5
|
+
- Add HTML5 form fields
|
|
6
|
+
- Add :chosen form_ui, and :chosen and :multi_chosen search_ui
|
|
7
|
+
- Fix nested with has_one associations, and belongs_to associations with :list action
|
|
8
|
+
- Support optgroup in :select and :chosen form_ui
|
|
9
|
+
- Support render_form_field with multiple rows (rows with associated-record class)
|
|
10
|
+
- Support for updating columns, row or table after updating a column with inplace_edit
|
|
11
|
+
- Keep order for records in plural subforms, so new records are saved in same order as form order
|
|
12
|
+
- Support add_subgroup in horizontal subforms
|
|
13
|
+
- Improve support in helpers for using :select form_ui with polymorphic associations (needs to use a select to choose the class)
|
|
14
|
+
- Allow to create in nested has_many :through associations, when source association is a belongs_to
|
|
15
|
+
- Fix calculations using field_search with has_many includes
|
|
16
|
+
- Add support to ActiveScaffold.create_record_row to insert after or before of an element
|
|
17
|
+
- Add support for dynamic action group
|
|
18
|
+
|
|
19
|
+
= 3.2.17 (not released yet)
|
|
14
20
|
- fix constraints for columns with multiple columns in search_sql
|
|
15
21
|
- remove unauthorized collection links
|
|
16
22
|
- copy parameters and html_options on cloning action link
|
data/README
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
ActiveScaffold Gem/Plugin by Scott Rutherford (scott@caronsoftware.com), Richard White (rrwhite@gmail.com), Lance Ivy (lance@cainlevy.net), Ed Moss, Tim Harper and Sergio Cambra (sergio@entrecables.com)
|
|
2
|
+
|
|
3
|
+
Uses DhtmlHistory by Brad Neuberg (bkn3@columbia.edu)
|
|
4
|
+
http://codinginparadise.org
|
|
5
|
+
|
|
6
|
+
Uses Querystring by Adam Vandenberg
|
|
7
|
+
http://adamv.com/dev/javascript/querystring
|
|
8
|
+
|
|
9
|
+
Uses Paginator by Bruce Williams
|
|
10
|
+
http://paginator.rubyforge.org/
|
|
11
|
+
|
|
12
|
+
Supports RecordSelect by Lance Ivy
|
|
13
|
+
http://code.google.com/p/recordselect/
|
|
14
|
+
|
|
15
|
+
== Version Information
|
|
16
|
+
|
|
17
|
+
If you want to use the gem, add to your Gemfile:
|
|
18
|
+
gem "active_scaffold"
|
|
19
|
+
|
|
20
|
+
In case you would like to use most recent commit:
|
|
21
|
+
gem 'active_scaffold', :git => 'git://github.com/activescaffold/active_scaffold.git'
|
|
22
|
+
|
|
23
|
+
3.1.* and 3.2.* versions works with rails 3.1 and 3.2, 3.0.* versions with rails 3.0.
|
|
24
|
+
To use previous rails versions you will have to install the right branch as a plugin.
|
|
25
|
+
|
|
26
|
+
Active Scaffold master currently supports rails 3.1 and rails 3.2, you can use following branches for previous rails versions:
|
|
27
|
+
Rails 3.0.*: Active Scaffold rails-3.0
|
|
28
|
+
Rails 2.3.*: Active Scaffold rails-2.3 and v2.4
|
|
29
|
+
Rails 2.2.*: Active Scaffold rails-2.2
|
|
30
|
+
Rails 2.1.*: Active Scaffold rails-2.1
|
|
31
|
+
Rails < 2.1: Active Scaffold 1-1-stable (no guarantees)
|
|
32
|
+
|
|
33
|
+
Since Rails 2.3, render_component plugin is needed for nested and embedded scaffolds. It works with rails-2.3 branch from ewildgoose repository:
|
|
34
|
+
script/plugin install git://github.com/ewildgoose/render_component.git -r rails-2.3
|
|
35
|
+
|
|
36
|
+
Since Rails 3.0 render_component is not used for nesting, but is optional for embedded scaffolds.
|
|
37
|
+
For Rails 3.0, https://github.com/rails/verification.git is also needed, not in rails 3.1 or higher.
|
|
38
|
+
|
|
39
|
+
If you want to install as plugins under vendor/plugins, install these versions:
|
|
40
|
+
rails plugin install git://github.com/vhochstein/render_component.git
|
|
41
|
+
rails plugin install git://github.com/rails/verification.git
|
|
42
|
+
rails plugin install git://github.com/activescaffold/active_scaffold.git -r 'rails-3.0'
|
|
43
|
+
|
|
44
|
+
== Pick your own javascript framework
|
|
45
|
+
|
|
46
|
+
The Rails 3.0 version uses unobtrusive Javascript, so you are free to pick your javascript framework.
|
|
47
|
+
Out of the box Prototype or JQuery are supported for rails 3.1 and later. For rails 3.0 pick a JS file:
|
|
48
|
+
|
|
49
|
+
Prototype 1.7 (default js framework)
|
|
50
|
+
rails.js in git://github.com/vhochstein/prototype-ujs.git
|
|
51
|
+
|
|
52
|
+
JQuery 1.4.1, 1.4.2
|
|
53
|
+
https://github.com/vhochstein/jquery-ujs/raw/jquery1_4_2/src/rails.js
|
|
54
|
+
|
|
55
|
+
JQuery > 1.4.2
|
|
56
|
+
https://github.com/vhochstein/jquery-ujs/raw/master/src/rails.js
|
|
57
|
+
|
|
58
|
+
To configure the javascript framework when installed under vendor/plugins/
|
|
59
|
+
uncomment last line in config/initializers/active_scaffold.rb in order to use jquery instead of prototype.
|
|
60
|
+
That file is created when you install ActiveScaffold as a plugin.
|
|
61
|
+
|
|
62
|
+
To configure the javascript framework when installed as a gem:
|
|
63
|
+
Add a config/initializers/active_scaffold.rb containing:
|
|
64
|
+
ActiveScaffold.js_framework = :jquery # :prototype is the default
|
|
65
|
+
|
|
66
|
+
Released under the MIT license (included)
|
|
@@ -1,32 +1,40 @@
|
|
|
1
|
-
jQuery(document).ready(function() {
|
|
2
|
-
jQuery(
|
|
1
|
+
jQuery(document).ready(function($) {
|
|
2
|
+
jQuery(document).click(function(event) {
|
|
3
|
+
jQuery('.action_group.dyn ul').remove();
|
|
4
|
+
});
|
|
5
|
+
jQuery(document).on('ajax:complete', '.action_group.dyn ul a', function(event) {
|
|
6
|
+
var action_link = ActiveScaffold.find_action_link(event.target);
|
|
7
|
+
if (action_link.loading_indicator) action_link.loading_indicator.css('visibility','hidden');
|
|
8
|
+
jQuery(event.target).closest('.action_group.dyn ul').remove();
|
|
9
|
+
});
|
|
10
|
+
jQuery(document).on('ajax:beforeSend', 'form.as_form', function(event) {
|
|
3
11
|
var as_form = jQuery(this).closest("form");
|
|
4
|
-
if (as_form.
|
|
12
|
+
if (as_form.data('loading') == true) {
|
|
5
13
|
ActiveScaffold.disable_form(as_form);
|
|
6
14
|
}
|
|
7
15
|
return true;
|
|
8
16
|
});
|
|
9
17
|
|
|
10
|
-
jQuery(
|
|
18
|
+
jQuery(document).on('ajax:complete', 'form.as_form', function(event) {
|
|
11
19
|
var as_form = jQuery(this).closest("form");
|
|
12
|
-
if (as_form.
|
|
20
|
+
if (as_form.data('loading') == true) {
|
|
13
21
|
ActiveScaffold.enable_form(as_form);
|
|
14
22
|
}
|
|
15
23
|
});
|
|
16
|
-
jQuery(
|
|
24
|
+
jQuery(document).on('ajax:error', 'form.as_form', function(event, xhr, status, error) {
|
|
17
25
|
var as_div = jQuery(this).closest("div.active-scaffold");
|
|
18
26
|
if (as_div.length) {
|
|
19
27
|
ActiveScaffold.report_500_response(as_div);
|
|
20
28
|
}
|
|
21
29
|
});
|
|
22
|
-
jQuery(
|
|
30
|
+
jQuery(document).on('submit', 'form.as_form:not([data-remote])', function(event) {
|
|
23
31
|
var as_form = jQuery(this).closest("form");
|
|
24
|
-
if (as_form.
|
|
32
|
+
if (as_form.data('loading') == true) {
|
|
25
33
|
setTimeout("ActiveScaffold.disable_form('" + as_form.attr('id') + "')", 10);
|
|
26
34
|
}
|
|
27
35
|
return true;
|
|
28
36
|
});
|
|
29
|
-
jQuery(
|
|
37
|
+
jQuery(document).on('ajax:before', 'a.as_action', function(event) {
|
|
30
38
|
var action_link = ActiveScaffold.ActionLink.get(jQuery(this));
|
|
31
39
|
if (action_link) {
|
|
32
40
|
if (action_link.is_disabled()) {
|
|
@@ -38,7 +46,7 @@ jQuery(document).ready(function() {
|
|
|
38
46
|
}
|
|
39
47
|
return true;
|
|
40
48
|
});
|
|
41
|
-
jQuery(
|
|
49
|
+
jQuery(document).on('ajax:success', 'a.as_action', function(event, response) {
|
|
42
50
|
var action_link = ActiveScaffold.ActionLink.get(jQuery(this));
|
|
43
51
|
if (action_link) {
|
|
44
52
|
if (action_link.position) {
|
|
@@ -51,14 +59,14 @@ jQuery(document).ready(function() {
|
|
|
51
59
|
}
|
|
52
60
|
return true;
|
|
53
61
|
});
|
|
54
|
-
jQuery(
|
|
62
|
+
jQuery(document).on('ajax:complete', 'a.as_action', function(event) {
|
|
55
63
|
var action_link = ActiveScaffold.ActionLink.get(jQuery(this));
|
|
56
64
|
if (action_link) {
|
|
57
65
|
if (action_link.loading_indicator) action_link.loading_indicator.css('visibility','hidden');
|
|
58
66
|
}
|
|
59
67
|
return true;
|
|
60
68
|
});
|
|
61
|
-
jQuery(
|
|
69
|
+
jQuery(document).on('ajax:error', 'a.as_action', function(event, xhr, status, error) {
|
|
62
70
|
var action_link = ActiveScaffold.ActionLink.get(jQuery(this));
|
|
63
71
|
if (action_link) {
|
|
64
72
|
ActiveScaffold.report_500_response(action_link.scaffold_id());
|
|
@@ -66,7 +74,7 @@ jQuery(document).ready(function() {
|
|
|
66
74
|
}
|
|
67
75
|
return true;
|
|
68
76
|
});
|
|
69
|
-
jQuery(
|
|
77
|
+
jQuery(document).on('ajax:before', 'a.as_cancel', function(event) {
|
|
70
78
|
var as_cancel = jQuery(this);
|
|
71
79
|
var action_link = ActiveScaffold.find_action_link(as_cancel);
|
|
72
80
|
|
|
@@ -80,7 +88,7 @@ jQuery(document).ready(function() {
|
|
|
80
88
|
}
|
|
81
89
|
return true;
|
|
82
90
|
});
|
|
83
|
-
jQuery(
|
|
91
|
+
jQuery(document).on('ajax:success', 'a.as_cancel', function(event, response) {
|
|
84
92
|
var action_link = ActiveScaffold.find_action_link(jQuery(this));
|
|
85
93
|
|
|
86
94
|
if (action_link) {
|
|
@@ -92,28 +100,27 @@ jQuery(document).ready(function() {
|
|
|
92
100
|
}
|
|
93
101
|
return true;
|
|
94
102
|
});
|
|
95
|
-
jQuery(
|
|
103
|
+
jQuery(document).on('ajax:error', 'a.as_cancel', function(event, xhr, status, error) {
|
|
96
104
|
var action_link = ActiveScaffold.find_action_link(jQuery(this));
|
|
97
105
|
if (action_link) {
|
|
98
106
|
ActiveScaffold.report_500_response(action_link.scaffold_id());
|
|
99
107
|
}
|
|
100
108
|
return true;
|
|
101
109
|
});
|
|
102
|
-
jQuery(
|
|
110
|
+
jQuery(document).on('ajax:before', 'a.as_sort', function(event) {
|
|
103
111
|
var as_sort = jQuery(this);
|
|
104
|
-
var history_controller_id = as_sort.
|
|
112
|
+
var history_controller_id = as_sort.data('page-history');
|
|
105
113
|
if (history_controller_id) addActiveScaffoldPageToHistory(as_sort.attr('href'), history_controller_id);
|
|
106
114
|
as_sort.closest('th').addClass('loading');
|
|
107
115
|
return true;
|
|
108
116
|
});
|
|
109
|
-
jQuery(
|
|
117
|
+
jQuery(document).on('ajax:error', 'a.as_sort', function(event, xhr, status, error) {
|
|
110
118
|
var as_scaffold = jQuery(this).closest('.active-scaffold');
|
|
111
119
|
ActiveScaffold.report_500_response(as_scaffold);
|
|
112
120
|
return true;
|
|
113
121
|
});
|
|
114
|
-
jQuery(
|
|
122
|
+
jQuery(document).on('hover', 'td.in_place_editor_field', function(event) {
|
|
115
123
|
var td = jQuery(this), span = td.find('span.in_place_editor_field');
|
|
116
|
-
span.data(); // $ 1.4.2 workaround
|
|
117
124
|
if (event.type == 'mouseenter') {
|
|
118
125
|
if (td.hasClass('empty') || typeof(span.data('editInPlace')) === 'undefined') td.find('span').addClass("hover");
|
|
119
126
|
}
|
|
@@ -122,30 +129,30 @@ jQuery(document).ready(function() {
|
|
|
122
129
|
}
|
|
123
130
|
return true;
|
|
124
131
|
});
|
|
125
|
-
jQuery('td.in_place_editor_field, th.as_marked-column_heading'
|
|
132
|
+
jQuery(document).on('click', 'td.in_place_editor_field, th.as_marked-column_heading', function(event) {
|
|
126
133
|
var span = jQuery(this).find('span.in_place_editor_field');
|
|
127
134
|
span.data('addEmptyOnCancel', jQuery(this).hasClass('empty'));
|
|
128
135
|
jQuery(this).removeClass('empty');
|
|
129
136
|
if (span.data('editInPlace')) span.trigger('click.editInPlace');
|
|
130
137
|
else ActiveScaffold.in_place_editor_field_clicked(span);
|
|
131
138
|
});
|
|
132
|
-
jQuery(
|
|
139
|
+
jQuery(document).on('ajax:before', 'a.as_paginate',function(event) {
|
|
133
140
|
var as_paginate = jQuery(this);
|
|
134
|
-
var history_controller_id = as_paginate.
|
|
141
|
+
var history_controller_id = as_paginate.data('page-history');
|
|
135
142
|
if (history_controller_id) addActiveScaffoldPageToHistory(as_paginate.attr('href'), history_controller_id);
|
|
136
143
|
as_paginate.prevAll('img.loading-indicator').css('visibility','visible');
|
|
137
144
|
return true;
|
|
138
145
|
});
|
|
139
|
-
jQuery(
|
|
146
|
+
jQuery(document).on('ajax:error', 'a.as_paginate', function(event, xhr, status, error) {
|
|
140
147
|
var as_scaffold = jQuery(this).closest('.active-scaffold');
|
|
141
148
|
ActiveScaffold.report_500_response(as_scaffold);
|
|
142
149
|
return true;
|
|
143
150
|
});
|
|
144
|
-
jQuery(
|
|
151
|
+
jQuery(document).on('ajax:complete', 'a.as_paginate', function(event) {
|
|
145
152
|
jQuery(this).prevAll('img.loading-indicator').css('visibility','hidden');
|
|
146
153
|
return true;
|
|
147
154
|
});
|
|
148
|
-
jQuery('a.as_add_existing, a.as_replace_existing'
|
|
155
|
+
jQuery(document).on('ajax:before', 'a.as_add_existing, a.as_replace_existing', function(event) {
|
|
149
156
|
var id = jQuery(this).prev().val();
|
|
150
157
|
if (id) {
|
|
151
158
|
if (!jQuery(this).data('href')) jQuery(this).data('href', jQuery(this).attr('href'));
|
|
@@ -153,26 +160,26 @@ jQuery(document).ready(function() {
|
|
|
153
160
|
return true;
|
|
154
161
|
} else return false;
|
|
155
162
|
});
|
|
156
|
-
jQuery('input.update_form:not(.recordselect), textarea.update_form, select.update_form'
|
|
163
|
+
jQuery(document).on('change', 'input.update_form:not(.recordselect), textarea.update_form, select.update_form', function(event) {
|
|
157
164
|
var element = jQuery(this);
|
|
158
165
|
var value = element.is("input:checkbox:not(:checked)") ? null : element.val();
|
|
159
|
-
ActiveScaffold.update_column(element, element.
|
|
166
|
+
ActiveScaffold.update_column(element, element.data('update_url'), element.data('update_send_form'), element.attr('id'), value);
|
|
160
167
|
return true;
|
|
161
168
|
});
|
|
162
|
-
jQuery(
|
|
169
|
+
jQuery(document).on('recordselect:change', 'input.recordselect.update_form', function(event, id, label) {
|
|
163
170
|
var element = jQuery(this);
|
|
164
|
-
ActiveScaffold.update_column(element, element.
|
|
171
|
+
ActiveScaffold.update_column(element, element.data('update_url'), element.data('update_send_form'), element.attr('id'), id);
|
|
165
172
|
return true;
|
|
166
173
|
});
|
|
167
174
|
|
|
168
|
-
jQuery(
|
|
175
|
+
jQuery(document).on('change', 'select.as_search_range_option', function(event) {
|
|
169
176
|
var element = jQuery(this);
|
|
170
177
|
ActiveScaffold[element.val() == 'BETWEEN' ? 'show' : 'hide'](element.closest('dd').find('.as_search_range_between'));
|
|
171
178
|
ActiveScaffold[(element.val() == 'null' || element.val() == 'not_null') ? 'hide' : 'show'](element.attr('id').replace(/_opt/, '_numeric'));
|
|
172
179
|
return true;
|
|
173
180
|
});
|
|
174
181
|
|
|
175
|
-
jQuery(
|
|
182
|
+
jQuery(document).on('change', 'select.as_search_date_time_option', function(event) {
|
|
176
183
|
var element = jQuery(this);
|
|
177
184
|
ActiveScaffold[!(element.val() == 'PAST' || element.val() == 'FUTURE' || element.val() == 'RANGE') ? 'show' : 'hide'](element.attr('id').replace(/_opt/, '_numeric'));
|
|
178
185
|
ActiveScaffold[(element.val() == 'PAST' || element.val() == 'FUTURE') ? 'show' : 'hide'](element.attr('id').replace(/_opt/, '_trend'));
|
|
@@ -180,18 +187,18 @@ jQuery(document).ready(function() {
|
|
|
180
187
|
return true;
|
|
181
188
|
});
|
|
182
189
|
|
|
183
|
-
jQuery(
|
|
190
|
+
jQuery(document).on('change', 'select.as_update_date_operator', function(event) {
|
|
184
191
|
ActiveScaffold[jQuery(this).val() == 'REPLACE' ? 'show' : 'hide'](jQuery(this).next());
|
|
185
192
|
ActiveScaffold[jQuery(this).val() == 'REPLACE' ? 'hide' : 'show'](jQuery(this).next().next());
|
|
186
193
|
return true;
|
|
187
194
|
});
|
|
188
195
|
|
|
189
|
-
jQuery('a[data-popup]'
|
|
196
|
+
jQuery(document).on('click', 'a[data-popup]', function(e) {
|
|
190
197
|
window.open(jQuery(this).attr('href'));
|
|
191
198
|
e.preventDefault();
|
|
192
199
|
});
|
|
193
200
|
|
|
194
|
-
jQuery(
|
|
201
|
+
jQuery(document).on("click", '.hover_click', function(event) {
|
|
195
202
|
var element = jQuery(this);
|
|
196
203
|
var ul_element = element.children('ul').first();
|
|
197
204
|
if (ul_element.is(':visible')) {
|
|
@@ -201,7 +208,7 @@ jQuery(document).ready(function() {
|
|
|
201
208
|
}
|
|
202
209
|
return false;
|
|
203
210
|
});
|
|
204
|
-
jQuery('.hover_click a.as_action'
|
|
211
|
+
jQuery(document).on('click', '.hover_click a.as_action', function(event) {
|
|
205
212
|
var element = jQuery(this).closest('.hover_click');
|
|
206
213
|
if (element) {
|
|
207
214
|
element.find('ul').hide();
|
|
@@ -209,10 +216,11 @@ jQuery(document).ready(function() {
|
|
|
209
216
|
return true;
|
|
210
217
|
});
|
|
211
218
|
|
|
212
|
-
jQuery('.message a.close'
|
|
219
|
+
jQuery(document).on('click', '.message a.close', function(e) {
|
|
213
220
|
ActiveScaffold.hide(jQuery(this).closest('.message'));
|
|
214
221
|
e.preventDefault();
|
|
215
222
|
});
|
|
223
|
+
|
|
216
224
|
});
|
|
217
225
|
|
|
218
226
|
/* Simple Inheritance
|
|
@@ -288,7 +296,7 @@ jQuery(document).ready(function() {
|
|
|
288
296
|
*/
|
|
289
297
|
|
|
290
298
|
if (typeof(jQuery.fn.delayedObserver) === 'undefined') {
|
|
291
|
-
(function() {
|
|
299
|
+
(function($) {
|
|
292
300
|
var delayedObserverStack = [];
|
|
293
301
|
var observed;
|
|
294
302
|
|
|
@@ -334,7 +342,7 @@ if (typeof(jQuery.fn.delayedObserver) === 'undefined') {
|
|
|
334
342
|
});
|
|
335
343
|
}
|
|
336
344
|
});
|
|
337
|
-
})();
|
|
345
|
+
})(jQuery);
|
|
338
346
|
};
|
|
339
347
|
|
|
340
348
|
|
|
@@ -434,9 +442,10 @@ var ActiveScaffold = {
|
|
|
434
442
|
return element;
|
|
435
443
|
},
|
|
436
444
|
|
|
437
|
-
remove: function(element) {
|
|
445
|
+
remove: function(element, callback) {
|
|
438
446
|
if (typeof(element) == 'string') element = '#' + element;
|
|
439
447
|
jQuery(element).remove();
|
|
448
|
+
if (callback) callback();
|
|
440
449
|
},
|
|
441
450
|
|
|
442
451
|
update_inplace_edit: function(element, value, empty) {
|
|
@@ -460,22 +469,23 @@ var ActiveScaffold = {
|
|
|
460
469
|
jQuery(element).get(0).reset();
|
|
461
470
|
},
|
|
462
471
|
|
|
463
|
-
disable_form: function(as_form) {
|
|
472
|
+
disable_form: function(as_form, skip_loading_indicator) {
|
|
464
473
|
if (typeof(as_form) == 'string') as_form = '#' + as_form;
|
|
465
474
|
as_form = jQuery(as_form)
|
|
466
475
|
var loading_indicator = jQuery('#' + as_form.attr('id').replace(/-form$/, '-loading-indicator'));
|
|
467
|
-
if (loading_indicator) loading_indicator.css('visibility','visible');
|
|
476
|
+
if (!skip_loading_indicator && loading_indicator) loading_indicator.css('visibility','visible');
|
|
468
477
|
jQuery('input[type=submit]', as_form).attr('disabled', 'disabled');
|
|
469
|
-
|
|
478
|
+
// data-remote-disabled attr instead of set data because is used to in selector later
|
|
479
|
+
jQuery("input:enabled,select:enabled,textarea:enabled", as_form).attr('disabled', 'disabled').attr('data-remove-disabled', true);
|
|
470
480
|
},
|
|
471
481
|
|
|
472
|
-
enable_form: function(as_form) {
|
|
482
|
+
enable_form: function(as_form, skip_loading_indicator) {
|
|
473
483
|
if (typeof(as_form) == 'string') as_form = '#' + as_form;
|
|
474
484
|
as_form = jQuery(as_form)
|
|
475
485
|
var loading_indicator = jQuery('#' + as_form.attr('id').replace(/-form$/, '-loading-indicator'));
|
|
476
|
-
if (loading_indicator) loading_indicator.css('visibility','hidden');
|
|
486
|
+
if (!skip_loading_indicator && loading_indicator) loading_indicator.css('visibility','hidden');
|
|
477
487
|
jQuery('input[type=submit]', as_form).removeAttr('disabled');
|
|
478
|
-
|
|
488
|
+
jQuery("input[data-remove-disabled],select[data-remove-disabled],textarea[data-remove-disabled]", as_form).removeAttr('disabled data-remove-disabled');
|
|
479
489
|
},
|
|
480
490
|
|
|
481
491
|
focus_first_element_of_form: function(form_element) {
|
|
@@ -498,11 +508,24 @@ var ActiveScaffold = {
|
|
|
498
508
|
} else {
|
|
499
509
|
new_row = tbody.append(html).children().last();
|
|
500
510
|
}
|
|
511
|
+
} else if (typeof options.insert_at == 'object') {
|
|
512
|
+
var insert_method, get_method, row, id;
|
|
513
|
+
if (options.insert_at.after) {
|
|
514
|
+
insert_method = 'after';
|
|
515
|
+
get_method = 'next';
|
|
516
|
+
} else {
|
|
517
|
+
insert_method = 'before';
|
|
518
|
+
get_method = 'prev';
|
|
519
|
+
}
|
|
520
|
+
if (id = options.insert_at[insert_method]) row = tbody.children('#' + id);
|
|
521
|
+
if (row && row.length) {
|
|
522
|
+
new_row = row[insert_method](html)[get_method]();
|
|
523
|
+
}
|
|
501
524
|
}
|
|
502
525
|
this.stripe(tbody);
|
|
503
526
|
this.hide_empty_message(tbody);
|
|
504
527
|
this.increment_record_count(tbody.closest('div.active-scaffold'));
|
|
505
|
-
|
|
528
|
+
this.highlight(new_row);
|
|
506
529
|
},
|
|
507
530
|
|
|
508
531
|
create_record_row_from_url: function(active_scaffold_id, url, options) {
|
|
@@ -525,26 +548,17 @@ var ActiveScaffold = {
|
|
|
525
548
|
}
|
|
526
549
|
}
|
|
527
550
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
551
|
+
ActiveScaffold.remove(row, function() {
|
|
552
|
+
ActiveScaffold.stripe(tbody);
|
|
553
|
+
ActiveScaffold.decrement_record_count(tbody.closest('div.active-scaffold'));
|
|
554
|
+
ActiveScaffold.reload_if_empty(tbody, page_reload_url);
|
|
555
|
+
});
|
|
532
556
|
},
|
|
533
557
|
|
|
534
558
|
delete_subform_record: function(record) {
|
|
535
559
|
if (typeof(record) == 'string') record = '#' + record;
|
|
536
|
-
record = jQuery(record);
|
|
537
|
-
var errors = record.prev();
|
|
538
|
-
if (errors.hasClass('association-record-errors')) {
|
|
539
|
-
this.remove(errors);
|
|
540
|
-
}
|
|
541
|
-
var associated = jQuery(record).next();
|
|
560
|
+
record = jQuery(record).closest('.sub-form-record');
|
|
542
561
|
this.remove(record);
|
|
543
|
-
while (associated.hasClass('associated-record')) {
|
|
544
|
-
record = associated;
|
|
545
|
-
associated = jQuery(record).next();
|
|
546
|
-
this.remove(record);
|
|
547
|
-
}
|
|
548
562
|
},
|
|
549
563
|
|
|
550
564
|
report_500_response: function(active_scaffold_id) {
|
|
@@ -562,6 +576,13 @@ var ActiveScaffold = {
|
|
|
562
576
|
element = jQuery(element);
|
|
563
577
|
return ActiveScaffold.ActionLink.get(element.is('.actions a') ? element : element.closest('.as_adapter'));
|
|
564
578
|
},
|
|
579
|
+
|
|
580
|
+
display_dynamic_action_group: function(link, html) {
|
|
581
|
+
if (typeof(link) == 'string') link = jQuery('#' + link);
|
|
582
|
+
link.next('ul').remove();
|
|
583
|
+
link.closest('td').addClass('action_group dyn');
|
|
584
|
+
link.after(html);
|
|
585
|
+
},
|
|
565
586
|
|
|
566
587
|
scroll_to: function(element, checkInViewport) {
|
|
567
588
|
if (typeof checkInViewport == 'undefined') checkInViewport = true;
|
|
@@ -578,18 +599,23 @@ var ActiveScaffold = {
|
|
|
578
599
|
},
|
|
579
600
|
|
|
580
601
|
process_checkbox_inplace_edit: function(checkbox, options) {
|
|
581
|
-
var checked = checkbox.is(':checked');
|
|
602
|
+
var checked = checkbox.is(':checked'), td = checkbox.closest('td');
|
|
582
603
|
if (checked === true) options['params'] += '&value=1';
|
|
583
604
|
jQuery.ajax({
|
|
584
605
|
url: options.url,
|
|
585
606
|
type: "POST",
|
|
586
607
|
data: options['params'],
|
|
587
608
|
dataType: options.ajax_data_type,
|
|
588
|
-
|
|
609
|
+
beforeSend: function(request, settings) {
|
|
610
|
+
if (options.beforeSend) options.beforeSend.call(checkbox, request, settings);
|
|
589
611
|
checkbox.attr('disabled', 'disabled');
|
|
612
|
+
td.closest('tr').find('td.actions .loading-indicator').css('visibility','visible');
|
|
590
613
|
},
|
|
591
614
|
complete: function(request){
|
|
592
615
|
checkbox.removeAttr('disabled');
|
|
616
|
+
},
|
|
617
|
+
success: function(request){
|
|
618
|
+
td.closest('tr').find('td.actions .loading-indicator').css('visibility','hidden');
|
|
593
619
|
}
|
|
594
620
|
});
|
|
595
621
|
},
|
|
@@ -637,16 +663,18 @@ var ActiveScaffold = {
|
|
|
637
663
|
content = jQuery(content);
|
|
638
664
|
if (options.singular == false) {
|
|
639
665
|
if (!(options.id && jQuery('#' + options.id).size() > 0)) {
|
|
640
|
-
var
|
|
641
|
-
|
|
666
|
+
var tfoot = element.find('tfoot');
|
|
667
|
+
if (tfoot.length) tfoot.before(content);
|
|
668
|
+
else element.append(content);
|
|
669
|
+
content.trigger('as:element_created');
|
|
642
670
|
}
|
|
643
671
|
} else {
|
|
644
|
-
var current = jQuery('#' + element.attr('id') + ' .
|
|
672
|
+
var current = jQuery('#' + element.attr('id') + ' .sub-form-record')
|
|
645
673
|
if (current[0]) {
|
|
646
674
|
this.replace(current[0], content);
|
|
647
675
|
} else {
|
|
648
676
|
element.prepend(content);
|
|
649
|
-
content.trigger('as:
|
|
677
|
+
content.trigger('as:element_created');
|
|
650
678
|
}
|
|
651
679
|
}
|
|
652
680
|
},
|
|
@@ -654,7 +682,7 @@ var ActiveScaffold = {
|
|
|
654
682
|
render_form_field: function(source, content, options) {
|
|
655
683
|
if (typeof(source) == 'string') source = '#' + source;
|
|
656
684
|
var source = jQuery(source);
|
|
657
|
-
var element = source.closest('.association-record');
|
|
685
|
+
var element = source.closest('.association-record').nextUntil('.association-record').andSelf();
|
|
658
686
|
if (element.length == 0) {
|
|
659
687
|
element = source.closest('form > ol.form');
|
|
660
688
|
}
|
|
@@ -669,21 +697,6 @@ var ActiveScaffold = {
|
|
|
669
697
|
}
|
|
670
698
|
},
|
|
671
699
|
|
|
672
|
-
sortable: function(element, controller, options, url_params) {
|
|
673
|
-
if (typeof(element) == 'string') element = '#' + element;
|
|
674
|
-
var element = jQuery(element);
|
|
675
|
-
var sortable_options = jQuery.extend({}, options);
|
|
676
|
-
if (options.update === true) {
|
|
677
|
-
url_params.authenticity_token = jQuery('meta[name=csrf-param]').attr('content');
|
|
678
|
-
sortable_options.update = function(event, ui) {
|
|
679
|
-
var url = controller + '/' + options.action + '?'
|
|
680
|
-
url += jQuery(this).sortable('serialize',{key: encodeURIComponent(jQuery(this).attr('id') + '[]'), expression:/^[^_-](?:[A-Za-z0-9_-]*)-(.*)-row$/});
|
|
681
|
-
jQuery.post(url.append_params(url_params));
|
|
682
|
-
}
|
|
683
|
-
}
|
|
684
|
-
element.sortable(sortable_options);
|
|
685
|
-
},
|
|
686
|
-
|
|
687
700
|
record_select_onselect: function(edit_associated_url, active_scaffold_id, id){
|
|
688
701
|
jQuery.ajax({
|
|
689
702
|
url: edit_associated_url.split('--ID--').join(id),
|
|
@@ -721,7 +734,6 @@ var ActiveScaffold = {
|
|
|
721
734
|
},
|
|
722
735
|
|
|
723
736
|
in_place_editor_field_clicked: function(span) {
|
|
724
|
-
span.data(); // $ 1.4.2 workaround
|
|
725
737
|
// test editor is open
|
|
726
738
|
if (typeof(span.data('editInPlace')) === 'undefined') {
|
|
727
739
|
var options = {show_buttons: true,
|
|
@@ -729,8 +741,12 @@ var ActiveScaffold = {
|
|
|
729
741
|
element_id: 'editor_id',
|
|
730
742
|
ajax_data_type: "script",
|
|
731
743
|
delegate: {
|
|
732
|
-
willCloseEditInPlace: function(span, options
|
|
744
|
+
willCloseEditInPlace: function(span, options) {
|
|
733
745
|
if (span.data('addEmptyOnCancel')) span.closest('td').addClass('empty');
|
|
746
|
+
span.closest('tr').find('td.actions .loading-indicator').css('visibility','visible');
|
|
747
|
+
},
|
|
748
|
+
didCloseEditInPlace: function(span, options) {
|
|
749
|
+
span.closest('tr').find('td.actions .loading-indicator').css('visibility','hidden');
|
|
734
750
|
}
|
|
735
751
|
},
|
|
736
752
|
update_value: 'value'},
|
|
@@ -764,11 +780,11 @@ var ActiveScaffold = {
|
|
|
764
780
|
|
|
765
781
|
if (csrf_param) options['params'] = csrf_param.attr('content') + '=' + csrf_token.attr('content');
|
|
766
782
|
|
|
767
|
-
if (span.closest('div.active-scaffold').
|
|
783
|
+
if (span.closest('div.active-scaffold').data('eid')) {
|
|
768
784
|
if (options['params'].length > 0) {
|
|
769
785
|
options['params'] += "&";
|
|
770
786
|
}
|
|
771
|
-
options['params'] += ("eid=" + span.closest('div.active-scaffold').
|
|
787
|
+
options['params'] += ("eid=" + span.closest('div.active-scaffold').data('eid'));
|
|
772
788
|
}
|
|
773
789
|
|
|
774
790
|
if (mode === 'clone') {
|
|
@@ -782,6 +798,26 @@ var ActiveScaffold = {
|
|
|
782
798
|
if (column_heading.data('ie-plural')) plural = true;
|
|
783
799
|
options.field_type = 'remote';
|
|
784
800
|
options.editor_url = render_url.replace(/__id__/, record_id)
|
|
801
|
+
if (!options.delegate) options.delegate = {}
|
|
802
|
+
options.delegate.didOpenEditInPlace = function(dom) { dom.trigger('as:element_updated'); }
|
|
803
|
+
}
|
|
804
|
+
var actions, forms;
|
|
805
|
+
options.beforeSend = function(xhr, settings) {
|
|
806
|
+
switch (span.data('ie-update')) {
|
|
807
|
+
case 'update_row':
|
|
808
|
+
actions = span.closest('tr').find('.actions a:not(.disabled)').addClass('disabled');
|
|
809
|
+
break;
|
|
810
|
+
case 'update_table':
|
|
811
|
+
var table = span.closest('.as_content');
|
|
812
|
+
actions = table.find('.actions a:not(.disabled)').addClass('disabled');
|
|
813
|
+
forms = table.find('.as_form');
|
|
814
|
+
ActiveScaffold.disable_form(forms);
|
|
815
|
+
break;
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
options.error = options.success = function() {
|
|
819
|
+
if (actions) actions.removeClass('disabled');
|
|
820
|
+
if (forms) ActiveScaffold.enable_form(forms);
|
|
785
821
|
}
|
|
786
822
|
if (mode === 'inline_checkbox') {
|
|
787
823
|
ActiveScaffold.process_checkbox_inplace_edit(span.find('input:checkbox'), options);
|
|
@@ -797,11 +833,13 @@ var ActiveScaffold = {
|
|
|
797
833
|
var params = null;
|
|
798
834
|
|
|
799
835
|
if (send_form) {
|
|
800
|
-
var selector;
|
|
836
|
+
var selector, base = as_form;
|
|
837
|
+
if (send_form == 'row') base = element.closest('.association-record, form');
|
|
801
838
|
if (selector = element.data('update_send_form_selector'))
|
|
802
|
-
params =
|
|
803
|
-
else params =
|
|
804
|
-
|
|
839
|
+
params = base.find(selector).serialize();
|
|
840
|
+
else if (send_form != as_form) params = base.find(':input').serialize();
|
|
841
|
+
else base.serialize();
|
|
842
|
+
params += '&_method=&' + jQuery.param({"source_id": source_id});
|
|
805
843
|
} else {
|
|
806
844
|
params = {value: val};
|
|
807
845
|
params.source_id = source_id;
|
|
@@ -810,6 +848,7 @@ var ActiveScaffold = {
|
|
|
810
848
|
jQuery.ajax({
|
|
811
849
|
url: url,
|
|
812
850
|
data: params,
|
|
851
|
+
type: 'post',
|
|
813
852
|
beforeSend: function(event) {
|
|
814
853
|
element.nextAll('img.loading-indicator').css('visibility','visible');
|
|
815
854
|
ActiveScaffold.disable_form(as_form);
|
|
@@ -828,7 +867,7 @@ var ActiveScaffold = {
|
|
|
828
867
|
},
|
|
829
868
|
|
|
830
869
|
draggable_lists: function(element) {
|
|
831
|
-
jQuery('#' + element).draggable_lists();
|
|
870
|
+
jQuery('ul#' + element).draggable_lists();
|
|
832
871
|
}
|
|
833
872
|
}
|
|
834
873
|
|
|
@@ -897,15 +936,15 @@ ActiveScaffold.ActionLink = {
|
|
|
897
936
|
element.data(); // $ 1.4.2 workaround
|
|
898
937
|
if (typeof(element.data('action_link')) === 'undefined' && !element.hasClass('as_adapter')) {
|
|
899
938
|
var parent = element.closest('.actions');
|
|
900
|
-
if (parent.length === 0) {
|
|
939
|
+
if (parent.length === 0 || parent.is('td')) {
|
|
901
940
|
// maybe an column action_link
|
|
902
|
-
parent = element.
|
|
941
|
+
parent = element.closest('tr.record');
|
|
903
942
|
}
|
|
904
|
-
if (parent
|
|
943
|
+
if (parent.is('tr')) {
|
|
905
944
|
// record action
|
|
906
|
-
parent = parent.closest('tr.record');
|
|
907
945
|
var target = parent.find('a.as_action');
|
|
908
946
|
var loading_indicator = parent.find('td.actions .loading-indicator');
|
|
947
|
+
if (!loading_indicator.length) loading_indicator = element.parent().find('.loading-indicator');
|
|
909
948
|
new ActiveScaffold.Actions.Record(target, parent, loading_indicator);
|
|
910
949
|
} else if (parent && parent.is('div')) {
|
|
911
950
|
//table action
|
|
@@ -923,12 +962,12 @@ ActiveScaffold.ActionLink.Abstract = Class.extend({
|
|
|
923
962
|
init: function(a, target, loading_indicator) {
|
|
924
963
|
this.tag = jQuery(a);
|
|
925
964
|
this.url = this.tag.attr('href');
|
|
926
|
-
this.method = this.tag.
|
|
965
|
+
this.method = this.tag.data('method') || 'get';
|
|
927
966
|
this.target = target;
|
|
928
967
|
this.loading_indicator = loading_indicator;
|
|
929
968
|
this.hide_target = false;
|
|
930
|
-
this.position = this.tag.
|
|
931
|
-
this.action = this.tag.
|
|
969
|
+
this.position = this.tag.data('position');
|
|
970
|
+
this.action = this.tag.data('action');
|
|
932
971
|
|
|
933
972
|
this.tag.data('action_link', this);
|
|
934
973
|
return this;
|
|
@@ -943,10 +982,17 @@ ActiveScaffold.ActionLink.Abstract = Class.extend({
|
|
|
943
982
|
},
|
|
944
983
|
|
|
945
984
|
close: function() {
|
|
946
|
-
this
|
|
947
|
-
this.adapter
|
|
948
|
-
|
|
949
|
-
|
|
985
|
+
var link = this;
|
|
986
|
+
ActiveScaffold.remove(this.adapter, function() {
|
|
987
|
+
link.enable();
|
|
988
|
+
if (link.hide_target) link.target.show();
|
|
989
|
+
if (ActiveScaffold.config.scroll_on_close) ActiveScaffold.scroll_to(link.target.attr('id'), ActiveScaffold.config.scroll_on_close == 'checkInViewport');
|
|
990
|
+
});
|
|
991
|
+
},
|
|
992
|
+
|
|
993
|
+
reload: function() {
|
|
994
|
+
this.close();
|
|
995
|
+
this.open();
|
|
950
996
|
},
|
|
951
997
|
|
|
952
998
|
get_new_adapter_id: function() {
|
|
@@ -985,6 +1031,9 @@ ActiveScaffold.ActionLink.Abstract = Class.extend({
|
|
|
985
1031
|
this.adapter.addClass('as_adapter');
|
|
986
1032
|
this.adapter.data('action_link', this);
|
|
987
1033
|
if (this.refresh_url) jQuery('.as_cancel', this.adapter).attr('href', this.refresh_url);
|
|
1034
|
+
},
|
|
1035
|
+
keep_open: function() {
|
|
1036
|
+
return this.tag.data('keep-open');
|
|
988
1037
|
}
|
|
989
1038
|
});
|
|
990
1039
|
|
|
@@ -994,7 +1043,7 @@ ActiveScaffold.ActionLink.Abstract = Class.extend({
|
|
|
994
1043
|
ActiveScaffold.Actions.Record = ActiveScaffold.Actions.Abstract.extend({
|
|
995
1044
|
instantiate_link: function(link) {
|
|
996
1045
|
var l = new ActiveScaffold.ActionLink.Record(link, this.target, this.loading_indicator);
|
|
997
|
-
var refresh = this.target.
|
|
1046
|
+
var refresh = this.target.data('refresh');
|
|
998
1047
|
if (refresh) l.refresh_url = refresh;
|
|
999
1048
|
|
|
1000
1049
|
if (l.position) {
|
|
@@ -1010,9 +1059,8 @@ ActiveScaffold.ActionLink.Record = ActiveScaffold.ActionLink.Abstract.extend({
|
|
|
1010
1059
|
close_previous_adapter: function() {
|
|
1011
1060
|
var _this = this;
|
|
1012
1061
|
jQuery.each(this.set.links, function(index, item) {
|
|
1013
|
-
if (item.url != _this.url && item.is_disabled() && item.adapter) {
|
|
1014
|
-
item.enable();
|
|
1015
|
-
item.adapter.remove();
|
|
1062
|
+
if (item.url != _this.url && item.is_disabled() && !item.keep_open() && item.adapter) {
|
|
1063
|
+
ActiveScaffold.remove(item.adapter, function () { item.enable(); });
|
|
1016
1064
|
}
|
|
1017
1065
|
});
|
|
1018
1066
|
},
|
|
@@ -1105,9 +1153,4 @@ ActiveScaffold.ActionLink.Table = ActiveScaffold.ActionLink.Abstract.extend({
|
|
|
1105
1153
|
}
|
|
1106
1154
|
ActiveScaffold.highlight(this.adapter.find('td').first().children());
|
|
1107
1155
|
},
|
|
1108
|
-
|
|
1109
|
-
reload: function() {
|
|
1110
|
-
this.close();
|
|
1111
|
-
this.open();
|
|
1112
|
-
},
|
|
1113
1156
|
});
|