changeset 750:3ee8507c841f feature_14

Correctly filtering by tag and name.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Wed, 09 Nov 2011 17:02:45 +0000
parents 3f28aebc5fc1
children 7bf2d69e9aeb
files vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb
diffstat 1 files changed, 15 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb	Tue Nov 08 17:12:52 2011 +0000
+++ b/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb	Wed Nov 09 17:02:45 2011 +0000
@@ -56,19 +56,26 @@
 
           def calculate_filtered_projects
 
-            @question = (params[:q] || "").strip
-            @custom_fields = params[:custom_fields] || {}
+            @question = (params[:q] || "").strip            
 
+            if params.has_key?(:project)
+              @tag_list = (params[:project][:tag_list] || "").strip.split(",")
+            else
+              @tag_list = []
+            end
+            
             @projects = Project.visible
 
-            unless @custom_fields.empty?
-              @projects = @projects.with_custom_values(params[:custom_fields])
-            end
-
             @featured_projects = @projects.featured if Project.respond_to? :featured
 
-            @projects = @projects.search_by_question(@question)
-            debugger                                  
+            # luisf 
+            @projects = @projects.search_by_question(@question) unless @question == ""
+            @tagged_projects_ids = Project.tagged_with(@tag_list).collect{ |project| Project.find(project.id) } unless @tag_list.empty?
+            
+            # intersection of both prject groups            
+            @projects = @projects && @tagged_projects_ids unless @tag_list.empty?
+            
+            # luisf: what exactly are the featured projects? could they be "my projects"?
             @featured_projects = @featured_projects.search_by_question(@question) if @featured_projects
 
           end