diff --git a/app/helpers/filters_helper.rb b/app/helpers/filters_helper.rb
index bfb22cfc5..3e66f5f5c 100644
--- a/app/helpers/filters_helper.rb
+++ b/app/helpers/filters_helper.rb
@@ -3,16 +3,10 @@ module FiltersHelper
"#{name}_filter--#{value}"
end
- def filter_chips(filter, terms, **)
- filters = filter.to_h.map do |kind, object|
+ def filter_chips(filter, **)
+ filter.to_h.map do |kind, object|
filter_button_from kind, object, **
- end
-
- terms = Array.wrap(terms).map do |term|
- filter_button_from :terms, term, **
- end
-
- safe_join filters + terms
+ end.join.html_safe
end
def filter_chip_tag(display:, value:, name:, **options)
diff --git a/app/models/filter.rb b/app/models/filter.rb
index 74a56301a..e8f7b2f60 100644
--- a/app/models/filter.rb
+++ b/app/models/filter.rb
@@ -28,6 +28,10 @@ class Filter < ApplicationRecord
result = result.assigned_to(assignees.ids) if assignees.present?
result = result.in_bucket(buckets.ids) if buckets.present?
result = result.tagged_with(tags.ids) if tags.present?
+ result = terms.reduce(result) do |result, term|
+ result.mentioning(term)
+ end
+
result
end
end
diff --git a/app/models/filter/fields.rb b/app/models/filter/fields.rb
index 68268545c..085ead833 100644
--- a/app/models/filter/fields.rb
+++ b/app/models/filter/fields.rb
@@ -9,20 +9,20 @@ module Filter::Fields
end
end
- def assignments=(value)
- fields["assignments"] = value
- end
+ included do
+ store_accessor :fields, :indexed_by, :assignments, :terms
- def assignments
- fields["assignments"].to_s.inquiry
- end
+ def indexed_by
+ (super || default_fields["indexed_by"]).inquiry
+ end
- def indexed_by=(value)
- fields["indexed_by"] = value
- end
+ def assignments
+ super.to_s.inquiry
+ end
- def indexed_by
- (fields["indexed_by"] || default_fields["indexed_by"]).inquiry
+ def terms
+ Array(super)
+ end
end
private
diff --git a/app/models/filter/params.rb b/app/models/filter/params.rb
index cac5a6641..6fe266b53 100644
--- a/app/models/filter/params.rb
+++ b/app/models/filter/params.rb
@@ -1,7 +1,7 @@
module Filter::Params
extend ActiveSupport::Concern
- PERMITTED_PARAMS = [ :indexed_by, :assignments, bucket_ids: [], assignee_ids: [], tag_ids: [] ]
+ PERMITTED_PARAMS = [ :indexed_by, :assignments, bucket_ids: [], assignee_ids: [], tag_ids: [], terms: [] ]
included do
before_save { self.params_digest = self.class.digest_params(as_params) }
@@ -22,6 +22,7 @@ module Filter::Params
h["assignees"] = assignees
h["tags"] = tags
h["buckets"] = buckets
+ h["terms"] = terms
end.reject do |k, v|
default_fields[k] == v
end.compact_blank
diff --git a/app/models/filter/summarized.rb b/app/models/filter/summarized.rb
index 67f194e81..c6c23adfd 100644
--- a/app/models/filter/summarized.rb
+++ b/app/models/filter/summarized.rb
@@ -1,6 +1,6 @@
module Filter::Summarized
def summary
- [ index_summary, tag_summary, assignee_summary ].compact.to_sentence + " #{bucket_summary}"
+ [ index_summary, tag_summary, assignee_summary, terms_summary ].compact.to_sentence + " #{bucket_summary}"
end
def plain_summary
@@ -33,4 +33,10 @@ module Filter::Summarized
"in all projects"
end
end
+
+ def terms_summary
+ if terms.any?
+ "matching #{terms.map { |term| %Q("#{term}") }.to_sentence}"
+ end
+ end
end
diff --git a/app/views/bubbles/_filters.html.erb b/app/views/bubbles/_filters.html.erb
index 139e2919c..abf39c727 100644
--- a/app/views/bubbles/_filters.html.erb
+++ b/app/views/bubbles/_filters.html.erb
@@ -10,7 +10,7 @@
<%= form_with url: bubbles_path, method: :get, class: "flex-inline center align-center gap-half", data: { controller: "form" } do %>
- <%= filter_chips filter, terms %>
+ <%= filter_chips filter %>
<% end %>
@@ -38,7 +38,7 @@
<%= form_with url: bubbles_path, id: :filter_form, method: :get, class: "flex-inline center align-center gap-half" do %>
- <%= filter_chips filter, terms, class: "fill-selected" %>
+ <%= filter_chips filter, class: "fill-selected" %>
<% end %>
diff --git a/app/views/bubbles/index.html.erb b/app/views/bubbles/index.html.erb
index 9065ff749..406a1960d 100644
--- a/app/views/bubbles/index.html.erb
+++ b/app/views/bubbles/index.html.erb
@@ -8,7 +8,7 @@
<% end %>
- <%= render "bubbles/filters", filter: @filter, terms: params[:terms] %>
+ <%= render "bubbles/filters", filter: @filter %>
<% if @filter.buckets.any? %>