Consolidate bucket_view_helper and filters_helper

This commit is contained in:
Jose Farias
2024-10-17 21:37:48 -06:00
parent c9e6ecda58
commit c0df006ebc
4 changed files with 28 additions and 29 deletions
-27
View File
@@ -1,27 +0,0 @@
module BucketViewsHelper
def default_bucket_view?
bubble_filter_params.values.all?(&:blank?) || bubble_filter_params.to_h == Bucket::View.default_filters
end
def bubble_filter_form_tag(path, method:, id:)
form_tag path, method: method, id: id do
yield if block_given?
if params[:order_by].present?
concat hidden_field_tag(:order_by, params[:order_by])
end
if params[:status].present?
concat hidden_field_tag(:status, params[:status])
end
Array(params[:assignee_ids]).each do |assignee_id|
concat hidden_field_tag("assignee_ids[]", assignee_id, id: nil)
end
Array(params[:tag_ids]).each do |tag_id|
concat hidden_field_tag("tag_ids[]", tag_id, id: nil)
end
end
end
end
+26
View File
@@ -32,4 +32,30 @@ module FiltersHelper
def unassigned_filter_activated?
params[:status] == "unassigned"
end
def default_filters?
bubble_filter_params.values.all?(&:blank?) || bubble_filter_params.to_h == Bucket::View.default_filters
end
def bubble_filter_form_tag(path, method:, id: nil)
form_tag path, method: method, id: id do
yield if block_given?
if params[:order_by].present?
concat hidden_field_tag(:order_by, params[:order_by])
end
if params[:status].present?
concat hidden_field_tag(:status, params[:status])
end
Array(params[:assignee_ids]).each do |assignee_id|
concat hidden_field_tag("assignee_ids[]", assignee_id, id: nil)
end
Array(params[:tag_ids]).each do |tag_id|
concat hidden_field_tag("tag_ids[]", tag_id, id: nil)
end
end
end
end
+1 -1
View File
@@ -13,6 +13,6 @@
<% end %>
</h2>
<% unless default_bucket_view? %>
<% unless default_filters? %>
<%= render "bubbles/filters/bucket_view_form", bucket: bucket, view: view %>
<% end %>
+1 -1
View File
@@ -28,7 +28,7 @@
<section class="bubbles-list unpad-inline center margin-block-start">
<header class="flex-inline align-center gap txt-small margin-block-end-half center">
<%= bubble_filter_form_tag bucket_bubbles_path(@bucket), method: :get, id: dom_id(@bucket, :search) do %>
<%= bubble_filter_form_tag bucket_bubbles_path(@bucket), method: :get do %>
<%= search_field_tag :term, params[:term], class: "input center flex-inline", placeholder: "Type to filter…" %>
<% end %>
</header>