Skip to content
This repository has been archived by the owner on Apr 10, 2023. It is now read-only.

RedmineUP Agile plugin compability #166

Open
kusmierz opened this issue Apr 4, 2017 · 0 comments
Open

RedmineUP Agile plugin compability #166

kusmierz opened this issue Apr 4, 2017 · 0 comments
Assignees

Comments

@kusmierz
Copy link

kusmierz commented Apr 4, 2017

I'm not good with redmine plugins, but I achieved what I wanted to do. Basically I was trying to integrate tags filter into RedmineCRM/UP Agile board (where is misses). Maybe somebody could make ixti/redmine_tags' PR from this, so it would be permanent, better solution.

This is diff for RedmineCRM/UP Agile Plugin v1.4.3.

--- ./plugins/redmine_agile/app/models/agile_query.rb	2017-03-20 11:12:52.000000000 +0100
+++ ./plugins/redmine_agile/app/models/agile_query.rb	2017-04-04 17:49:14.013707782 +0200
@@ -247,6 +247,9 @@
         :values => subprojects.collect{|s| [s.name, s.id.to_s] }
     end
 
+    add_available_filter "tags",
+      :type => :list_optional,
+      :values => Issue.available_tags(project: project).collect {|t| [t.name, t.name] }
 
     add_custom_fields_filters(issue_custom_fields)
 
@@ -569,11 +572,32 @@
       # substitute id for current version
       filters['fixed_version_id'][:values] = [version.id.to_s] if version
     end
+    if filters
+      filter  = filters.delete 'tags'
+    end
     clauses = super
     if version
       # return string for correct value in a select on a form
       filters['fixed_version_id'][:values] = ['current_version']
     end
+
+    if filter
+      filters.merge! 'tags' => filter
+      op = operator_for 'tags'
+      case op
+      when '=', '!'
+        issues = Issue.tagged_with(values_for('tags'), any: true)
+      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 }) ) "
+    end
+
     clauses
   end
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants