# HG changeset patch # User luisf # Date 1353430513 0 # Node ID 2ad2f9ab46a69041326634ccb3f5dcc865a45cef # Parent 5b9e5464d162be3e1aedd1fa34e771458c652b29 moved the tags helper patch from the projects helper patch to the projects controller patch diff -r 5b9e5464d162 -r 2ad2f9ab46a6 vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb --- a/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb Tue Nov 20 10:36:40 2012 +0000 +++ b/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb Tue Nov 20 16:55:13 2012 +0000 @@ -3,21 +3,24 @@ module RedmineTags module Patches - module ProjectsControllerPatch + module ProjectsControllerPatch def self.included(base) base.send(:include, InstanceMethods) - base.class_eval do - unloadable + base.class_eval do + unloadable skip_before_filter :authorize, :only => [:set_fieldset_status] skip_before_filter :find_project, :only => [:set_fieldset_status] before_filter :add_tags_to_project, :only => [:save, :update] + helper :tags + include TagsHelper + alias :index filtered_index end end module InstanceMethods - + def add_tags_to_project if params && params[:project] && !params[:project][:tag_list].nil? @@ -57,17 +60,17 @@ else @myproj_status = session[:my_projects_fieldset_status] end - + if session[:filters_fieldset_status].nil? @filter_status = "false" else @filter_status = session[:filters_fieldset_status] end - + if params && params[:project] && !params[:project][:tag_list].nil? @filter_status = "true" end - + end # Lists visible projects. Paginator is for top-level projects only @@ -78,17 +81,17 @@ get_fieldset_statuses respond_to do |format| - format.html { + format.html { paginate_projects - - @projects = Project.visible_roots.find(@projects, :offset => @offset, :limit => @limit, :order => sort_clause) + + @projects = Project.visible_roots.find(@projects, :offset => @offset, :limit => @limit, :order => sort_clause) if User.current.logged? # seems sort_by gives us case-sensitive ordering, which we don't want # @user_projects = User.current.projects.sort_by(&:name) @user_projects = User.current.projects.all(:order => :name) end - + render :template => 'projects/index.html.erb', :layout => !request.xhr? } format.api { @@ -112,8 +115,8 @@ private - def filter_projects - @question = (params[:q] || "").strip + def filter_projects + @question = (params[:q] || "").strip if params.has_key?(:project) @tag_list = (params[:project][:tag_list] || "").strip.split(",") @@ -126,7 +129,7 @@ else @projects = Project.visible_roots.find(Project.visible.search_by_question(@question)) end - + unless @tag_list.empty? @tagged_projects_ids = Project.visible.tagged_with(@tag_list).collect{ |project| Project.find(project.id).root } @projects = @projects & @tagged_projects_ids diff -r 5b9e5464d162 -r 2ad2f9ab46a6 vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb --- a/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb Tue Nov 20 10:36:40 2012 +0000 +++ b/vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb Tue Nov 20 16:55:13 2012 +0000 @@ -4,13 +4,13 @@ def self.included(base) # :nodoc: base.send(:include, InstanceMethods) - base.send(:include, TagsHelper) + # base.send(:include, TagsHelper) base.class_eval do unloadable end end - module InstanceMethods + module InstanceMethods # Renders a tree of projects that the current user does not belong # to, or of all projects if the current user is not logged in. The # given collection may be a subset of the whole project tree @@ -19,30 +19,30 @@ # description, manager(s), creation date, last activity date, # general activity level, whether there is anything actually hosted # here for the project, etc. - def render_project_table_with_filtering(projects, question) + def render_project_table_with_filtering(projects, question) custom_fields = "" s = "" if projects.any? tokens = RedmineProjectFiltering.calculate_tokens(question, custom_fields) - + s << "
" s << "" s << "" - + s << sort_header_tag('name', :caption => l("field_name")) s << "" s << "" s << sort_header_tag('created_on', :default_order => 'desc') s << sort_header_tag('updated_on', :default_order => 'desc') - + s << "" - + original_project = @project - + projects.each do |project| s << render_project_in_table_with_filtering(project, cycle('odd', 'even'), 0, tokens) end - + s << "
" << l("tags") << "" << l("label_managers") << "
" else s << "\n" @@ -52,7 +52,7 @@ s end - def render_project_in_table_with_filtering(project, oddeven, level, tokens) + def render_project_in_table_with_filtering(project, oddeven, level, tokens) # set the project environment to please macros. @project = project @@ -72,7 +72,7 @@ s << "" << project.tag_counts.collect{ |t| render_project_tag_link(t) }.join(', ') << "" s << "" - + u = project.users_by_role if u u.keys.each do |r| @@ -91,7 +91,7 @@ end s << "" - + s << "" << format_date(project.created_on) << "" s << "" << format_date(project.updated_on) << "" @@ -105,9 +105,9 @@ s end - - - + + + # Renders a tree of projects as a nested set of unordered lists # The given collection may be a subset of the whole project tree # (eg. some intermediate nodes are private and can not be seen) @@ -116,7 +116,7 @@ if projects.any? tokens = RedmineProjectFiltering.calculate_tokens(question, custom_fields) debugger - + ancestors = [] original_project = @project @@ -128,14 +128,14 @@ else ancestors.pop s << "" - while (ancestors.any? && !project.is_descendant_of?(ancestors.last)) + while (ancestors.any? && !project.is_descendant_of?(ancestors.last)) ancestors.pop s << "" end end classes = (ancestors.empty? ? 'root' : 'child') s << "
  • " + - link_to( highlight_tokens(project.name, tokens), + link_to( highlight_tokens(project.name, tokens), {:controller => 'projects', :action => 'show', :id => project}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}" ) @@ -146,7 +146,7 @@ # value = value_model.present? ? value_model.value : nil # s << "
  • #{field.name.humanize}: #{highlight_tokens(value, tokens)}
  • " if value.present? # end - + s << "" s << "
    " unless project.description.blank? @@ -163,7 +163,7 @@ end s.join "\n" end - + # Renders a tree of projects where the current user belongs # as a nested set of unordered lists # The given collection may be a subset of the whole project tree @@ -193,9 +193,9 @@ s end - - - + + + def render_my_project_in_hierarchy_with_tags(project) @@ -215,7 +215,7 @@ else s << " " << l(:field_is_private) << "" end - + tc = project.tag_counts if tc.empty? s << " " << l(:field_no_tags) << "" @@ -242,15 +242,15 @@ end - - + + private - + # copied from search_helper. This one doesn't escape html or limit the text length def highlight_tokens(text, tokens) return text unless text && tokens && !tokens.empty? re_tokens = tokens.collect {|t| Regexp.escape(t)} - regexp = Regexp.new "(#{re_tokens.join('|')})", Regexp::IGNORECASE + regexp = Regexp.new "(#{re_tokens.join('|')})", Regexp::IGNORECASE result = '' text.split(regexp).each_with_index do |words, i| words = words.mb_chars @@ -263,7 +263,7 @@ end result end - + end end end