sn_filterable 1.0.1 → 1.1.1

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: 1d92b60cf8e65b1e9e7ff21155740d51f9a1a4b6b7bf7e81ba5a3d074c9fd8df
4
- data.tar.gz: fba0177360cf72c903a695fb10adcf05daffbcca0be615c7ba5c6dd989f69267
3
+ metadata.gz: 4d4ca6d509892a2c953861a953127b8488669f6b8b5a4ffad77e18c70797961c
4
+ data.tar.gz: f395268a282728c7b7632a9638cc7ee325eca5de6e3c9ff46f346f897794cc85
5
5
  SHA512:
6
- metadata.gz: ad2f3ec556867d5f643aa234de026dd4513ffb9866b78120ed863bbf136fff8e6ad08794ab670205063d46c271cff1b70b4dac637ce34b832c173aa48ca504ba
7
- data.tar.gz: 8c10a4fb5ec63e12dd3ac35a6edbd49873a2fefb15e0836892f363b4121e80ce38f7ec71c2a65ee31a3ec6295d81741a56882d71a3c3769e092da6d1bbbbb372
6
+ metadata.gz: 4dd00f9138cc3b36004a984e9285d339b2eab51e939ba45a8f0049e9a051b3b4d6970eee191a0b7954d1511f5f215b00591efc378da22920f18018c8c6ce1748
7
+ data.tar.gz: 23901c70d787118584e856012389a20440dc274768479057102e35bbcafa16ce6e1d035de49dac2390290f7af8183974ed5fe9d201cf38eb66cec572fb162c70
data/README.md CHANGED
@@ -20,7 +20,7 @@ There are a couple key requirements for your app to be compatible with this gem:
20
20
  Add this line to your application's Gemfile:
21
21
 
22
22
  ```ruby
23
- gem "sn_filterable", git: "https://github.com/ibm-skills-network/sn_filterable.git"
23
+ gem "sn_filterable"
24
24
  ```
25
25
 
26
26
  And then execute:
@@ -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
@@ -70,7 +70,7 @@
70
70
  </div>
71
71
  <% end %>
72
72
 
73
- <%= turbo_frame_tag @frame_id, "data-turbo-action": "advance" do %>
73
+ <%= turbo_frame_tag @frame_id, "data-turbo-action": @update_url_on_submit ? "advance" : nil do %>
74
74
  <%= content_tag :input, "", type: "hidden", name: "sort", value: @filtered.queries["sort"] if @filtered.queries["sort"].present? %>
75
75
  <%= content_tag :input, "", type: "hidden", name: "order", value: @filtered.queries["order"] if @filtered.queries["order"].present? %>
76
76
 
@@ -23,13 +23,15 @@ module SnFilterable
23
23
  # @param [String, nil] url Optional, the base URL of where the filters are displayed
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
- def initialize(frame_id:, filtered:, filters:, url: nil, search_filter_name: nil, show_sidebar: true)
26
+ # @param [Boolean] update_url_on_submit If true, will update the URL in the user's browser on form submission.
27
+ def initialize(frame_id:, filtered:, filters:, url: nil, search_filter_name: nil, show_sidebar: true, update_url_on_submit: true)
27
28
  @frame_id = frame_id
28
29
  @filtered = filtered
29
30
  @filters = filters
30
31
  @url = url
31
32
  @search_filter_name = search_filter_name
32
33
  @show_sidebar = show_sidebar
34
+ @update_url_on_submit = update_url_on_submit
33
35
  end
34
36
 
35
37
  def search_field
@@ -1,5 +1,4 @@
1
1
  require "rails/engine"
2
- require "view_component/engine"
3
2
 
4
3
  module SnFilterable
5
4
  class Engine < Rails::Engine
@@ -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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SnFilterable
4
- VERSION = "1.0.1"
4
+ VERSION = "1.1.1"
5
5
  end
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.0.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chase McDougall
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-29 00:00:00.000000000 Z
11
+ date: 2023-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: heroicon
@@ -287,7 +287,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
287
287
  - !ruby/object:Gem::Version
288
288
  version: '0'
289
289
  requirements: []
290
- rubygems_version: 3.4.1
290
+ rubygems_version: 3.4.10
291
291
  signing_key:
292
292
  specification_version: 4
293
293
  summary: Skills Network - Item filtering component