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: 374c4336d215f1d32fcd3275cb9a5a79be7b0470
4
- data.tar.gz: 1179542dc6067ad0ce805f7756c0a7f0c4eba969
3
+ metadata.gz: 46aa33c1ac28fdf69a6c7a312c77136f5f89f286
4
+ data.tar.gz: 16ac2160318afdd2cdcb9e56f291d73647128935
5
5
  SHA512:
6
- metadata.gz: 07c43c23e6e2bdd17591e64aa8a045402b0500229654f0843ee076790e64f8320ada5ebf8b9781c30443bcde8b71b30f4fa1066c36422e8d79ea8e08769361d3
7
- data.tar.gz: 5b6f87ac8a785b6393f73aa71d48679b7fc3459d869dd0155862e3d2aaa277d5c6103eeb510a6c0f061727b4c7c7cb5e1155de67477a335533160babc6c9e5d7
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: 'users/filter'
11
+ url: url
11
12
  type: 'GET'
12
13
  dataType: 'json'
13
14
  data:
@@ -1,5 +1,5 @@
1
1
  module ActiveAdmin
2
2
  module AjaxFilter
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
5
5
  end
@@ -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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-ajax_filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Emelyanov