activeadmin-ajax_filter 0.3.4 → 0.3.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
  SHA1:
3
- metadata.gz: 378f102874a548df3322f7051f71e65be22920a8
4
- data.tar.gz: 7eb221e104eae5081be4cb421f7a907678bd01d8
3
+ metadata.gz: c3c7f4aee3fd33b595a1ffc93607105ddf846bd5
4
+ data.tar.gz: e8f49b3b765797df812bea7f0a0eb83a544c76ad
5
5
  SHA512:
6
- metadata.gz: 8b0b91afb812c4b200278eb6180cd551c0b7f139ad8125f6e19845d7b1ab386933a7217d92b90c13bad07786e952f33f7c2845868a808bac4253680fc04537f1
7
- data.tar.gz: 61cba6b7b463cd73e6d4fbd67466851971bc356ca74b00b681b7ad8efa8bdef7f71b9d8f4d0bf719693f2f605885e7c2a0ccf80c69ae546c9279dbb7901050e7
6
+ metadata.gz: dd107194fc32f19bf54573adcf15d6e63d5cee4d770d6584771c9b67c4e3421053b2b1de824e7832e0edda824ff0a35284e890da0c209583406266f0614e23b6
7
+ data.tar.gz: 80cd974c4dbd3ea41b283af0cfc049e839f82ad59f2cf0c5fd6f09a1c53dd2ffe80bda9448450e0fdc3b88a77a4f94b89ef1e931c0fe3ae88b4423b13b003245
data/README.md CHANGED
@@ -65,7 +65,7 @@ end
65
65
  # As a filter
66
66
  ActiveAdmin.register Invoice do
67
67
  filter :user, as: :ajax_select, data: {
68
- url: '/admin/users/filter',
68
+ url: :filter_admin_users_path,
69
69
  search_fields: [:email, :customer_uid],
70
70
  limit: 7,
71
71
  }
@@ -77,7 +77,7 @@ ActiveAdmin.register Invoice do
77
77
  form do |f|
78
78
  f.input :language # used by ajax_search_fields
79
79
  f.input :user, as: :ajax_select, data: {
80
- url: '/admin/users/filter',
80
+ url: filter_admin_users_path,
81
81
  search_fields: [:name],
82
82
  static_ransack: { active_eq: true },
83
83
  ajax_search_fields: [:language_id],
@@ -94,7 +94,7 @@ You can use next parameters in `data` hash:
94
94
  * `value_field` - value field for html select element, by default `id`
95
95
  * `ordering` - sort string like `email ASC, customer_uid DESC`, by default it uses first value of `search_fields` with `ASC` direction
96
96
  * `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`
97
- * `url` - url for AJAX query by default is builded from field name
97
+ * `url` - url for AJAX query by default is builded from field name. For inputs you can use url helpers, but on filters level url helpers isn't available, so if you need them you can pass symbols and it will be evaluated as url path (e.g. `:filter_admin_users_path`). `String` with relative path (like `/admin/users/filter`) can be used for both inputs and filters.
98
98
  * `ajax_search_fields` - array of field names. `ajax_select` input depends on `ajax_search_fields` values: e.g. you can scope user by languages.
99
99
  * `static_ransack` - hash of ransack predicates which will be applied statically and independently from current input field value
100
100
 
@@ -15,8 +15,10 @@ module ActiveAdmin
15
15
  dsl.instance_eval do
16
16
  collection_action :filter, method: :get do
17
17
  scope = collection.ransack(params[:q]).result
18
+ scope = scope.order(params[:order]).limit(params[:limit] || 10)
19
+ scope = apply_collection_decorator(scope)
18
20
 
19
- render text: scope.order(params[:order]).limit(params[:limit] || 10).to_json
21
+ render plain: scope.to_json
20
22
  end
21
23
  end
22
24
  end
@@ -1,5 +1,5 @@
1
1
  module ActiveAdmin
2
2
  module AjaxFilter
3
- VERSION = '0.3.4'
3
+ VERSION = '0.3.5'
4
4
  end
5
5
  end
@@ -58,7 +58,11 @@ module ActiveAdmin
58
58
  end
59
59
 
60
60
  def url
61
- ajax_data[:url] || "#{method.to_s.pluralize}/filter"
61
+ case (url = ajax_data[:url])
62
+ when nil then "#{method.to_s.pluralize}/filter"
63
+ when Symbol then Rails.application.routes.url_helpers.send(url)
64
+ else url
65
+ end
62
66
  end
63
67
 
64
68
  def selected_value
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin-ajax_filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Emelyanov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-23 00:00:00.000000000 Z
11
+ date: 2016-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin
@@ -302,7 +302,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
302
302
  version: '0'
303
303
  requirements: []
304
304
  rubyforge_project:
305
- rubygems_version: 2.5.1
305
+ rubygems_version: 2.6.2
306
306
  signing_key:
307
307
  specification_version: 4
308
308
  summary: AJAX filters for ActiveAdmin