To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / vendor / plugins / redmine_tags / lib / redmine_tags / patches / projects_controller_patch.rb @ 745:4acfc770e79f
History | View | Annotate | Download (2.43 KB)
| 1 |
require_dependency 'projects_controller'
|
|---|---|
| 2 |
|
| 3 |
module RedmineTags |
| 4 |
module Patches |
| 5 |
module ProjectsControllerPatch |
| 6 |
def self.included(base) |
| 7 |
base.send(:include, InstanceMethods) |
| 8 |
base.class_eval do
|
| 9 |
unloadable |
| 10 |
before_filter :add_tags_to_project, :only => [:save, :update] |
| 11 |
before_filter :filter_projects, :only => :index |
| 12 |
end
|
| 13 |
end
|
| 14 |
|
| 15 |
module InstanceMethods |
| 16 |
def add_tags_to_project |
| 17 |
if params && params[:project] && !params[:project][:tag_list].nil? |
| 18 |
old_tags = @project.tag_list.to_s
|
| 19 |
new_tags = params[:project][:tag_list].to_s |
| 20 |
|
| 21 |
unless (old_tags == new_tags)
|
| 22 |
@project.tag_list = new_tags
|
| 23 |
end
|
| 24 |
end
|
| 25 |
end
|
| 26 |
|
| 27 |
|
| 28 |
def calculate_project_filtering_settings |
| 29 |
@project_filtering_settings = Setting[:plugin_redmine_project_filtering] |
| 30 |
end
|
| 31 |
|
| 32 |
def filter_projects |
| 33 |
|
| 34 |
logger.error { "FILTRA PA!" }
|
| 35 |
|
| 36 |
respond_to do |format|
|
| 37 |
format.any(:html, :xml) { |
| 38 |
calculate_filtered_projects |
| 39 |
} |
| 40 |
format.js {
|
| 41 |
calculate_filtered_projects |
| 42 |
render :update do |page| |
| 43 |
page.replace_html 'projects', :partial => 'filtered_projects' |
| 44 |
end
|
| 45 |
} |
| 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 |
end
|
| 52 |
end
|
| 53 |
|
| 54 |
private |
| 55 |
|
| 56 |
def calculate_filtered_projects |
| 57 |
|
| 58 |
@question = (params[:q] || "").strip |
| 59 |
@custom_fields = params[:custom_fields] || {} |
| 60 |
|
| 61 |
@projects = Project.visible |
| 62 |
|
| 63 |
unless @custom_fields.empty? |
| 64 |
@projects = @projects.with_custom_values(params[:custom_fields]) |
| 65 |
end
|
| 66 |
|
| 67 |
@featured_projects = @projects.featured if Project.respond_to? :featured |
| 68 |
|
| 69 |
@projects = @projects.search_by_question(@question) |
| 70 |
debugger |
| 71 |
@featured_projects = @featured_projects.search_by_question(@question) if @featured_projects |
| 72 |
|
| 73 |
end
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
end
|
| 79 |
end
|
| 80 |
end
|
| 81 |
end
|