simple_form-polymorphic_associations 0.0.4 → 0.0.5
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0886162b184227281cbda58946bcaebe1b4c9414d4b63f8f27457e786714a293'
|
4
|
+
data.tar.gz: 6498888d3b5c2e4cb0706731a34d395f4523cb675a702258b41fbb5138bdd430
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d34e50a1cfd8ac921abe43a93667bcba3cd744c2742de5b67675a144f15cfe2a6943b4b9fb64a93ee5ee6ad862323a997b2c9340b6b8d6f6e1536bffc1f47a70
|
7
|
+
data.tar.gz: 97932eb80112cb60eb6f98da0a542f09515e3289ee63980ee66e0db5831597095519a0e22f31eebab754eb11221e10b3db2066c0c61ddf98d251e0c669fe95da
|
data/app/assets/javascripts/simple_form-polymorphic_associations/application/autocomplete.js.coffee
CHANGED
@@ -1,7 +1,32 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
window.SimpleFormPolymorphicAssociations = window.SimpleFormPolymorphicAssociations ? {}
|
2
|
+
|
3
|
+
# When dynamically adding a new polymorphic association, we need to rebind the
|
4
|
+
# autocomplete to the new select2 element. This is done by calling the constructor
|
5
|
+
# on the new element.
|
6
|
+
#
|
7
|
+
# Example:
|
8
|
+
#
|
9
|
+
# :javascript
|
10
|
+
# var resourceSelect = $("#some-form").find(".polymorphic-association-resource-select")
|
11
|
+
# if (window.SimpleFormPolymorphicAssociations) {
|
12
|
+
# new window.SimpleFormPolymorphicAssociations.Autocomplete(resourceSelect);
|
13
|
+
# } else {
|
14
|
+
# console.error('window.SimpleFormPolymorphicAssociations.Autocomplete is not defined');
|
15
|
+
# }
|
16
|
+
#
|
17
|
+
class SimpleFormPolymorphicAssociations.Autocomplete
|
18
|
+
constructor: (@element) ->
|
19
|
+
@getUrl = @getUrl.bind(this)
|
20
|
+
@element.select2 ajax: @getAjaxOptions()
|
21
|
+
|
22
|
+
getAjaxOptions: ->
|
23
|
+
url: @getUrl
|
24
|
+
dataType: 'json'
|
7
25
|
delay: 500
|
26
|
+
|
27
|
+
getUrl: ->
|
28
|
+
klass = @element.siblings('.polymorphic-association-class-select').first().val()
|
29
|
+
@element.parent().find(".polymorphic-association-autocomplete-link[data-class='#{klass}']").attr('href')
|
30
|
+
|
31
|
+
$ ->
|
32
|
+
new SimpleFormPolymorphicAssociations.Autocomplete($('.polymorphic-association-resource-select'))
|
@@ -1 +1 @@
|
|
1
|
-
//= require simple_form-polymorphic_associations/application
|
1
|
+
//= require simple_form-polymorphic_associations/application
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_form-polymorphic_associations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roberto Vasquez Angel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_form
|