Permalink
Browse files

added support for filtering by tagged or untagged Issues

  • Loading branch information...
1 parent ad9bc91 commit d5d2b5f58a9957119d4a002ab024ccbc9db6ebeb Ben Asher committed Feb 24, 2012
Showing with 13 additions and 4 deletions.
  1. +13 −4 lib/redmine_tags/patches/query_patch.rb
@@ -46,9 +46,18 @@ def statement_extended
if filter
filters.merge!( 'tags' => filter )
- values = values_for('tags').clone
- compare = operator_for('tags').eql?('=') ? 'IN' : 'NOT IN'
- ids_list = Issue.tagged_with(values).collect{ |issue| issue.id }.push(0).join(',')
+ op = operator_for('tags')
+ case op
+ when '=', '!'
+ issues = Issue.tagged_with(values_for('tags').clone)
+ when '!*'
+ issues = Issue.tagged_with(ActsAsTaggableOn::Tag.all.map(&:to_s), :exclude => true)
+ else
+ issues = Issue.tagged_with(ActsAsTaggableOn::Tag.all.map(&:to_s), :any => true)
+ end
+
+ compare = op.eql?('!') ? 'NOT IN' : 'IN'
+ ids_list = issues.collect{ |issue| issue.id }.push(0).join(',')
clauses << " AND " unless clauses.empty?
clauses << "( #{Issue.table_name}.id #{compare} (#{ids_list}) ) "
@@ -61,7 +70,7 @@ def statement_extended
def available_filters_extended
unless @available_filters
available_filters_original.merge!({ 'tags' => {
- :type => :list,
+ :type => :list_optional,
:order => 6,
:values => Issue.available_tags(:project => project).collect{ |t| [t.name, t.name] }
}})

0 comments on commit d5d2b5f

Please sign in to comment.