active_admin_paranoia 1.0.10 → 1.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/active_admin_paranoia/dsl.rb +21 -3
- data/lib/active_admin_paranoia/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cec3ccee649c706e1af5a3886157a05724d49c6e
|
4
|
+
data.tar.gz: 3b032c0e20e70919ee52239b4d5fa28d6c35b251
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ccd4997e8c4725618b57111682ba767eb8f33b1260cfa9f4e8c9c4db9cec8ec9be35183138f27b04a18e33bc2c2edd27459b4eba38935e1ec771166c3aef783
|
7
|
+
data.tar.gz: 0f12c674b89af8789e83ee36ffe02df227c25c348e548309bf6703d6a9a410923dbe720b53ac1c26e31bc7d7f4de6c3dedca00f6c88db221edf54f65585d21aa
|
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.11'
|
9
9
|
|
10
10
|
```
|
11
11
|
|
@@ -9,12 +9,24 @@ module ActiveAdminParanoia
|
|
9
9
|
|
10
10
|
batch_action :destroy, confirm: proc{ I18n.t('active_admin.batch_actions.delete_confirmation', plural_model: resource_class.to_s.downcase.pluralize) }, if: proc{ authorized?(ActiveAdmin::Auth::DESTROY, resource_class) && params[:scope] != 'archived' } do |ids|
|
11
11
|
resource_class.to_s.camelize.constantize.where(id: ids).destroy_all
|
12
|
-
|
12
|
+
options = { notice: I18n.t('active_admin.batch_actions.succesfully_destroyed', count: ids.count, model: resource_class.to_s.camelize.constantize.model_name, plural_model: resource_class.to_s.downcase.pluralize) }
|
13
|
+
# For more info, see here: https://github.com/rails/rails/pull/22506
|
14
|
+
if Rails::VERSION::MAJOR >= 5
|
15
|
+
redirect_back({ fallback_location: ActiveAdmin.application.root_to }.merge(options))
|
16
|
+
else
|
17
|
+
redirect_to :back, options
|
18
|
+
end
|
13
19
|
end
|
14
20
|
|
15
21
|
batch_action :restore, confirm: proc{ I18n.t('active_admin_paranoia.batch_actions.restore_confirmation', plural_model: resource_class.to_s.downcase.pluralize) }, if: proc{ authorized?(ActiveAdminParanoia::Auth::RESTORE, resource_class) && params[:scope] == 'archived' } do |ids|
|
16
22
|
resource_class.to_s.camelize.constantize.restore(ids, recursive: true)
|
17
|
-
|
23
|
+
options = { 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) }
|
24
|
+
# For more info, see here: https://github.com/rails/rails/pull/22506
|
25
|
+
if Rails::VERSION::MAJOR >= 5
|
26
|
+
redirect_back({ fallback_location: ActiveAdmin.application.root_to }.merge(options))
|
27
|
+
else
|
28
|
+
redirect_to :back, options
|
29
|
+
end
|
18
30
|
end
|
19
31
|
|
20
32
|
action_item :restore, only: :show do
|
@@ -23,7 +35,13 @@ module ActiveAdminParanoia
|
|
23
35
|
|
24
36
|
member_action :restore, method: :put, confirm: proc{ I18n.t('active_admin_paranoia.restore_confirmation') }, if: proc{ authorized?(ActiveAdminParanoia::Auth::RESTORE, resource_class) } do
|
25
37
|
resource.restore(recursive: true)
|
26
|
-
|
38
|
+
options = { 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) }
|
39
|
+
# For more info, see here: https://github.com/rails/rails/pull/22506
|
40
|
+
if Rails::VERSION::MAJOR >= 5
|
41
|
+
redirect_back({ fallback_location: ActiveAdmin.application.root_to }.merge(options))
|
42
|
+
else
|
43
|
+
redirect_to :back, options
|
44
|
+
end
|
27
45
|
end
|
28
46
|
|
29
47
|
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) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.11
|
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: 2017-
|
11
|
+
date: 2017-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|