diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-09-20 17:55:31 +0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-10-19 19:58:24 +0300 |
commit | b10e5764ac0765b556d64dfebb9dad948154e31a (patch) | |
tree | 20dfe3bf8920b97383313daa8e43bd57c31fa8a4 /app/finders/labels_finder.rb | |
parent | baf47a0bd0e0563cbc99b3ae4b1336b8b3b4380a (diff) |
List only labels that belongs to the group on the group issues page
Diffstat (limited to 'app/finders/labels_finder.rb')
-rw-r--r-- | app/finders/labels_finder.rb | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/app/finders/labels_finder.rb b/app/finders/labels_finder.rb index a27ff56309b..85ef9bea08d 100644 --- a/app/finders/labels_finder.rb +++ b/app/finders/labels_finder.rb @@ -20,13 +20,17 @@ class LabelsFinder < UnionFinder label_ids << Label.where(project_id: projects.select(:id)).select(:id) end + def sort(items) + items.reorder(title: :asc, type: :desc) + end + def with_title(items) items = items.where(title: title) if title.present? items end - def sort(items) - items.reorder(title: :asc) + def group_id + params[:group_id].presence end def project_id @@ -40,13 +44,10 @@ class LabelsFinder < UnionFinder def projects return @projects if defined?(@projects) - if project_id - @projects = ProjectsFinder.new.execute(current_user) - .where(id: project_id) - .reorder(nil) - else - @projects = Project.none - end + @projects = ProjectsFinder.new.execute(current_user) + @projects = @projects.joins(:namespace).where(namespaces: { id: group_id, type: 'Group' }) if group_id + @projects = @projects.where(id: project_id) if project_id + @projects = @projects.reorder(nil) @projects end |