From bd27ff8e1dd755b20e74ac1eb94a5d9cdc55d76e Mon Sep 17 00:00:00 2001 From: Sam Pohlenz Date: Wed, 18 Sep 2024 22:15:14 +0930 Subject: [PATCH] Target main turbo-frame in search box and filters forms and reset links (#60) --- app/views/trestle/search/_search.html.erb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/views/trestle/search/_search.html.erb b/app/views/trestle/search/_search.html.erb index 76ed5ae..4d9b00b 100644 --- a/app/views/trestle/search/_search.html.erb +++ b/app/views/trestle/search/_search.html.erb @@ -1,13 +1,13 @@
<% if admin.searchable? %> @@ -15,7 +15,7 @@ <% if admin.filterable? %>
- <%= 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 %> @@ -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 %> <% end %>