Revision 823:73057b65abcb vendor/plugins/redmine_tags/lib/redmine_tags
| vendor/plugins/redmine_tags/lib/redmine_tags/hooks/views_projects_hook.rb | ||
|---|---|---|
| 2 | 2 |
module Hooks |
| 3 | 3 |
class ViewsProjectsHook < Redmine::Hook::ViewListener |
| 4 | 4 |
render_on :view_projects_form, :partial => 'projects/tags_form' |
| 5 |
render_on :view_projects_show_left, :partial => 'projects/tags'
|
|
| 5 |
render_on :view_projects_show_sidebar_top, :partial => 'projects/tags'
|
|
| 6 | 6 |
# render_on :view_issues_sidebar_planning_bottom, :partial => 'issues/tags_sidebar' |
| 7 | 7 |
end |
| 8 | 8 |
end |
| vendor/plugins/redmine_tags/lib/redmine_tags/patches/auto_completes_controller_patch.rb | ||
|---|---|---|
| 38 | 38 |
@tags = Project.available_tags :name_like => @name |
| 39 | 39 |
render :layout => false, :partial => 'tag_list' |
| 40 | 40 |
end |
| 41 |
|
|
| 42 |
def project_search_tags |
|
| 43 |
@name = params[:q].to_s |
|
| 44 |
@tags = Project.available_tags :name_like => @name |
|
| 45 |
render :layout => false, :partial => 'search_tag_list' |
|
| 46 |
end |
|
| 41 | 47 |
end |
| 42 | 48 |
end |
| 43 | 49 |
end |
| vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_controller_patch.rb | ||
|---|---|---|
| 2 | 2 |
|
| 3 | 3 |
module RedmineTags |
| 4 | 4 |
module Patches |
| 5 |
module ProjectsControllerPatch |
|
| 5 |
module ProjectsControllerPatch
|
|
| 6 | 6 |
def self.included(base) |
| 7 | 7 |
base.send(:include, InstanceMethods) |
| 8 | 8 |
base.class_eval do |
| 9 | 9 |
unloadable |
| 10 |
skip_before_filter :authorize, :only => [:set_fieldset_status] |
|
| 11 |
skip_before_filter :find_project, :only => [:set_fieldset_status] |
|
| 10 | 12 |
before_filter :add_tags_to_project, :only => [:save, :update] |
| 11 |
before_filter :filter_projects, :only => :index |
|
| 13 |
# before_filter :filter_projects, :only => :index |
|
| 14 |
|
|
| 15 |
alias :index filtered_index |
|
| 12 | 16 |
end |
| 13 | 17 |
end |
| 14 | 18 |
|
| 15 | 19 |
module InstanceMethods |
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 16 | 23 |
def add_tags_to_project |
| 17 | 24 |
|
| 18 | 25 |
if params && params[:project] && !params[:project][:tag_list].nil? |
| ... | ... | |
| 25 | 32 |
end |
| 26 | 33 |
end |
| 27 | 34 |
|
| 28 |
# # luisf - TO BE REMOVED? |
|
| 29 |
# def calculate_project_filtering_settings |
|
| 30 |
# @project_filtering_settings = Setting[:plugin_redmine_project_filtering] |
|
| 31 |
# end |
|
| 35 |
def paginate_projects |
|
| 36 |
sort_init 'name' |
|
| 37 |
sort_update %w(name lft created_on updated_on) |
|
| 38 |
@limit = per_page_option |
|
| 39 |
@project_count = Project.visible_roots.find(@projects).count |
|
| 40 |
@project_pages = ActionController::Pagination::Paginator.new self, @project_count, @limit, params['page'] |
|
| 41 |
@offset ||= @project_pages.current.offset |
|
| 42 |
end |
|
| 32 | 43 |
|
| 33 |
def filter_projects |
|
| 44 |
def set_fieldset_status |
|
| 45 |
|
|
| 46 |
# luisf. test for missing parameters……… |
|
| 47 |
field = params[:field_id] |
|
| 48 |
status = params[:status] |
|
| 49 |
|
|
| 50 |
session[(field + "_status").to_sym] = status |
|
| 51 |
render :nothing => true |
|
| 52 |
end |
|
| 53 |
|
|
| 54 |
# gets the status of the collabsible fieldsets |
|
| 55 |
def get_fieldset_statuses |
|
| 56 |
if session[:my_projects_fieldset_status].nil? |
|
| 57 |
@myproj_status = "true" |
|
| 58 |
else |
|
| 59 |
@myproj_status = session[:my_projects_fieldset_status] |
|
| 60 |
end |
|
| 61 |
|
|
| 62 |
if session[:filters_fieldset_status].nil? |
|
| 63 |
@filter_status = "false" |
|
| 64 |
else |
|
| 65 |
@filter_status = session[:filters_fieldset_status] |
|
| 66 |
end |
|
| 67 |
|
|
| 68 |
if params && params[:project] && !params[:project][:tag_list].nil? |
|
| 69 |
@filter_status = "true" |
|
| 70 |
end |
|
| 71 |
|
|
| 72 |
end |
|
| 73 |
|
|
| 74 |
# Lists visible projects. Paginator is for top-level projects only |
|
| 75 |
# (subprojects belong to them) |
|
| 76 |
def filtered_index |
|
| 34 | 77 |
@project = Project.new |
| 78 |
filter_projects |
|
| 79 |
get_fieldset_statuses |
|
| 35 | 80 |
|
| 36 | 81 |
respond_to do |format| |
| 37 |
format.any(:html, :xml) {
|
|
| 38 |
calculate_filtered_projects |
|
| 82 |
format.html {
|
|
| 83 |
paginate_projects |
|
| 84 |
|
|
| 85 |
@projects = Project.visible_roots.find(@projects, :offset => @offset, :limit => @limit, :order => sort_clause) |
|
| 86 |
|
|
| 87 |
if User.current.logged? |
|
| 88 |
# seems sort_by gives us case-sensitive ordering, which we don't want |
|
| 89 |
# @user_projects = User.current.projects.sort_by(&:name) |
|
| 90 |
@user_projects = User.current.projects.all(:order => :name) |
|
| 91 |
end |
|
| 92 |
|
|
| 93 |
render :template => 'projects/index.rhtml', :layout => !request.xhr? |
|
| 94 |
} |
|
| 95 |
format.api {
|
|
| 96 |
@offset, @limit = api_offset_and_limit |
|
| 97 |
@project_count = Project.visible.count |
|
| 98 |
@projects = Project.visible.find(@projects, :offset => @offset, :limit => @limit, :order => 'lft') |
|
| 99 |
} |
|
| 100 |
format.atom {
|
|
| 101 |
projects = Project.visible.find(:all, :order => 'created_on DESC', :limit => Setting.feeds_limit.to_i) |
|
| 102 |
render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
|
|
| 39 | 103 |
} |
| 40 | 104 |
format.js {
|
| 41 |
calculate_filtered_projects |
|
| 105 |
paginate_projects |
|
| 106 |
@projects = Project.visible_roots.find(@projects, :offset => @offset, :limit => @limit, :order => sort_clause) |
|
| 42 | 107 |
render :update do |page| |
| 43 | 108 |
page.replace_html 'projects', :partial => 'filtered_projects' |
| 44 | 109 |
end |
| 45 | 110 |
} |
| 46 |
format.atom {
|
|
| 47 |
projects = Project.visible.find(:all, :order => 'created_on DESC', |
|
| 48 |
:limit => Setting.feeds_limit.to_i) |
|
| 49 |
render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
|
|
| 50 |
} |
|
| 51 | 111 |
end |
| 52 | 112 |
end |
| 53 | 113 |
|
| 54 | 114 |
private |
| 55 | 115 |
|
| 56 |
def calculate_filtered_projects
|
|
| 116 |
def filter_projects
|
|
| 57 | 117 |
@question = (params[:q] || "").strip |
| 58 | 118 |
|
| 59 | 119 |
if params.has_key?(:project) |
| ... | ... | |
| 62 | 122 |
@tag_list = [] |
| 63 | 123 |
end |
| 64 | 124 |
|
| 65 |
@projects = Project.visible |
|
| 125 |
if @question == "" |
|
| 126 |
@projects = Project.visible |
|
| 127 |
else |
|
| 128 |
@projects = Project.visible.search_by_question(@question) |
|
| 129 |
end |
|
| 130 |
|
|
| 131 |
unless @tag_list.empty? |
|
| 132 |
@tagged_projects_ids = Project.visible.tagged_with(@tag_list).collect{ |project| Project.find(project.id) }
|
|
| 133 |
@projects = @projects & @tagged_projects_ids |
|
| 134 |
end |
|
| 135 |
|
|
| 136 |
@projects = @projects.collect{ |project| project.root }
|
|
| 137 |
@projects = @projects.uniq |
|
| 66 | 138 |
|
| 67 |
@featured_projects = @projects.featured if Project.respond_to? :featured |
|
| 68 |
|
|
| 69 |
# luisf |
|
| 70 |
@projects = @projects.search_by_question(@question) unless @question == "" |
|
| 71 |
@tagged_projects_ids = Project.tagged_with(@tag_list).collect{ |project| Project.find(project.id) } unless @tag_list.empty?
|
|
| 72 |
|
|
| 73 |
debugger |
|
| 74 |
|
|
| 75 |
# intersection of both prject groups |
|
| 76 |
@projects = @projects && @tagged_projects_ids unless @tag_list.empty? |
|
| 77 |
|
|
| 78 |
@filtered_projects = @projects |
|
| 79 | 139 |
end |
| 80 | 140 |
end |
| 81 | 141 |
end |
| vendor/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb | ||
|---|---|---|
| 18 | 18 |
# description, manager(s), creation date, last activity date, |
| 19 | 19 |
# general activity level, whether there is anything actually hosted |
| 20 | 20 |
# here for the project, etc. |
| 21 |
def render_project_table_with_filtering(projects, question) |
|
| 22 |
debugger |
|
| 23 |
|
|
| 21 |
def render_project_table_with_filtering(projects, question) |
|
| 24 | 22 |
custom_fields = "" |
| 25 | 23 |
s = "" |
| 26 | 24 |
if projects.any? |
| ... | ... | |
| 31 | 29 |
s << "<thead><tr>" |
| 32 | 30 |
|
| 33 | 31 |
s << sort_header_tag('name', :caption => l("field_name"))
|
| 32 |
s << "<th class='tags'>" << l("tags") << "</th>"
|
|
| 34 | 33 |
s << "<th class='managers'>" << l("label_managers") << "</th>"
|
| 35 |
s << "<th class='tags'>" << l("tags") << "</th>"
|
|
| 36 | 34 |
s << sort_header_tag('created_on', :default_order => 'desc')
|
| 37 | 35 |
s << sort_header_tag('updated_on', :default_order => 'desc')
|
| 38 | 36 |
|
| ... | ... | |
| 66 | 64 |
s << " no_description" if project.description.blank? |
| 67 | 65 |
s << "'>" << link_to( highlight_tokens(project.name, tokens), {:controller => 'projects', :action => 'show', :id => project}, :class => "project #{User.current.member_of?(project) ? 'my-project' : nil}")
|
| 68 | 66 |
s << "</div>" |
| 69 |
s << render_project_short_description(project) |
|
| 67 |
s << highlight_tokens(render_project_short_description(project), tokens) |
|
| 68 |
s << "</td>" |
|
| 69 |
|
|
| 70 |
# taglist |
|
| 71 |
s << "<td class='tags' align=top>" << project.tag_counts.collect{ |t| render_project_tag_link(t) }.join(', ') << "</td>"
|
|
| 72 |
|
|
| 70 | 73 |
s << "<td class='managers' align=top>" |
| 71 | 74 |
|
| 72 | 75 |
u = project.users_by_role |
| ... | ... | |
| 88 | 91 |
|
| 89 | 92 |
s << "</td>" |
| 90 | 93 |
|
| 91 |
# taglist |
|
| 92 |
s << "<td class='tags' align=top>" << project.tag_counts.collect{ |t| render_project_tag_link(t) }.join(', ') << "</td>"
|
|
| 93 | 94 |
s << "<td class='created_on' align=top>" << format_date(project.created_on) << "</td>" |
| 94 | 95 |
s << "<td class='updated_on' align=top>" << format_date(project.updated_on) << "</td>" |
| 95 | 96 |
|
| ... | ... | |
| 162 | 163 |
s.join "\n" |
| 163 | 164 |
end |
| 164 | 165 |
|
| 166 |
# Renders a tree of projects where the current user belongs |
|
| 167 |
# as a nested set of unordered lists |
|
| 168 |
# The given collection may be a subset of the whole project tree |
|
| 169 |
# (eg. some intermediate nodes are private and can not be seen) |
|
| 170 |
def render_my_project_hierarchy_with_tags(projects) |
|
| 171 |
|
|
| 172 |
s = '' |
|
| 173 |
|
|
| 174 |
original_project = @project |
|
| 175 |
|
|
| 176 |
projects.each do |project| |
|
| 177 |
if project.root? || !projects.include?(project.parent) |
|
| 178 |
s << render_my_project_in_hierarchy_with_tags(project) |
|
| 179 |
end |
|
| 180 |
end |
|
| 181 |
|
|
| 182 |
@project = original_project |
|
| 183 |
|
|
| 184 |
if s != '' |
|
| 185 |
a = '' |
|
| 186 |
a << "<ul class='projects root'>\n" |
|
| 187 |
a << s |
|
| 188 |
a << "</ul>\n" |
|
| 189 |
s = a |
|
| 190 |
end |
|
| 191 |
|
|
| 192 |
s |
|
| 193 |
|
|
| 194 |
end |
|
| 195 |
|
|
| 196 |
|
|
| 197 |
|
|
| 198 |
|
|
| 199 |
def render_my_project_in_hierarchy_with_tags(project) |
|
| 200 |
|
|
| 201 |
s = '' |
|
| 202 |
|
|
| 203 |
if User.current.member_of?(project) |
|
| 204 |
|
|
| 205 |
# set the project environment to please macros. |
|
| 206 |
@project = project |
|
| 207 |
|
|
| 208 |
classes = (project.root? ? 'root' : 'child') |
|
| 209 |
|
|
| 210 |
s << "<li class='#{classes}'><div class='#{classes}'>" +
|
|
| 211 |
link_to_project(project, {}, :class => "project my-project")
|
|
| 212 |
if project.is_public? |
|
| 213 |
s << " <span class='public'>" << l(:field_is_public) << "</span>" |
|
| 214 |
else |
|
| 215 |
s << " <span class='private'>" << l(:field_is_private) << "</span>" |
|
| 216 |
end |
|
| 217 |
|
|
| 218 |
tc = project.tag_counts |
|
| 219 |
if tc.empty? |
|
| 220 |
s << " <span class='no-tags'>" << l(:field_no_tags) << "</span>" |
|
| 221 |
else |
|
| 222 |
s << " <span class='tags'>" << tc.collect{ |t| render_project_tag_link(t) }.join(', ') << "</span>"
|
|
| 223 |
end |
|
| 224 |
|
|
| 225 |
s << render_project_short_description(project) |
|
| 226 |
|
|
| 227 |
s << "</div>\n" |
|
| 228 |
|
|
| 229 |
cs = '' |
|
| 230 |
project.children.each do |child| |
|
| 231 |
cs << render_my_project_in_hierarchy_with_tags(child) |
|
| 232 |
end |
|
| 233 |
|
|
| 234 |
if cs != '' |
|
| 235 |
s << "<ul class='projects'>\n" << cs << "</ul>\n"; |
|
| 236 |
end |
|
| 237 |
|
|
| 238 |
end |
|
| 239 |
|
|
| 240 |
s |
|
| 241 |
|
|
| 242 |
end |
|
| 243 |
|
|
| 244 |
|
|
| 245 |
|
|
| 165 | 246 |
private |
| 166 | 247 |
|
| 167 | 248 |
# copied from search_helper. This one doesn't escape html or limit the text length |
Also available in: Unified diff