@@ -1,58 +1,61 | |||
|
1 | 1 | class ContextMenusController < ApplicationController |
|
2 | 2 | helper :watchers |
|
3 | 3 | helper :issues |
|
4 | 4 | |
|
5 | 5 | def issues |
|
6 | 6 | @issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project) |
|
7 | 7 | |
|
8 | 8 | if (@issues.size == 1) |
|
9 | 9 | @issue = @issues.first |
|
10 | 10 | @allowed_statuses = @issue.new_statuses_allowed_to(User.current) |
|
11 | 11 | else |
|
12 | 12 | @allowed_statuses = @issues.map do |i| |
|
13 | 13 | i.new_statuses_allowed_to(User.current) |
|
14 | 14 | end.inject do |memo,s| |
|
15 | 15 | memo & s |
|
16 | 16 | end |
|
17 | 17 | end |
|
18 | 18 | @projects = @issues.collect(&:project).compact.uniq |
|
19 | 19 | @project = @projects.first if @projects.size == 1 |
|
20 | 20 | |
|
21 | 21 | @can = {:edit => User.current.allowed_to?(:edit_issues, @projects), |
|
22 | 22 | :log_time => (@project && User.current.allowed_to?(:log_time, @project)), |
|
23 | 23 | :update => (User.current.allowed_to?(:edit_issues, @projects) || (User.current.allowed_to?(:change_status, @projects) && !@allowed_statuses.blank?)), |
|
24 | 24 | :move => (@project && User.current.allowed_to?(:move_issues, @project)), |
|
25 | 25 | :copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)), |
|
26 | 26 | :delete => User.current.allowed_to?(:delete_issues, @projects) |
|
27 | 27 | } |
|
28 | 28 | if @project |
|
29 | @assignables = @project.assignable_users | |
|
30 | @assignables << @issue.assigned_to if @issue && @issue.assigned_to && !@assignables.include?(@issue.assigned_to) | |
|
29 | if @issue | |
|
30 | @assignables = @issue.assignable_users | |
|
31 | else | |
|
32 | @assignables = @project.assignable_users | |
|
33 | end | |
|
31 | 34 | @trackers = @project.trackers |
|
32 | 35 | else |
|
33 | 36 | #when multiple projects, we only keep the intersection of each set |
|
34 | 37 | @assignables = @projects.map(&:assignable_users).inject{|memo,a| memo & a} |
|
35 | 38 | @trackers = @projects.map(&:trackers).inject{|memo,t| memo & t} |
|
36 | 39 | end |
|
37 | 40 | |
|
38 | 41 | @priorities = IssuePriority.active.reverse |
|
39 | 42 | @statuses = IssueStatus.find(:all, :order => 'position') |
|
40 | 43 | @back = back_url |
|
41 | 44 | |
|
42 | 45 | render :layout => false |
|
43 | 46 | end |
|
44 | 47 | |
|
45 | 48 | def time_entries |
|
46 | 49 | @time_entries = TimeEntry.all( |
|
47 | 50 | :conditions => {:id => params[:ids]}, :include => :project) |
|
48 | 51 | @projects = @time_entries.collect(&:project).compact.uniq |
|
49 | 52 | @project = @projects.first if @projects.size == 1 |
|
50 | 53 | @activities = TimeEntryActivity.shared.active |
|
51 | 54 | @can = {:edit => User.current.allowed_to?(:log_time, @projects), |
|
52 | 55 | :update => User.current.allowed_to?(:log_time, @projects), |
|
53 | 56 | :delete => User.current.allowed_to?(:log_time, @projects) |
|
54 | 57 | } |
|
55 | 58 | @back = back_url |
|
56 | 59 | render :layout => false |
|
57 | 60 | end |
|
58 | 61 | end |
General Comments 0
You need to be logged in to leave comments.
Login now