effective_logging 1.10.4 → 1.10.5

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: 5d567d6badd11813f0275b72ada91d72306ca5a2
4
- data.tar.gz: c0b753689f05b4140d0ae6c961e7f497bc5bc09e
3
+ metadata.gz: 2de145b956fd6e8284b0176ddb914f149e7e7ddc
4
+ data.tar.gz: 693cccaee263fde6fd67e186e20c3f44d72c9e22
5
5
  SHA512:
6
- metadata.gz: adbbd2194efad68de68495fbaf513826daf0287102f4de0db0383a434348559c4d34271d09d4f336f7ea4bab1d7d2f152c5653788ffb9bc76e9d3f9bc6ecd9c6
7
- data.tar.gz: ce68767bd2e1a015cd8860ddb4cc86f4e6b4e061140e077d2dc62cde691550410fff21f534051b7bb35eb23f38893e6743790c72ecbc11a01301766f56479472
6
+ metadata.gz: 9834c2c5d1383e9ea216126aa7dd92ee8c04092fcae2f22ec01b2c99e69633c150d88848212a7736d8db528f29998039f18eb932d4e4eb2a79839af959af9727
7
+ data.tar.gz: 43c2a682dda427c41995f9473ff9bf53a7cb5687f216c69fa321fc1a60a975bdb2745cb99204ac2dd14b1ff2efa8c206e1a67f3a86e486d0f0f609738efa9be8
@@ -1,4 +1,4 @@
1
- if defined?(EffectiveDatatables)
1
+ if defined?(EffectiveDatatables) && Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
2
2
  module Effective
3
3
  module Datatables
4
4
  class Logs < Effective::Datatable
@@ -74,3 +74,80 @@ if defined?(EffectiveDatatables)
74
74
  end
75
75
  end
76
76
  end
77
+
78
+ if defined?(EffectiveDatatables) && Gem::Version.new(EffectiveDatatables::VERSION) >= Gem::Version.new('3.0')
79
+ module Effective
80
+ module Datatables
81
+ class Logs < Effective::Datatable
82
+ include EffectiveLoggingHelper
83
+
84
+ datatable do
85
+ order :updated_at
86
+
87
+ col :updated_at, label: 'Date'
88
+ col :id, visible: false
89
+
90
+ if attributes[:user] == false
91
+ # Do not include
92
+ elsif attributes[:user_id].present?
93
+ col :user, search: { collection: User.where(id: Array(attributes[:user_id])) }
94
+ elsif attributes[:user].present?
95
+ col :user, search: { collection: User.where(id: Array(attributes[:user]).map { |user| user.to_param }) }
96
+ else
97
+ col :user, search: {as: :string}
98
+ end
99
+
100
+ unless attributes[:status] == false
101
+ col :status, search: { collection: EffectiveLogging.statuses }
102
+ end
103
+
104
+ unless attributes[:log_changes]
105
+ col :associated_type, search: { as: :string }, visible: false
106
+ col :associated_id, search: { as: :integer }, visible: false, label: 'Associated Id'
107
+ col :associated_to_s, search: { as: :string }, label: 'Associated'
108
+ end
109
+
110
+ col :message do |log|
111
+ log.message.starts_with?("\t") ? log.message.gsub("\t", "&nbsp;&nbsp;") : log.message
112
+ end
113
+
114
+ col :logs_count, visible: false
115
+
116
+ col :details, visible: false, sort: false do |log|
117
+ tableize_hash(log.details.except(:email), th: true, sub_th: false, width: '100%')
118
+ end
119
+
120
+ # unless attributes[:actions] == false
121
+ # actions_col partial: 'admin/logs/actions'
122
+ # end
123
+ end
124
+
125
+ # A nil attributes[:log_id] means give me all the top level log entries
126
+ # If we set a log_id then it's for sub logs
127
+ collection do
128
+ scope = Effective::Log.unscoped.where(parent_id: attributes[:log_id]).includes(:user, :associated)
129
+
130
+ if attributes[:log_changes]
131
+ scope = scope.where(status: EffectiveLogging.log_changes_status)
132
+ end
133
+
134
+ if (attributes[:user] || attributes[:user_id]).present?
135
+ user_ids = Array(attributes[:user].presence || attributes[:user_id]).map { |user| user.kind_of?(User) ? user.id : user.to_i }
136
+ scope = scope.where('user_id IN (?) OR (associated_id IN (?) AND associated_type = ?)', user_ids, user_ids, 'User')
137
+ end
138
+
139
+ if attributes[:associated_id] && attributes[:associated_type]
140
+ scope = scope.where(associated_id: attributes[:associated_id], associated_type: attributes[:associated_type])
141
+ end
142
+
143
+ if attributes[:associated]
144
+ scope = scope.where(associated: attributes[:associated])
145
+ end
146
+
147
+ scope
148
+ end
149
+
150
+ end
151
+ end
152
+ end
153
+ end
@@ -1,3 +1,3 @@
1
1
  module EffectiveLogging
2
- VERSION = '1.10.4'.freeze
2
+ VERSION = '1.10.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_logging
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.4
4
+ version: 1.10.5
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: 2017-02-07 00:00:00.000000000 Z
11
+ date: 2017-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails