effective_trash 0.2.2 → 0.2.3

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: d48b6ae4a747e8d6d2567827966736aff26b6b53
4
- data.tar.gz: e4eb0078becab79191be39d8bb2b0d94159e43f7
3
+ metadata.gz: 74550c4d1c0f1e096e3fa84cab3e66cd2599b60f
4
+ data.tar.gz: 6348841841f51fda296e4b5074abbb188424f4ab
5
5
  SHA512:
6
- metadata.gz: 0ff0bc35b9b92526df5bd06991f872f57a5a831779524774490e353160f9cc06c7ed6e46077e4d284d3af8e5a3ace5f5a47d814f540eec77c52a40998b5f9dd1
7
- data.tar.gz: 208dfa88a8522b943c9135e138a5040ce58916bc2ac21e11bb6609145e20e047244562847fa833e9690896a271a63d2778831d62159fd5f9c265e7e1f1538dfd
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
- @datatable = Effective::Datatables::Trash.new()
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
- @datatable = Effective::Datatables::Trash.new(user_id: current_user.id)
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
@@ -1,4 +1,4 @@
1
- if defined?(EffectiveDatatables)
1
+ if Gem::Version.new(EffectiveDatatables::VERSION) < Gem::Version.new('3.0')
2
2
  module Effective
3
3
  module Datatables
4
4
  class Trash < Effective::Datatable
@@ -1,7 +1,7 @@
1
1
  :ruby
2
2
  show_path =
3
- if datatables_active_admin_path?
4
- admin_effective_trash_path(trash)
3
+ if datatable.try(:admin_namespace?)
4
+ effective_trash.admin_trash_path(trash)
5
5
  elsif datatables_admin_path?
6
6
  effective_trash.admin_trash_path(trash)
7
7
  else
@@ -1,3 +1,3 @@
1
1
  module EffectiveTrash
2
- VERSION = '0.2.2'.freeze
2
+ VERSION = '0.2.3'.freeze
3
3
  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.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-02-03 00:00:00.000000000 Z
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