rails_admin_selectable 0.1.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2a1aefed38ddbce34eb40a22dc1f428c3ebafbfa
4
+ data.tar.gz: 4d172f71be403d030981fc667ba096189c54e8e3
5
+ SHA512:
6
+ metadata.gz: 04ab13b176210b097a1fb43d8c819303a6b943e6048db1816f8d2e3191df9f2af284f11b54f08bd313314f01403dc0895b86119719eccc249759f6c14693bab0
7
+ data.tar.gz: 5db1b46be62b5823903d68617ebf63fb7aec538a370459f23cb1c88b78d7851373e8d93539064eaa73c38bf87a96f4ab0b038f5d07e03348236f7a5045beb6b4
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ InstalledFiles
7
+ _yardoc
8
+ coverage
9
+ doc/
10
+ lib/bundler/man
11
+ pkg
12
+ rdoc
13
+ spec/reports
14
+ test/tmp
15
+ test/version_tmp
16
+ tmp
17
+ .idea
18
+ tags
@@ -0,0 +1,2 @@
1
+ rails_admin_selectable
2
+
@@ -0,0 +1,2 @@
1
+ 2.2.1
2
+
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails_admin', github: 'sferik/rails_admin'
4
+
5
+ # Specify your gem's dependencies in rails_admin_toggleable.gemspec
6
+ gemspec
@@ -0,0 +1,164 @@
1
+ GIT
2
+ remote: git://github.com/sferik/rails_admin.git
3
+ revision: 5aafa20156439309ce013bcfbaf4120bd03d7cca
4
+ specs:
5
+ rails_admin (1.0.0.beta)
6
+ builder (~> 3.1)
7
+ coffee-rails (~> 4.0)
8
+ font-awesome-rails (>= 3.0, < 5)
9
+ haml (~> 4.0)
10
+ jquery-rails (>= 3.0, < 5)
11
+ jquery-ui-rails (~> 5.0)
12
+ kaminari (~> 0.14)
13
+ nested_form (~> 0.3)
14
+ rack-pjax (~> 0.7)
15
+ rails (~> 4.0)
16
+ remotipart (~> 1.0)
17
+ safe_yaml (~> 1.0)
18
+ sass-rails (>= 4.0, < 6)
19
+
20
+ PATH
21
+ remote: .
22
+ specs:
23
+ rails_admin_selectable (0.1.0)
24
+ rails_admin
25
+
26
+ GEM
27
+ remote: https://rubygems.org/
28
+ specs:
29
+ actionmailer (4.2.3)
30
+ actionpack (= 4.2.3)
31
+ actionview (= 4.2.3)
32
+ activejob (= 4.2.3)
33
+ mail (~> 2.5, >= 2.5.4)
34
+ rails-dom-testing (~> 1.0, >= 1.0.5)
35
+ actionpack (4.2.3)
36
+ actionview (= 4.2.3)
37
+ activesupport (= 4.2.3)
38
+ rack (~> 1.6)
39
+ rack-test (~> 0.6.2)
40
+ rails-dom-testing (~> 1.0, >= 1.0.5)
41
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
42
+ actionview (4.2.3)
43
+ activesupport (= 4.2.3)
44
+ builder (~> 3.1)
45
+ erubis (~> 2.7.0)
46
+ rails-dom-testing (~> 1.0, >= 1.0.5)
47
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
48
+ activejob (4.2.3)
49
+ activesupport (= 4.2.3)
50
+ globalid (>= 0.3.0)
51
+ activemodel (4.2.3)
52
+ activesupport (= 4.2.3)
53
+ builder (~> 3.1)
54
+ activerecord (4.2.3)
55
+ activemodel (= 4.2.3)
56
+ activesupport (= 4.2.3)
57
+ arel (~> 6.0)
58
+ activesupport (4.2.3)
59
+ i18n (~> 0.7)
60
+ json (~> 1.7, >= 1.7.7)
61
+ minitest (~> 5.1)
62
+ thread_safe (~> 0.3, >= 0.3.4)
63
+ tzinfo (~> 1.1)
64
+ arel (6.0.2)
65
+ builder (3.2.2)
66
+ coffee-rails (4.1.0)
67
+ coffee-script (>= 2.2.0)
68
+ railties (>= 4.0.0, < 5.0)
69
+ coffee-script (2.4.1)
70
+ coffee-script-source
71
+ execjs
72
+ coffee-script-source (1.9.1.1)
73
+ erubis (2.7.0)
74
+ execjs (2.5.2)
75
+ font-awesome-rails (4.3.0.0)
76
+ railties (>= 3.2, < 5.0)
77
+ globalid (0.3.5)
78
+ activesupport (>= 4.1.0)
79
+ haml (4.0.6)
80
+ tilt
81
+ i18n (0.7.0)
82
+ jquery-rails (4.0.4)
83
+ rails-dom-testing (~> 1.0)
84
+ railties (>= 4.2.0)
85
+ thor (>= 0.14, < 2.0)
86
+ jquery-ui-rails (5.0.5)
87
+ railties (>= 3.2.16)
88
+ json (1.8.3)
89
+ kaminari (0.16.3)
90
+ actionpack (>= 3.0.0)
91
+ activesupport (>= 3.0.0)
92
+ loofah (2.0.2)
93
+ nokogiri (>= 1.5.9)
94
+ mail (2.6.3)
95
+ mime-types (>= 1.16, < 3)
96
+ mime-types (2.6.1)
97
+ mini_portile (0.6.2)
98
+ minitest (5.7.0)
99
+ nested_form (0.3.2)
100
+ nokogiri (1.6.6.2)
101
+ mini_portile (~> 0.6.0)
102
+ rack (1.6.4)
103
+ rack-pjax (0.8.0)
104
+ nokogiri (~> 1.5)
105
+ rack (~> 1.1)
106
+ rack-test (0.6.3)
107
+ rack (>= 1.0)
108
+ rails (4.2.3)
109
+ actionmailer (= 4.2.3)
110
+ actionpack (= 4.2.3)
111
+ actionview (= 4.2.3)
112
+ activejob (= 4.2.3)
113
+ activemodel (= 4.2.3)
114
+ activerecord (= 4.2.3)
115
+ activesupport (= 4.2.3)
116
+ bundler (>= 1.3.0, < 2.0)
117
+ railties (= 4.2.3)
118
+ sprockets-rails
119
+ rails-deprecated_sanitizer (1.0.3)
120
+ activesupport (>= 4.2.0.alpha)
121
+ rails-dom-testing (1.0.6)
122
+ activesupport (>= 4.2.0.beta, < 5.0)
123
+ nokogiri (~> 1.6.0)
124
+ rails-deprecated_sanitizer (>= 1.0.1)
125
+ rails-html-sanitizer (1.0.2)
126
+ loofah (~> 2.0)
127
+ railties (4.2.3)
128
+ actionpack (= 4.2.3)
129
+ activesupport (= 4.2.3)
130
+ rake (>= 0.8.7)
131
+ thor (>= 0.18.1, < 2.0)
132
+ rake (10.4.2)
133
+ remotipart (1.2.1)
134
+ safe_yaml (1.0.4)
135
+ sass (3.4.16)
136
+ sass-rails (5.0.3)
137
+ railties (>= 4.0.0, < 5.0)
138
+ sass (~> 3.1)
139
+ sprockets (>= 2.8, < 4.0)
140
+ sprockets-rails (>= 2.0, < 4.0)
141
+ tilt (~> 1.1)
142
+ sprockets (3.2.0)
143
+ rack (~> 1.0)
144
+ sprockets-rails (2.3.2)
145
+ actionpack (>= 3.0)
146
+ activesupport (>= 3.0)
147
+ sprockets (>= 2.8, < 4.0)
148
+ thor (0.19.1)
149
+ thread_safe (0.3.5)
150
+ tilt (1.4.1)
151
+ tzinfo (1.2.2)
152
+ thread_safe (~> 0.1)
153
+
154
+ PLATFORMS
155
+ ruby
156
+
157
+ DEPENDENCIES
158
+ bundler
159
+ rails_admin!
160
+ rails_admin_selectable!
161
+ rake
162
+
163
+ BUNDLED WITH
164
+ 1.10.6
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Gleb Tv
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.
@@ -0,0 +1,46 @@
1
+ # RailsAdminSelectable
2
+
3
+ Make any association field easily selectable from index view in rails admin
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rails_admin_selectable'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rails_admin_selectable
18
+
19
+ ## Usage
20
+
21
+ Add the selectable action:
22
+
23
+ RailsAdmin.config do |config|
24
+ config.actions do
25
+ ......
26
+ select
27
+ end
28
+ end
29
+
30
+ Make the field you need selectable:
31
+
32
+ rails_admin do
33
+ list do
34
+ field :enabled, :select
35
+ ...
36
+ end
37
+ ...
38
+ end
39
+
40
+ ## Contributing
41
+
42
+ 1. Fork it
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,9 @@
1
+ en:
2
+ admin:
3
+ actions:
4
+ select:
5
+ title: "Select"
6
+ select:
7
+ success: '"%{attr}" changed success'
8
+ error: "Error: %{err}"
9
+ no_id: "No ID provided"
@@ -0,0 +1,10 @@
1
+ ru:
2
+ admin:
3
+ actions:
4
+ select:
5
+ title: "Выбрать"
6
+ select:
7
+ enabled: '"%{attr}" успешно обновлен'
8
+ error: "Ошибка: %{err}"
9
+ no_id: "Не указан ID"
10
+
@@ -0,0 +1,9 @@
1
+ require "rails_admin_selectable/version"
2
+
3
+ require 'rails_admin/config/actions'
4
+ require 'rails_admin/config/model'
5
+
6
+ require 'rails_admin_selectable/action'
7
+ require 'rails_admin_selectable/field'
8
+ require 'rails_admin_selectable/engine'
9
+
@@ -0,0 +1,71 @@
1
+ module RailsAdmin
2
+ module Config
3
+ module Actions
4
+ class Select < 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 do
23
+ if params['id'].present?
24
+ begin
25
+ @object = @abstract_model.model.find(params['id'])
26
+ @meth = params[:method]
27
+ @object.send(@meth + '=', params[:value])
28
+ if @object.save
29
+ if params['ajax'].present?
30
+ render json: { ok: true }
31
+ else
32
+ flash[:success] = I18n.t('admin.toggle.success', attr: @meth)
33
+ end
34
+ else
35
+ if params['ajax'].present?
36
+ render text: @object.errors.full_messages.join(', '), layout: false, status: 422
37
+ else
38
+ flash[:error] = @object.errors.full_messages.join(', ')
39
+ end
40
+ end
41
+ rescue Exception => e
42
+ if params['ajax'].present?
43
+ render text: I18n.t('admin.toggle.error', err: e.to_s), status: 422
44
+ else
45
+ flash[:error] = I18n.t('admin.toggle.error', err: e.to_s)
46
+ end
47
+ end
48
+ else
49
+ if params['ajax'].present?
50
+ render text: I18n.t('admin.toggle.no_id'), status: 422
51
+ else
52
+ flash[:error] = I18n.t('admin.toggle.no_id')
53
+ end
54
+
55
+ end
56
+
57
+ redirect_to :back unless params['ajax'].present?
58
+ end
59
+ end
60
+
61
+ register_instance_option :link_icon do
62
+ 'icon-move'
63
+ end
64
+
65
+ register_instance_option :http_methods do
66
+ [:post]
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,4 @@
1
+ module RailsAdminSelectable
2
+ class Engine < ::Rails::Engine
3
+ end
4
+ end
@@ -0,0 +1,37 @@
1
+ require 'builder'
2
+
3
+ module RailsAdmin
4
+ module Config
5
+ module Fields
6
+ module Types
7
+ class Select < RailsAdmin::Config::Fields::Association
8
+ RailsAdmin::Config::Fields::Types.register(self)
9
+ include RailsAdmin::Engine.routes.url_helpers
10
+
11
+ register_instance_option :view_helper do
12
+ :select
13
+ end
14
+
15
+ register_instance_option :pretty_value do
16
+ v = bindings[:view]
17
+ o = bindings[:object]
18
+ value = o.send(name)
19
+ collection = association.klass.order(associated_model_config.object_label_method).all
20
+ v.select_tag(name, v.options_from_collection_for_select(collection, :id, associated_model_config.object_label_method, value.try(:id)),
21
+ onchange: "var $t = $(this); $t.before('<i class=\"fa fa-spinner fa-spin\"></i>'); $.ajax({type: 'POST', url: '#{select_path(model_name: @abstract_model, id: o.id, method: association.foreign_key)}' + '&value=' + $t.val(), data: {ajax:true}, success: function(r) { $t.prev().remove(); $t.animate({ boxShadow: '0px 0px 10px #33CC33' }, 300).animate({ boxShadow: '' }, 700) }, error: function(e) { alert(e.responseText); }}); return false;"
22
+ )
23
+ end
24
+
25
+ register_instance_option :export_value do
26
+ value.inspect
27
+ end
28
+
29
+ # Accessor for field's help text displayed below input field.
30
+ register_instance_option :help do
31
+ ""
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,3 @@
1
+ module RailsAdminSelectable
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,25 @@
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_selectable/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "rails_admin_selectable"
8
+ gem.version = RailsAdminSelectable::VERSION
9
+ gem.authors = ["Gleb Tv", "Oleg Bavaev"]
10
+ gem.email = ["glebtv@gmail.com", "csolg7@gmail.com"]
11
+ gem.description = %q{Selectable field from index view for rails admin}
12
+ gem.summary = %q{Make any association field easily selectable from index view in rails admin}
13
+ gem.homepage = "https://github.com/jesson/rails_admin_selectable"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "rails_admin"
21
+
22
+ gem.add_development_dependency "bundler"
23
+ gem.add_development_dependency "rake"
24
+ end
25
+
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_admin_selectable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gleb Tv
8
+ - Oleg Bavaev
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-09-04 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails_admin
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ description: Selectable field from index view for rails admin
57
+ email:
58
+ - glebtv@gmail.com
59
+ - csolg7@gmail.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - ".ruby-gemset"
66
+ - ".ruby-version"
67
+ - Gemfile
68
+ - Gemfile.lock
69
+ - LICENSE.txt
70
+ - README.md
71
+ - Rakefile
72
+ - config/locales/en.rails_admin_selectable.yml
73
+ - config/locales/ru.rails_admin_selectable.yml
74
+ - lib/rails_admin_selectable.rb
75
+ - lib/rails_admin_selectable/action.rb
76
+ - lib/rails_admin_selectable/engine.rb
77
+ - lib/rails_admin_selectable/field.rb
78
+ - lib/rails_admin_selectable/version.rb
79
+ - rails_admin_selectable.gemspec
80
+ homepage: https://github.com/jesson/rails_admin_selectable
81
+ licenses: []
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.4.8
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: Make any association field easily selectable from index view in rails admin
103
+ test_files: []