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

added quoting

Jonas Jabari971bcd430b99
diff --git a/app/components/work_packages/activities_tab/journals/item_component.html.erb b/app/components/work_packages/activities_tab/journals/item_component.html.erb
index 9378d0daef3..7b92abdd9a4 100644
--- a/app/components/work_packages/activities_tab/journals/item_component.html.erb
+++ b/app/components/work_packages/activities_tab/journals/item_component.html.erb
@@ -59,6 +59,7 @@
scheme: :invisible)
copy_url_action_item(menu)
edit_action_item(menu) if editable?
+ quote_action_item(menu) if journal.notes.present?
end
end
end
diff --git a/app/components/work_packages/activities_tab/journals/item_component.rb b/app/components/work_packages/activities_tab/journals/item_component.rb
index 40734e39fd0..94dc2dacc63 100644
--- a/app/components/work_packages/activities_tab/journals/item_component.rb
+++ b/app/components/work_packages/activities_tab/journals/item_component.rb
@@ -105,7 +105,7 @@ module WorkPackages
end
def edit_action_item(menu)
- menu.with_item(label: t("label_edit"),
+ menu.with_item(label: t("js.label_edit_comment"),
href: edit_work_package_activity_path(journal.journable, journal),
content_arguments: {
data: { "turbo-stream": true }
@@ -114,6 +114,20 @@ module WorkPackages
end
end
+ def quote_action_item(menu)
+ menu.with_item(label: t("js.label_quote_comment"),
+ tag: :button,
+ content_arguments: {
+ data: {
+ action: "click->work-packages--activities-tab--index#quote",
+ "content-param": journal.notes,
+ "user-name-param": I18n.t(:text_user_wrote, value: ERB::Util.html_escape(journal.user))
+ }
+ }) do |item|
+ item.with_leading_visual_icon(icon: :quote)
+ end
+ end
+
def bubble_html
"
<span
diff --git a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
index 92357601352..b6522cbd275 100644
--- a/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
+++ b/frontend/src/stimulus/controllers/dynamic/work-packages/activities-tab/index.controller.ts
@@ -30,6 +30,9 @@
import * as Turbo from '@hotwired/turbo';
import { Controller } from '@hotwired/stimulus';
+import {
+ ICKEditorInstance,
+} from 'core-app/shared/components/editor/components/ckeditor/ckeditor.types';
export default class IndexController extends Controller {
static values = {
@@ -196,6 +199,37 @@ export default class IndexController extends Controller {
}
}
+ quote(event:Event) {
+ event.preventDefault();
+ const userName = (event.currentTarget as HTMLElement).dataset.userNameParam as string;
+ const content = (event.currentTarget as HTMLElement).dataset.contentParam as string;
+
+ this.openEditorWithQuotedText(this.quotedText(content, userName));
+ }
+
+ quotedText(rawComment:string, userName:string) {
+ const quoted = rawComment.split('\n')
+ .map((line:string) => `\n> ${line}`)
+ .join('');
+
+ return `${userName}\n${quoted}`;
+ }
+
+ openEditorWithQuotedText(quotedText:string) {
+ this.showForm();
+ const AngularCkEditorElement = this.element.querySelector('opce-ckeditor-augmented-textarea');
+ if (AngularCkEditorElement) {
+ const ckeditorInstance = jQuery(AngularCkEditorElement).data('editor') as ICKEditorInstance;
+ if (ckeditorInstance) {
+ const currentData = ckeditorInstance.getData({ trim: false });
+ // only quote if the editor is empty
+ if (currentData.length === 0) {
+ ckeditorInstance.setData(quotedText);
+ }
+ }
+ }
+ }
+
async onSubmit(event:Event) {
event.preventDefault(); // Prevent the native form submission