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
|
|
|
|
2010-08-19 20:16:54 +02:00
|
|
|
def issues
|
2010-12-29 20:55:52 +01:00
|
|
|
@issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project)
|
2010-08-19 20:16:54 +02:00
|
|
|
if (@issues.size == 1)
|
|
|
|
@issue = @issues.first
|
|
|
|
end
|
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-09-03 23:43:07 +02:00
|
|
|
@projects = @issues.collect(&:project).compact.uniq
|
|
|
|
@project = @projects.first if @projects.size == 1
|
2010-08-19 20:16:54 +02:00
|
|
|
|
2010-10-08 05:09:51 +02:00
|
|
|
@can = {:edit => User.current.allowed_to?(:edit_issues, @projects),
|
2010-08-19 20:16:54 +02:00
|
|
|
:log_time => (@project && User.current.allowed_to?(:log_time, @project)),
|
2010-10-08 05:09:51 +02:00
|
|
|
:update => (User.current.allowed_to?(:edit_issues, @projects) || (User.current.allowed_to?(:change_status, @projects) && !@allowed_statuses.blank?)),
|
2010-08-19 20:16:54 +02: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 07:11:28 +02:00
|
|
|
:delete => User.current.allowed_to?(:delete_issues, @projects)
|
2010-08-19 20:16:54 +02:00
|
|
|
}
|
|
|
|
if @project
|
2011-07-23 22:02:31 +02:00
|
|
|
if @issue
|
|
|
|
@assignables = @issue.assignable_users
|
|
|
|
else
|
|
|
|
@assignables = @project.assignable_users
|
|
|
|
end
|
2010-08-19 20:16:54 +02:00
|
|
|
@trackers = @project.trackers
|
2010-10-08 05:09:51 +02:00
|
|
|
else
|
|
|
|
#when multiple projects, we only keep the intersection of each set
|
2012-02-09 21:06:36 +01:00
|
|
|
@assignables = @projects.map(&:assignable_users).reduce(:&)
|
|
|
|
@trackers = @projects.map(&:trackers).reduce(:&)
|
2010-08-19 20:16:54 +02:00
|
|
|
end
|
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]
|
2012-02-09 21:06:36 +01:00
|
|
|
custom_fields = @issues.map(&:available_custom_fields).reduce(:&).select do |f|
|
2012-02-09 19:22:11 +01:00
|
|
|
%w(bool list user version).include?(f.field_format) && !f.multiple?
|
|
|
|
end
|
|
|
|
custom_fields.each do |field|
|
|
|
|
values = field.possible_values_options(@projects)
|
|
|
|
if values.any?
|
|
|
|
@options_by_custom_field[field] = values
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2010-08-19 20:16:54 +02:00
|
|
|
render :layout => false
|
|
|
|
end
|
2011-04-04 13:53:03 +02:00
|
|
|
|
|
|
|
def time_entries
|
|
|
|
@time_entries = TimeEntry.all(
|
|
|
|
:conditions => {:id => params[:ids]}, :include => :project)
|
|
|
|
@projects = @time_entries.collect(&:project).compact.uniq
|
|
|
|
@project = @projects.first if @projects.size == 1
|
|
|
|
@activities = TimeEntryActivity.shared.active
|
2011-11-24 22:31:21 +01:00
|
|
|
@can = {:edit => User.current.allowed_to?(:edit_time_entries, @projects),
|
|
|
|
:delete => User.current.allowed_to?(:edit_time_entries, @projects)
|
2011-04-04 13:53:03 +02:00
|
|
|
}
|
|
|
|
@back = back_url
|
|
|
|
render :layout => false
|
2011-08-30 15:03:57 +02:00
|
|
|
end
|
2010-08-19 20:16:54 +02:00
|
|
|
end
|