Chris@909: # encoding: utf-8 Chris@909: # Chris@909: # Redmine - project management software Chris@909: # Copyright (C) 2006-2011 Jean-Philippe Lang Chris@909: # Chris@909: # This program is free software; you can redistribute it and/or Chris@909: # modify it under the terms of the GNU General Public License Chris@909: # as published by the Free Software Foundation; either version 2 Chris@909: # of the License, or (at your option) any later version. Chris@909: # Chris@909: # This program is distributed in the hope that it will be useful, Chris@909: # but WITHOUT ANY WARRANTY; without even the implied warranty of Chris@909: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Chris@909: # GNU General Public License for more details. Chris@909: # Chris@909: # You should have received a copy of the GNU General Public License Chris@909: # along with this program; if not, write to the Free Software Chris@909: # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Chris@909: Chris@909: module ProjectsHelper Chris@909: def link_to_version(version, options = {}) Chris@909: return '' unless version && version.is_a?(Version) Chris@909: link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, options Chris@909: end Chris@909: Chris@909: def project_settings_tabs Chris@909: tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural}, Chris@909: {:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural}, Chris@909: {:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural}, Chris@909: {:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural}, Chris@909: {:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural}, Chris@909: {:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki}, Chris@909: {:name => 'repository', :action => :manage_repository, :partial => 'projects/settings/repository', :label => :label_repository}, Chris@909: {:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural}, Chris@909: {:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities} Chris@909: ] Chris@909: tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)} Chris@909: end Chris@909: Chris@909: def parent_project_select_tag(project) Chris@909: selected = project.parent Chris@909: # retrieve the requested parent project Chris@909: parent_id = (params[:project] && params[:project][:parent_id]) || params[:parent_id] Chris@909: if parent_id Chris@909: selected = (parent_id.blank? ? nil : Project.find(parent_id)) Chris@909: end Chris@909: Chris@909: options = '' Chris@909: options << "" if project.allowed_parents.include?(nil) Chris@909: options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected) Chris@909: content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id') Chris@909: end Chris@909: Chris@909: # Renders a tree of projects as a nested set of unordered lists Chris@909: # The given collection may be a subset of the whole project tree Chris@909: # (eg. some intermediate nodes are private and can not be seen) Chris@909: def render_project_hierarchy(projects) Chris@909: s = '' Chris@909: if projects.any? Chris@909: ancestors = [] Chris@909: original_project = @project Chris@909: projects.each do |project| Chris@909: # set the project environment to please macros. Chris@909: @project = project Chris@909: if (ancestors.empty? || project.is_descendant_of?(ancestors.last)) Chris@909: s << "