effective_trash 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/admin/trash_controller.rb +6 -1
- data/app/controllers/effective/trash_controller.rb +7 -1
- data/app/datatables/effective_trash_datatable.rb +47 -0
- data/app/models/effective/datatables/trash.rb +1 -1
- data/app/views/admin/trash/_actions.html.haml +2 -2
- data/lib/effective_trash/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 74550c4d1c0f1e096e3fa84cab3e66cd2599b60f
|
4
|
+
data.tar.gz: 6348841841f51fda296e4b5074abbb188424f4ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c69bd045b99ff0b940a5e9d4a344d2d885220ad4515b7e6747b8f90b9fc15856ac0f7271b150f44c5f74eea005528cd154566f2e8b27ee1137c2cd5da8d8eae5
|
7
|
+
data.tar.gz: cd3e883e13314508164b627f661d4d705a7017ab4a6e02d3e028c4ab0daea0ec9815d2da7429a4d42799862387debcd8594d48128ed6554cdd687c5065f8806e
|
@@ -9,7 +9,12 @@ module Admin
|
|
9
9
|
helper EffectiveTrashHelper
|
10
10
|
|
11
11
|
def index
|
12
|
-
|
12
|
+
if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
|
13
|
+
@datatable = Effective::Datatables::Trash.new
|
14
|
+
else
|
15
|
+
@datatable = EffectiveTrashDatatable.new(self)
|
16
|
+
end
|
17
|
+
|
13
18
|
@page_title = 'Trash'
|
14
19
|
|
15
20
|
EffectiveTrash.authorized?(self, :index, Effective::Trash)
|
@@ -8,7 +8,13 @@ module Effective
|
|
8
8
|
|
9
9
|
# This is the User index event
|
10
10
|
def index
|
11
|
-
|
11
|
+
|
12
|
+
if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
|
13
|
+
@datatable = Effective::Datatables::Trash.new(user_id: current_user.id)
|
14
|
+
else
|
15
|
+
@datatable = EffectiveTrashDatatable.new(self, user_id: current_user.id)
|
16
|
+
end
|
17
|
+
|
12
18
|
@page_title = 'Trash'
|
13
19
|
|
14
20
|
EffectiveTrash.authorized?(self, :index, Effective::Trash.new(user_id: current_user.id))
|
@@ -0,0 +1,47 @@
|
|
1
|
+
unless Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
|
2
|
+
class EffectiveTrashDatatable < Effective::Datatable
|
3
|
+
datatable do
|
4
|
+
order :created_at, :desc
|
5
|
+
|
6
|
+
col :created_at, label: 'Destroyed at'
|
7
|
+
col :id, visible: false
|
8
|
+
|
9
|
+
unless attributes[:user_id] || attributes[:user] || (attributes[:user] == false)
|
10
|
+
col :user, label: 'Destroyed by'
|
11
|
+
end
|
12
|
+
|
13
|
+
col :trashed_type, label: 'Type'
|
14
|
+
col :trashed_id, label: 'Original Id', visible: false
|
15
|
+
col :trashed_to_s, label: 'Item'
|
16
|
+
|
17
|
+
col :details, visible: false do |trash|
|
18
|
+
tableize_hash(trash.details, th: true, sub_th: false, width: '100%')
|
19
|
+
end
|
20
|
+
|
21
|
+
unless attributes[:actions] == false
|
22
|
+
actions_col partial: 'admin/trash/actions', partial_as: :trash
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# A nil attributes[:log_id] means give me all the top level log entries
|
27
|
+
# If we set a log_id then it's for sub trash
|
28
|
+
collection do
|
29
|
+
collection = Effective::Trash.all.includes(:user)
|
30
|
+
|
31
|
+
if attributes[:user_id].present?
|
32
|
+
collection = collection.where(user_id: attributes[:user_id])
|
33
|
+
end
|
34
|
+
|
35
|
+
if attributes[:user].present?
|
36
|
+
collection = collection.where(user: attributes[:user])
|
37
|
+
end
|
38
|
+
|
39
|
+
if attributes[:trashed_id] && attributes[:trashed_type]
|
40
|
+
collection = collection.where(trashed_id: attributes[:trashed_id], trashed_type: attributes[:trashed_type])
|
41
|
+
end
|
42
|
+
|
43
|
+
collection
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_trash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
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-
|
11
|
+
date: 2017-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- README.md
|
106
106
|
- app/controllers/admin/trash_controller.rb
|
107
107
|
- app/controllers/effective/trash_controller.rb
|
108
|
+
- app/datatables/effective_trash_datatable.rb
|
108
109
|
- app/helpers/effective_trash_helper.rb
|
109
110
|
- app/models/concerns/acts_as_trashable.rb
|
110
111
|
- app/models/effective/access_denied.rb
|