rails_admin_toggleable 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c21adfddd7f663d4ed432ab95a5990337152fac2
|
4
|
+
data.tar.gz: 620062625106c01a8a44a035e9dce8701a8af8e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 465ac594ea59d0f021dbe506c6f748ed0eb24f8b0e3b5e0f8200de5504cd0c94af427fd16e88bc6cccd04f0c6db02693a6b6ac4f5e49ea52167fdbdd9ff65972
|
7
|
+
data.tar.gz: 7f8359d90e4e4a6d9a78610564ee443e0ca86e7dd00abfcc2e512a97edfd924eabe557c1ed4f7afed1de67cc9e4078cf95c0754ccb992d4a0984902356750f82
|
@@ -1,54 +1,63 @@
|
|
1
|
-
require 'builder'
|
2
|
-
|
3
|
-
module RailsAdmin
|
4
|
-
module Config
|
5
|
-
module Fields
|
6
|
-
module Types
|
7
|
-
class Toggle < RailsAdmin::Config::Fields::Base
|
8
|
-
# Register field type for the type loader
|
9
|
-
RailsAdmin::Config::Fields::Types::register(self)
|
10
|
-
include RailsAdmin::Engine.routes.url_helpers
|
11
|
-
|
12
|
-
register_instance_option :view_helper do
|
13
|
-
:check_box
|
14
|
-
end
|
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
|
-
register_instance_option :pretty_value do
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
1
|
+
require 'builder'
|
2
|
+
|
3
|
+
module RailsAdmin
|
4
|
+
module Config
|
5
|
+
module Fields
|
6
|
+
module Types
|
7
|
+
class Toggle < RailsAdmin::Config::Fields::Base
|
8
|
+
# Register field type for the type loader
|
9
|
+
RailsAdmin::Config::Fields::Types::register(self)
|
10
|
+
include RailsAdmin::Engine.routes.url_helpers
|
11
|
+
|
12
|
+
register_instance_option :view_helper do
|
13
|
+
:check_box
|
14
|
+
end
|
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
|
+
register_instance_option :pretty_value do
|
30
|
+
def g_link(fv, on, badge)
|
31
|
+
bindings[:view].link_to(
|
32
|
+
fv.html_safe,
|
33
|
+
toggle_path(model_name: @abstract_model, id: bindings[:object].id, method: name, on: on.to_s),
|
34
|
+
method: :post,
|
35
|
+
class: 'badge ' + badge
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
case value
|
40
|
+
when nil
|
41
|
+
g_link('✘', 0, 'badge-important') + g_link('✓', 1, 'badge-success')
|
42
|
+
when false
|
43
|
+
g_link('✘', 1, 'badge-important')
|
44
|
+
when true
|
45
|
+
g_link('✓', 0, 'badge-success')
|
46
|
+
else
|
47
|
+
%{<span class="badge">-</span>}
|
48
|
+
end.html_safe
|
49
|
+
end
|
50
|
+
|
51
|
+
register_instance_option :export_value do
|
52
|
+
value.inspect
|
53
|
+
end
|
54
|
+
|
55
|
+
# Accessor for field's help text displayed below input field.
|
56
|
+
register_instance_option :help do
|
57
|
+
""
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
54
63
|
end
|
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.
|
4
|
+
version: 0.3.0
|
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-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Toggleable field for rails admin
|
14
14
|
email:
|