Project

General

Profile

Defect #44258 » journal_delete_preserve_note_index.patch

Yasu Saku, 2026-07-11 11:11

View differences:

app/controllers/journals_controller.rb
89 89
    journal_attributes[:updated_by] = User.current
90 90
    @journal.safe_attributes = journal_attributes
91 91
    @journal.save
92
    @journal.destroy if @journal.details.empty? && @journal.notes.blank?
93 92
    call_hook(:controller_journals_edit_post, {:journal => @journal, :params => params})
94 93
    respond_to do |format|
95 94
      format.html {redirect_to issue_path(@journal.journalized)}
app/models/journal.rb
102 102
  def save(*args)
103 103
    journalize_changes
104 104
    # Do not save an empty journal
105
    notes_and_details_empty? ? false : super()
105
    (new_record? && notes_and_details_empty?) ? false : super()
106 106
  end
107 107

  
108 108
  def notes_and_details_empty?
app/views/journals/update.js.erb
1
<% if @journal.frozen? %>
1
<% if @journal.frozen? || @journal.notes_and_details_empty? %>
2 2
  $("#change-<%= @journal.id %>").remove();
3 3
<% else %>
4 4
  $("#change-<%= @journal.id %>").attr('class', '<%= @journal.css_classes %>');
(1-1/2)