active_admin_tokeninput 0.0.2 → 0.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a185b6d32121eef50d5943d37dbd38391fd599ff
4
- data.tar.gz: 13fad77e729f70a0fdcf19b787413f501af071f9
3
+ metadata.gz: 40f148eafa2629d3f1eaa5784845ea2927d3c2c5
4
+ data.tar.gz: b384646740b7acfae1a271425ae60a718ad7acbc
5
5
  SHA512:
6
- metadata.gz: 12252b74d2d4a3f913c54c278f122d82fac6a6944614a06c32c3f1d2efa5c1e5a436cb57125c4dad3fa5551edc14336c243f57076153ea7ed353495e79908acb
7
- data.tar.gz: 1493a370e2f1e90c1c24dd0006e06a8264b38ab9d532f9110481a5c3221ed1a82b320d2948a9dc5e53dd9e63ac7183fa25665fc9cff03e914d4522a62e1ccbaa
6
+ metadata.gz: 450237641d1e4d8df43d5eeba6d4ec516b877b2c98b71a78d16d63ab9a3b4dde5acdc60786dca66c9ed31c871a6447fc1d490e3c4e1383d18b14afc201d00138
7
+ data.tar.gz: a158b515b528e85d2c58b8553be97e952a1773327194fc8cd77fdcbc103c416324efc575359bacd15c8016eb2b39e780e32d6c4e55983736bb4d433d7bbf96fe
@@ -0,0 +1,20 @@
1
+ //= require jquery.pl.tokeninput
2
+
3
+ $(document).ready(function() {
4
+ $("input.active-admin-tokeninput").each(function() {
5
+ autocomplete_path = $(this).attr('data-autocomplete-path');
6
+ tokenLimit = $(this).attr('data-token-limit');
7
+ fieldName = $(this).attr('data-field-name');
8
+
9
+
10
+ $(this).tokenInput(autocomplete_path, {
11
+ prePopulate: $(this).data("pre"),
12
+ allowCreate: true,
13
+ preventDuplicates: true,
14
+ theme: "facebook",
15
+ parentInput: "#" + $(this).attr('id'),
16
+ fieldName: fieldName,
17
+ tokenLimit: tokenLimit
18
+ });
19
+ });
20
+ });
@@ -0,0 +1,13 @@
1
+ class BelongsToTokenInput < Formtastic::Inputs::StringInput
2
+
3
+ def input_html_options
4
+ super.merge(
5
+ "data-token-limit" => 1,
6
+ "class" => "active-admin-tokeninput",
7
+ "data-field-name" => "#{object_name.underscore}[#{method.to_s.singularize}_id]",
8
+ "data-pre" => "[#{object.send("#{method}").to_json(:only => [:id, :name])}]",
9
+ "name" => "",
10
+ "value" => "",
11
+ )
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class HasManyTokenInput < Formtastic::Inputs::StringInput
2
+
3
+ def input_html_options
4
+ super.merge(
5
+ "class" => "active-admin-tokeninput",
6
+ "data-field-name" => "#{object_name.underscore}[#{method.to_s.singularize}_ids][]",
7
+ "data-pre" => object.send("#{method}").map.to_json(:only => [:id, :name]),
8
+ "name" => "",
9
+ "value" => "",
10
+ "data-autocomplete-path" => options[:autocomplete_path] ||= Rails.application.routes.url_helpers.send("autocomplete_admin_#{method.to_s}_path")
11
+ )
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module ActiveAdminTokeninput
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_admin_tokeninput
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Porter
@@ -45,6 +45,9 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - app/assets/javascripts/active_admin_tokeninput/active_admin_tokeninput.js
49
+ - app/inputs/belongs_to_token_input.rb
50
+ - app/inputs/has_many_token_input.rb
48
51
  - vendor/assets/javascripts/jquery.pl.tokeninput.js
49
52
  - lib/active_admin_tokeninput/dsl.rb
50
53
  - lib/active_admin_tokeninput/engine.rb