To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.
root / app / controllers / context_menus_controller.rb @ 1022:f2ec92061fca
History | View | Annotate | Download (2.28 KB)
| 1 |
class ContextMenusController < ApplicationController |
|---|---|
| 2 |
helper :watchers
|
| 3 |
helper :issues
|
| 4 |
|
| 5 |
def issues |
| 6 |
@issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project) |
| 7 |
|
| 8 |
if (@issues.size == 1) |
| 9 |
@issue = @issues.first |
| 10 |
@allowed_statuses = @issue.new_statuses_allowed_to(User.current) |
| 11 |
else
|
| 12 |
@allowed_statuses = @issues.map do |i| |
| 13 |
i.new_statuses_allowed_to(User.current)
|
| 14 |
end.inject do |memo,s| |
| 15 |
memo & s |
| 16 |
end
|
| 17 |
end
|
| 18 |
@projects = @issues.collect(&:project).compact.uniq |
| 19 |
@project = @projects.first if @projects.size == 1 |
| 20 |
|
| 21 |
@can = {:edit => User.current.allowed_to?(:edit_issues, @projects), |
| 22 |
:log_time => (@project && User.current.allowed_to?(:log_time, @project)), |
| 23 |
:update => (User.current.allowed_to?(:edit_issues, @projects) || (User.current.allowed_to?(:change_status, @projects) && !@allowed_statuses.blank?)), |
| 24 |
:move => (@project && User.current.allowed_to?(:move_issues, @project)), |
| 25 |
:copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)), |
| 26 |
:delete => User.current.allowed_to?(:delete_issues, @projects) |
| 27 |
} |
| 28 |
if @project |
| 29 |
if @issue |
| 30 |
@assignables = @issue.assignable_users |
| 31 |
else
|
| 32 |
@assignables = @project.assignable_users |
| 33 |
end
|
| 34 |
@trackers = @project.trackers |
| 35 |
else
|
| 36 |
#when multiple projects, we only keep the intersection of each set
|
| 37 |
@assignables = @projects.map(&:assignable_users).inject{|memo,a| memo & a} |
| 38 |
@trackers = @projects.map(&:trackers).inject{|memo,t| memo & t} |
| 39 |
end
|
| 40 |
|
| 41 |
@priorities = IssuePriority.active.reverse |
| 42 |
@statuses = IssueStatus.find(:all, :order => 'position') |
| 43 |
@back = back_url
|
| 44 |
|
| 45 |
render :layout => false |
| 46 |
end
|
| 47 |
|
| 48 |
def time_entries |
| 49 |
@time_entries = TimeEntry.all( |
| 50 |
:conditions => {:id => params[:ids]}, :include => :project) |
| 51 |
@projects = @time_entries.collect(&:project).compact.uniq |
| 52 |
@project = @projects.first if @projects.size == 1 |
| 53 |
@activities = TimeEntryActivity.shared.active |
| 54 |
@can = {:edit => User.current.allowed_to?(:edit_time_entries, @projects), |
| 55 |
:delete => User.current.allowed_to?(:edit_time_entries, @projects) |
| 56 |
} |
| 57 |
@back = back_url
|
| 58 |
render :layout => false |
| 59 |
end
|
| 60 |
end
|