summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-08 11:16:54 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2012-01-08 11:16:54 +0000
commit121bc44cc504b3086c35d40f984d75d978c59fb0 (patch)
treece23bebc4b702daad08241c105f36bba18bee68d /app
parentf134eeef459e7027b43500cc6a3b7306882c10b7 (diff)
downloadredmine-121bc44cc504b3086c35d40f984d75d978c59fb0.tar.gz
redmine-121bc44cc504b3086c35d40f984d75d978c59fb0.zip
Use the regular issue form to copy a single issue.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8552 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/issues_controller.rb2
-rw-r--r--app/models/issue.rb11
-rw-r--r--app/views/context_menus/issues.html.erb9
-rw-r--r--app/views/issues/_action_menu.html.erb3
-rw-r--r--app/views/issues/_form.html.erb2
-rw-r--r--app/views/issues/new.html.erb3
6 files changed, 21 insertions, 9 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index ad1d0a012..43ed6387e 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -158,7 +158,7 @@ class IssuesController < ApplicationController
format.html {
render_attachment_warning_if_needed(@issue)
flash[:notice] = l(:notice_issue_successful_create, :id => "<a href='#{issue_path(@issue)}'>##{@issue.id}</a>")
- redirect_to(params[:continue] ? { :action => 'new', :project_id => @project, :issue => {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} } :
+ redirect_to(params[:continue] ? { :action => 'new', :project_id => @issue.project, :issue => {:tracker_id => @issue.tracker, :parent_issue_id => @issue.parent_issue_id}.reject {|k,v| v.nil?} } :
{ :action => 'show', :id => @issue })
}
format.api { render :action => 'show', :status => :created, :location => issue_url(@issue) }
diff --git a/app/models/issue.rb b/app/models/issue.rb
index 4e4deb5db..1259361da 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -127,12 +127,14 @@ class Issue < ActiveRecord::Base
(project && tracker) ? (project.all_issue_custom_fields & tracker.custom_fields.all) : []
end
+ # Copies attributes from another issue, arg can be an id or an Issue
def copy_from(arg)
issue = arg.is_a?(Issue) ? arg : Issue.visible.find(arg)
self.attributes = issue.attributes.dup.except("id", "root_id", "parent_id", "lft", "rgt", "created_on", "updated_on")
self.custom_field_values = issue.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}
self.status = issue.status
self.author = User.current
+ @copied_from = issue
self
end
@@ -143,6 +145,11 @@ class Issue < ActiveRecord::Base
copy
end
+ # Returns true if the issue is a copy
+ def copy?
+ @copied_from.present?
+ end
+
# Moves/copies an issue to a new project and tracker
# Returns the moved/copied issue on success, false on failure
def move_to_project(new_project, new_tracker=nil, options={})
@@ -255,7 +262,9 @@ class Issue < ActiveRecord::Base
safe_attributes 'project_id',
:if => lambda {|issue, user|
- if user.allowed_to?(:move_issues, issue.project)
+ if issue.new_record?
+ issue.copy?
+ elsif user.allowed_to?(:move_issues, issue.project)
projects = Issue.allowed_target_projects_on_move(user)
projects.include?(issue.project) && projects.size > 1
end
diff --git a/app/views/context_menus/issues.html.erb b/app/views/context_menus/issues.html.erb
index 628433cb7..ce418af58 100644
--- a/app/views/context_menus/issues.html.erb
+++ b/app/views/context_menus/issues.html.erb
@@ -107,11 +107,12 @@
<% end %>
<% if @issue.present? %>
- <li><%= context_menu_link l(:button_duplicate), {:controller => 'issues', :action => 'new', :project_id => @project, :copy_from => @issue},
- :class => 'icon-duplicate', :disabled => !@can[:copy] %></li>
-<% end %>
+ <li><%= context_menu_link l(:button_copy), {:controller => 'issues', :action => 'new', :project_id => @project, :copy_from => @issue},
+ :class => 'icon-copy', :disabled => !@can[:copy] %></li>
+<% else %>
<li><%= context_menu_link l(:button_copy), {:controller => 'issues', :action => 'bulk_edit', :ids => @issues.collect(&:id), :copy => '1'},
- :class => 'icon-copy', :disabled => !@can[:move] %></li>
+ :class => 'icon-copy', :disabled => !@can[:move] %></li>
+<% end %>
<li><%= context_menu_link l(:button_delete), issues_path(:ids => @issues.collect(&:id), :back_url => @back),
:method => :delete, :confirm => issues_destroy_confirmation_message(@issues), :class => 'icon-del', :disabled => !@can[:delete] %></li>
diff --git a/app/views/issues/_action_menu.html.erb b/app/views/issues/_action_menu.html.erb
index d4a6c6552..c643934d1 100644
--- a/app/views/issues/_action_menu.html.erb
+++ b/app/views/issues/_action_menu.html.erb
@@ -2,7 +2,6 @@
<%= link_to_if_authorized(l(:button_update), {:controller => 'issues', :action => 'edit', :id => @issue }, :onclick => 'showAndScrollTo("update", "notes"); return false;', :class => 'icon icon-edit', :accesskey => accesskey(:edit)) %>
<%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'new', :issue_id => @issue}, :class => 'icon icon-time-add' %>
<%= watcher_tag(@issue, User.current) %>
-<%= link_to_if_authorized l(:button_duplicate), {:controller => 'issues', :action => 'new', :project_id => @project, :copy_from => @issue }, :class => 'icon icon-duplicate' %>
-<%= link_to_if_authorized l(:button_copy), {:controller => 'issues', :action => 'bulk_edit', :id => @issue, :copy => '1'}, :class => 'icon icon-copy' %>
+<%= link_to_if_authorized l(:button_copy), {:controller => 'issues', :action => 'new', :project_id => @project, :copy_from => @issue}, :class => 'icon icon-copy' %>
<%= link_to l(:button_delete), issue_path(@issue), :confirm => issues_destroy_confirmation_message(@issue), :method => :delete, :class => 'icon icon-del' if User.current.allowed_to?(:delete_issues, @project) %>
</div>
diff --git a/app/views/issues/_form.html.erb b/app/views/issues/_form.html.erb
index 4aab69a64..19b5f08eb 100644
--- a/app/views/issues/_form.html.erb
+++ b/app/views/issues/_form.html.erb
@@ -7,7 +7,7 @@
</p>
<% end %>
-<% if !@issue.new_record? && @issue.safe_attribute?('project_id') %>
+<% if @issue.safe_attribute? 'project_id' %>
<p><%= f.select :project_id, project_tree_options_for_select(Issue.allowed_target_projects_on_move, :selected => @issue.project), :required => true %></p>
<%= observe_field :issue_project_id, :url => project_issue_form_path(@project, :id => @issue, :project_change => '1'),
:with => "Form.serialize('issue-form')" %>
diff --git a/app/views/issues/new.html.erb b/app/views/issues/new.html.erb
index 615263b23..e7a6bcaca 100644
--- a/app/views/issues/new.html.erb
+++ b/app/views/issues/new.html.erb
@@ -5,8 +5,11 @@
<% labelled_form_for @issue, :url => project_issues_path(@project),
:html => {:id => 'issue-form', :multipart => true} do |f| %>
<%= error_messages_for 'issue' %>
+ <%= hidden_field_tag 'copy_from', params[:copy_from] if params[:copy_from] %>
<div class="box tabular">
+ <div id="all_attributes">
<%= render :partial => 'issues/form', :locals => {:f => f} %>
+ </div>
<p id="attachments_form"><%= label_tag('attachments[1][file]', l(:label_attachment_plural))%><%= render :partial => 'attachments/form' %></p>