Revision 1254:a54ce736229d plugins/redmine_tags/lib/redmine_tags

View differences:

plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb
8 8
        base.send(:include, InstanceMethods)
9 9
        base.class_eval do
10 10
          unloadable
11
          skip_before_filter :authorize, :only => [:set_fieldset_status]
12
          skip_before_filter :find_project, :only => [:set_fieldset_status]
11
          # skip_before_filter :authorize, :only => [:set_fieldset_status]
12
          # skip_before_filter :find_project, :only => [:set_fieldset_status]
13 13

  
14 14
          alias :index filtered_index
15 15
        end
......
22 22
          @limit = per_page_option
23 23

  
24 24
          # Only top-level visible projects are counted --lf.10Jan2013
25
          top_level_visible_projects = @projects.select{ |p| p.parent_id.nil? and p.visible? }
25
          top_level_visible_projects = @projects.visible_roots
26 26
          @project_count = top_level_visible_projects.count
27 27

  
28 28
          # Project.visible_roots.find(@projects).count
......
31 31
          @offset ||= @project_pages.current.offset
32 32
        end
33 33

  
34
        def set_fieldset_status
35

  
36
          # luisf. test for missing parameters………
37
          field = params[:field_id]
38
          status = params[:status]
39

  
40
          session[(field + "_status").to_sym] = status
41
          render :nothing => true
42
        end
34
        # def set_fieldset_status
35
#
36
        #   # luisf. test for missing parameters………
37
        #   field = params[:field_id]
38
        #   status = params[:status]
39
#
40
        #   session[(field + "_status").to_sym] = status
41
        #   render :nothing => true
42
        # end
43 43

  
44 44
        # gets the status of the collabsible fieldsets
45
        def get_fieldset_statuses
46
          if session[:my_projects_fieldset_status].nil?
47
            @myproj_status = "true"
48
          else
49
            @myproj_status = session[:my_projects_fieldset_status]
50
          end
51

  
52
          if session[:filters_fieldset_status].nil?
53
            @filter_status = "false"
54
          else
55
            @filter_status = session[:filters_fieldset_status]
56
          end
57

  
58
          if params && params[:project] && !params[:project][:tag_list].nil?
59
            @filter_status = "true"
60
          end
61

  
62
        end
45
        # def get_fieldset_statuses
46
        #   if session[:my_projects_fieldset_status].nil?
47
        #     @myproj_status = "true"
48
        #   else
49
        #     @myproj_status = session[:my_projects_fieldset_status]
50
        #   end
51
#
52
        #   if session[:filters_fieldset_status].nil?
53
        #     @filter_status = "false"
54
        #   else
55
        #     @filter_status = session[:filters_fieldset_status]
56
        #   end
57
#
58
        #   if params && params[:project] && !params[:project][:tag_list].# nil?
59
        #     @filter_status = "true"
60
        #   end
61
#
62
        # end
63 63

  
64 64
        # Lists visible projects. Paginator is for top-level projects only
65 65
        # (subprojects belong to them)
66 66
        def filtered_index
67 67
          @project = Project.new
68 68
          filter_projects
69
          get_fieldset_statuses
69
          # get_fieldset_statuses
70 70

  
71 71
          sort_clause = "name"
72 72

  
......
101 101
        private
102 102

  
103 103
        def filter_projects
104
          @question = (params[:q] || "").strip
104
          # find projects like question
105
          @question = (params[:search] || "").strip
106
#
107
          # if params.has_key?(:project)
108
          #   @tag_list = (params[:project][:tag_list] || "").strip.split(",")
109
          # else
110
          #   @tag_list = []
111
          # end
112
#
113
          # if  @question == ""
114
          #   @projects = Project.visible_roots
115
          # else
116
          #   @projects = Project.visible_roots.find(Project.visible.like(@question))
117
          # end
118
#
119
          # unless @tag_list.empty?
120
          #   @tagged_projects_ids = Project.visible.tagged_with(@tag_list).collect{ |# project| Project.find(project.id).root }
121
#
122
          #   @projects = @projects & @tagged_projects_ids
123
          #   @projects = @projects.uniq
124
          # end
105 125

  
106
          if params.has_key?(:project)
107
            @tag_list = (params[:project][:tag_list] || "").strip.split(",")
108
          else
109
            @tag_list = []
110
          end
126
          # hack...
127
          @projects = Project.like(@question)
111 128

  
112
          if  @question == ""
113
            @projects = Project.visible_roots
114
          else
115
            @projects = Project.visible_roots.find(Project.visible.search_by_question(@question))
116
          end
117

  
118
          unless @tag_list.empty?
119
            @tagged_projects_ids = Project.visible.tagged_with(@tag_list).collect{ |project| Project.find(project.id).root }
120

  
121
            @projects = @projects & @tagged_projects_ids
122
            @projects = @projects.uniq
123
          end
124 129
        end
125 130
      end
126 131
    end
plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb
104 104
            end
105 105
          end
106 106

  
107
          s
107
          s.html_safe
108 108
        end
109 109

  
110 110

  
......
239 239

  
240 240
          end
241 241

  
242
          s
242
          s.html_safe
243 243

  
244 244
        end
245 245

  
246

  
247

  
248 246
        private
249 247

  
250 248
        # copied from search_helper. This one doesn't escape html or limit the text length
......
262 260
              result << content_tag('span', words, :class => "highlight token-#{t}")
263 261
            end
264 262
          end
265
          result
263
          result.html_safe
266 264
        end
267 265

  
268 266
      end

Also available in: Unified diff