use AdditionalsApplicationRecord for redmine 5.x and 6 support as temp solution
This commit is contained in:
parent
98b1f5e580
commit
35b9daade1
7
app/models/additionals_application_record.rb
Normal file
7
app/models/additionals_application_record.rb
Normal file
@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# NOTE: this file is used for compatibility with Redmine 5.x and Redmine 6
|
||||
|
||||
class AdditionalsApplicationRecord < (defined?(ApplicationRecord) == 'constant' ? ApplicationRecord : ActiveRecord::Base)
|
||||
self.abstract_class = true
|
||||
end
|
@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class Dashboard < Rails.version < '7.1' ? ActiveRecord::Base : ApplicationRecord
|
||||
class Dashboard < AdditionalsApplicationRecord
|
||||
include Redmine::I18n
|
||||
include Redmine::SafeAttributes
|
||||
include Additionals::EntityMethods
|
||||
|
@ -1,6 +1,6 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class DashboardRole < Rails.version < '7.1' ? ActiveRecord::Base : ApplicationRecord
|
||||
class DashboardRole < AdditionalsApplicationRecord
|
||||
include Redmine::SafeAttributes
|
||||
|
||||
belongs_to :dashboard
|
||||
|
@ -2,6 +2,25 @@
|
||||
|
||||
module Additionals
|
||||
module Helpers
|
||||
def entry_page_title(name:, obj: nil, obj_link: nil, query: nil)
|
||||
title = []
|
||||
case obj
|
||||
when Issue
|
||||
title << link_to(h("#{obj.subject} ##{obj.id}"),
|
||||
issue_path(obj),
|
||||
class: obj.css_classes)
|
||||
when User
|
||||
title << user_with_avatar(obj, no_link: true, size: 50)
|
||||
else
|
||||
title << obj_link if obj_link
|
||||
end
|
||||
|
||||
title << name if name
|
||||
title << h(query.name) if query && !query.new_record?
|
||||
|
||||
safe_join title, Additionals::LIST_SEPARATOR
|
||||
end
|
||||
|
||||
def label_with_count(label, info, only_positive: false)
|
||||
text = label.is_a?(Symbol) ? l(label) : label
|
||||
if info.blank? || only_positive && !info.positive?
|
||||
|
Loading…
Reference in New Issue
Block a user