diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-02-29 22:54:07 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-02-29 22:54:07 +0000 |
commit | c01c64e9783dc361d98ca8dc37d2b3a661ae1945 (patch) | |
tree | 42c3c5a2b6e59e5a1879601f37d69d4c651911e3 /app | |
parent | 87742f23edb3bbcbaf12540d2ff510ad8edac09e (diff) | |
download | redmine-c01c64e9783dc361d98ca8dc37d2b3a661ae1945.tar.gz redmine-c01c64e9783dc361d98ca8dc37d2b3a661ae1945.zip |
Let the user choose when deleting issues with reported hours (closes #734, #71):
* to delete the hours
* to assign the hours to the project
* to reassign the hours to another issue
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1182 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/issues_controller.rb | 20 | ||||
-rw-r--r-- | app/models/issue.rb | 2 | ||||
-rw-r--r-- | app/views/issue_categories/destroy.rhtml | 4 | ||||
-rw-r--r-- | app/views/issues/destroy.rhtml | 15 |
4 files changed, 38 insertions, 3 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index e03afb252..53627db92 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -263,6 +263,26 @@ class IssuesController < ApplicationController end def destroy + @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f + if @hours > 0 + case params[:todo] + when 'destroy' + # nothing to do + when 'nullify' + TimeEntry.update_all('issue_id = NULL', ['issue_id IN (?)', @issues]) + when 'reassign' + reassign_to = @project.issues.find_by_id(params[:reassign_to_id]) + if reassign_to.nil? + flash.now[:error] = l(:error_issue_not_found_in_project) + return + else + TimeEntry.update_all("issue_id = #{reassign_to.id}", ['issue_id IN (?)', @issues]) + end + else + # display the destroy form + return + end + end @issues.each(&:destroy) redirect_to :action => 'index', :project_id => @project end diff --git a/app/models/issue.rb b/app/models/issue.rb index 9d7f6eaaf..1d25a4604 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -27,7 +27,7 @@ class Issue < ActiveRecord::Base has_many :journals, :as => :journalized, :dependent => :destroy has_many :attachments, :as => :container, :dependent => :destroy - has_many :time_entries, :dependent => :nullify + has_many :time_entries, :dependent => :delete_all has_many :custom_values, :dependent => :delete_all, :as => :customized has_many :custom_fields, :through => :custom_values has_and_belongs_to_many :changesets, :order => "revision ASC" diff --git a/app/views/issue_categories/destroy.rhtml b/app/views/issue_categories/destroy.rhtml index a563736e2..2b61810e7 100644 --- a/app/views/issue_categories/destroy.rhtml +++ b/app/views/issue_categories/destroy.rhtml @@ -3,9 +3,9 @@ <% form_tag({}) do %> <div class="box"> <p><strong><%= l(:text_issue_category_destroy_question, @issue_count) %></strong></p> -<p><%= radio_button_tag 'todo', 'nullify', true %> <%= l(:text_issue_category_destroy_assignments) %><br /> +<p><label><%= radio_button_tag 'todo', 'nullify', true %> <%= l(:text_issue_category_destroy_assignments) %></label><br /> <% if @categories.size > 0 %> -<%= radio_button_tag 'todo', 'reassign', false %> <%= l(:text_issue_category_reassign_to) %>: +<label><%= radio_button_tag 'todo', 'reassign', false %> <%= l(:text_issue_category_reassign_to) %></label>: <%= select_tag 'reassign_to_id', options_from_collection_for_select(@categories, 'id', 'name') %></p> <% end %> </div> diff --git a/app/views/issues/destroy.rhtml b/app/views/issues/destroy.rhtml new file mode 100644 index 000000000..2f3c036b6 --- /dev/null +++ b/app/views/issues/destroy.rhtml @@ -0,0 +1,15 @@ +<h2><%= l(:confirmation) %></h2> + +<% form_tag do %> +<%= @issues.collect {|i| hidden_field_tag 'ids[]', i.id } %> +<div class="box"> +<p><strong><%= l(:text_destroy_time_entries_question, @hours) %></strong></p> +<p> +<label><%= radio_button_tag 'todo', 'destroy', true %> <%= l(:text_destroy_time_entries) %></label><br /> +<label><%= radio_button_tag 'todo', 'nullify', false %> <%= l(:text_assign_time_entries_to_project) %></label><br /> +<label><%= radio_button_tag 'todo', 'reassign', false, :onchange => 'if (this.checked) { $("reassign_to_id").focus(); }' %> <%= l(:text_reassign_time_entries) %></label> +<%= text_field_tag 'reassign_to_id', params[:reassign_to_id], :size => 6, :onfocus => '$("todo_reassign").checked=true;' %> +</p> +</div> +<%= submit_tag l(:button_apply) %> +<% end %> |