activeadmin-ajax_filter 0.2.1 → 0.2.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46aa33c1ac28fdf69a6c7a312c77136f5f89f286
|
4
|
+
data.tar.gz: 16ac2160318afdd2cdcb9e56f291d73647128935
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c5771600ec5d2aeb8e0ef815df17e504b85a6ca23539b6aa08a28405d6280e61356d417a9f2a3562c7f7266fbdd05ec0a5ae24562cad14c0e489bed22f4b8e0
|
7
|
+
data.tar.gz: 4f7314e3bb8ebc891bfb5896eda8c9a7be0cab5149749d6a656fb5dc2c9cacf312e246aa17f440fa505dea81110018d5c496e6f729ed32a42bdd7fe2bb7ea16f
|
data/README.md
CHANGED
@@ -62,11 +62,12 @@ end
|
|
62
62
|
|
63
63
|
You can use next parameters in `data` hash:
|
64
64
|
|
65
|
+
* `search_fields` - fields by which AJAX search will be performed, **required**
|
65
66
|
* `limit` - count of the items which will be requested by AJAX, by default `5`
|
66
67
|
* `value_field` - value field for html select element, by default `id`
|
67
|
-
* `search_fields` - fields by which AJAX search will be performed, required
|
68
68
|
* `ordering` - sort string like `email ASC, customer_uid DESC`, by default it uses first value of `search_fields` with `ASC` direction
|
69
69
|
* `ransack` - ransack query which will be applied, by default it's builded from `search_fields` with `or` and `contains` clauses, e.g.: `email_or_customer_uid_cont`
|
70
|
+
* `url` - url for AJAX query by default is builded from field name
|
70
71
|
|
71
72
|
## Development
|
72
73
|
|
@@ -4,10 +4,11 @@ $ ->
|
|
4
4
|
valueField = select.data('value-field')
|
5
5
|
searchFields = select.data('search-fields').split(' ')
|
6
6
|
ordering = select.data('ordering')
|
7
|
+
url = select.data('url')
|
7
8
|
|
8
9
|
loadOptions = (q, callback) ->
|
9
10
|
$.ajax
|
10
|
-
url:
|
11
|
+
url: url
|
11
12
|
type: 'GET'
|
12
13
|
dataType: 'json'
|
13
14
|
data:
|
@@ -20,6 +20,7 @@ module ActiveAdmin
|
|
20
20
|
'data-ordering' => ordering,
|
21
21
|
'data-ransack' => ransack,
|
22
22
|
'data-selected-value' => selected_value,
|
23
|
+
'data-url' => url,
|
23
24
|
)
|
24
25
|
end
|
25
26
|
|
@@ -47,6 +48,10 @@ module ActiveAdmin
|
|
47
48
|
ajax_data[:ransack] || "#{search_fields.join('_or_')}_cont"
|
48
49
|
end
|
49
50
|
|
51
|
+
def url
|
52
|
+
ajax_data[:url] || "#{method.to_s.pluralize}/filter"
|
53
|
+
end
|
54
|
+
|
50
55
|
def selected_value
|
51
56
|
if @object
|
52
57
|
@object.try(:send, input_name)
|