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 @ 441:cbce1fd3b1b7
History | View | Annotate | Download (2.38 KB)
| 1 | 14:1d32c0a0efbf | Chris | class ContextMenusController < ApplicationController |
|---|---|---|---|
| 2 | helper :watchers
|
||
| 3 | 441:cbce1fd3b1b7 | Chris | helper :issues
|
| 4 | 14:1d32c0a0efbf | Chris | |
| 5 | def issues |
||
| 6 | 119:8661b858af72 | Chris | @issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project) |
| 7 | |||
| 8 | 14:1d32c0a0efbf | Chris | if (@issues.size == 1) |
| 9 | @issue = @issues.first |
||
| 10 | @allowed_statuses = @issue.new_statuses_allowed_to(User.current) |
||
| 11 | 22:40f7cfd4df19 | chris | 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 | 14:1d32c0a0efbf | Chris | end
|
| 18 | 22:40f7cfd4df19 | chris | @projects = @issues.collect(&:project).compact.uniq |
| 19 | @project = @projects.first if @projects.size == 1 |
||
| 20 | 14:1d32c0a0efbf | Chris | |
| 21 | 37:94944d00e43c | chris | @can = {:edit => User.current.allowed_to?(:edit_issues, @projects), |
| 22 | 14:1d32c0a0efbf | Chris | :log_time => (@project && User.current.allowed_to?(:log_time, @project)), |
| 23 | 37:94944d00e43c | chris | :update => (User.current.allowed_to?(:edit_issues, @projects) || (User.current.allowed_to?(:change_status, @projects) && !@allowed_statuses.blank?)), |
| 24 | 14:1d32c0a0efbf | Chris | :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 | 37:94944d00e43c | chris | :delete => User.current.allowed_to?(:delete_issues, @projects) |
| 27 | 14:1d32c0a0efbf | Chris | } |
| 28 | if @project |
||
| 29 | @assignables = @project.assignable_users |
||
| 30 | @assignables << @issue.assigned_to if @issue && @issue.assigned_to && !@assignables.include?(@issue.assigned_to) |
||
| 31 | @trackers = @project.trackers |
||
| 32 | 37:94944d00e43c | chris | else
|
| 33 | #when multiple projects, we only keep the intersection of each set
|
||
| 34 | @assignables = @projects.map(&:assignable_users).inject{|memo,a| memo & a} |
||
| 35 | @trackers = @projects.map(&:trackers).inject{|memo,t| memo & t} |
||
| 36 | 14:1d32c0a0efbf | Chris | end
|
| 37 | |||
| 38 | @priorities = IssuePriority.all.reverse |
||
| 39 | @statuses = IssueStatus.find(:all, :order => 'position') |
||
| 40 | @back = back_url
|
||
| 41 | |||
| 42 | render :layout => false |
||
| 43 | end
|
||
| 44 | 441:cbce1fd3b1b7 | Chris | |
| 45 | def time_entries |
||
| 46 | @time_entries = TimeEntry.all( |
||
| 47 | :conditions => {:id => params[:ids]}, :include => :project) |
||
| 48 | @projects = @time_entries.collect(&:project).compact.uniq |
||
| 49 | @project = @projects.first if @projects.size == 1 |
||
| 50 | @activities = TimeEntryActivity.shared.active |
||
| 51 | @can = {:edit => User.current.allowed_to?(:log_time, @projects), |
||
| 52 | :update => User.current.allowed_to?(:log_time, @projects), |
||
| 53 | :delete => User.current.allowed_to?(:log_time, @projects) |
||
| 54 | } |
||
| 55 | @back = back_url
|
||
| 56 | render :layout => false |
||
| 57 | end
|
||
| 58 | 14:1d32c0a0efbf | Chris | end |