annotate .svn/pristine/8b/8bccd0624e4f8225c7389853d52b177216bc29f0.svn-base @ 1486:234d18ea18e9 redmine-2.4-integration

Semi-automatic merge of changes from upstream view files into plugin view files
author Chris Cannam
date Wed, 15 Jan 2014 13:46:51 +0000
parents 261b3d9a4903
children
rev   line source
Chris@1464 1 # Redmine - project management software
Chris@1464 2 # Copyright (C) 2006-2013 Jean-Philippe Lang
Chris@1464 3 #
Chris@1464 4 # This program is free software; you can redistribute it and/or
Chris@1464 5 # modify it under the terms of the GNU General Public License
Chris@1464 6 # as published by the Free Software Foundation; either version 2
Chris@1464 7 # of the License, or (at your option) any later version.
Chris@1464 8 #
Chris@1464 9 # This program is distributed in the hope that it will be useful,
Chris@1464 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@1464 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@1464 12 # GNU General Public License for more details.
Chris@1464 13 #
Chris@1464 14 # You should have received a copy of the GNU General Public License
Chris@1464 15 # along with this program; if not, write to the Free Software
Chris@1464 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Chris@1464 17
Chris@1464 18 class ContextMenusController < ApplicationController
Chris@1464 19 helper :watchers
Chris@1464 20 helper :issues
Chris@1464 21
Chris@1464 22 def issues
Chris@1464 23 @issues = Issue.visible.all(:conditions => {:id => params[:ids]}, :include => :project)
Chris@1464 24 (render_404; return) unless @issues.present?
Chris@1464 25 if (@issues.size == 1)
Chris@1464 26 @issue = @issues.first
Chris@1464 27 end
Chris@1464 28 @issue_ids = @issues.map(&:id).sort
Chris@1464 29
Chris@1464 30 @allowed_statuses = @issues.map(&:new_statuses_allowed_to).reduce(:&)
Chris@1464 31 @projects = @issues.collect(&:project).compact.uniq
Chris@1464 32 @project = @projects.first if @projects.size == 1
Chris@1464 33
Chris@1464 34 @can = {:edit => User.current.allowed_to?(:edit_issues, @projects),
Chris@1464 35 :log_time => (@project && User.current.allowed_to?(:log_time, @project)),
Chris@1464 36 :update => (User.current.allowed_to?(:edit_issues, @projects) || (User.current.allowed_to?(:change_status, @projects) && !@allowed_statuses.blank?)),
Chris@1464 37 :move => (@project && User.current.allowed_to?(:move_issues, @project)),
Chris@1464 38 :copy => (@issue && @project.trackers.include?(@issue.tracker) && User.current.allowed_to?(:add_issues, @project)),
Chris@1464 39 :delete => User.current.allowed_to?(:delete_issues, @projects)
Chris@1464 40 }
Chris@1464 41 if @project
Chris@1464 42 if @issue
Chris@1464 43 @assignables = @issue.assignable_users
Chris@1464 44 else
Chris@1464 45 @assignables = @project.assignable_users
Chris@1464 46 end
Chris@1464 47 @trackers = @project.trackers
Chris@1464 48 else
Chris@1464 49 #when multiple projects, we only keep the intersection of each set
Chris@1464 50 @assignables = @projects.map(&:assignable_users).reduce(:&)
Chris@1464 51 @trackers = @projects.map(&:trackers).reduce(:&)
Chris@1464 52 end
Chris@1464 53 @versions = @projects.map {|p| p.shared_versions.open}.reduce(:&)
Chris@1464 54
Chris@1464 55 @priorities = IssuePriority.active.reverse
Chris@1464 56 @back = back_url
Chris@1464 57
Chris@1464 58 @options_by_custom_field = {}
Chris@1464 59 if @can[:edit]
Chris@1464 60 custom_fields = @issues.map(&:available_custom_fields).reduce(:&).select do |f|
Chris@1464 61 %w(bool list user version).include?(f.field_format) && !f.multiple?
Chris@1464 62 end
Chris@1464 63 custom_fields.each do |field|
Chris@1464 64 values = field.possible_values_options(@projects)
Chris@1464 65 if values.any?
Chris@1464 66 @options_by_custom_field[field] = values
Chris@1464 67 end
Chris@1464 68 end
Chris@1464 69 end
Chris@1464 70
Chris@1464 71 @safe_attributes = @issues.map(&:safe_attribute_names).reduce(:&)
Chris@1464 72 render :layout => false
Chris@1464 73 end
Chris@1464 74
Chris@1464 75 def time_entries
Chris@1464 76 @time_entries = TimeEntry.all(
Chris@1464 77 :conditions => {:id => params[:ids]}, :include => :project)
Chris@1464 78 (render_404; return) unless @time_entries.present?
Chris@1464 79
Chris@1464 80 @projects = @time_entries.collect(&:project).compact.uniq
Chris@1464 81 @project = @projects.first if @projects.size == 1
Chris@1464 82 @activities = TimeEntryActivity.shared.active
Chris@1464 83 @can = {:edit => User.current.allowed_to?(:edit_time_entries, @projects),
Chris@1464 84 :delete => User.current.allowed_to?(:edit_time_entries, @projects)
Chris@1464 85 }
Chris@1464 86 @back = back_url
Chris@1464 87 render :layout => false
Chris@1464 88 end
Chris@1464 89 end