Skip to content

Commit

Permalink
Retain persistent params when searching and filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
spohlenz committed Sep 18, 2024
1 parent bd27ff8 commit f8ffc5d
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/views/trestle/search/_search.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
<% if admin.searchable? %>
<div class="searchbox">
<%= form_tag admin.path, method: :get, data: { turbo_frame: "main" } do %>
<%= serialize_persistent_params except: :q %>

<div class="input-group">
<%= label_tag :q, icon("fas fa-search"), class: "input-group-text" %>

<%= search_field_tag :q, params[:q], class: "form-control", autocomplete: "off", placeholder: admin.t("search.placeholder", default: "Search") %>

<%= link_to icon("fas fa-times"), admin.path, class: "btn btn-clear-search", data: { turbo_frame: "main" } if params[:q].present? %>
<%= link_to icon("fas fa-times"), persistent_params.except(:q), class: "btn btn-clear-search", data: { turbo_frame: "main" } if params[:q].present? %>
</div>
<% end %>
</div>
Expand All @@ -16,9 +18,7 @@
<% if admin.filterable? %>
<div class="search-filters">
<%= form_for admin.filters, as: :f, url: admin.path, method: :get, builder: Trestle::Form::Builder, html: { id: nil, class: nil, data: { turbo_frame: "main" } } do |f| %>
<% persistent_params.each do |k, v| %>
<%= hidden_field_tag k, v unless k == "f" %>
<% end %>
<%= serialize_persistent_params except: :f %>

<button type="button" class="btn <%= admin.filters.active(params).any? ? "btn-warning" : "btn-info" %>" data-controller="search-filters"><%= icon("fa fa-filter") %></button>

Expand Down

0 comments on commit f8ffc5d

Please sign in to comment.