rails_admin_toggleable 0.3.0 → 0.3.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cdf07752624f3739bc2bf661c7b439421a4c57bd
|
4
|
+
data.tar.gz: e6eb4dd883bd7e870b72ea44b522a4733805c6b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d34159c692761853a752006bccae2f36d6cb2024015e9095b124bfc6871188e729739adcf4520c5704a374e2b49cce755d56bf5e61d3a2acfeee3f00bcbac34
|
7
|
+
data.tar.gz: 5a393f72baa767302192148904f4bb36d46eb478fdaee68c843ae04a384d73ef1751a0a10747608efa1a1f38f4a8bbe2a48efd01797768675be972a5c92f70d8
|
@@ -1,58 +1,58 @@
|
|
1
|
-
module RailsAdmin
|
2
|
-
module Config
|
3
|
-
module Actions
|
4
|
-
class Toggle < Base
|
5
|
-
RailsAdmin::Config::Actions.register(self)
|
6
|
-
|
7
|
-
# Is the action acting on the root level (Example: /admin/contact)
|
8
|
-
register_instance_option :root? do
|
9
|
-
false
|
10
|
-
end
|
11
|
-
|
12
|
-
register_instance_option :collection? do
|
13
|
-
false
|
14
|
-
end
|
15
|
-
|
16
|
-
# Is the action on an object scope (Example: /admin/team/1/edit)
|
17
|
-
register_instance_option :member? do
|
18
|
-
true
|
19
|
-
end
|
20
|
-
|
21
|
-
register_instance_option :controller do
|
22
|
-
Proc.new do |klass|
|
23
|
-
if params['id'].present?
|
24
|
-
begin
|
25
|
-
obj = @abstract_model.model.find(params['id'])
|
26
|
-
method = params[:method]
|
27
|
-
obj.send(method + '=', params[:on] == '1' ? true : false)
|
28
|
-
if obj.save
|
29
|
-
if params[:on] == '1'
|
30
|
-
flash[:success] = I18n.t('admin.toggle.enabled', attr: method)
|
31
|
-
else
|
32
|
-
flash[:success] = I18n.t('admin.toggle.disabled', attr: method)
|
33
|
-
end
|
34
|
-
|
35
|
-
else
|
36
|
-
flash[:error] = obj.errors.full_messages.join(', ')
|
37
|
-
end
|
38
|
-
rescue Exception => e
|
39
|
-
flash[:error] = I18n.t('admin.toggle.error', err: e.to_s)
|
40
|
-
end
|
41
|
-
else
|
42
|
-
flash[:error] = I18n.t('admin.toggle.no_id')
|
43
|
-
end
|
44
|
-
redirect_to :back
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
register_instance_option :link_icon do
|
49
|
-
'icon-move'
|
50
|
-
end
|
51
|
-
|
52
|
-
register_instance_option :http_methods do
|
53
|
-
[:post]
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
1
|
+
module RailsAdmin
|
2
|
+
module Config
|
3
|
+
module Actions
|
4
|
+
class Toggle < Base
|
5
|
+
RailsAdmin::Config::Actions.register(self)
|
6
|
+
|
7
|
+
# Is the action acting on the root level (Example: /admin/contact)
|
8
|
+
register_instance_option :root? do
|
9
|
+
false
|
10
|
+
end
|
11
|
+
|
12
|
+
register_instance_option :collection? do
|
13
|
+
false
|
14
|
+
end
|
15
|
+
|
16
|
+
# Is the action on an object scope (Example: /admin/team/1/edit)
|
17
|
+
register_instance_option :member? do
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
register_instance_option :controller do
|
22
|
+
Proc.new do |klass|
|
23
|
+
if params['id'].present?
|
24
|
+
begin
|
25
|
+
obj = @abstract_model.model.find(params['id'])
|
26
|
+
method = params[:method]
|
27
|
+
obj.send(method + '=', params[:on] == '1' ? true : false)
|
28
|
+
if obj.save
|
29
|
+
if params[:on] == '1'
|
30
|
+
flash[:success] = I18n.t('admin.toggle.enabled', attr: method)
|
31
|
+
else
|
32
|
+
flash[:success] = I18n.t('admin.toggle.disabled', attr: method)
|
33
|
+
end
|
34
|
+
|
35
|
+
else
|
36
|
+
flash[:error] = obj.errors.full_messages.join(', ')
|
37
|
+
end
|
38
|
+
rescue Exception => e
|
39
|
+
flash[:error] = I18n.t('admin.toggle.error', err: e.to_s)
|
40
|
+
end
|
41
|
+
else
|
42
|
+
flash[:error] = I18n.t('admin.toggle.no_id')
|
43
|
+
end
|
44
|
+
redirect_to :back
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
register_instance_option :link_icon do
|
49
|
+
'icon-move'
|
50
|
+
end
|
51
|
+
|
52
|
+
register_instance_option :http_methods do
|
53
|
+
[:post]
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -13,19 +13,6 @@ module RailsAdmin
|
|
13
13
|
:check_box
|
14
14
|
end
|
15
15
|
|
16
|
-
register_instance_option :formatted_value do
|
17
|
-
case value
|
18
|
-
when nil
|
19
|
-
'-'
|
20
|
-
when false
|
21
|
-
'On'
|
22
|
-
when true
|
23
|
-
'Off'
|
24
|
-
else
|
25
|
-
'-'
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
16
|
register_instance_option :pretty_value do
|
30
17
|
def g_link(fv, on, badge)
|
31
18
|
bindings[:view].link_to(
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin_toggleable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gleb Tv
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Toggleable field for rails admin
|
14
14
|
email:
|
@@ -49,7 +49,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
49
|
version: '0'
|
50
50
|
requirements: []
|
51
51
|
rubyforge_project:
|
52
|
-
rubygems_version: 2.0.
|
52
|
+
rubygems_version: 2.0.6
|
53
53
|
signing_key:
|
54
54
|
specification_version: 4
|
55
55
|
summary: Make any boolean field easily toggleable on\off from index view in rails
|