Mercurial > hg > soundsoftware-site
comparison app/controllers/context_menus_controller.rb @ 1115:433d4f72a19b redmine-2.2
Update to Redmine SVN revision 11137 on 2.2-stable branch
author | Chris Cannam |
---|---|
date | Mon, 07 Jan 2013 12:01:42 +0000 |
parents | cbb26bc654de |
children | 622f24f53b42 261b3d9a4903 |
comparison
equal
deleted
inserted
replaced
929:5f33065ddc4b | 1115:433d4f72a19b |
---|---|
1 # Redmine - project management software | |
2 # Copyright (C) 2006-2012 Jean-Philippe Lang | |
3 # | |
4 # This program is free software; you can redistribute it and/or | |
5 # modify it under the terms of the GNU General Public License | |
6 # as published by the Free Software Foundation; either version 2 | |
7 # of the License, or (at your option) any later version. | |
8 # | |
9 # This program is distributed in the hope that it will be useful, | |
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 # GNU General Public License for more details. | |
13 # | |
14 # You should have received a copy of the GNU General Public License | |
15 # along with this program; if not, write to the Free Software | |
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
17 | |
1 class ContextMenusController < ApplicationController | 18 class ContextMenusController < ApplicationController |
2 helper :watchers | 19 helper :watchers |
3 helper :issues | 20 helper :issues |
4 | 21 |
5 def issues | 22 def issues |
6 @issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project) | 23 @issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project) |
7 | |
8 if (@issues.size == 1) | 24 if (@issues.size == 1) |
9 @issue = @issues.first | 25 @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 | 26 end |
27 @issue_ids = @issues.map(&:id).sort | |
28 | |
29 @allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&) | |
18 @projects = @issues.collect(&:project).compact.uniq | 30 @projects = @issues.collect(&:project).compact.uniq |
19 @project = @projects.first if @projects.size == 1 | 31 @project = @projects.first if @projects.size == 1 |
20 | 32 |
21 @can = {:edit => User.current.allowed_to?(:edit_issues, @projects), | 33 @can = {:edit => User.current.allowed_to?(:edit_issues, @projects), |
22 :log_time => (@project && User.current.allowed_to?(:log_time, @project)), | 34 :log_time => (@project && User.current.allowed_to?(:log_time, @project)), |
32 @assignables = @project.assignable_users | 44 @assignables = @project.assignable_users |
33 end | 45 end |
34 @trackers = @project.trackers | 46 @trackers = @project.trackers |
35 else | 47 else |
36 #when multiple projects, we only keep the intersection of each set | 48 #when multiple projects, we only keep the intersection of each set |
37 @assignables = @projects.map(&:assignable_users).inject{|memo,a| memo & a} | 49 @assignables = @projects.map(&:assignable_users).reduce(:&) |
38 @trackers = @projects.map(&:trackers).inject{|memo,t| memo & t} | 50 @trackers = @projects.map(&:trackers).reduce(:&) |
51 end | |
52 @versions = @projects.map {|p| p.shared_versions.open}.reduce(:&) | |
53 | |
54 @priorities = IssuePriority.active.reverse | |
55 @back = back_url | |
56 | |
57 @options_by_custom_field = {} | |
58 if @can[:edit] | |
59 custom_fields = @issues.map(&:available_custom_fields).reduce(:&).select do |f| | |
60 %w(bool list user version).include?(f.field_format) && !f.multiple? | |
61 end | |
62 custom_fields.each do |field| | |
63 values = field.possible_values_options(@projects) | |
64 if values.any? | |
65 @options_by_custom_field[field] = values | |
66 end | |
67 end | |
39 end | 68 end |
40 | 69 |
41 @priorities = IssuePriority.active.reverse | 70 @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&) |
42 @statuses = IssueStatus.find(:all, :order => 'position') | |
43 @back = back_url | |
44 | |
45 render :layout => false | 71 render :layout => false |
46 end | 72 end |
47 | 73 |
48 def time_entries | 74 def time_entries |
49 @time_entries = TimeEntry.all( | 75 @time_entries = TimeEntry.all( |