| 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 |
10 |
before_filter :add_tags_to_project, :only => [:save, :update]
|
| 11 |
|
before_filter :filter_projects, :only => :index
|
|
11 |
# before_filter :filter_projects, :only => :index
|
|
12 |
|
|
13 |
alias :index filtered_index
|
| 12 |
14 |
end
|
| 13 |
15 |
end
|
| 14 |
16 |
|
| 15 |
17 |
module InstanceMethods
|
|
18 |
|
|
19 |
|
|
20 |
|
| 16 |
21 |
def add_tags_to_project
|
| 17 |
22 |
|
| 18 |
23 |
if params && params[:project] && !params[:project][:tag_list].nil?
|
| ... | ... | |
| 25 |
30 |
end
|
| 26 |
31 |
end
|
| 27 |
32 |
|
| 28 |
|
# # luisf - TO BE REMOVED?
|
| 29 |
|
# def calculate_project_filtering_settings
|
| 30 |
|
# @project_filtering_settings = Setting[:plugin_redmine_project_filtering]
|
| 31 |
|
# end
|
| 32 |
33 |
|
| 33 |
|
def filter_projects
|
|
34 |
def paginate_projects
|
|
35 |
sort_init 'name'
|
|
36 |
sort_update %w(name lft created_on updated_on)
|
|
37 |
@limit = per_page_option
|
|
38 |
@project_count = Project.visible_roots.count
|
|
39 |
@project_pages = ActionController::Pagination::Paginator.new self, @project_count, @limit, params['page']
|
|
40 |
@offset ||= @project_pages.current.offset
|
|
41 |
end
|
|
42 |
|
|
43 |
|
|
44 |
# Lists visible projects. Paginator is for top-level projects only
|
|
45 |
# (subprojects belong to them)
|
|
46 |
def filtered_index
|
| 34 |
47 |
@project = Project.new
|
|
48 |
filter_projects
|
| 35 |
49 |
|
| 36 |
50 |
respond_to do |format|
|
| 37 |
|
format.any(:html, :xml) {
|
| 38 |
|
calculate_filtered_projects
|
|
51 |
format.html {
|
|
52 |
paginate_projects
|
|
53 |
@projects = Project.visible_roots.find(@filtered_projects, :offset => @offset, :limit => @limit, :order => sort_clause)
|
|
54 |
|
|
55 |
if User.current.logged?
|
|
56 |
# seems sort_by gives us case-sensitive ordering, which we don't want
|
|
57 |
# @user_projects = User.current.projects.sort_by(&:name)
|
|
58 |
@user_projects = User.current.projects.all(:order => :name)
|
|
59 |
end
|
|
60 |
|
|
61 |
render :template => 'projects/index.rhtml', :layout => !request.xhr?
|
|
62 |
}
|
|
63 |
format.api {
|
|
64 |
@offset, @limit = api_offset_and_limit
|
|
65 |
@project_count = Project.visible.count
|
|
66 |
@projects = Project.visible.find(@filtered_projects, :offset => @offset, :limit => @limit, :order => 'lft')
|
|
67 |
}
|
|
68 |
format.atom {
|
|
69 |
projects = Project.visible.find(:all, :order => 'created_on DESC', :limit => Setting.feeds_limit.to_i)
|
|
70 |
render_feed(projects, :title => "#{Setting.app_title}: #{l(:label_project_latest)}")
|
| 39 |
71 |
}
|
| 40 |
72 |
format.js {
|
| 41 |
|
calculate_filtered_projects
|
| 42 |
73 |
render :update do |page|
|
|
74 |
paginate_projects
|
|
75 |
@projects = Project.visible_roots.find(@filtered_projects, :offset => @offset, :limit => @limit, :order => sort_clause)
|
| 43 |
76 |
page.replace_html 'projects', :partial => 'filtered_projects'
|
| 44 |
77 |
end
|
| 45 |
78 |
}
|
| 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 |
79 |
end
|
| 52 |
80 |
end
|
| 53 |
81 |
|
| 54 |
82 |
private
|
| 55 |
83 |
|
| 56 |
|
def calculate_filtered_projects
|
|
84 |
def filter_projects
|
| 57 |
85 |
@question = (params[:q] || "").strip
|
| 58 |
86 |
|
| 59 |
87 |
if params.has_key?(:project)
|