kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
3.1 KiB
73 lines
3.1 KiB
13 years ago
|
#-- encoding: UTF-8
|
||
14 years ago
|
#-- copyright
|
||
12 years ago
|
# OpenProject is a project management system.
|
||
11 years ago
|
# Copyright (C) 2012-2013 the OpenProject Foundation (OPF)
|
||
14 years ago
|
#
|
||
14 years ago
|
# This program is free software; you can redistribute it and/or
|
||
12 years ago
|
# modify it under the terms of the GNU General Public License version 3.
|
||
14 years ago
|
#
|
||
11 years ago
|
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
|
||
|
# Copyright (C) 2006-2013 Jean-Philippe Lang
|
||
|
# Copyright (C) 2010-2013 the ChiliProject Team
|
||
|
#
|
||
|
# 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.
|
||
|
#
|
||
|
# 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.
|
||
|
#
|
||
|
# 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.
|
||
|
#
|
||
14 years ago
|
# See doc/COPYRIGHT.rdoc for more details.
|
||
|
#++
|
||
|
|
||
11 years ago
|
class WorkPackages::ContextMenusController < ApplicationController
|
||
14 years ago
|
|
||
11 years ago
|
def index
|
||
|
@work_packages = WorkPackage.visible.all(conditions: {id: params[:ids]},
|
||
|
include: :project)
|
||
14 years ago
|
|
||
11 years ago
|
if (@work_packages.size == 1)
|
||
|
@work_package = @work_packages.first
|
||
|
@allowed_statuses = @work_package.new_statuses_allowed_to(User.current)
|
||
14 years ago
|
else
|
||
11 years ago
|
@allowed_statuses = @work_packages.map do |i|
|
||
14 years ago
|
i.new_statuses_allowed_to(User.current)
|
||
|
end.inject do |memo,s|
|
||
|
memo & s
|
||
|
end
|
||
14 years ago
|
end
|
||
11 years ago
|
@projects = @work_packages.collect(&:project).compact.uniq
|
||
14 years ago
|
@project = @projects.first if @projects.size == 1
|
||
14 years ago
|
|
||
12 years ago
|
@can = {:edit => User.current.allowed_to?(:edit_work_packages, @projects),
|
||
14 years ago
|
:log_time => (@project && User.current.allowed_to?(:log_time, @project)),
|
||
12 years ago
|
:update => (User.current.allowed_to?(:edit_work_packages, @projects) || (User.current.allowed_to?(:change_status, @projects) && !@allowed_statuses.blank?)),
|
||
11 years ago
|
:move => (@project && User.current.allowed_to?(:move_work_packages, @project)),
|
||
11 years ago
|
:copy => (@work_package && @project.types.include?(@work_package.type) && User.current.allowed_to?(:add_work_packages, @project)),
|
||
11 years ago
|
:delete => User.current.allowed_to?(:delete_work_packages, @projects)
|
||
14 years ago
|
}
|
||
|
if @project
|
||
|
@assignables = @project.assignable_users
|
||
11 years ago
|
@assignables << @work_package.assigned_to if @work_package && @work_package.assigned_to && !@assignables.include?(@work_package.assigned_to)
|
||
11 years ago
|
@types = @project.types
|
||
14 years ago
|
else
|
||
|
#when multiple projects, we only keep the intersection of each set
|
||
|
@assignables = @projects.map(&:assignable_users).inject{|memo,a| memo & a}
|
||
11 years ago
|
@types = @projects.map(&:types).inject{|memo,t| memo & t}
|
||
14 years ago
|
end
|
||
14 years ago
|
|
||
14 years ago
|
@priorities = IssuePriority.all.reverse
|
||
|
@statuses = IssueStatus.find(:all, :order => 'position')
|
||
|
@back = back_url
|
||
14 years ago
|
|
||
14 years ago
|
render :layout => false
|
||
|
end
|
||
|
end
|