Skip to content

Commit

Permalink
Target main turbo-frame in search box and filters forms and reset links
Browse files Browse the repository at this point in the history
  • Loading branch information
spohlenz committed Sep 18, 2024
1 parent 2678b43 commit 5f28f89
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app/views/trestle/search/_search.html.erb
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<div class="search-container">
<% if admin.searchable? %>
<div class="searchbox">
<%= form_tag admin.path, method: :get do %>
<%= form_tag admin.path, method: :get, data: { turbo_frame: "main" } do %>
<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" if params[:q].present? %>
<%= link_to icon("fas fa-times"), admin.path, class: "btn btn-clear-search", data: { turbo_frame: "main" } if params[:q].present? %>
</div>
<% end %>
</div>
<% end %>
<% 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 } do |f| %>
<%= 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 %>
Expand All @@ -28,7 +28,10 @@
<% end %>
<%= f.submit admin.t("search.filter", default: "Filter"), class: "btn btn-info w-100" %>
<%= link_to admin.t("search.reset_filters", default: "Reset Filters"), persistent_params.except(:f), class: "btn btn-light btn-sm w-100 mt-2" if admin.filters.active(params).any? %>
<% if admin.filters.active(params).any? %>
<%= link_to admin.t("search.reset_filters", default: "Reset Filters"), persistent_params.except(:f), class: "btn btn-light btn-sm w-100 mt-2", data: { turbo_frame: "main" } %>
<% end %>
</template>
<% end %>
</div>
Expand Down

0 comments on commit 5f28f89

Please sign in to comment.