2011-12-14 23:56:23 +04:00
|
|
|
# encoding: utf-8
|
|
|
|
#
|
2011-05-18 15:13:02 +04:00
|
|
|
# Redmine - project management software
|
2013-01-12 13:29:31 +04:00
|
|
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
2007-03-12 20:59:02 +03:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU General Public License
|
|
|
|
# as published by the Free Software Foundation; either version 2
|
|
|
|
# of the License, or (at your option) any later version.
|
2011-05-18 15:13:02 +04:00
|
|
|
#
|
2007-03-12 20:59:02 +03:00
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
2011-05-18 15:13:02 +04:00
|
|
|
#
|
2007-03-12 20:59:02 +03:00
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
|
|
|
|
module ProjectsHelper
|
2007-05-07 20:54:26 +04:00
|
|
|
def link_to_version(version, options = {})
|
|
|
|
return '' unless version && version.is_a?(Version)
|
2009-12-06 13:28:20 +03:00
|
|
|
link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, options
|
2007-05-07 20:54:26 +04:00
|
|
|
end
|
2011-05-18 15:13:02 +04:00
|
|
|
|
2007-09-14 15:34:08 +04:00
|
|
|
def project_settings_tabs
|
|
|
|
tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural},
|
|
|
|
{:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural},
|
|
|
|
{:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural},
|
|
|
|
{:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural},
|
|
|
|
{:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural},
|
|
|
|
{:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki},
|
2012-01-16 02:55:14 +04:00
|
|
|
{:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural},
|
2009-10-22 02:34:45 +04:00
|
|
|
{:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural},
|
|
|
|
{:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities}
|
2007-09-14 15:34:08 +04:00
|
|
|
]
|
2011-05-18 15:13:02 +04:00
|
|
|
tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
|
2007-09-14 15:34:08 +04:00
|
|
|
end
|
2011-05-18 15:13:02 +04:00
|
|
|
|
2009-01-24 14:31:15 +03:00
|
|
|
def parent_project_select_tag(project)
|
2009-12-24 19:18:15 +03:00
|
|
|
selected = project.parent
|
|
|
|
# retrieve the requested parent project
|
|
|
|
parent_id = (params[:project] && params[:project][:parent_id]) || params[:parent_id]
|
|
|
|
if parent_id
|
|
|
|
selected = (parent_id.blank? ? nil : Project.find(parent_id))
|
|
|
|
end
|
2011-05-18 15:13:02 +04:00
|
|
|
|
2009-12-24 19:18:15 +03:00
|
|
|
options = ''
|
|
|
|
options << "<option value=''></option>" if project.allowed_parents.include?(nil)
|
|
|
|
options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected)
|
2011-08-21 02:52:37 +04:00
|
|
|
content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id')
|
2009-01-24 14:31:15 +03:00
|
|
|
end
|
2011-05-18 15:13:02 +04:00
|
|
|
|
2012-08-10 21:09:48 +04:00
|
|
|
# Renders the projects index
|
2009-01-24 14:31:15 +03:00
|
|
|
def render_project_hierarchy(projects)
|
2012-08-10 21:09:48 +04:00
|
|
|
render_project_nested_lists(projects) do |project|
|
|
|
|
s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
|
|
|
|
if project.description.present?
|
|
|
|
s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description')
|
2009-01-24 14:31:15 +03:00
|
|
|
end
|
2012-08-10 21:09:48 +04:00
|
|
|
s
|
2009-01-24 14:31:15 +03:00
|
|
|
end
|
|
|
|
end
|
2009-12-06 13:28:20 +03:00
|
|
|
|
|
|
|
# Returns a set of options for a select field, grouped by project.
|
|
|
|
def version_options_for_select(versions, selected=nil)
|
|
|
|
grouped = Hash.new {|h,k| h[k] = []}
|
|
|
|
versions.each do |version|
|
2009-12-23 22:58:41 +03:00
|
|
|
grouped[version.project.name] << [version.name, version.id]
|
2009-12-06 13:28:20 +03:00
|
|
|
end
|
2011-05-18 15:13:02 +04:00
|
|
|
|
2009-12-06 13:28:20 +03:00
|
|
|
if grouped.keys.size > 1
|
|
|
|
grouped_options_for_select(grouped, selected && selected.id)
|
|
|
|
else
|
2009-12-09 12:22:16 +03:00
|
|
|
options_for_select((grouped.values.first || []), selected && selected.id)
|
2009-12-06 13:28:20 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def format_version_sharing(sharing)
|
|
|
|
sharing = 'none' unless Version::VERSION_SHARINGS.include?(sharing)
|
|
|
|
l("label_version_sharing_#{sharing}")
|
|
|
|
end
|
2006-06-28 22:11:03 +04:00
|
|
|
end
|