listings 0.1.10 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +12 -0
- data/lib/listings/filter_view.rb +7 -1
- data/lib/listings/version.rb +1 -1
- data/spec/dummy/app/assets/config/manifest.js +1 -0
- data/spec/dummy/app/listings/tracks_listing.rb +13 -1
- data/spec/dummy/app/models/track.rb +1 -1
- data/spec/dummy/db/schema.rb +1 -0
- data/spec/dummy/db/seeds.rb +3 -1
- data/spec/dummy/spec +1 -1
- metadata +27 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4e4cd3fbee2a8df1a03f92b7b2253f3f015c650225c7369509dbd7635092aec1
|
4
|
+
data.tar.gz: e043d6119e93ea0ac355678326107a11617cd4b38173c66cfc9882fc480785e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 64ecbd2ae0bdd670cfc3229b84fe234873d556108afbce5d74bd7568091040063dd9f620b00119d1d650a64dacdc5253626f4510ea6017825d4600a6036d076a
|
7
|
+
data.tar.gz: 3a445d1e9f502d83e19cb15a3fb5ca16ef479dee04ba9a888acb2673a4756c54bb1acb77f3ab794b0264f75efbfcf873517bbdaef6b87d0ddaa712fb29806b22
|
data/README.md
CHANGED
@@ -243,6 +243,18 @@ It supports `title:` and a block
|
|
243
243
|
end
|
244
244
|
```
|
245
245
|
|
246
|
+
A `values: :method` can be specified to avoid the select distinct over the values.
|
247
|
+
|
248
|
+
```ruby
|
249
|
+
filter album: :name, values: :all_album_names, title: 'Album' do |album_name|
|
250
|
+
album_name.titleize
|
251
|
+
end
|
252
|
+
|
253
|
+
def all_album_names
|
254
|
+
Album.order("name").pluck("distinct name").reject(&:nil?)
|
255
|
+
end
|
256
|
+
```
|
257
|
+
|
246
258
|
Also `render:` option can be used to suppress the rendering of the filter, but allowing the user to filter by it. For example to filter by the id:
|
247
259
|
|
248
260
|
```ruby
|
data/lib/listings/filter_view.rb
CHANGED
@@ -9,7 +9,13 @@ module Listings
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def values
|
12
|
-
@values ||=
|
12
|
+
@values ||= begin
|
13
|
+
if method = @field_description.props[:values]
|
14
|
+
listing.send(method)
|
15
|
+
else
|
16
|
+
listing.data_source.values_for_filter(field)
|
17
|
+
end
|
18
|
+
end
|
13
19
|
end
|
14
20
|
|
15
21
|
def value_for(value)
|
data/lib/listings/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
{ }
|
@@ -2,11 +2,23 @@ class TracksListing < Listings::Base
|
|
2
2
|
|
3
3
|
model Track
|
4
4
|
|
5
|
-
filter album: :name
|
5
|
+
# filter album: :name # this also works but will do a distinct over the mode
|
6
|
+
filter album: :name, values: :album_names
|
6
7
|
filter album: :id, title: 'The Album Id' do |value|
|
7
8
|
"#{value}!"
|
8
9
|
end
|
9
10
|
filter :order, render: false
|
11
|
+
filter :label, values: :label_values
|
12
|
+
|
13
|
+
def album_names
|
14
|
+
Album.order("name").pluck("distinct name").reject(&:nil?)
|
15
|
+
end
|
16
|
+
|
17
|
+
def label_values
|
18
|
+
res = ["red", "blue"]
|
19
|
+
res << params[:l] if params[:l]
|
20
|
+
res
|
21
|
+
end
|
10
22
|
|
11
23
|
custom_filter :order_lte do |items, value|
|
12
24
|
items.where('"order" <= ?', value.to_i)
|
data/spec/dummy/db/schema.rb
CHANGED
data/spec/dummy/db/seeds.rb
CHANGED
data/spec/dummy/spec
CHANGED
@@ -1 +1 @@
|
|
1
|
-
spec
|
1
|
+
../../spec
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: listings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian J. Cardiff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.2.22
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.2.22
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: haml-rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,16 +84,30 @@ dependencies:
|
|
84
84
|
name: sqlite3
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 1.3.5
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 1.3.5
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: test-unit
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rspec-rails
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -189,6 +203,7 @@ files:
|
|
189
203
|
- lib/tasks/listings_tasks.rake
|
190
204
|
- spec/dummy/README.rdoc
|
191
205
|
- spec/dummy/Rakefile
|
206
|
+
- spec/dummy/app/assets/config/manifest.js
|
192
207
|
- spec/dummy/app/assets/javascripts/application.js
|
193
208
|
- spec/dummy/app/assets/stylesheets/application.css
|
194
209
|
- spec/dummy/app/controllers/application_controller.rb
|
@@ -279,8 +294,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
279
294
|
- !ruby/object:Gem::Version
|
280
295
|
version: '0'
|
281
296
|
requirements: []
|
282
|
-
|
283
|
-
rubygems_version: 2.6.12
|
297
|
+
rubygems_version: 3.0.3
|
284
298
|
signing_key:
|
285
299
|
specification_version: 4
|
286
300
|
summary: Simple creation of listings in rails applications.
|
@@ -309,6 +323,7 @@ test_files:
|
|
309
323
|
- spec/dummy/app/views/welcome/hash.html.haml
|
310
324
|
- spec/dummy/app/views/welcome/tracks.html.haml
|
311
325
|
- spec/dummy/app/views/layouts/application.html.erb
|
326
|
+
- spec/dummy/app/assets/config/manifest.js
|
312
327
|
- spec/dummy/app/assets/javascripts/application.js
|
313
328
|
- spec/dummy/app/assets/stylesheets/application.css
|
314
329
|
- spec/dummy/app/helpers/posts_helper.rb
|