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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5cd0c44502cbcc7967b70dad031314557ade83db
4
- data.tar.gz: f392e547939379fc6f1c8452d9d52fbad41889ad
3
+ metadata.gz: 1492534bbf5bf0ae3b14f8083cb416449e963d56
4
+ data.tar.gz: 240734c1c652fe8410ed54a51cdfb8087eb8dbb3
5
5
  SHA512:
6
- metadata.gz: 5b45dafbac1c12df2690fd2e1987b8cd94e7d2c5c918cf3dbf2a3ed40de561d3d6befa3f184fcac58a0c99a911f4477c9c273856ad2f7447a1ba1e3f258cab6d
7
- data.tar.gz: b45b7308b54d5ee979160d7c23b8b44ec10c6f82c006113ca5aa82a065d958f113d08cf808c2232cd7e6d62c15551e886e6aaf9f4bdeee94111e175774c9ce7d
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 :include, ActiveScaffoldSortable::Core
28
- ActiveScaffold::AttributeParams.send :include, ActiveScaffoldSortable::AttributeParams
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 self.included(base)
4
- base.alias_method_chain :update_column_from_params, :sortable
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 self.included(base)
4
- base.alias_method_chain :initialize, :sortable
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
@@ -2,7 +2,7 @@ module ActiveScaffoldSortable
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 3
5
- PATCH = 0
5
+ PATCH = 1
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
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.0
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-03-22 00:00:00.000000000 Z
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
  - - ">="