administrate_ransack 0.1.13 → 0.1.14
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03cd63f65e6f42ec034fa6452a68effb67323fbe935036a643c4f17f6013adfa
|
4
|
+
data.tar.gz: d7bb0e58c6a9a0cd8791a8d4faf130361a9bfc823e6c006ac581213ad874fc3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31d0540c3ed2218c72fe49e1f8ce25c9cfcd2b8e45e716fde2343a75ef72af886120b555f27821e6412a33c76bd51cd6238d29f37e037f5a4b2be63114ce581f
|
7
|
+
data.tar.gz: 288e6c8a0ec50670583e4a5fc5b9e65bf4238a01538e57308bdfa20d3ab5d626262aca02d90508a924ffa41a775ff4b8c1e1a20630dd5d2973e8c18e6cf8ba47
|
data/README.md
CHANGED
@@ -16,7 +16,7 @@ prepend AdministrateRansack::Searchable
|
|
16
16
|
```erb
|
17
17
|
<%= render('administrate_ransack/filters') %>
|
18
18
|
```
|
19
|
-
- See the
|
19
|
+
- See the Usage section for extra options
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
- The filters partial accepts some optional parameters:
|
@@ -37,12 +37,6 @@ end
|
|
37
37
|
|
38
38
|
## Notes
|
39
39
|
- Administrate Search logic works independently from Ransack searches, I suggest to disable it eventually (ex. overriding `show_search_bar?` in the controller)
|
40
|
-
- Ordering by clicking on the headers of the table preserving the Ransack searches requires a change to the headers links, replacing the th links of *_collection* partial with:
|
41
|
-
```rb
|
42
|
-
sort_link(@ransack_results, attr_name) do
|
43
|
-
# ...
|
44
|
-
end
|
45
|
-
```
|
46
40
|
- Date/time filters use Rails `datetime_field` method which produces a `datetime-local` input field, at the moment this type of element is not broadly supported, a workaround is to include [flatpickr](https://github.com/flatpickr/flatpickr) datetime library.
|
47
41
|
+ This gem checks if `flatpickr` function is available in the global scope and applies it to the `datetime-local` filter inputs;
|
48
42
|
+ you can include the library using your application assets or via CDN, ex. adding to **app/views/layouts/admin/application.html.erb**:
|
@@ -23,6 +23,7 @@
|
|
23
23
|
clear_filters_path = url_for(url_for([:admin, @ransack_results.klass]))
|
24
24
|
end
|
25
25
|
%>
|
26
|
+
|
26
27
|
<%= search_form_for form_path, form_options do |f| %>
|
27
28
|
<div class="filters">
|
28
29
|
<% attribute_types.each do |field, type| %>
|
@@ -82,7 +83,7 @@
|
|
82
83
|
</div>
|
83
84
|
|
84
85
|
<div class="filters-buttons">
|
85
|
-
<%= f.submit %>
|
86
|
+
<%= f.submit t('administrate_ransack.filters.search'), name: nil %>
|
86
87
|
<%= link_to t('administrate_ransack.filters.clear_filters'), clear_filters_path, class: 'btn-clear-filters' %>
|
87
88
|
</div>
|
88
89
|
<% end %>
|
data/config/locales/en.yml
CHANGED
@@ -8,5 +8,20 @@ module AdministrateRansack
|
|
8
8
|
@ransack_results = super.ransack(params[:q])
|
9
9
|
@ransack_results.result(distinct: true)
|
10
10
|
end
|
11
|
+
|
12
|
+
# ref => https://github.com/thoughtbot/administrate/blob/v0.15.0/app/helpers/administrate/application_helper.rb#L54-L60
|
13
|
+
def sanitized_order_params(page, current_field_name)
|
14
|
+
collection_names = page.item_includes + [current_field_name]
|
15
|
+
association_params = collection_names.map do |assoc_name|
|
16
|
+
{ assoc_name => %i[order direction page per_page] }
|
17
|
+
end
|
18
|
+
params.permit(:search, :id, :page, :per_page, association_params, q: {})
|
19
|
+
end
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def prepended(base)
|
23
|
+
base.helper_method :sanitized_order_params
|
24
|
+
end
|
25
|
+
end
|
11
26
|
end
|
12
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: administrate_ransack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattia Roccoberton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-04-
|
11
|
+
date: 2021-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: administrate
|
@@ -227,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
227
|
- !ruby/object:Gem::Version
|
228
228
|
version: '0'
|
229
229
|
requirements: []
|
230
|
-
rubygems_version: 3.
|
230
|
+
rubygems_version: 3.0.3
|
231
231
|
signing_key:
|
232
232
|
specification_version: 4
|
233
233
|
summary: Administrate Ransack plugin
|