2012-05-05 14:56:53 +02:00
|
|
|
# Redmine - project management software
|
2016-03-13 11:30:10 +01:00
|
|
|
# Copyright (C) 2006-2016 Jean-Philippe Lang
|
2012-05-05 14:56:53 +02: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 20:16:54 +02:00
|
|
|
class ContextMenusController < ApplicationController
|
|
|
|
helper :watchers
|
2011-04-17 17:17:18 +02:00
|
|
|
helper :issues
|
2011-08-30 15:03:57 +02:00
|
|
|
|
2016-07-14 09:27:31 +02:00
|
|
|
before_action :find_issues, :only => :issues
|
2013-06-11 20:33:06 +02:00
|
|
|
|
2010-08-19 20:16:54 +02:00
|
|
|
def issues
|
|
|
|
if (@issues.size == 1)
|
|
|
|
@issue = @issues.first
|
|
|
|
end
|
2012-07-08 15:31:22 +02:00
|
|
|
@issue_ids = @issues.map(&:id).sort
|
2012-02-09 20:51:38 +01:00
|
|
|
|
2012-02-09 21:06:36 +01:00
|
|
|
@allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
|
2010-08-19 20:16:54 +02:00
|
|
|
|
2016-06-05 15:45:10 +02:00
|
|
|
@can = {:edit => @issues.all?(&:attributes_editable?),
|
2010-08-19 20:16:54 +02:00
|
|
|
:log_time => (@project && User.current.allowed_to?(:log_time, @project)),
|
2015-02-08 13:07:00 +01:00
|
|
|
:copy => User.current.allowed_to?(:copy_issues, @projects) && Issue.allowed_target_projects.any?,
|
2016-04-09 09:37:49 +02:00
|
|
|
:add_watchers => User.current.allowed_to?(:add_issue_watchers, @projects),
|
2016-06-05 15:45:10 +02:00
|
|
|
:delete => @issues.all?(&:deletable?)
|
2010-08-19 20:16:54 +02:00
|
|
|
}
|
2016-06-28 22:31:08 +02:00
|
|
|
|
|
|
|
@assignables = @issues.map(&:assignable_users).reduce(:&)
|
2016-05-30 20:20:13 +02:00
|
|
|
@trackers = @projects.map {|p| Issue.allowed_target_trackers(p) }.reduce(:&)
|
2012-07-08 15:19:46 +02:00
|
|
|
@versions = @projects.map {|p| p.shared_versions.open}.reduce(:&)
|
2011-08-30 15:03:57 +02:00
|
|
|
|
2011-06-13 21:43:40 +02:00
|
|
|
@priorities = IssuePriority.active.reverse
|
2010-08-19 20:16:54 +02:00
|
|
|
@back = back_url
|
2011-08-30 15:03:57 +02:00
|
|
|
|
2012-02-09 19:22:11 +01:00
|
|
|
@options_by_custom_field = {}
|
|
|
|
if @can[:edit]
|
2016-10-23 13:48:52 +02:00
|
|
|
custom_fields = @issues.map(&:editable_custom_fields).reduce(:&).reject(&:multiple?).select {|field| field.format.bulk_edit_supported}
|
2012-02-09 19:22:11 +01:00
|
|
|
custom_fields.each do |field|
|
|
|
|
values = field.possible_values_options(@projects)
|
2013-12-14 09:57:30 +01:00
|
|
|
if values.present?
|
2012-02-09 19:22:11 +01:00
|
|
|
@options_by_custom_field[field] = values
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-05 14:20:07 +02:00
|
|
|
@safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
|
2010-08-19 20:16:54 +02:00
|
|
|
render :layout => false
|
|
|
|
end
|
2011-04-04 13:53:03 +02:00
|
|
|
|
|
|
|
def time_entries
|
2016-11-18 09:19:11 +01:00
|
|
|
@time_entries = TimeEntry.where(:id => params[:ids]).
|
|
|
|
preload(:project => :time_entry_activities).
|
|
|
|
preload(:user).to_a
|
|
|
|
|
2013-01-20 17:04:25 +01:00
|
|
|
(render_404; return) unless @time_entries.present?
|
2014-07-29 19:52:27 +02:00
|
|
|
if (@time_entries.size == 1)
|
|
|
|
@time_entry = @time_entries.first
|
|
|
|
end
|
2013-01-20 17:04:25 +01:00
|
|
|
|
2011-04-04 13:53:03 +02:00
|
|
|
@projects = @time_entries.collect(&:project).compact.uniq
|
|
|
|
@project = @projects.first if @projects.size == 1
|
2016-11-18 09:19:11 +01:00
|
|
|
@activities = @projects.map(&:activities).reduce(:&)
|
2015-05-09 12:10:28 +02:00
|
|
|
|
|
|
|
edit_allowed = @time_entries.all? {|t| t.editable_by?(User.current)}
|
|
|
|
@can = {:edit => edit_allowed, :delete => edit_allowed}
|
2011-04-04 13:53:03 +02:00
|
|
|
@back = back_url
|
2014-07-29 19:52:27 +02:00
|
|
|
|
|
|
|
@options_by_custom_field = {}
|
|
|
|
if @can[:edit]
|
2016-10-23 13:51:26 +02:00
|
|
|
custom_fields = @time_entries.map(&:editable_custom_fields).reduce(:&).reject(&:multiple?).select {|field| field.format.bulk_edit_supported}
|
2014-07-29 19:52:27 +02:00
|
|
|
custom_fields.each do |field|
|
|
|
|
values = field.possible_values_options(@projects)
|
|
|
|
if values.present?
|
|
|
|
@options_by_custom_field[field] = values
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-04-04 13:53:03 +02:00
|
|
|
render :layout => false
|
2011-08-30 15:03:57 +02:00
|
|
|
end
|
2010-08-19 20:16:54 +02:00
|
|
|
end
|