Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

obey rubocop

as-ope9fa439e071b
diff --git a/lib/open_project/text_formatting/matchers/attribute_macros.rb b/lib/open_project/text_formatting/matchers/attribute_macros.rb
index 9d21b035a0c..09511d88f34 100644
--- a/lib/open_project/text_formatting/matchers/attribute_macros.rb
+++ b/lib/open_project/text_formatting/matchers/attribute_macros.rb
@@ -70,6 +70,14 @@ module OpenProject::TextFormatting
macro_attributes[:id].nil?
end
+ def self.relative_id(macro_attributes, context)
+ if project_embed?(macro_attributes) && context[:project].present?
+ context[:project].try(:id)
+ elsif work_package_embed?(macro_attributes) && work_package_context?(context)
+ context[:object].try(:id)
+ end
+ end
+
def self.process_match(match, _matched_string, context)
# Leading string before match
macro_attributes = {
@@ -79,13 +87,7 @@ module OpenProject::TextFormatting
}
type = match[2].downcase
- if relative_embed?(macro_attributes)
- if project_embed?(macro_attributes) && context[:project].present?
- macro_attributes[:id] = context[:project].try(:id)
- elsif work_package_embed?(macro_attributes) && work_package_context?(context)
- macro_attributes[:id] = context[:object].try(:id)
- end
- end
+ macro_attributes[:id] = relative_id(macro_attributes, context) if relative_embed?(macro_attributes)
ApplicationController.helpers.content_tag "opce-macro-attribute-#{type}",
"",