sn_filterable 1.1.0 → 1.2.0
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4336044ac4cbb8ec562c2b2dba9476223cd93044830290c7bca832e806710583
|
4
|
+
data.tar.gz: c664cc00c442d9638d4d648942b8a3a22fa4f56f4f8b0a624926d3458f2f52f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f58e96ceb91c84632ccd441cdf7b5343a9a726fc016ce462ee65cb63edd53a4eda740f46589abf4a677fb20e1908020dae6eded35841105da6c097492c7b46d
|
7
|
+
data.tar.gz: 2b795ac02cfa49ec8ed72bdee4d8d3bb74d941e4555fbb93539a238801126e7f5c3d1a4240b2abf70bd1d473df1edda3bd84aa1615b89c12e502476c7f0afba2
|
data/README.md
CHANGED
@@ -53,6 +53,13 @@ en:
|
|
53
53
|
<%= SnFilterable.load_js %>
|
54
54
|
```
|
55
55
|
|
56
|
+
If your application does not allow for use of `.js.erb` files the JavaScript can be loaded by adding the following to your layout:
|
57
|
+
```javascript
|
58
|
+
<%= javascript_tag nonce: true do %>
|
59
|
+
<%= SnFilterable.load_js.html_safe %>
|
60
|
+
<% end %>
|
61
|
+
```
|
62
|
+
|
56
63
|
3. Configure your app's Tailwind to scan the gem
|
57
64
|
```javascript
|
58
65
|
// tailwind.config.js
|
@@ -190,8 +197,29 @@ Now the test suite can be run from the project root using
|
|
190
197
|
bundle exec rspec
|
191
198
|
```
|
192
199
|
|
200
|
+
### Using a Development Version
|
201
|
+
|
202
|
+
Your changes can be tested manually by making one of the following additions to an App's Gemfile:
|
203
|
+
|
204
|
+
For using a local version:
|
205
|
+
```ruby
|
206
|
+
gem "sn_filterable", path: "path/to/gem/sn_filterable"
|
207
|
+
```
|
208
|
+
|
209
|
+
For using a GitHub branch:
|
210
|
+
```ruby
|
211
|
+
gem "sn_filterable", git: "https://github.com/ibm-skills-network/sn_filterable.git", branch: "defaults_to_main"
|
212
|
+
```
|
213
|
+
|
214
|
+
|
193
215
|
## Contributing
|
194
216
|
|
217
|
+
Once you have made your updates to the codebase do the following to ensure a smooth merge:
|
218
|
+
|
219
|
+
1. Update `lib/sn_filterable/version.rb` to follow [Semantic Versioning](https://semver.org)
|
220
|
+
|
221
|
+
2. Run `bundle` to update the `Gemfile.lock` with your new version
|
222
|
+
|
195
223
|
Bug reports and pull requests are welcome on [GitHub](https://github.com/ibm-skills-network/sn_filterable).
|
196
224
|
|
197
225
|
## License
|
@@ -7,6 +7,9 @@
|
|
7
7
|
"data-turbo-frame": @frame_id,
|
8
8
|
"class": "relative",
|
9
9
|
"@submit": "filtersLoading = true" do %>
|
10
|
+
<% @extra_params.each do |k, v| %>
|
11
|
+
<%= content_tag :input, "", class: "hidden", type: "hidden", value: v, name: k %>
|
12
|
+
<% end %>
|
10
13
|
<div class="absolute w-full h-full pointer-events-none">
|
11
14
|
<div class="absolute flex flex-col sm:grid sm:grid-cols-3 gap-4 w-full pointer-events-none">
|
12
15
|
<div class="sm:hidden h-14"></div>
|
@@ -24,7 +24,8 @@ module SnFilterable
|
|
24
24
|
# @param [String, nil] search_filter_name Optional, enable's and set's the search filter, specified by the filter's parameter name
|
25
25
|
# @param [Boolean] show_sidebar If true, will show the sidebar with the filters.
|
26
26
|
# @param [Boolean] update_url_on_submit If true, will update the URL in the user's browser on form submission.
|
27
|
-
|
27
|
+
# @param [Hash] extra_params Optional, allows for custom form values to be supplied. Useful if you need to retain non-filterable query params
|
28
|
+
def initialize(frame_id:, filtered:, filters:, url: nil, search_filter_name: nil, show_sidebar: true, update_url_on_submit: true, extra_params: {})
|
28
29
|
@frame_id = frame_id
|
29
30
|
@filtered = filtered
|
30
31
|
@filters = filters
|
@@ -32,6 +33,7 @@ module SnFilterable
|
|
32
33
|
@search_filter_name = search_filter_name
|
33
34
|
@show_sidebar = show_sidebar
|
34
35
|
@update_url_on_submit = update_url_on_submit
|
36
|
+
@extra_params = extra_params
|
35
37
|
end
|
36
38
|
|
37
39
|
def search_field
|
@@ -33,9 +33,8 @@ module SnFilterable
|
|
33
33
|
filter_params = filter_params(params)
|
34
34
|
sort_params = sort_params(params)
|
35
35
|
other_params = other_params(params, items)
|
36
|
-
|
37
|
-
items = perform_filter(items, filter_params)
|
38
36
|
items, sort_name, reverse_order = perform_sort(items, sort_params, default_sort)
|
37
|
+
items = perform_filter(items, filter_params)
|
39
38
|
items = items.page(other_params[:page]).per(other_params[:per]) if pagination_enabled
|
40
39
|
|
41
40
|
Filtered.new(self, items, generate_url_queries(filter_params, sort_params, other_params), sort_name, reverse_order)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sn_filterable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- IBM Skills Network
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: heroicon
|
@@ -237,7 +237,7 @@ dependencies:
|
|
237
237
|
description: This gem adds a ViewComponent powered filtering component for searching
|
238
238
|
and filtering your PostgreSQL data.
|
239
239
|
email:
|
240
|
-
-
|
240
|
+
- Skills.Network@ibm.com
|
241
241
|
executables: []
|
242
242
|
extensions: []
|
243
243
|
extra_rdoc_files: []
|
@@ -280,14 +280,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
280
280
|
requirements:
|
281
281
|
- - ">="
|
282
282
|
- !ruby/object:Gem::Version
|
283
|
-
version: 2.
|
283
|
+
version: 3.2.0
|
284
284
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
285
285
|
requirements:
|
286
286
|
- - ">="
|
287
287
|
- !ruby/object:Gem::Version
|
288
288
|
version: '0'
|
289
289
|
requirements: []
|
290
|
-
rubygems_version: 3.
|
290
|
+
rubygems_version: 3.5.3
|
291
291
|
signing_key:
|
292
292
|
specification_version: 4
|
293
293
|
summary: Skills Network - Item filtering component
|