active_scaffold_sortable 3.3.0 → 3.3.1
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/jquery/active_scaffold_sortable.js +11 -0
- data/lib/active_scaffold_sortable.rb +2 -2
- data/lib/active_scaffold_sortable/attribute_params.rb +2 -6
- data/lib/active_scaffold_sortable/core.rb +2 -6
- data/lib/active_scaffold_sortable/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1492534bbf5bf0ae3b14f8083cb416449e963d56
|
4
|
+
data.tar.gz: 240734c1c652fe8410ed54a51cdfb8087eb8dbb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7009981cb6e297c4794fc29c9e32399f132f2d560eb092f01d9ab177fee1ef9202892ddf224d8de04b4618d55d36f62a8f73b6ef9e01f941b31e6d7bae6008cd
|
7
|
+
data.tar.gz: a806fccf5949785ccef9cd6878316f68b777bef939cda32a3923668a4af7393e19d1c8e5c19dbc8c1e0cd963b4a460f00cb34da563008ebcadd7e80f76b03c78
|
@@ -8,10 +8,19 @@ ActiveScaffold.update_positions = function(content) {
|
|
8
8
|
ActiveScaffold.sortable = function(element) {
|
9
9
|
var fixHelper = function(e, ui) {
|
10
10
|
ui.find('*').each(function() {
|
11
|
+
$(this).data('sortable-prev-style', $(this).attr('style'));
|
11
12
|
$(this).width($(this).width());
|
12
13
|
});
|
13
14
|
return ui;
|
14
15
|
};
|
16
|
+
var restoreHelper = function(ui) {
|
17
|
+
ui.find('*').each(function() {
|
18
|
+
var style = $(this).data('sortable-prev-style');
|
19
|
+
if (style) $(this).attr('style', style);
|
20
|
+
else $(this).removeAttr('style');
|
21
|
+
$(this).removeData('sortable-prev-style');
|
22
|
+
});
|
23
|
+
};
|
15
24
|
var form, content, sortable_options = {containment: 'parent', tolerance: 'pointer', forcePlaceholderSize: true, placeholder: 'sortable-highlight', helper: fixHelper};
|
16
25
|
if (typeof(element) == 'string') {
|
17
26
|
content = jQuery('#' + element);
|
@@ -26,6 +35,7 @@ ActiveScaffold.sortable = function(element) {
|
|
26
35
|
|
27
36
|
if (form) {
|
28
37
|
sortable_options.update = function(event, ui) {
|
38
|
+
restoreHelper(content);
|
29
39
|
ActiveScaffold.update_positions(content);
|
30
40
|
};
|
31
41
|
} else {
|
@@ -33,6 +43,7 @@ ActiveScaffold.sortable = function(element) {
|
|
33
43
|
if (url) {
|
34
44
|
var csrf = jQuery('meta[name=csrf-param]').attr('content') + '=' + jQuery('meta[name=csrf-token]').attr('content');
|
35
45
|
sortable_options.update = function(event, ui) {
|
46
|
+
restoreHelper(content);
|
36
47
|
var body = jQuery(this).sortable('serialize',{key: encodeURIComponent(jQuery(this).attr('id') + '[]'), expression: new RegExp(element.data('format'))});
|
37
48
|
var params = element.data('with');
|
38
49
|
if (params) body += '&' + params;
|
@@ -24,7 +24,7 @@ module ActiveScaffold
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
ActionView::Base.send :include, ActiveScaffoldSortable::ViewHelpers
|
27
|
-
ActiveScaffold::Config::Core.send :
|
28
|
-
ActiveScaffold::AttributeParams.send :
|
27
|
+
ActiveScaffold::Config::Core.send :prepend, ActiveScaffoldSortable::Core
|
28
|
+
ActiveScaffold::AttributeParams.send :prepend, ActiveScaffoldSortable::AttributeParams
|
29
29
|
ActiveScaffold.stylesheets << 'active_scaffold_sortable'
|
30
30
|
ActiveScaffold.javascripts << 'active_scaffold_sortable'
|
@@ -1,11 +1,7 @@
|
|
1
1
|
module ActiveScaffoldSortable
|
2
2
|
module AttributeParams
|
3
|
-
def
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
def update_column_from_params_with_sortable(parent_record, column, attribute, avoid_changes = false)
|
8
|
-
update_column_from_params_without_sortable(parent_record, column, attribute, avoid_changes).tap do |value|
|
3
|
+
def update_column_from_params(parent_record, column, attribute, avoid_changes = false)
|
4
|
+
super.tap do |value|
|
9
5
|
if column.association.try(:collection?)
|
10
6
|
config = active_scaffold_config_for(column.association.klass)
|
11
7
|
if config.actions.include?(:sortable)
|
@@ -1,11 +1,7 @@
|
|
1
1
|
module ActiveScaffoldSortable
|
2
2
|
module Core
|
3
|
-
def
|
4
|
-
|
5
|
-
end
|
6
|
-
|
7
|
-
def initialize_with_sortable(model_id)
|
8
|
-
initialize_without_sortable(model_id)
|
3
|
+
def initialize(model_id)
|
4
|
+
super
|
9
5
|
# seems some rubies are returning strings in instance_methods and other symbols...
|
10
6
|
if !(model.instance_methods & ['acts_as_list_class', :acts_as_list_class, 'nested_set_scope', :nested_set_scope]).empty?
|
11
7
|
self.actions << :sortable
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_scaffold_sortable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.3.
|
4
|
+
version: 3.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Cambra
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-06-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: active_scaffold
|
@@ -98,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
98
|
requirements:
|
99
99
|
- - ">="
|
100
100
|
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
101
|
+
version: '2.0'
|
102
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
104
|
- - ">="
|