Skip to content

Commit

Permalink
Redmine 5 compatibility: do not change non-private notes with attachm…
Browse files Browse the repository at this point in the history
…ents behaviour
  • Loading branch information
nanego committed Jun 20, 2024
1 parent a8ca210 commit 9f1e093
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/redmine_comments/application_helper_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def parse_inline_attachments(text, project, obj, attr, only_path, options)
if !desc.blank? && alttext.blank?
alt = " title=\"#{desc}\" alt=\"#{desc}\""
end
"src=\"#{image_url}\"#{alt} loading=\"lazy\""
"src=\"#{image_url}\"#{alt}#{" loading=\"lazy\"" if Redmine::VERSION::MAJOR >= 5}"
else
m
end
Expand Down
14 changes: 9 additions & 5 deletions lib/redmine_comments/journal_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ class Journal < ActiveRecord::Base

acts_as_attachable

# Ensure method :attachments is removed
def attachments; end

remove_method :attachments
def attachments
if private_notes?
super
else
standard_attachments_method
end
end

has_many :journal_roles, dependent: :destroy
has_many :roles, through: :journal_roles
Expand All @@ -27,7 +30,8 @@ def journal_attachments
end

def standard_attachments_method
journalized.respond_to?(:attachments) ? journalized.attachments : []
ids = details.select {|d| d.property == 'attachment' && d.value.present?}.map(&:prop_key)
Attachment.where(id: ids).sort_by {|a| ids.index(a.id.to_s)}
end

# Returns a SQL condition to filter out journals with notes that are not visible to user
Expand Down

0 comments on commit 9f1e093

Please sign in to comment.