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: 3b6c282c0e8b78fd7acce4f39772ce093625a7b1
4
- data.tar.gz: 84711cb5319ce18e383f5d26093ba362f5dbf3f2
3
+ metadata.gz: c21adfddd7f663d4ed432ab95a5990337152fac2
4
+ data.tar.gz: 620062625106c01a8a44a035e9dce8701a8af8e5
5
5
  SHA512:
6
- metadata.gz: 75f05af11fd9332b04d2907818f98bba2fadaa3005a1e6ec61fa3aa3c726ec8ac553e4d85d57fd576403ef155c80cfbbc8d9119da77d7eae81e04d55d19ca846
7
- data.tar.gz: 4a210b6a5eaef08d7cf88e797dcd00a57707be19eb533a4454c755b384aa73459a710cc4fffba496545e210841eb843f9c204cbcc4bfc8caaf9c6e0929e6f4b3
6
+ metadata.gz: 465ac594ea59d0f021dbe506c6f748ed0eb24f8b0e3b5e0f8200de5504cd0c94af427fd16e88bc6cccd04f0c6db02693a6b6ac4f5e49ea52167fdbdd9ff65972
7
+ data.tar.gz: 7f8359d90e4e4a6d9a78610564ee443e0ca86e7dd00abfcc2e512a97edfd924eabe557c1ed4f7afed1de67cc9e4078cf95c0754ccb992d4a0984902356750f82
@@ -1,4 +1,4 @@
1
- ru:
1
+ en:
2
2
  admin:
3
3
  actions:
4
4
  toggle:
@@ -7,4 +7,4 @@ ru:
7
7
  enabled: '"%{attr}" enabled'
8
8
  disabled: '"%{attr}" disabled'
9
9
  error: "Error: %{err}"
10
- no_id: No ID provided
10
+ no_id: No ID provided
@@ -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
- case value
31
- when nil
32
- %{<span class="badge">-</span>}
33
- when false
34
- bindings[:view].link_to '&#x2718;'.html_safe, toggle_path(model_name: @abstract_model, id: bindings[:object].id, method: name, on: '1'), method: :post, class: 'badge badge-important'
35
- when true
36
- bindings[:view].link_to '&#x2713;'.html_safe, toggle_path(model_name: @abstract_model, id: bindings[:object].id, method: name, on: '0'), method: :post, class: 'badge badge-success'
37
- else
38
- %{<span class="badge">-</span>}
39
- end.html_safe
40
- end
41
-
42
- register_instance_option :export_value do
43
- value.inspect
44
- end
45
-
46
- # Accessor for field's help text displayed below input field.
47
- register_instance_option :help do
48
- ""
49
- end
50
- end
51
- end
52
- end
53
- end
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('&#x2718;', 0, 'badge-important') + g_link('&#x2713;', 1, 'badge-success')
42
+ when false
43
+ g_link('&#x2718;', 1, 'badge-important')
44
+ when true
45
+ g_link('&#x2713', 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
@@ -1,3 +1,3 @@
1
1
  module RailsAdminToggleable
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  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.2.1
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-05-17 00:00:00.000000000 Z
11
+ date: 2013-06-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Toggleable field for rails admin
14
14
  email: