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 @ 1298:4f746d8966dd
History | View | Annotate | Download (3.51 KB)
| 1 | 1115:433d4f72a19b | Chris | # Redmine - project management software
|
|---|---|---|---|
| 2 | 1295:622f24f53b42 | Chris | # Copyright (C) 2006-2013 Jean-Philippe Lang
|
| 3 | 1115:433d4f72a19b | Chris | #
|
| 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 | 14:1d32c0a0efbf | Chris | class ContextMenusController < ApplicationController |
| 19 | helper :watchers
|
||
| 20 | 441:cbce1fd3b1b7 | Chris | helper :issues
|
| 21 | 909:cbb26bc654de | Chris | |
| 22 | 14:1d32c0a0efbf | Chris | def issues |
| 23 | 119:8661b858af72 | Chris | @issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project) |
| 24 | 1295:622f24f53b42 | Chris | (render_404; return) unless @issues.present? |
| 25 | 14:1d32c0a0efbf | Chris | if (@issues.size == 1) |
| 26 | @issue = @issues.first |
||
| 27 | end
|
||
| 28 | 1115:433d4f72a19b | Chris | @issue_ids = @issues.map(&:id).sort |
| 29 | |||
| 30 | @allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&) |
||
| 31 | 22:40f7cfd4df19 | chris | @projects = @issues.collect(&:project).compact.uniq |
| 32 | @project = @projects.first if @projects.size == 1 |
||
| 33 | 14:1d32c0a0efbf | Chris | |
| 34 | 37:94944d00e43c | chris | @can = {:edit => User.current.allowed_to?(:edit_issues, @projects), |
| 35 | 14:1d32c0a0efbf | Chris | :log_time => (@project && User.current.allowed_to?(:log_time, @project)), |
| 36 | 37:94944d00e43c | chris | :update => (User.current.allowed_to?(:edit_issues, @projects) || (User.current.allowed_to?(:change_status, @projects) && !@allowed_statuses.blank?)), |
| 37 | 14:1d32c0a0efbf | Chris | :move => (@project && User.current.allowed_to?(:move_issues, @project)), |
| 38 | :copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)), |
||
| 39 | 37:94944d00e43c | chris | :delete => User.current.allowed_to?(:delete_issues, @projects) |
| 40 | 14:1d32c0a0efbf | Chris | } |
| 41 | if @project |
||
| 42 | 909:cbb26bc654de | Chris | if @issue |
| 43 | @assignables = @issue.assignable_users |
||
| 44 | else
|
||
| 45 | @assignables = @project.assignable_users |
||
| 46 | end
|
||
| 47 | 14:1d32c0a0efbf | Chris | @trackers = @project.trackers |
| 48 | 37:94944d00e43c | chris | else
|
| 49 | #when multiple projects, we only keep the intersection of each set
|
||
| 50 | 1115:433d4f72a19b | Chris | @assignables = @projects.map(&:assignable_users).reduce(:&) |
| 51 | @trackers = @projects.map(&:trackers).reduce(:&) |
||
| 52 | end
|
||
| 53 | @versions = @projects.map {|p| p.shared_versions.open}.reduce(:&) |
||
| 54 | |||
| 55 | @priorities = IssuePriority.active.reverse |
||
| 56 | @back = back_url
|
||
| 57 | |||
| 58 | @options_by_custom_field = {}
|
||
| 59 | if @can[:edit] |
||
| 60 | custom_fields = @issues.map(&:available_custom_fields).reduce(:&).select do |f| |
||
| 61 | %w(bool list user version).include?(f.field_format) && !f.multiple?
|
||
| 62 | end
|
||
| 63 | custom_fields.each do |field|
|
||
| 64 | values = field.possible_values_options(@projects)
|
||
| 65 | if values.any?
|
||
| 66 | @options_by_custom_field[field] = values
|
||
| 67 | end
|
||
| 68 | end
|
||
| 69 | 14:1d32c0a0efbf | Chris | end
|
| 70 | 909:cbb26bc654de | Chris | |
| 71 | 1115:433d4f72a19b | Chris | @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&) |
| 72 | 14:1d32c0a0efbf | Chris | render :layout => false |
| 73 | end
|
||
| 74 | 441:cbce1fd3b1b7 | Chris | |
| 75 | def time_entries |
||
| 76 | @time_entries = TimeEntry.all( |
||
| 77 | :conditions => {:id => params[:ids]}, :include => :project) |
||
| 78 | 1295:622f24f53b42 | Chris | (render_404; return) unless @time_entries.present? |
| 79 | |||
| 80 | 441:cbce1fd3b1b7 | Chris | @projects = @time_entries.collect(&:project).compact.uniq |
| 81 | @project = @projects.first if @projects.size == 1 |
||
| 82 | @activities = TimeEntryActivity.shared.active |
||
| 83 | 909:cbb26bc654de | Chris | @can = {:edit => User.current.allowed_to?(:edit_time_entries, @projects), |
| 84 | :delete => User.current.allowed_to?(:edit_time_entries, @projects) |
||
| 85 | 441:cbce1fd3b1b7 | Chris | } |
| 86 | @back = back_url
|
||
| 87 | render :layout => false |
||
| 88 | 909:cbb26bc654de | Chris | end
|
| 89 | 14:1d32c0a0efbf | Chris | end |