diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2018-07-20 17:19:58 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2018-07-31 12:46:36 +0300 |
commit | f42fe0b6370692afd8fe1a123dd136e2dd45d5dc (patch) | |
tree | 34de501fd74da1aedb87241198e7fb8d1240bf81 /app/finders | |
parent | 02e35a0d2630d6995652d67d32fb2462ae2f68b2 (diff) |
Add ability to filter labels by title or description
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/labels_finder.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/app/finders/labels_finder.rb b/app/finders/labels_finder.rb index afd1f824b32..de2eeee122d 100644 --- a/app/finders/labels_finder.rb +++ b/app/finders/labels_finder.rb @@ -14,6 +14,7 @@ class LabelsFinder < UnionFinder @skip_authorization = skip_authorization items = find_union(label_ids, Label) || Label.none items = with_title(items) + items = by_search(items) sort(items) end @@ -63,6 +64,12 @@ class LabelsFinder < UnionFinder items.where(title: title) end + def by_search(labels) + return labels unless params[:search].present? + + labels.search(params[:search]) + end + # Gets redacted array of group ids # which can include the ancestors and descendants of the requested group. def group_ids_for(group) |