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 @ 1355:3d01be97cb5a
History | View | Annotate | Download (3.4 KB)
| 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 |
|
| 18 |
class ContextMenusController < ApplicationController |
| 19 |
helper :watchers
|
| 20 |
helper :issues
|
| 21 |
|
| 22 |
def issues |
| 23 |
@issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project) |
| 24 |
if (@issues.size == 1) |
| 25 |
@issue = @issues.first |
| 26 |
end
|
| 27 |
@issue_ids = @issues.map(&:id).sort |
| 28 |
|
| 29 |
@allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&) |
| 30 |
@projects = @issues.collect(&:project).compact.uniq |
| 31 |
@project = @projects.first if @projects.size == 1 |
| 32 |
|
| 33 |
@can = {:edit => User.current.allowed_to?(:edit_issues, @projects), |
| 34 |
:log_time => (@project && User.current.allowed_to?(:log_time, @project)), |
| 35 |
:update => (User.current.allowed_to?(:edit_issues, @projects) || (User.current.allowed_to?(:change_status, @projects) && !@allowed_statuses.blank?)), |
| 36 |
:move => (@project && User.current.allowed_to?(:move_issues, @project)), |
| 37 |
:copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)), |
| 38 |
:delete => User.current.allowed_to?(:delete_issues, @projects) |
| 39 |
} |
| 40 |
if @project |
| 41 |
if @issue |
| 42 |
@assignables = @issue.assignable_users |
| 43 |
else
|
| 44 |
@assignables = @project.assignable_users |
| 45 |
end
|
| 46 |
@trackers = @project.trackers |
| 47 |
else
|
| 48 |
#when multiple projects, we only keep the intersection of each set
|
| 49 |
@assignables = @projects.map(&:assignable_users).reduce(:&) |
| 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
|
| 68 |
end
|
| 69 |
|
| 70 |
@safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&) |
| 71 |
render :layout => false |
| 72 |
end
|
| 73 |
|
| 74 |
def time_entries |
| 75 |
@time_entries = TimeEntry.all( |
| 76 |
:conditions => {:id => params[:ids]}, :include => :project) |
| 77 |
@projects = @time_entries.collect(&:project).compact.uniq |
| 78 |
@project = @projects.first if @projects.size == 1 |
| 79 |
@activities = TimeEntryActivity.shared.active |
| 80 |
@can = {:edit => User.current.allowed_to?(:edit_time_entries, @projects), |
| 81 |
:delete => User.current.allowed_to?(:edit_time_entries, @projects) |
| 82 |
} |
| 83 |
@back = back_url
|
| 84 |
render :layout => false |
| 85 |
end
|
| 86 |
end
|