Skip to content

Commit

Permalink
feat: add update_url_on_submit option (#13)
Browse files Browse the repository at this point in the history
* Add update_url_on_submit option

* Bump minor version

* bundle

Co-authored-by: Chase McDougall <[email protected]>
  • Loading branch information
michaelroudnitski and chasemcdo authored Jan 4, 2023
1 parent e46ce1b commit 4fdf4e4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
sn_filterable (1.0.1)
sn_filterable (1.1.0)
heroicon (~> 1)
kaminari (~> 1)
pg (~> 1)
Expand Down
2 changes: 1 addition & 1 deletion app/components/sn_filterable/main_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
</div>
<% end %>
<%= turbo_frame_tag @frame_id, "data-turbo-action": "advance" do %>
<%= turbo_frame_tag @frame_id, "data-turbo-action": @update_url_on_submit ? "advance" : nil do %>
<%= content_tag :input, "", type: "hidden", name: "sort", value: @filtered.queries["sort"] if @filtered.queries["sort"].present? %>
<%= content_tag :input, "", type: "hidden", name: "order", value: @filtered.queries["order"] if @filtered.queries["order"].present? %>

Expand Down
4 changes: 3 additions & 1 deletion app/components/sn_filterable/main_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ class MainComponent < ViewComponent::Base
# @param [String, nil] url Optional, the base URL of where the filters are displayed
# @param [String, nil] search_filter_name Optional, enable's and set's the search filter, specified by the filter's parameter name
# @param [Boolean] show_sidebar If true, will show the sidebar with the filters.
def initialize(frame_id:, filtered:, filters:, url: nil, search_filter_name: nil, show_sidebar: true)
# @param [Boolean] update_url_on_submit If true, will update the URL in the user's browser on form submission.
def initialize(frame_id:, filtered:, filters:, url: nil, search_filter_name: nil, show_sidebar: true, update_url_on_submit: true)
@frame_id = frame_id
@filtered = filtered
@filters = filters
@url = url
@search_filter_name = search_filter_name
@show_sidebar = show_sidebar
@update_url_on_submit = update_url_on_submit
end

def search_field
Expand Down
2 changes: 1 addition & 1 deletion lib/sn_filterable/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module SnFilterable
VERSION = "1.0.1"
VERSION = "1.1.0"
end

0 comments on commit 4fdf4e4

Please sign in to comment.