Add frame to search terms form

This commit is contained in:
Jose Farias
2024-11-12 20:20:38 -06:00
parent ec16237bf4
commit 8301db767a
3 changed files with 11 additions and 10 deletions
+6 -6
View File
@@ -3,6 +3,10 @@ module FiltersHelper
"#{name}_filter--#{value}"
end
def filter_chip_frame_id(kind)
"#{kind}_chips"
end
def filter_chips(filter, **)
safe_join [
chips_for_filter_kind(filter, :indexed_by, **),
@@ -71,17 +75,13 @@ module FiltersHelper
when :terms
[ %Q("#{object}"), object, "terms[]" ]
end.then do |display, value, name|
{ display: display, value: value, name: name, frame: filter_chip_frame(kind) }
{ display: display, value: value, name: name, frame: filter_chip_frame_id(kind) }
end
end
def filter_chip_frame(kind)
"#{kind}_chips"
end
def frame_for_filter_kind(filter, kind, **)
chips_for_filter_kind(filter, kind, **).then do |chips|
turbo_frame_tag filter_chip_frame(kind) do
turbo_frame_tag filter_chip_frame_id(kind) do
safe_join chips
end
end
+4 -4
View File
@@ -17,12 +17,12 @@ module Filter::Params
def to_h
@to_h ||= {}.tap do |h|
h["tags"] = tags
h["terms"] = terms
h["buckets"] = buckets
h["assignees"] = assignees
h["indexed_by"] = indexed_by
h["assignments"] = assignments
h["assignees"] = assignees
h["tags"] = tags
h["buckets"] = buckets
h["terms"] = terms
end.reject do |k, v|
default_fields[k] == v
end.compact_blank.with_indifferent_access
+1
View File
@@ -44,6 +44,7 @@
<%= form_with url: filter_chips_path, method: :post, class: "flex gap flex-item-grow align-center justify-center full-width center margin-block" do %>
<%= hidden_field_tag :name, "terms[]" %>
<%= hidden_field_tag :frame, filter_chip_frame_id(:terms) %>
<input name="value" type="text" class="input full-width" placeholder="Type to match words…" autocomplete="off" />
<button class="btn txt-small" type="submit">