administrate_ransack 0.3.0 → 0.3.2
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 +43 -2
- data/app/views/administrate_ransack/_filters.html.erb +3 -2
- data/app/views/administrate_ransack/components/_field_date.html.erb +1 -1
- data/app/views/administrate_ransack/components/_field_datetime.html.erb +1 -1
- data/lib/administrate_ransack/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53f9b7117bb0a7ddf959ed0d6e6e054e781cbb50904e076ecba27790f221d2c0
|
4
|
+
data.tar.gz: dbc0c054f730be1b2b6479e8fa4e72a55d0adf0d9f1f46c3143606700289e9ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd13d31b54c05bacbc172eb81871044ab80e9fe1f5182fcdb20e7c4ef96245e3f95be05753abd5b7e7f5cd99367545530b992242d1845b6d4e9dea592d40862f
|
7
|
+
data.tar.gz: 0befebe036ae09c3336bfd214ae904acb6bfc773d4fe16dbdb89ed5248d36d921616e4b526a7e9c1bbfd430106f3830588be79786d67d64b55b19782bb5da9ec
|
data/README.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
# Administrate Ransack
|
1
|
+
# Administrate Ransack
|
2
|
+
[](https://badge.fury.io/rb/administrate_ransack)
|
3
|
+
[](https://rubygems.org/gems/administrate_ransack)
|
4
|
+
[](https://github.com/blocknotes/administrate_ransack/actions/workflows/linters.yml)
|
5
|
+
[](https://github.com/blocknotes/administrate_ransack/actions/workflows/specs.yml)
|
2
6
|
|
3
7
|
A plugin for [Administrate](https://github.com/thoughtbot/administrate) to use [Ransack](https://github.com/activerecord-hackery/ransack) for filtering resources.
|
4
8
|
|
@@ -26,6 +30,7 @@ prepend AdministrateRansack::Searchable
|
|
26
30
|
+ `attribute_labels`: hash used to override the field labels, ex. `{ title: "The title" }`
|
27
31
|
+ `attribute_types`: hash used to specify the filter fields, ex. `{ title: Administrate::Field::String }`
|
28
32
|
+ `search_path`: the path to use for searching (form URL)
|
33
|
+
+ `namespace`: the namespace used by Administrate, ex. `:supervisor`
|
29
34
|
- For associations (_has many_/_belongs to_) the label used can be customized adding an `admin_label` method to the target model which returns a string while the collection can by filtered with `admin_scope`. Example:
|
30
35
|
|
31
36
|
```rb
|
@@ -106,7 +111,11 @@ attribute_labels = {
|
|
106
111
|
```erb
|
107
112
|
<%= render('administrate_ransack/filters', attribute_types: @dashboard.class::RANSACK_TYPES) %>
|
108
113
|
```
|
114
|
+
|
115
|
+
## Sample styles
|
116
|
+
|
109
117
|
- Some basic style to setup the filters as a sidebar (see the screenshot below):
|
118
|
+
|
110
119
|
```css
|
111
120
|
.main-content__body {
|
112
121
|
display: inline-block;
|
@@ -131,7 +140,38 @@ attribute_labels = {
|
|
131
140
|
```
|
132
141
|
|
133
142
|
Screenshot:
|
134
|
-

|
143
|
+

|
144
|
+
|
145
|
+
- Alternative styles for an horizontal search bar:
|
146
|
+
|
147
|
+
```css
|
148
|
+
[data-administrate-ransack-filters] {
|
149
|
+
border: 1px solid #ddd;
|
150
|
+
padding: 10px;
|
151
|
+
text-align: center;
|
152
|
+
}
|
153
|
+
|
154
|
+
[data-administrate-ransack-filters] .filters {
|
155
|
+
display: inline-block;
|
156
|
+
}
|
157
|
+
|
158
|
+
[data-administrate-ransack-filters] .filter, [data-administrate-ransack-filters] .filter > label {
|
159
|
+
display: inline-block;
|
160
|
+
}
|
161
|
+
|
162
|
+
[data-administrate-ransack-filters] .filter > input {
|
163
|
+
display: inline-block;
|
164
|
+
width: auto;
|
165
|
+
}
|
166
|
+
|
167
|
+
[data-administrate-ransack-filters] .filters-buttons {
|
168
|
+
display: inline-block;
|
169
|
+
margin-left: 20px;
|
170
|
+
}
|
171
|
+
```
|
172
|
+
|
173
|
+
Screenshot:
|
174
|
+

|
135
175
|
|
136
176
|
## Extra notes
|
137
177
|
|
@@ -162,6 +202,7 @@ Or consider offering me a coffee, it's a small thing but it is greatly appreciat
|
|
162
202
|
## Contributors
|
163
203
|
|
164
204
|
- [Mattia Roccoberton](https://blocknot.es/): author
|
205
|
+
- The good guys that opened issues and pull requests from time to time
|
165
206
|
|
166
207
|
## License
|
167
208
|
|
@@ -14,13 +14,14 @@
|
|
14
14
|
attribute_labels ||= {}
|
15
15
|
attribute_types ||= @dashboard.attribute_types.select { |key, _value| @dashboard.collection_attributes.include?(key) }
|
16
16
|
form_options = { html: { 'data-administrate-ransack-filters': '1' } }
|
17
|
+
namespace = local_assigns[:namespace] || :admin
|
17
18
|
if local_assigns.has_key?(:search_path)
|
18
19
|
form_path = @ransack_results
|
19
20
|
form_options[:url] = search_path
|
20
21
|
clear_filters_path = search_path
|
21
22
|
else
|
22
|
-
form_path = [
|
23
|
-
clear_filters_path = url_for(url_for([
|
23
|
+
form_path = [namespace, @ransack_results]
|
24
|
+
clear_filters_path = url_for(url_for([namespace, @ransack_results.klass]))
|
24
25
|
end
|
25
26
|
%>
|
26
27
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= form.label(label) %>
|
2
2
|
<% if model.ransackable_scopes.include?(field) %>
|
3
|
-
<%= form.date_field(field) %>
|
3
|
+
<%= form.date_field(field, value: form.object.send(field)) %>
|
4
4
|
<% else %>
|
5
5
|
<%= form.date_field("#{field}_gteq") %>
|
6
6
|
<%= form.date_field("#{field}_lteq") %>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<%= form.label(label) %>
|
2
2
|
<% if model.ransackable_scopes.include?(field) %>
|
3
|
-
<%= form.datetime_field(field) %>
|
3
|
+
<%= form.datetime_field(field, value: form.object.send(field)) %>
|
4
4
|
<% else %>
|
5
5
|
<%= form.datetime_field("#{field}_gteq") %>
|
6
6
|
<%= form.datetime_field("#{field}_lteq") %>
|
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.3.
|
4
|
+
version: 0.3.2
|
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-
|
11
|
+
date: 2021-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: administrate
|