active_admin_paranoia 1.0.7 → 1.0.9
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 +13 -5
- data/README.md +1 -1
- data/active_admin_paranoia.gemspec +2 -2
- data/config/locales/en.yml +3 -1
- data/lib/active_admin_paranoia/dsl.rb +27 -0
- data/lib/active_admin_paranoia/version.rb +1 -1
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YWI5MGIyM2JiNDQwMDA4NjA4Y2M2YjQzOTExMjM5YzMwYWVlYmY2OQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NTQ3NjYyM2YwMmUxYjM1OTEwNmU2OTU5NDgxZWU5MjhlNGVlZTAxZg==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
OTc2ODIxMGRiYWNkZGM4OWJlZTE0NmFlODliODlkZmRhMmU0Y2QzMzEwZjNm
|
10
|
+
NjY3M2NmMDc3NjZiMjQ4MjJlMjI1MTBjOGU0ODI0ZGE3NDFhYjIwYzQ3MGQy
|
11
|
+
M2RmZTcyNTdmYTIwZDlhOTQ4NWNhODhiNGY1NTg2Mzg4NDNhMGI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MGM2MmNjYTMyNjViMTFjYzdhM2VmODMxNGU2ZjYyYWU1MzdhZDMyOTI2NWVm
|
14
|
+
NDVkY2Q2NzQ5MTVlZTljOGRjOWU5MTE4MGM1MGY1ODE0MWJiMmU4MGU4Nzgz
|
15
|
+
NDQ1ZGJmNDVlOWI3MjYzZGFhODMxYzcwMWE5ODkxNzJkNTQxNzI=
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ This gem extends ActiveAdmin so that batch restore and batch archive actions wil
|
|
5
5
|
This gem assumes that you have already configured [paranoia](https://github.com/radar/paranoia) for you desire resource. Add this line to your application's Gemfile:
|
6
6
|
|
7
7
|
```ruby
|
8
|
-
gem "active_admin_paranoia" , '~> 1.0.
|
8
|
+
gem "active_admin_paranoia" , '~> 1.0.9'
|
9
9
|
|
10
10
|
```
|
11
11
|
|
@@ -16,6 +16,6 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
17
|
gem.require_paths = %w(lib)
|
18
18
|
|
19
|
-
gem.add_dependency 'rails', '
|
20
|
-
gem.add_dependency 'paranoia', '
|
19
|
+
gem.add_dependency 'rails', '>= 4.0'
|
20
|
+
gem.add_dependency 'paranoia', '>= 1.0'
|
21
21
|
end
|
data/config/locales/en.yml
CHANGED
@@ -18,4 +18,6 @@ en:
|
|
18
18
|
other: "Successfully restored %{count} %{plural_model}"
|
19
19
|
archived: "Archived"
|
20
20
|
non_archived: "Non Archived"
|
21
|
-
|
21
|
+
restore: "Restore"
|
22
|
+
restore_confirmation: "Are you sure you want to restore this?"
|
23
|
+
something_wrong: "Something went wrong. Please try again"
|
@@ -17,8 +17,35 @@ module ActiveAdminParanoia
|
|
17
17
|
redirect_to :back, notice: I18n.t('active_admin_paranoia.batch_actions.succesfully_restored', count: ids.count, model: resource_class.to_s.camelize.constantize.model_name, plural_model: resource_class.to_s.downcase.pluralize)
|
18
18
|
end
|
19
19
|
|
20
|
+
member_action :restore, method: :put, confirm: proc{ I18n.t('active_admin_paranoia.restore_confirmation') }, if: proc{ authorized?(ActiveAdminParanoia::Auth::RESTORE, resource_class) } do
|
21
|
+
resource.restore(recursive: true)
|
22
|
+
redirect_to :back, notice: I18n.t('active_admin_paranoia.batch_actions.succesfully_restored', count: 1, model: resource_class.to_s.camelize.constantize.model_name, plural_model: resource_class.to_s.downcase.pluralize)
|
23
|
+
end
|
24
|
+
|
20
25
|
scope(I18n.t('active_admin_paranoia.non_archived'), default: true) { |scope| scope.where(resource_class.to_s.camelize.constantize.paranoia_column => resource_class.to_s.camelize.constantize.paranoia_sentinel_value) }
|
21
26
|
scope(I18n.t('active_admin_paranoia.archived')) { |scope| scope.unscope(:where => resource_class.to_s.camelize.constantize.paranoia_column).where.not(resource_class.to_s.camelize.constantize.paranoia_column => resource_class.to_s.camelize.constantize.paranoia_sentinel_value) }
|
22
27
|
end
|
23
28
|
end
|
24
29
|
end
|
30
|
+
|
31
|
+
module ActiveAdmin
|
32
|
+
module Views
|
33
|
+
class IndexAsTable < ActiveAdmin::Component
|
34
|
+
class IndexTableFor < ::ActiveAdmin::Views::TableFor
|
35
|
+
alias_method :orig_defaults, :defaults
|
36
|
+
|
37
|
+
def defaults(resource, options = {})
|
38
|
+
if resource.respond_to?(:deleted?) && resource.deleted?
|
39
|
+
if controller.action_methods.include?('restore') && authorized?(ActiveAdminParanoia::Auth::RESTORE, resource_class)
|
40
|
+
# TODO: find a way to use the correct path helper
|
41
|
+
item I18n.t('active_admin_paranoia.restore'), "#{resource_path(resource)}/restore", method: :put, class: "restore_link #{options[:css_class]}",
|
42
|
+
data: {confirm: I18n.t('active_admin_paranoia.restore_confirmation')}
|
43
|
+
end
|
44
|
+
else
|
45
|
+
orig_defaults(resource, options)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_admin_paranoia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miah Raihan Mahmud Arman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ! '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: paranoia
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ! '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ! '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.0'
|
41
41
|
description: This gem extends ActiveAdmin so that batch restore and batch archive
|
@@ -48,7 +48,7 @@ executables: []
|
|
48
48
|
extensions: []
|
49
49
|
extra_rdoc_files: []
|
50
50
|
files:
|
51
|
-
-
|
51
|
+
- .gitignore
|
52
52
|
- Gemfile
|
53
53
|
- LICENSE
|
54
54
|
- README.md
|
@@ -70,17 +70,17 @@ require_paths:
|
|
70
70
|
- lib
|
71
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- -
|
73
|
+
- - ! '>='
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
77
|
requirements:
|
78
|
-
- -
|
78
|
+
- - ! '>='
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
82
|
rubyforge_project:
|
83
|
-
rubygems_version: 2.4.
|
83
|
+
rubygems_version: 2.4.3
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: Paranoia extension for ActiveAdmin
|