Project

General

Profile

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

Go MAEDA, 2022-09-19 11:45

View differences:

app/helpers/journals_helper.rb
# Returns the attachments of a journal that are displayed as thumbnails
def journal_thumbnail_attachments(journal)
ids = journal.details.select {|d| d.property == 'attachment' && d.value.present?}.map(&:prop_key)
ids.any? ? Attachment.where(:id => ids).select(&:thumbnailable?).sort_by{|a| ids.index(a.id.to_s)} : []
journal.attachments.select(&:thumbnailable?)
end
# Returns the action links for an issue journal
app/models/journal.rb
def attachments
ids = details.select {|d| d.property == 'attachment' && d.value.present?}.map(&:prop_key)
Attachment.where(id: ids).to_a
Attachment.where(id: ids).sort_by {|a| ids.index(a.id.to_s)}
end
# Returns a string of css classes
(3-3/3)