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

hack support for macros on statusExplanation and description

ulferts601dc29ccc47
diff --git a/app/forms/custom_fields/inputs/text.rb b/app/forms/custom_fields/inputs/text.rb
index 4a6ffe3ec85..adb224761a3 100644
--- a/app/forms/custom_fields/inputs/text.rb
+++ b/app/forms/custom_fields/inputs/text.rb
@@ -33,7 +33,8 @@ class CustomFields::Inputs::Text < CustomFields::Inputs::Base::Input
def rich_text_options
{
- resource: nil
+ resource: nil,
+ macros: "none"
}
end
end
diff --git a/app/views/custom_fields/_form.html.erb b/app/views/custom_fields/_form.html.erb
index 16dc232c5ac..f1b0039a02b 100644
--- a/app/views/custom_fields/_form.html.erb
+++ b/app/views/custom_fields/_form.html.erb
@@ -151,6 +151,7 @@ See COPYRIGHT and LICENSE files for more details.
cols: 100,
rows: 20,
class: 'wiki-edit',
+ macros: "none",
with_text_formatting: true %>
<% end %>
</div>
diff --git a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.ts b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.ts
index f7045f98d6b..3b94dd32bea 100644
--- a/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.ts
+++ b/frontend/src/app/shared/components/dynamic-forms/components/dynamic-inputs/formattable-textarea-input/components/formattable-control/formattable-control.component.ts
@@ -45,7 +45,10 @@ export class FormattableControlComponent implements ControlValueAccessor, OnInit
public get ckEditorContext():ICKEditorContext {
return {
type: this.templateOptions.editorType,
- macros: 'none',
+ // This is a very project resource specific hack to allow macros on description and statusExplanation but
+ // disable it for custom fields. As the formly based approach is currently limited to projects, and that is to be removed,
+ // such a "pragmatic" approach should be ok.
+ macros: (this.templateOptions.property as string).startsWith('customField') ? 'none' : 'resource',
options: { rtl: this.templateOptions?.rtl },
};
}
diff --git a/spec/features/projects/project_status_administration_spec.rb b/spec/features/projects/project_status_administration_spec.rb
index e32d04a5f46..a6a2b3ab1b4 100644
--- a/spec/features/projects/project_status_administration_spec.rb
+++ b/spec/features/projects/project_status_administration_spec.rb
@@ -66,7 +66,7 @@ RSpec.describe "Projects status administration", :js, :with_cuprite do
status_field.select_option "On track"
status_description.set_markdown "Everything is fine at the start"
- status_description.expect_supports_no_macros
+ status_description.expect_supports_macros
click_button "Save"
diff --git a/spec/support/components/wysiwyg/wysiwyg_editor.rb b/spec/support/components/wysiwyg/wysiwyg_editor.rb
index afee2036c5b..1000027e86f 100644
--- a/spec/support/components/wysiwyg/wysiwyg_editor.rb
+++ b/spec/support/components/wysiwyg/wysiwyg_editor.rb
@@ -59,9 +59,9 @@ module Components
expect(editor_element.text).to eq(value)
end
- def expect_supports_no_macros
+ def expect_supports_macros
expect(container)
- .to have_no_css(".ck-button", visible: :all, text: "Macros")
+ .to have_css(".ck-button", visible: :all, text: "Macros")
end
def within_enabled_preview