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: 42a1366723d6c700c2b5fb7c7fd613601182216b
4
- data.tar.gz: 2781167994252173acbb561c09a0cf9f437b52a8
3
+ metadata.gz: a9b89f0b4d171f32ab9d0cec5bdbf9aed4dfc6d8
4
+ data.tar.gz: 072ae799d4ec109020421d1f90051801aec70225
5
5
  SHA512:
6
- metadata.gz: ebd8eb10dd82fd0bd5db5642a5b8b74dc0e75f5f839d800b2ed9f76c9578d80475a6716627f90cffe80ffd6ce3204ce32e0a3853e0a802396fa5e2547bf6a410
7
- data.tar.gz: bb2baf349bc5722e809f1b11cfe0424e758c775ccde053ed39f8f20af6865f7b3030cc9171c42a5ccb8956e2531b6276793d3a0a80c67c7d3915875b2cc68542
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
- @datatable = EffectiveDatatables.find(params[:id])
25
- @datatable.view = view_context
24
+ begin
25
+ @datatable = EffectiveDatatables.find(params[:id])
26
+ @datatable.view = view_context
26
27
 
27
- @resource = @datatable.collection.find(params[:reorder][:id])
28
- EffectiveDatatables.authorize!(self, :update, @resource)
28
+ @resource = @datatable.collection.find(params[:reorder][:id])
29
29
 
30
- attribute = @datatable.columns[:_reorder][:reorder]
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
- @resource.class.transaction do
35
- if new_index > old_index
36
- @datatable.collection.where("#{attribute} > ? AND #{attribute} <= ?", old_index, new_index).update_all("#{attribute} = #{attribute} - 1")
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
- if old_index > new_index
41
- @datatable.collection.where("#{attribute} >= ? AND #{attribute} < ?", new_index, old_index).update_all("#{attribute} = #{attribute} + 1")
42
- @resource.update_column(attribute, new_index)
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)
@@ -1,3 +1,3 @@
1
1
  module EffectiveDatatables
2
- VERSION = '4.3.8'.freeze
2
+ VERSION = '4.3.9'.freeze
3
3
  end
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.8
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-02 00:00:00.000000000 Z
11
+ date: 2018-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails