annotate .svn/pristine/11/1168184b847515eb2b5857914207c9183b271a1d.svn-base @ 1524:82fac3dcf466 redmine-2.5-integration

Fix failure to interpret Javascript when autocompleting members for project
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Thu, 11 Sep 2014 10:24:38 +0100
parents dffacf8a6908
children
rev   line source
Chris@1517 1 # encoding: utf-8
Chris@1517 2 #
Chris@1517 3 # Redmine - project management software
Chris@1517 4 # Copyright (C) 2006-2014 Jean-Philippe Lang
Chris@1517 5 #
Chris@1517 6 # This program is free software; you can redistribute it and/or
Chris@1517 7 # modify it under the terms of the GNU General Public License
Chris@1517 8 # as published by the Free Software Foundation; either version 2
Chris@1517 9 # of the License, or (at your option) any later version.
Chris@1517 10 #
Chris@1517 11 # This program is distributed in the hope that it will be useful,
Chris@1517 12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1517 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1517 14 # GNU General Public License for more details.
Chris@1517 15 #
Chris@1517 16 # You should have received a copy of the GNU General Public License
Chris@1517 17 # along with this program; if not, write to the Free Software
Chris@1517 18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1517 19
Chris@1517 20 module ProjectsHelper
Chris@1517 21 def link_to_version(version, options = {})
Chris@1517 22 return '' unless version && version.is_a?(Version)
Chris@1517 23 link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, options
Chris@1517 24 end
Chris@1517 25
Chris@1517 26 def project_settings_tabs
Chris@1517 27 tabs = [{:name => 'info', :action => :edit_project, :partial => 'projects/edit', :label => :label_information_plural},
Chris@1517 28 {:name => 'modules', :action => :select_project_modules, :partial => 'projects/settings/modules', :label => :label_module_plural},
Chris@1517 29 {:name => 'members', :action => :manage_members, :partial => 'projects/settings/members', :label => :label_member_plural},
Chris@1517 30 {:name => 'versions', :action => :manage_versions, :partial => 'projects/settings/versions', :label => :label_version_plural},
Chris@1517 31 {:name => 'categories', :action => :manage_categories, :partial => 'projects/settings/issue_categories', :label => :label_issue_category_plural},
Chris@1517 32 {:name => 'wiki', :action => :manage_wiki, :partial => 'projects/settings/wiki', :label => :label_wiki},
Chris@1517 33 {:name => 'repositories', :action => :manage_repository, :partial => 'projects/settings/repositories', :label => :label_repository_plural},
Chris@1517 34 {:name => 'boards', :action => :manage_boards, :partial => 'projects/settings/boards', :label => :label_board_plural},
Chris@1517 35 {:name => 'activities', :action => :manage_project_activities, :partial => 'projects/settings/activities', :label => :enumeration_activities}
Chris@1517 36 ]
Chris@1517 37 tabs.select {|tab| User.current.allowed_to?(tab[:action], @project)}
Chris@1517 38 end
Chris@1517 39
Chris@1517 40 def parent_project_select_tag(project)
Chris@1517 41 selected = project.parent
Chris@1517 42 # retrieve the requested parent project
Chris@1517 43 parent_id = (params[:project] && params[:project][:parent_id]) || params[:parent_id]
Chris@1517 44 if parent_id
Chris@1517 45 selected = (parent_id.blank? ? nil : Project.find(parent_id))
Chris@1517 46 end
Chris@1517 47
Chris@1517 48 options = ''
Chris@1517 49 options << "<option value=''>&nbsp;</option>" if project.allowed_parents.include?(nil)
Chris@1517 50 options << project_tree_options_for_select(project.allowed_parents.compact, :selected => selected)
Chris@1517 51 content_tag('select', options.html_safe, :name => 'project[parent_id]', :id => 'project_parent_id')
Chris@1517 52 end
Chris@1517 53
Chris@1517 54 def render_project_action_links
Chris@1517 55 links = []
Chris@1517 56 links << link_to(l(:label_project_new), {:controller => 'projects', :action => 'new'}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true)
Chris@1517 57 links << link_to(l(:label_issue_view_all), issues_path) if User.current.allowed_to?(:view_issues, nil, :global => true)
Chris@1517 58 links << link_to(l(:label_overall_spent_time), time_entries_path) if User.current.allowed_to?(:view_time_entries, nil, :global => true)
Chris@1517 59 links << link_to(l(:label_overall_activity), { :controller => 'activities', :action => 'index', :id => nil })
Chris@1517 60 links.join(" | ").html_safe
Chris@1517 61 end
Chris@1517 62
Chris@1517 63 # Renders the projects index
Chris@1517 64 def render_project_hierarchy(projects)
Chris@1517 65 render_project_nested_lists(projects) do |project|
Chris@1517 66 s = link_to_project(project, {}, :class => "#{project.css_classes} #{User.current.member_of?(project) ? 'my-project' : nil}")
Chris@1517 67 if project.description.present?
Chris@1517 68 s << content_tag('div', textilizable(project.short_description, :project => project), :class => 'wiki description')
Chris@1517 69 end
Chris@1517 70 s
Chris@1517 71 end
Chris@1517 72 end
Chris@1517 73
Chris@1517 74 # Returns a set of options for a select field, grouped by project.
Chris@1517 75 def version_options_for_select(versions, selected=nil)
Chris@1517 76 grouped = Hash.new {|h,k| h[k] = []}
Chris@1517 77 versions.each do |version|
Chris@1517 78 grouped[version.project.name] << [version.name, version.id]
Chris@1517 79 end
Chris@1517 80
Chris@1517 81 selected = selected.is_a?(Version) ? selected.id : selected
Chris@1517 82 if grouped.keys.size > 1
Chris@1517 83 grouped_options_for_select(grouped, selected)
Chris@1517 84 else
Chris@1517 85 options_for_select((grouped.values.first || []), selected)
Chris@1517 86 end
Chris@1517 87 end
Chris@1517 88
Chris@1517 89 def format_version_sharing(sharing)
Chris@1517 90 sharing = 'none' unless Version::VERSION_SHARINGS.include?(sharing)
Chris@1517 91 l("label_version_sharing_#{sharing}")
Chris@1517 92 end
Chris@1517 93 end