Mercurial > hg > soundsoftware-site
comparison app/helpers/projects_helper.rb @ 511:107d36338b70 live
Merge from branch "cannam"
author | Chris Cannam |
---|---|
date | Thu, 14 Jul 2011 10:43:07 +0100 |
parents | d7326bb4f6f0 |
children | 863f447c4d88 |
comparison
equal
deleted
inserted
replaced
451:a9f6345cb43d | 511:107d36338b70 |
---|---|
1 # redMine - project management software | 1 # Redmine - project management software |
2 # Copyright (C) 2006 Jean-Philippe Lang | 2 # Copyright (C) 2006-2011 Jean-Philippe Lang |
3 # | 3 # |
4 # This program is free software; you can redistribute it and/or | 4 # This program is free software; you can redistribute it and/or |
5 # modify it under the terms of the GNU General Public License | 5 # modify it under the terms of the GNU General Public License |
6 # as published by the Free Software Foundation; either version 2 | 6 # as published by the Free Software Foundation; either version 2 |
7 # of the License, or (at your option) any later version. | 7 # of the License, or (at your option) any later version. |
8 # | 8 # |
9 # This program is distributed in the hope that it will be useful, | 9 # This program is distributed in the hope that it will be useful, |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 # GNU General Public License for more details. | 12 # GNU General Public License for more details. |
13 # | 13 # |
14 # You should have received a copy of the GNU General Public License | 14 # You should have received a copy of the GNU General Public License |
15 # along with this program; if not, write to the Free Software | 15 # along with this program; if not, write to the Free Software |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
17 | 17 |
18 module ProjectsHelper | 18 module ProjectsHelper |
19 def link_to_version(version, options = {}) | 19 def link_to_version(version, options = {}) |
20 return '' unless version && version.is_a?(Version) | 20 return '' unless version && version.is_a?(Version) |
21 link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, options | 21 link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, options |
22 end | 22 end |
23 | 23 |
24 def project_settings_tabs | 24 def project_settings_tabs |
25 tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural}, | 25 tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural}, |
26 {:name => 'overview', :action => :edit_project, :partial => 'projects/settings/overview', :label => :label_welcome_page}, | 26 {:name => 'overview', :action => :edit_project, :partial => 'projects/settings/overview', :label => :label_welcome_page}, |
27 {:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural}, | 27 {:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural}, |
28 {:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural}, | |
29 {:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural}, | 28 {:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural}, |
30 {:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural}, | 29 {:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural}, |
31 {:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki}, | 30 {:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki}, |
32 {:name => 'repository', :action => :manage_repository, :partial => 'projects/settings/repository', :label => :label_repository}, | 31 {:name => 'repository', :action => :manage_repository, :partial => 'projects/settings/repository', :label => :label_repository}, |
33 {:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural}, | 32 {:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural}, |
34 {:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities} | 33 {:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities} |
35 ] | 34 ] |
36 tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} | 35 tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} |
37 end | 36 end |
38 | 37 |
39 def parent_project_select_tag(project) | 38 def parent_project_select_tag(project) |
40 selected = project.parent | 39 selected = project.parent |
41 # retrieve the requested parent project | 40 # retrieve the requested parent project |
42 parent_id = (params[:project] && params[:project][:parent_id]) || params[:parent_id] | 41 parent_id = (params[:project] && params[:project][:parent_id]) || params[:parent_id] |
43 if parent_id | 42 if parent_id |
44 selected = (parent_id.blank? ? nil : Project.find(parent_id)) | 43 selected = (parent_id.blank? ? nil : Project.find(parent_id)) |
45 end | 44 end |
46 | 45 |
47 options = '' | 46 options = '' |
48 options << "<option value=''></option>" if project.allowed_parents.include?(nil) | 47 options << "<option value=''></option>" if project.allowed_parents.include?(nil) |
49 options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected) | 48 options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected) |
50 content_tag('select', options, :name => 'project[parent_id]', :id => 'project_parent_id') | 49 content_tag('select', options, :name => 'project[parent_id]', :id => 'project_parent_id') |
51 end | 50 end |
74 if (ancestors.empty? || project.is_descendant_of?(ancestors.last)) | 73 if (ancestors.empty? || project.is_descendant_of?(ancestors.last)) |
75 s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n" | 74 s << "<ul class='projects #{ ancestors.empty? ? 'root' : nil}'>\n" |
76 else | 75 else |
77 ancestors.pop | 76 ancestors.pop |
78 s << "</li>" | 77 s << "</li>" |
79 while (ancestors.any? && !project.is_descendant_of?(ancestors.last)) | 78 while (ancestors.any? && !project.is_descendant_of?(ancestors.last)) |
80 ancestors.pop | 79 ancestors.pop |
81 s << "</ul></li>\n" | 80 s << "</ul></li>\n" |
82 end | 81 end |
83 end | 82 end |
84 classes = (ancestors.empty? ? 'root' : 'child') | 83 classes = (ancestors.empty? ? 'root' : 'child') |
259 end | 258 end |
260 # Add in the selected | 259 # Add in the selected |
261 if selected && !versions.include?(selected) | 260 if selected && !versions.include?(selected) |
262 grouped[selected.project.name] << [selected.name, selected.id] | 261 grouped[selected.project.name] << [selected.name, selected.id] |
263 end | 262 end |
264 | 263 |
265 if grouped.keys.size > 1 | 264 if grouped.keys.size > 1 |
266 grouped_options_for_select(grouped, selected && selected.id) | 265 grouped_options_for_select(grouped, selected && selected.id) |
267 else | 266 else |
268 options_for_select((grouped.values.first || []), selected && selected.id) | 267 options_for_select((grouped.values.first || []), selected && selected.id) |
269 end | 268 end |