Defect #44258 » journal_delete_preserve_note_index.patch
| app/controllers/journals_controller.rb | ||
|---|---|---|
|
journal_attributes[:updated_by] = User.current
|
||
|
@journal.safe_attributes = journal_attributes
|
||
|
@journal.save
|
||
|
@journal.destroy if @journal.details.empty? && @journal.notes.blank?
|
||
|
call_hook(:controller_journals_edit_post, {:journal => @journal, :params => params})
|
||
|
respond_to do |format|
|
||
|
format.html {redirect_to issue_path(@journal.journalized)}
|
||
| app/models/journal.rb | ||
|---|---|---|
|
def save(*args)
|
||
|
journalize_changes
|
||
|
# Do not save an empty journal
|
||
|
notes_and_details_empty? ? false : super()
|
||
|
(new_record? && notes_and_details_empty?) ? false : super()
|
||
|
end
|
||
|
def notes_and_details_empty?
|
||
| app/views/journals/update.js.erb | ||
|---|---|---|
|
<% if @journal.frozen? %>
|
||
|
<% if @journal.frozen? || @journal.notes_and_details_empty? %>
|
||
|
$("#change-<%= @journal.id %>").remove();
|
||
|
<% else %>
|
||
|
$("#change-<%= @journal.id %>").attr('class', '<%= @journal.css_classes %>');
|
||