summaryrefslogtreecommitdiffstats
path: root/app/controllers/issues_controller.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/issues_controller.rb')
-rw-r--r--app/controllers/issues_controller.rb37
1 files changed, 33 insertions, 4 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index 9976a93cc..df130f9d5 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -171,7 +171,7 @@ class IssuesController < ApplicationController
end
def edit
- update_issue_from_params
+ return unless update_issue_from_params
respond_to do |format|
format.html { }
@@ -180,9 +180,23 @@ class IssuesController < ApplicationController
end
def update
- update_issue_from_params
+ return unless update_issue_from_params
+ saved = false
+ begin
+ saved = @issue.save_issue_with_child_records(params, @time_entry)
+ rescue ActiveRecord::StaleObjectError
+ @conflict = true
+ if params[:last_journal_id]
+ if params[:last_journal_id].present?
+ last_journal_id = params[:last_journal_id].to_i
+ @conflict_journals = @issue.journals.all(:conditions => ["#{Journal.table_name}.id > ?", last_journal_id])
+ else
+ @conflict_journals = @issue.journals.all
+ end
+ end
+ end
- if @issue.save_issue_with_child_records(params, @time_entry)
+ if saved
render_attachment_warning_if_needed(@issue)
flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record?
@@ -345,7 +359,22 @@ private
@notes = params[:notes] || (params[:issue].present? ? params[:issue][:notes] : nil)
@issue.init_journal(User.current, @notes)
- @issue.safe_attributes = params[:issue]
+
+ issue_attributes = params[:issue]
+ if issue_attributes && params[:conflict_resolution]
+ case params[:conflict_resolution]
+ when 'overwrite'
+ issue_attributes = issue_attributes.dup
+ issue_attributes.delete(:lock_version)
+ when 'add_notes'
+ issue_attributes = {}
+ when 'cancel'
+ redirect_to issue_path(@issue)
+ return false
+ end
+ end
+ @issue.safe_attributes = issue_attributes
+ true
end
# TODO: Refactor, lots of extra code in here