rails_admin_toggleable 0.3.0 → 0.3.1

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: c21adfddd7f663d4ed432ab95a5990337152fac2
4
- data.tar.gz: 620062625106c01a8a44a035e9dce8701a8af8e5
3
+ metadata.gz: cdf07752624f3739bc2bf661c7b439421a4c57bd
4
+ data.tar.gz: e6eb4dd883bd7e870b72ea44b522a4733805c6b1
5
5
  SHA512:
6
- metadata.gz: 465ac594ea59d0f021dbe506c6f748ed0eb24f8b0e3b5e0f8200de5504cd0c94af427fd16e88bc6cccd04f0c6db02693a6b6ac4f5e49ea52167fdbdd9ff65972
7
- data.tar.gz: 7f8359d90e4e4a6d9a78610564ee443e0ca86e7dd00abfcc2e512a97edfd924eabe557c1ed4f7afed1de67cc9e4078cf95c0754ccb992d4a0984902356750f82
6
+ metadata.gz: 6d34159c692761853a752006bccae2f36d6cb2024015e9095b124bfc6871188e729739adcf4520c5704a374e2b49cce755d56bf5e61d3a2acfeee3f00bcbac34
7
+ data.tar.gz: 5a393f72baa767302192148904f4bb36d46eb478fdaee68c843ae04a384d73ef1751a0a10747608efa1a1f38f4a8bbe2a48efd01797768675be972a5c92f70d8
@@ -7,4 +7,5 @@ ru:
7
7
  enabled: '"%{attr}" включен'
8
8
  disabled: '"%{attr}" выключен'
9
9
  error: "Ошибка: %{err}"
10
- no_id: Не указан ID
10
+ no_id: "Не указан ID"
11
+
@@ -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(
@@ -1,3 +1,3 @@
1
1
  module RailsAdminToggleable
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
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.3.0
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-06-04 00:00:00.000000000 Z
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.3
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