rails_admin_boolean_toggle 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OGU2ODNkMTkzZDMxNjU1NzI1MDkwNzJhODM3ZTBlYmZkNGNjNWI2MQ==
5
+ data.tar.gz: !binary |-
6
+ Mjg2NDhlZTI2MDc4NDMxMjQyYTljNTEwZmE5YTQ1YWEyZTg5MWU1Yg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZTAxYzg0YWYxMTNjZDYyM2U3ZDU3ZmIxMTVhNjljM2M5YWM4YTA4NjQ0NGM4
10
+ MWY5YjEwOTdlNjQyNzlhN2U5YTJiNzBlYWVhZjlhNjVlZTM1MGYzYWI0NGNj
11
+ YjMwOWYyMzJlNzhiYmViZGUxMzBmMzA5NWEwYjU0NTc0YWFlMjQ=
12
+ data.tar.gz: !binary |-
13
+ ZTMyYjhhZThmODVhMWE0OWM4ZjllOWNlOGFkYzkzOWExNmNiNjEyMTU2YWI0
14
+ MDFkMzdlNDhiMWJjNjY4M2U2YTk2MDNmMjk4ZjMyZDlkZWM2NjJiODJhNzU4
15
+ NjQyMWY3YzAyOTE4MjEyYjgwMDg2NTdhZjViZTA3ZGZkM2I0MzE=
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rails_admin_boolean_toggle.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Sergey Malykh
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # RailsAdminBooleanToggle
2
+
3
+ Replace default boolean field behaviour with toggleable (https://github.com/rs-pro/rails_admin_toggleable). So boolean field now looks like rails_admin_toggleable but filter and sorting also working.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rails_admin_boolean_toggle'
10
+
11
+ Instead of:
12
+
13
+ gem 'rails_admin_toggleable'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install rails_admin_boolean_toggle
22
+
23
+ ## Usage
24
+
25
+ Add the toggleable action:
26
+
27
+ RailsAdmin.config do |config|
28
+ config.actions do
29
+ ......
30
+ toggle
31
+ end
32
+ end
33
+
34
+ Add boolean field:
35
+
36
+ rails_admin do
37
+ list do
38
+ field :enabled, :boolean
39
+ ...
40
+ end
41
+ ...
42
+ end
43
+
44
+ ## Contributing
45
+
46
+ 1. Fork it
47
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
48
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
49
+ 4. Push to the branch (`git push origin my-new-feature`)
50
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,6 @@
1
+ require "rails_admin_boolean_toggle/version"
2
+
3
+ require 'rails_admin/config/fields/types/boolean'
4
+ require 'rails_admin_toggleable/action'
5
+
6
+ require 'rails_admin_boolean_toggle/engine'
@@ -0,0 +1,44 @@
1
+ module RailsAdminBooleanToggle
2
+ class Engine < ::Rails::Engine
3
+ config.to_prepare do
4
+ RailsAdmin::Config::Fields::Types::Boolean.class_eval do
5
+ include RailsAdmin::Engine.routes.url_helpers
6
+
7
+ register_instance_option :view_helper do
8
+ :check_box
9
+ end
10
+
11
+ register_instance_option :pretty_value do
12
+ def g_link(fv, on, badge)
13
+ bindings[:view].link_to(
14
+ fv.html_safe,
15
+ toggle_path(model_name: @abstract_model, id: bindings[:object].id, method: name, on: on.to_s),
16
+ method: :post,
17
+ class: 'badge ' + badge
18
+ )
19
+ end
20
+
21
+ case value
22
+ when nil
23
+ g_link('&#x2718;', 0, 'badge-important') + g_link('&#x2713;', 1, 'badge-success')
24
+ when false
25
+ g_link('&#x2718;', 1, 'badge-important')
26
+ when true
27
+ g_link('&#x2713', 0, 'badge-success')
28
+ else
29
+ %{<span class="badge">-</span>}
30
+ end.html_safe
31
+ end
32
+
33
+ register_instance_option :export_value do
34
+ value.inspect
35
+ end
36
+
37
+ # Accessor for field's help text displayed below input field.
38
+ register_instance_option :help do
39
+ ""
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ module RailsAdminBooleanToggle
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rails_admin_boolean_toggle/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "rails_admin_boolean_toggle"
8
+ gem.version = RailsAdminBooleanToggle::VERSION
9
+ gem.authors = ["Sergey Malykh"]
10
+ gem.email = ["xronos.i.am@gmail.com"]
11
+ gem.description = %q{Boolean field behaviour replacement for rails admin}
12
+ gem.summary = %q{Replaces default boolean field behaviour with rails_admin_toggleable}
13
+ gem.homepage = "https://github.com/xronos-i-am/rails_admin_boolean_toggle"
14
+ gem.license = "MIT"
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_runtime_dependency "rails_admin_toggleable"
22
+
23
+ gem.add_development_dependency "rails_admin_toggleable"
24
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_admin_boolean_toggle
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Sergey Malykh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails_admin_toggleable
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rails_admin_toggleable
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Boolean field behaviour replacement for rails admin
42
+ email:
43
+ - xronos.i.am@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - lib/rails_admin_boolean_toggle.rb
54
+ - lib/rails_admin_boolean_toggle/engine.rb
55
+ - lib/rails_admin_boolean_toggle/version.rb
56
+ - rails_admin_boolean_toggle.gemspec
57
+ homepage: https://github.com/xronos-i-am/rails_admin_boolean_toggle
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.1.11
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Replaces default boolean field behaviour with rails_admin_toggleable
81
+ test_files: []