Show db entries and password names, if available

This commit is contained in:
Alexander Meindl
2020-01-25 11:59:13 +01:00
parent 442c3fb320
commit 49e847794f
2 changed files with 21 additions and 3 deletions

View File

@@ -151,23 +151,41 @@ class Messenger
false
end
def detail_to_field(detail)
def detail_to_field(detail, prj = nil)
field_format = nil
key = nil
escape = true
value = detail.value.to_s
if detail.property == 'cf'
key = CustomField.find(detail.prop_key)&.name
unless key.nil?
title = key
field_format = CustomField.find(detail.prop_key)&.field_format
value = IssuesController.helpers.format_value(detail.value, detail.custom_field) if detail.value.present?
end
elsif detail.property == 'attachment'
key = 'attachment'
title = I18n.t :label_attachment
value = detail.value.to_s
elsif detail.property == 'attr' &&
detail.prop_key == 'db_relation'
return { short: true } unless Messenger.setting_for_project(prj, :post_db)
title = I18n.t :field_db_relation
if detail.value.present?
entry = DbEntry.visible.find_by(id: detail.value)
value = entry.present? ? entry.name : detail.value.to_s
end
elsif detail.property == 'attr' &&
detail.prop_key == 'password_relation'
return { short: true } unless Messenger.setting_for_project(prj, :post_password)
title = I18n.t :field_password_relation
if detail.value.present?
entry = Password.visible.find_by(id: detail.value)
value = entry.present? ? entry.name : detail.value.to_s
end
else
key = detail.prop_key.to_s.sub('_id', '')
title = if key == 'parent'

View File

@@ -76,7 +76,7 @@ module RedmineMessenger
end
end
fields = current_journal.details.map { |d| Messenger.detail_to_field d }
fields = current_journal.details.map { |d| Messenger.detail_to_field(d, project) }
if saved_change_to_status_id?
fields << { title: I18n.t(:field_status),
value: Messenger.markup_format(status.to_s),