effective_datatables 4.39.0 → 4.39.2
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
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 12e01bd82fc2bf197109050265f20948617f7b0e57fac56c9d83cdf0469fd080
|
|
4
|
+
data.tar.gz: 043e49461b97e3d496b5556e4c14da0ce72249a6b03108bf66482c003f0e5d54
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a8c9b8745fcb7a477bff5ab7bc9699303a28edd8d616845f852fe949205c910b6e6e2bc453f7bd6e76105488b9e35cebbf9c42de7d4ca506eaf62777501b2a9
|
|
7
|
+
data.tar.gz: 77cc02b1405a176616ab8780e1afc21ad14f54244ccaadf4aa6575178b73c3bab28e51c4b506ffa1a6f1cf1f9a8263c2cfd2bfec823df352078c8a2c98ad2524
|
|
@@ -67,18 +67,19 @@ module Effective
|
|
|
67
67
|
EffectiveDatatables.authorize!(self, :update, @resource)
|
|
68
68
|
|
|
69
69
|
attribute = @datatable.columns[:_reorder][:reorder]
|
|
70
|
+
column = @resource.class.arel_table[attribute]
|
|
70
71
|
old_index = params[:reorder][:old].to_i
|
|
71
72
|
new_index = params[:reorder][:new].to_i
|
|
72
73
|
|
|
73
74
|
@resource.class.transaction do
|
|
74
75
|
if new_index > old_index
|
|
75
|
-
@datatable.collection.where(
|
|
76
|
+
@datatable.collection.where(column.gt(old_index).and(column.lteq(new_index))).update_all(attribute => column - 1)
|
|
76
77
|
@resource.update_column(attribute, new_index)
|
|
77
78
|
@resource.touch
|
|
78
79
|
end
|
|
79
80
|
|
|
80
81
|
if old_index > new_index
|
|
81
|
-
@datatable.collection.where(
|
|
82
|
+
@datatable.collection.where(column.gteq(new_index).and(column.lt(old_index))).update_all(attribute => column + 1)
|
|
82
83
|
@resource.update_column(attribute, new_index)
|
|
83
84
|
@resource.touch
|
|
84
85
|
end
|
|
@@ -88,7 +89,7 @@ module Effective
|
|
|
88
89
|
rescue Effective::AccessDenied => e
|
|
89
90
|
render(status: :unauthorized, body: 'Access Denied')
|
|
90
91
|
rescue Exception => e
|
|
91
|
-
render(status: :
|
|
92
|
+
render(status: :internal_server_error, body: 'Unexpected Error')
|
|
92
93
|
end
|
|
93
94
|
|
|
94
95
|
end
|
|
@@ -44,8 +44,12 @@ module Effective
|
|
|
44
44
|
def order_column(collection, direction, column, sql_column)
|
|
45
45
|
Rails.logger.info "COLUMN TOOL: order_column #{column.to_s} #{direction} #{sql_column}" if EffectiveDatatables.debug
|
|
46
46
|
|
|
47
|
-
if column[:
|
|
48
|
-
collection.
|
|
47
|
+
if column[:as] == :reorder && sql_column == column[:reorder]
|
|
48
|
+
attribute = collection.arel_table[column[:reorder]]
|
|
49
|
+
collection.order(direction.to_s.downcase == 'desc' ? attribute.desc : attribute.asc)
|
|
50
|
+
elsif column[:sql_as_column]
|
|
51
|
+
expression = Arel.sql(sql_column.to_s)
|
|
52
|
+
collection.order(direction.to_s.downcase == 'desc' ? expression.desc : expression.asc)
|
|
49
53
|
else
|
|
50
54
|
Effective::Resource.new(collection)
|
|
51
55
|
.order(column[:name], direction, as: column[:as], sort: column[:sort], sql_column: column[:sql_column], limit: datatable.limit)
|
|
@@ -99,12 +103,7 @@ module Effective
|
|
|
99
103
|
when Hash
|
|
100
104
|
count.size # This represents the number of displayed datatable rows, not the sum all groups (which might be more)
|
|
101
105
|
else
|
|
102
|
-
|
|
103
|
-
collection_sql = collection.klass.connection.unprepared_statement { collection.to_sql }
|
|
104
|
-
(collection.klass.connection.exec_query("SELECT COUNT(*) FROM (#{collection_sql}) AS datatables_total_count").rows[0][0] rescue 1)
|
|
105
|
-
else
|
|
106
|
-
(collection.klass.connection.exec_query("SELECT COUNT(*) FROM (#{collection.to_sql}) AS datatables_total_count").rows[0][0] rescue 1)
|
|
107
|
-
end.to_i
|
|
106
|
+
(collection.klass.unscoped.from(collection, :datatables_total_count).count(:all) rescue 1).to_i
|
|
108
107
|
end
|
|
109
108
|
end
|
|
110
109
|
|
|
@@ -103,7 +103,7 @@ module Effective
|
|
|
103
103
|
|
|
104
104
|
# Must return a string
|
|
105
105
|
def format_column(value, column, as: nil, csv: false)
|
|
106
|
-
return if value.nil? || (column[:resource] && value.blank?)
|
|
106
|
+
return if value.nil? || (column[:resource] && value != false && value.blank?)
|
|
107
107
|
|
|
108
108
|
if value.kind_of?(Array) && [:string, :text].include?(column[:as])
|
|
109
109
|
if csv
|