Mercurial > hg > soundsoftware-site
diff app/controllers/context_menus_controller.rb @ 1338:25603efa57b5
Merge from live branch
author | Chris Cannam |
---|---|
date | Thu, 20 Jun 2013 13:14:14 +0100 |
parents | 433d4f72a19b |
children | 622f24f53b42 261b3d9a4903 |
line wrap: on
line diff
--- a/app/controllers/context_menus_controller.rb Wed Jan 23 13:11:25 2013 +0000 +++ b/app/controllers/context_menus_controller.rb Thu Jun 20 13:14:14 2013 +0100 @@ -1,20 +1,32 @@ +# Redmine - project management software +# Copyright (C) 2006-2012 Jean-Philippe Lang +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + class ContextMenusController < ApplicationController helper :watchers helper :issues def issues @issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project) - if (@issues.size == 1) @issue = @issues.first - @allowed_statuses = @issue.new_statuses_allowed_to(User.current) - else - @allowed_statuses = @issues.map do |i| - i.new_statuses_allowed_to(User.current) - end.inject do |memo,s| - memo & s - end end + @issue_ids = @issues.map(&:id).sort + + @allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&) @projects = @issues.collect(&:project).compact.uniq @project = @projects.first if @projects.size == 1 @@ -34,14 +46,28 @@ @trackers = @project.trackers else #when multiple projects, we only keep the intersection of each set - @assignables = @projects.map(&:assignable_users).inject{|memo,a| memo & a} - @trackers = @projects.map(&:trackers).inject{|memo,t| memo & t} + @assignables = @projects.map(&:assignable_users).reduce(:&) + @trackers = @projects.map(&:trackers).reduce(:&) + end + @versions = @projects.map {|p| p.shared_versions.open}.reduce(:&) + + @priorities = IssuePriority.active.reverse + @back = back_url + + @options_by_custom_field = {} + if @can[:edit] + custom_fields = @issues.map(&:available_custom_fields).reduce(:&).select do |f| + %w(bool list user version).include?(f.field_format) && !f.multiple? + end + custom_fields.each do |field| + values = field.possible_values_options(@projects) + if values.any? + @options_by_custom_field[field] = values + end + end end - @priorities = IssuePriority.active.reverse - @statuses = IssueStatus.find(:all, :order => 'position') - @back = back_url - + @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&) render :layout => false end