Project

General

Profile

Patch #37687 » 0002-Unify-duplicate-codes.patch

Go MAEDA, 2022-09-19 11:45

View differences:

app/helpers/journals_helper.rb
21 21

  
22 22
  # Returns the attachments of a journal that are displayed as thumbnails
23 23
  def journal_thumbnail_attachments(journal)
24
    ids = journal.details.select {|d| d.property == 'attachment' && d.value.present?}.map(&:prop_key)
25
    ids.any? ? Attachment.where(:id => ids).select(&:thumbnailable?).sort_by{|a| ids.index(a.id.to_s)} : []
24
    journal.attachments.select(&:thumbnailable?)
26 25
  end
27 26

  
28 27
  # Returns the action links for an issue journal
app/models/journal.rb
143 143

  
144 144
  def attachments
145 145
    ids = details.select {|d| d.property == 'attachment' && d.value.present?}.map(&:prop_key)
146
    Attachment.where(id: ids).to_a
146
    Attachment.where(id: ids).sort_by {|a| ids.index(a.id.to_s)}
147 147
  end
148 148

  
149 149
  # Returns a string of css classes
(3-3/3)