@@ -1,89 +1,92 | |||
|
1 | 1 | # Redmine - project management software |
|
2 | 2 | # Copyright (C) 2006-2016 Jean-Philippe Lang |
|
3 | 3 | # |
|
4 | 4 | # This program is free software; you can redistribute it and/or |
|
5 | 5 | # modify it under the terms of the GNU General Public License |
|
6 | 6 | # as published by the Free Software Foundation; either version 2 |
|
7 | 7 | # of the License, or (at your option) any later version. |
|
8 | 8 | # |
|
9 | 9 | # This program is distributed in the hope that it will be useful, |
|
10 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 | 12 | # GNU General Public License for more details. |
|
13 | 13 | # |
|
14 | 14 | # You should have received a copy of the GNU General Public License |
|
15 | 15 | # along with this program; if not, write to the Free Software |
|
16 | 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
|
17 | 17 | |
|
18 | 18 | class ContextMenusController < ApplicationController |
|
19 | 19 | helper :watchers |
|
20 | 20 | helper :issues |
|
21 | 21 | |
|
22 | 22 | before_action :find_issues, :only => :issues |
|
23 | 23 | |
|
24 | 24 | def issues |
|
25 | 25 | if (@issues.size == 1) |
|
26 | 26 | @issue = @issues.first |
|
27 | 27 | end |
|
28 | 28 | @issue_ids = @issues.map(&:id).sort |
|
29 | 29 | |
|
30 | 30 | @allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&) |
|
31 | 31 | |
|
32 | 32 | @can = {:edit => @issues.all?(&:attributes_editable?), |
|
33 | 33 | :log_time => (@project && User.current.allowed_to?(:log_time, @project)), |
|
34 | 34 | :copy => User.current.allowed_to?(:copy_issues, @projects) && Issue.allowed_target_projects.any?, |
|
35 | 35 | :add_watchers => User.current.allowed_to?(:add_issue_watchers, @projects), |
|
36 | 36 | :delete => @issues.all?(&:deletable?) |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | 39 | @assignables = @issues.map(&:assignable_users).reduce(:&) |
|
40 | 40 | @trackers = @projects.map {|p| Issue.allowed_target_trackers(p) }.reduce(:&) |
|
41 | 41 | @versions = @projects.map {|p| p.shared_versions.open}.reduce(:&) |
|
42 | 42 | |
|
43 | 43 | @priorities = IssuePriority.active.reverse |
|
44 | 44 | @back = back_url |
|
45 | 45 | |
|
46 | 46 | @options_by_custom_field = {} |
|
47 | 47 | if @can[:edit] |
|
48 | 48 | custom_fields = @issues.map(&:editable_custom_fields).reduce(:&).reject(&:multiple?).select {|field| field.format.bulk_edit_supported} |
|
49 | 49 | custom_fields.each do |field| |
|
50 | 50 | values = field.possible_values_options(@projects) |
|
51 | 51 | if values.present? |
|
52 | 52 | @options_by_custom_field[field] = values |
|
53 | 53 | end |
|
54 | 54 | end |
|
55 | 55 | end |
|
56 | 56 | |
|
57 | 57 | @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&) |
|
58 | 58 | render :layout => false |
|
59 | 59 | end |
|
60 | 60 | |
|
61 | 61 | def time_entries |
|
62 |
@time_entries = TimeEntry.where(:id => params[:ids]). |
|
|
62 | @time_entries = TimeEntry.where(:id => params[:ids]). | |
|
63 | preload(:project => :time_entry_activities). | |
|
64 | preload(:user).to_a | |
|
65 | ||
|
63 | 66 | (render_404; return) unless @time_entries.present? |
|
64 | 67 | if (@time_entries.size == 1) |
|
65 | 68 | @time_entry = @time_entries.first |
|
66 | 69 | end |
|
67 | 70 | |
|
68 | 71 | @projects = @time_entries.collect(&:project).compact.uniq |
|
69 | 72 | @project = @projects.first if @projects.size == 1 |
|
70 | @activities = TimeEntryActivity.shared.active | |
|
73 | @activities = @projects.map(&:activities).reduce(:&) | |
|
71 | 74 | |
|
72 | 75 | edit_allowed = @time_entries.all? {|t| t.editable_by?(User.current)} |
|
73 | 76 | @can = {:edit => edit_allowed, :delete => edit_allowed} |
|
74 | 77 | @back = back_url |
|
75 | 78 | |
|
76 | 79 | @options_by_custom_field = {} |
|
77 | 80 | if @can[:edit] |
|
78 | 81 | custom_fields = @time_entries.map(&:editable_custom_fields).reduce(:&).reject(&:multiple?).select {|field| field.format.bulk_edit_supported} |
|
79 | 82 | custom_fields.each do |field| |
|
80 | 83 | values = field.possible_values_options(@projects) |
|
81 | 84 | if values.present? |
|
82 | 85 | @options_by_custom_field[field] = values |
|
83 | 86 | end |
|
84 | 87 | end |
|
85 | 88 | end |
|
86 | 89 | |
|
87 | 90 | render :layout => false |
|
88 | 91 | end |
|
89 | 92 | end |
General Comments 0
You need to be logged in to leave comments.
Login now