2012-05-05 16:56:53 +04:00
|
|
|
# Redmine - project management software
|
2014-01-30 02:45:39 +04:00
|
|
|
# Copyright (C) 2006-2014 Jean-Philippe Lang
|
2012-05-05 16:56:53 +04: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.
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2010-08-19 22:16:54 +04:00
|
|
|
class ContextMenusController < ApplicationController
|
|
|
|
helper :watchers
|
2011-04-17 19:17:18 +04:00
|
|
|
helper :issues
|
2011-08-30 17:03:57 +04:00
|
|
|
|
2013-06-11 22:33:06 +04:00
|
|
|
before_filter :find_issues, :only => :issues
|
|
|
|
|
2010-08-19 22:16:54 +04:00
|
|
|
def issues
|
|
|
|
if (@issues.size == 1)
|
|
|
|
@issue = @issues.first
|
|
|
|
end
|
2012-07-08 17:31:22 +04:00
|
|
|
@issue_ids = @issues.map(&:id).sort
|
2012-02-09 23:51:38 +04:00
|
|
|
|
2012-02-10 00:06:36 +04:00
|
|
|
@allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
|
2010-08-19 22:16:54 +04:00
|
|
|
|
2010-10-08 07:09:51 +04:00
|
|
|
@can = {:edit => User.current.allowed_to?(:edit_issues, @projects),
|
2010-08-19 22:16:54 +04:00
|
|
|
:log_time => (@project && User.current.allowed_to?(:log_time, @project)),
|
2010-10-08 07:09:51 +04:00
|
|
|
:update => (User.current.allowed_to?(:edit_issues, @projects) || (User.current.allowed_to?(:change_status, @projects) && !@allowed_statuses.blank?)),
|
2010-08-19 22:16:54 +04:00
|
|
|
:move => (@project && User.current.allowed_to?(:move_issues, @project)),
|
|
|
|
:copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
|
2010-10-07 09:11:28 +04:00
|
|
|
:delete => User.current.allowed_to?(:delete_issues, @projects)
|
2010-08-19 22:16:54 +04:00
|
|
|
}
|
|
|
|
if @project
|
2011-07-24 00:02:31 +04:00
|
|
|
if @issue
|
|
|
|
@assignables = @issue.assignable_users
|
|
|
|
else
|
|
|
|
@assignables = @project.assignable_users
|
|
|
|
end
|
2010-08-19 22:16:54 +04:00
|
|
|
@trackers = @project.trackers
|
2010-10-08 07:09:51 +04:00
|
|
|
else
|
|
|
|
#when multiple projects, we only keep the intersection of each set
|
2012-02-10 00:06:36 +04:00
|
|
|
@assignables = @projects.map(&:assignable_users).reduce(:&)
|
|
|
|
@trackers = @projects.map(&:trackers).reduce(:&)
|
2010-08-19 22:16:54 +04:00
|
|
|
end
|
2012-07-08 17:19:46 +04:00
|
|
|
@versions = @projects.map {|p| p.shared_versions.open}.reduce(:&)
|
2011-08-30 17:03:57 +04:00
|
|
|
|
2011-06-13 23:43:40 +04:00
|
|
|
@priorities = IssuePriority.active.reverse
|
2010-08-19 22:16:54 +04:00
|
|
|
@back = back_url
|
2011-08-30 17:03:57 +04:00
|
|
|
|
2012-02-09 22:22:11 +04:00
|
|
|
@options_by_custom_field = {}
|
|
|
|
if @can[:edit]
|
2014-05-02 11:32:41 +04:00
|
|
|
custom_fields = @issues.map(&:editable_custom_fields).reduce(:&).reject(&:multiple?)
|
2012-02-09 22:22:11 +04:00
|
|
|
custom_fields.each do |field|
|
|
|
|
values = field.possible_values_options(@projects)
|
2013-12-14 12:57:30 +04:00
|
|
|
if values.present?
|
2012-02-09 22:22:11 +04:00
|
|
|
@options_by_custom_field[field] = values
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-05 16:20:07 +04:00
|
|
|
@safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
|
2010-08-19 22:16:54 +04:00
|
|
|
render :layout => false
|
|
|
|
end
|
2011-04-04 15:53:03 +04:00
|
|
|
|
|
|
|
def time_entries
|
2013-06-12 23:13:25 +04:00
|
|
|
@time_entries = TimeEntry.where(:id => params[:ids]).preload(:project).to_a
|
2013-01-20 20:04:25 +04:00
|
|
|
(render_404; return) unless @time_entries.present?
|
|
|
|
|
2011-04-04 15:53:03 +04:00
|
|
|
@projects = @time_entries.collect(&:project).compact.uniq
|
|
|
|
@project = @projects.first if @projects.size == 1
|
|
|
|
@activities = TimeEntryActivity.shared.active
|
2011-11-25 01:31:21 +04:00
|
|
|
@can = {:edit => User.current.allowed_to?(:edit_time_entries, @projects),
|
|
|
|
:delete => User.current.allowed_to?(:edit_time_entries, @projects)
|
2011-04-04 15:53:03 +04:00
|
|
|
}
|
|
|
|
@back = back_url
|
|
|
|
render :layout => false
|
2011-08-30 17:03:57 +04:00
|
|
|
end
|
2010-08-19 22:16:54 +04:00
|
|
|
end
|