active_scaffold_sortable 3.3.5 → 3.3.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 12b3b4375b8bb35bcc851b5219b358178c9b4054
4
- data.tar.gz: adae7a6bf7560acd094fe1338586fb7df28616ca
2
+ SHA256:
3
+ metadata.gz: 10ec1d10c42ac1c64c3177691d8ce748b30225321d30383b98c8f78ab2b66a3d
4
+ data.tar.gz: 75ff1b0f847a0a28b8cafb0b73e2f0f37aed8c083afbc1166da5ba2bc94e32d4
5
5
  SHA512:
6
- metadata.gz: 1bd583874658fea4563d85c82a5352cafa482543c081c75d8cb9448203b5bb253f5b864184279c508e952da840695f8a1793db7aaa9712718130b1cbc536aa31
7
- data.tar.gz: df9a188389ee2ffb54fc270d750a0930eeea09eb59955147dd1c6bb5be51840222252fbd2d5e2cc93295455bf409d929bf42dc2eb43436976af1722fac830888
6
+ metadata.gz: 3ba523b89891741b6ff1dc435635a99fc4ba0d9370285ec2597a573f1b0f06a841d36da44f4e97df8d9358f1be77c6bcda377760a25c63cfae50454d74a6cde4
7
+ data.tar.gz: 79aa648f4702e2bc304738240195553e29ec3b8fef386f033052dd50d96e871670740688322b368a00a6bd99f610d669d0692803910fa9ddc7f94139b56aa7e5
@@ -53,7 +53,7 @@ module ActiveScaffold::Config
53
53
  @column.weight = 2**(0.size * 8 -2) -1 unless where == :first
54
54
  if @core.actions.include? :list
55
55
  if where == :first
56
- @core.list.columns = [:active_scaffold_sortable] + @core.list.columns.names_without_auth_check unless @core.list.columns.include? :active_scaffold_sortable
56
+ @core.list.columns = [:active_scaffold_sortable] + @core.list.columns.to_a unless @core.list.columns.include? :active_scaffold_sortable
57
57
  else
58
58
  @core.list.columns.add :active_scaffold_sortable
59
59
  end
@@ -1,4 +1,4 @@
1
1
  # Need to open the AS module carefully due to Rails 2.3 lazy loading
2
2
  ActiveScaffold::Config::Core.class_eval do
3
- ActionDispatch::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:reorder] = :post
3
+ ActiveScaffold::Routing::ACTIVE_SCAFFOLD_CORE_ROUTING[:collection][:reorder] = :post
4
4
  end
@@ -2,7 +2,7 @@ module ActiveScaffoldSortable
2
2
  module Version
3
3
  MAJOR = 3
4
4
  MINOR = 3
5
- PATCH = 5
5
+ PATCH = 6
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.5
4
+ version: 3.3.6
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-11-13 00:00:00.000000000 Z
12
+ date: 2019-03-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: active_scaffold
@@ -17,28 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - ">="
19
19
  - !ruby/object:Gem::Version
20
- version: 3.3.0.rc3
20
+ version: 3.6.0.pre
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - ">="
26
26
  - !ruby/object:Gem::Version
27
- version: 3.3.0.rc3
28
- - !ruby/object:Gem::Dependency
29
- name: rails
30
- requirement: !ruby/object:Gem::Requirement
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: '4.0'
35
- type: :runtime
36
- prerelease: false
37
- version_requirements: !ruby/object:Gem::Requirement
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- version: '4.0'
27
+ version: 3.6.0.pre
42
28
  description: Sort Tree or List Structures by Drag n Drop
43
29
  email: activescaffold@googlegroups.com
44
30
  executables: []
@@ -52,20 +38,15 @@ files:
52
38
  - app/assets/images/active_scaffold/sortable.png
53
39
  - app/assets/javascripts/active_scaffold_sortable.js.erb
54
40
  - app/assets/javascripts/jquery/active_scaffold_sortable.js
55
- - app/assets/javascripts/jquery/active_scaffold_sortable.js~
56
41
  - app/assets/javascripts/prototype/active_scaffold_sortable.js
57
- - app/assets/javascripts/prototype/active_scaffold_sortable.js~
58
42
  - app/assets/stylesheets/active_scaffold_sortable.css.scss
59
43
  - app/views/active_scaffold_overrides/_form_association.html.erb
60
44
  - app/views/active_scaffold_overrides/edit_associated.js.erb
61
45
  - frontends/default/active_scaffold_overrides/_list.html.erb
62
46
  - frontends/default/active_scaffold_overrides/on_create.js.erb
63
- - frontends/default/active_scaffold_overrides/on_create.js.erb~
64
47
  - frontends/default/active_scaffold_overrides/on_update.js.erb
65
- - frontends/default/active_scaffold_overrides/on_update.js.erb~
66
48
  - frontends/default/active_scaffold_overrides/reorder.js.erb
67
49
  - lib/active_scaffold/actions/sortable.rb
68
- - lib/active_scaffold/actions/sortable.rb~
69
50
  - lib/active_scaffold/config/sortable.rb
70
51
  - lib/active_scaffold/helpers/sortable_helpers.rb
71
52
  - lib/active_scaffold_sortable.rb
@@ -75,7 +56,6 @@ files:
75
56
  - lib/active_scaffold_sortable/engine.rb
76
57
  - lib/active_scaffold_sortable/version.rb
77
58
  - lib/active_scaffold_sortable/view_helpers.rb
78
- - lib/active_scaffold_sortable/view_helpers.rb~
79
59
  - test/auto_models_controller_test.rb
80
60
  - test/config_test.rb
81
61
  - test/controllers/auto_models_controller.rb
@@ -106,18 +86,18 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
86
  version: '0'
107
87
  requirements: []
108
88
  rubyforge_project:
109
- rubygems_version: 2.6.10
89
+ rubygems_version: 2.7.8
110
90
  signing_key:
111
91
  specification_version: 4
112
92
  summary: Drag n Drop Sorting for Activescaffold
113
93
  test_files:
114
- - test/auto_models_controller_test.rb
115
94
  - test/config_test.rb
116
- - test/controllers/auto_models_controller.rb
117
- - test/controllers/models_controller.rb
118
- - test/controllers/sortable_models_controller.rb
119
- - test/models/auto_model.rb
120
95
  - test/models/model.rb
96
+ - test/models/auto_model.rb
121
97
  - test/router_test.rb
122
- - test/schema.rb
123
98
  - test/test_helper.rb
99
+ - test/auto_models_controller_test.rb
100
+ - test/schema.rb
101
+ - test/controllers/auto_models_controller.rb
102
+ - test/controllers/sortable_models_controller.rb
103
+ - test/controllers/models_controller.rb
@@ -1,45 +0,0 @@
1
- ActiveScaffold.update_positions = function(content) {
2
- if (typeof(content) == 'string') content = jQuery('#' + content);
3
- var element = content.closest('.sortable-container');
4
- jQuery.each(content.find('.sub-form-record input[name$="[' + element.data('column') + ']"]'), function(i, field) {
5
- jQuery(field).val(i);
6
- });
7
- }
8
- ActiveScaffold.sortable = function(element) {
9
- var form, content, sortable_options = {};
10
- if (typeof(element) == 'string') {
11
- content = jQuery('#' + element);
12
- element = content.closest('.sortable-container');
13
- } else {
14
- var form = element.closest('form.as_form').length > 0;
15
- if (form) content = element;
16
- else content = element.find('.records:first');
17
- }
18
-
19
- if (form) {
20
- sortable_options.update = function(event, ui) {
21
- ActiveScaffold.update_positions(content);
22
- };
23
- } else {
24
- var csrf = jQuery('meta[name=csrf-param]').attr('content') + '=' + jQuery('meta[name=csrf-token]').attr('content');
25
- var url = element.data('reorder-url');
26
- sortable_options.update = function(event, ui) {
27
- var body = jQuery(this).sortable('serialize',{key: encodeURIComponent(jQuery(this).attr('id') + '[]'), expression: new RegExp(element.data('format'))});
28
- var params = element.data('with');
29
- if (params) body += '&' + params;
30
- jQuery.post(url, body + '&' + csrf);
31
- };
32
- }
33
- sortable_options.handle = element.data('handle');
34
- sortable_options.items = element.data('tag');
35
- content.sortable(sortable_options);
36
- };
37
-
38
- jQuery(document).ready(function($) {
39
- $(document).on('as:action_success', 'a.as_action', function(e, action_link) {
40
- var sortable = $('.sortable-container', action_link.adapter);
41
- if (sortable.length) $.each(sortable, function(i, s) { ActiveScaffold.sortable(s); });
42
- });
43
- var sortable = $('.sortable-container');
44
- if (sortable.length) ActiveScaffold.sortable(sortable);
45
- });
@@ -1,34 +0,0 @@
1
- ActiveScaffold.sortable = function(element) {
2
- var form, content, sortable_options = {};
3
- if (typeof(element) == 'string') {
4
- content = $(element);
5
- element = content.up('.sortable-container');
6
- } else {
7
- var form = !!element.up('form.as_form');
8
- if (form) content = element.down('.sub-form');
9
- else content = element.down('.records');
10
- }
11
-
12
- if (!form) {
13
- var csrf = $$('meta[name=csrf-param]')[0].readAttribute('content') + '=' + $$('meta[name=csrf-token]')[0].readAttribute('content');
14
- var url = element.readAttribute('data-reorder-url').append_params(csrf);
15
- sortable_options.onUpdate = function() {
16
- var body = Sortable.serialize(content);
17
- var params = element.readAttribute('data-with');
18
- if (params) body += '&' + params;
19
- new Ajax.Request(url, {method: 'post', parameters: body + '&' + csrf});
20
- }
21
- }
22
- sortable_options.handle = element.readAttribute('data-handle');
23
- sortable_options.items = element.readAttribute('data-tag');
24
- Sortable.create(content, sortable_options);
25
- };
26
-
27
- document.observe('dom:loaded', function(){
28
- document.on('as:action_success', 'a.as_action', function(e, action_link) {
29
- var sortable = $(action_link.adapter).find('.sortable-container');
30
- if (sortable.length) sortable.invoke(function(s) { ActiveScaffold.sortable(s); });
31
- });
32
- var sortable = $$('.sortable-container');
33
- if (sortable.length) ActiveScaffold.sortable(sortable[0]);
34
- });
@@ -1,4 +0,0 @@
1
- <%= render(:super, :locals => {:insert_at => :bottom}) %>
2
- <% if controller.send(:successful?) && !nested_singular_association? %>
3
- ActiveScaffold.sortable('<%= active_scaffold_tbody_id %>'); %>
4
- <% end %>
@@ -1,17 +0,0 @@
1
- <%= render(:super) %>
2
- <%
3
- # if we are currently editing a nested belongs_to association do not do any sorting stuff
4
- unless nested_singular_association?
5
- if ActiveScaffold.js_framework == :prototype
6
- %>
7
- <%= sortable_element_js(*sort_params) %>
8
- <%
9
- elsif ActiveScaffold.js_framework == :jquery
10
- reorder_params = {}
11
- reorder_params[:eid] = params[:eid] unless params[:eid].blank?
12
- %>
13
- <%= "ActiveScaffold.sortable('#{sort_params[0]}', #{controller_name.to_json}, #{reorder_params.to_json});".html_safe %>
14
- <%
15
- end if controller.send :successful?
16
- end
17
- %>
@@ -1,81 +0,0 @@
1
- module ActiveScaffold::Actions
2
- module Sortable
3
- def self.included(base)
4
- base.helper ActiveScaffold::Helpers::SortableHelpers
5
- base.before_filter :sortable_authorized?, :only => :reorder
6
- base.active_scaffold_config.configure do |config|
7
- config.list.pagination = false
8
-
9
- # turn sorting off
10
- sortable_column = config.sortable.column.name
11
- config.columns.each {|c| c.sort = false unless c.name == sortable_column }
12
- config.list.sorting = { sortable_column => "asc" }
13
-
14
- config.actions.each do |action_name|
15
- next if action_name == :subform
16
- action = config.send(action_name)
17
- action.columns.exclude(sortable_column) if action.respond_to? :columns
18
- end
19
-
20
- base.add_active_scaffold_path File.join(ActiveScaffold::Config::Sortable.plugin_directory, 'frontends', 'default')
21
- end
22
- end
23
-
24
- def reorder
25
- model = active_scaffold_config.model
26
-
27
- unless (model.instance_methods & [:nested_set_scope, 'nested_set_scope']).empty?
28
- reorder_children_in_tree(model)
29
- else
30
- if model.respond_to? :ancestry_column
31
- reorder_ancestry_tree(model)
32
- else
33
- reorder_simple_list(model)
34
- end
35
- end
36
- do_refresh_list if active_scaffold_config.sortable.refresh_list
37
- end
38
-
39
- protected
40
- def sortable_authorized?
41
- authorized_for?(:action => :update)
42
- end
43
-
44
- def reorder_ancestry_tree(model)
45
- first_record = model.find(params[active_scaffold_tbody_id].first)
46
- unless first_record.nil?
47
- records = first_record.is_root? ? model.roots: first_record.parent.children
48
- reorder_simple_list(model)
49
- else
50
- Rails.logger.info("Failed to find first record to reorder")
51
- end
52
- end
53
-
54
- def reorder_simple_list(model)
55
- column_name = active_scaffold_config.sortable.column.name
56
- debugger
57
- params[active_scaffold_tbody_id].each_with_index do |id, index|
58
- model.update_all({column_name => index + 1}, {model.primary_key => id})
59
- end
60
- end
61
-
62
- def reorder_children_in_tree(model)
63
- current_order = model.find(params[active_scaffold_tbody_id].first).try(:self_and_siblings)
64
- new_order = params[active_scaffold_tbody_id].collect {|item_id| item_id.to_i}
65
- new_order.each_with_index do |record_id, new_position|
66
- if record_id != current_order[new_position].id
67
- current_order = move_child(current_order.find {|child| child.id == record_id}, new_position, current_order)
68
- end
69
- end if new_order.length == current_order.length
70
- end
71
-
72
- def move_child(child, new_position, children)
73
- old_position = children.index(child)
74
- (old_position - new_position).abs.times do |step|
75
- child.send((old_position - new_position) > 0 ? :move_left : :move_right)
76
- end
77
- child.self_and_siblings
78
- end
79
-
80
- end
81
- end
@@ -1,16 +0,0 @@
1
- module ActiveScaffoldSortable
2
- module ViewHelpers
3
- def sort_params(config = active_scaffold_config)
4
- options = {
5
- :tag => 'tr',
6
- :reorder_url => url_for(params_for(:action => :reorder, :controller => controller_name)),
7
- :format => '^[^_-](?:[A-Za-z0-9_-]*)-(.*)-row$'
8
- }
9
- options.merge config.sortable.options
10
- end
11
-
12
- def active_scaffold_sortable_column(record, column)
13
- ''
14
- end
15
- end
16
- end