activeadmin-ajax_filter 0.3.4 → 0.3.5
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 +4 -4
- data/README.md +3 -3
- data/lib/active_admin/ajax_filter.rb +3 -1
- data/lib/active_admin/ajax_filter/version.rb +1 -1
- data/lib/active_admin/inputs/ajax_core.rb +5 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3c7f4aee3fd33b595a1ffc93607105ddf846bd5
|
4
|
+
data.tar.gz: e8f49b3b765797df812bea7f0a0eb83a544c76ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
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:
|
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
|
21
|
+
render plain: scope.to_json
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
@@ -58,7 +58,11 @@ module ActiveAdmin
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def url
|
61
|
-
ajax_data[:url]
|
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
|
+
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
|
+
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.
|
305
|
+
rubygems_version: 2.6.2
|
306
306
|
signing_key:
|
307
307
|
specification_version: 4
|
308
308
|
summary: AJAX filters for ActiveAdmin
|