Skip to content

Commit 4fdf4e4

Browse files
feat: add update_url_on_submit option (#13)
* Add update_url_on_submit option * Bump minor version * bundle Co-authored-by: Chase McDougall <[email protected]>
1 parent e46ce1b commit 4fdf4e4

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
sn_filterable (1.0.1)
4+
sn_filterable (1.1.0)
55
heroicon (~> 1)
66
kaminari (~> 1)
77
pg (~> 1)

app/components/sn_filterable/main_component.html.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
</div>
7171
<% end %>
7272

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 %>
7474
<%= content_tag :input, "", type: "hidden", name: "sort", value: @filtered.queries["sort"] if @filtered.queries["sort"].present? %>
7575
<%= content_tag :input, "", type: "hidden", name: "order", value: @filtered.queries["order"] if @filtered.queries["order"].present? %>
7676

app/components/sn_filterable/main_component.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ class MainComponent < ViewComponent::Base
2323
# @param [String, nil] url Optional, the base URL of where the filters are displayed
2424
# @param [String, nil] search_filter_name Optional, enable's and set's the search filter, specified by the filter's parameter name
2525
# @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)
2728
@frame_id = frame_id
2829
@filtered = filtered
2930
@filters = filters
3031
@url = url
3132
@search_filter_name = search_filter_name
3233
@show_sidebar = show_sidebar
34+
@update_url_on_submit = update_url_on_submit
3335
end
3436

3537
def search_field

lib/sn_filterable/version.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module SnFilterable
4-
VERSION = "1.0.1"
4+
VERSION = "1.1.0"
55
end

0 commit comments

Comments
 (0)