effective_datatables 4.3.8 → 4.3.9
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
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9b89f0b4d171f32ab9d0cec5bdbf9aed4dfc6d8
|
4
|
+
data.tar.gz: 072ae799d4ec109020421d1f90051801aec70225
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85b7cc85ed6373577c2d85b466986722588c9e9dc8515b612a077f111117f4169b385c8273fee057901db5510dfc92ad03a12cab882f3a88b02de8f51ff0e1ea
|
7
|
+
data.tar.gz: bbe868121e147e40912b5830988879f1a2291be4c687e4bbb07e59b412998a89f0c2d162be4dafb2292f07df79338ecbe2180b29736e028ec8f47bd61b063ebb
|
@@ -21,29 +21,37 @@ module Effective
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def reorder
|
24
|
-
|
25
|
-
|
24
|
+
begin
|
25
|
+
@datatable = EffectiveDatatables.find(params[:id])
|
26
|
+
@datatable.view = view_context
|
26
27
|
|
27
|
-
|
28
|
-
EffectiveDatatables.authorize!(self, :update, @resource)
|
28
|
+
@resource = @datatable.collection.find(params[:reorder][:id])
|
29
29
|
|
30
|
-
|
31
|
-
old_index = params[:reorder][:old].to_i
|
32
|
-
new_index = params[:reorder][:new].to_i
|
30
|
+
EffectiveDatatables.authorize!(self, :update, @resource)
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
@resource.update_column(attribute, new_index)
|
38
|
-
end
|
32
|
+
attribute = @datatable.columns[:_reorder][:reorder]
|
33
|
+
old_index = params[:reorder][:old].to_i
|
34
|
+
new_index = params[:reorder][:new].to_i
|
39
35
|
|
40
|
-
|
41
|
-
|
42
|
-
|
36
|
+
@resource.class.transaction do
|
37
|
+
if new_index > old_index
|
38
|
+
@datatable.collection.where("#{attribute} > ? AND #{attribute} <= ?", old_index, new_index).update_all("#{attribute} = #{attribute} - 1")
|
39
|
+
@resource.update_column(attribute, new_index)
|
40
|
+
end
|
41
|
+
|
42
|
+
if old_index > new_index
|
43
|
+
@datatable.collection.where("#{attribute} >= ? AND #{attribute} < ?", new_index, old_index).update_all("#{attribute} = #{attribute} + 1")
|
44
|
+
@resource.update_column(attribute, new_index)
|
45
|
+
end
|
43
46
|
end
|
47
|
+
|
48
|
+
render status: :ok, body: :ok
|
49
|
+
rescue Effective::AccessDenied => e
|
50
|
+
render(status: :unauthorized, body: 'Access Denied')
|
51
|
+
rescue => e
|
52
|
+
render(status: :error, body: 'Unexpected Error')
|
44
53
|
end
|
45
54
|
|
46
|
-
render status: :ok, body: :ok
|
47
55
|
end
|
48
56
|
|
49
57
|
private
|
@@ -34,8 +34,8 @@ module EffectiveDatatablesPrivateHelper
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def datatable_reorder(datatable)
|
37
|
-
return false unless datatable.reorder?
|
38
|
-
link_to(content_tag(:span, 'Reorder'), '#', class: 'btn btn-link btn-sm buttons-reorder')
|
37
|
+
return false unless datatable.reorder? && EffectiveDatatables.authorized?(self, :update, datatable.collection_class)
|
38
|
+
link_to(content_tag(:span, 'Reorder'), '#', class: 'btn btn-link btn-sm buttons-reorder', disabled: true)
|
39
39
|
end
|
40
40
|
|
41
41
|
def datatable_new_resource_button(datatable, name, column)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_datatables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.3.
|
4
|
+
version: 4.3.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|