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

Make turboFrameSrc for hoverCard configurable

Henriette Darge19ad97821b18
diff --git a/frontend/src/app/core/path-helper/path-helper.service.ts b/frontend/src/app/core/path-helper/path-helper.service.ts
index 1b2274db1c3..dc4db90fcea 100644
--- a/frontend/src/app/core/path-helper/path-helper.service.ts
+++ b/frontend/src/app/core/path-helper/path-helper.service.ts
@@ -280,6 +280,10 @@ export class PathHelperService {
return `${this.workPackagePath(workPackageId)}/shares`;
}
+ public workPackageHoverCardPath(workPackageId:string|number) {
+ return `${this.workPackagePath(workPackageId)}/hover_card`;
+ }
+
public workPackageProgressModalPath(workPackageId:string|number) {
if (workPackageId === 'new') {
return `${this.workPackagePath(workPackageId)}/progress/new`;
diff --git a/frontend/src/app/core/setup/globals/global-listeners/hover-card-trigger.service.ts b/frontend/src/app/core/setup/globals/global-listeners/hover-card-trigger.service.ts
index 8787b1304f8..eff95f2b842 100644
--- a/frontend/src/app/core/setup/globals/global-listeners/hover-card-trigger.service.ts
+++ b/frontend/src/app/core/setup/globals/global-listeners/hover-card-trigger.service.ts
@@ -51,17 +51,16 @@ export class HoverCardTriggerService {
const el = e.target as HTMLElement;
if (el) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
- const href = el.getAttribute('href');
+ const turboFrameUrl = el.getAttribute('data-hover-card-url');
- if (!href) {
+ if (!turboFrameUrl) {
return;
}
this.opModalService.show(
HoverCardComponent,
this.injector,
- // TODO
- { workPackageLink: href, event: e },
+ { turboFrameSrc: turboFrameUrl, event: e },
true,
).subscribe((previewModal) => {
this.modalElement = previewModal.elementRef.nativeElement as HTMLElement;
diff --git a/frontend/src/app/shared/components/fields/macros/work-package-quickinfo-macro.component.ts b/frontend/src/app/shared/components/fields/macros/work-package-quickinfo-macro.component.ts
index c2839b95704..35194ac8105 100644
--- a/frontend/src/app/shared/components/fields/macros/work-package-quickinfo-macro.component.ts
+++ b/frontend/src/app/shared/components/fields/macros/work-package-quickinfo-macro.component.ts
@@ -75,6 +75,8 @@ export class WorkPackageQuickinfoMacroComponent {
workPackageLink:string;
+ workPackageHoverCardUrl:string;
+
detailed = false;
constructor(readonly elementRef:ElementRef,
@@ -93,6 +95,7 @@ export class WorkPackageQuickinfoMacroComponent {
const id:string = element.dataset.id!;
this.detailed = element.dataset.detailed === 'true';
this.workPackageLink = this.pathHelper.workPackagePath(id);
+ this.workPackageHoverCardUrl = this.pathHelper.workPackageHoverCardPath(id);
this.workPackage$ = this
.apiV3Service
diff --git a/frontend/src/app/shared/components/fields/macros/work-package-quickinfo-macro.html b/frontend/src/app/shared/components/fields/macros/work-package-quickinfo-macro.html
index d652b451622..32fd8bd05d3 100644
--- a/frontend/src/app/shared/components/fields/macros/work-package-quickinfo-macro.html
+++ b/frontend/src/app/shared/components/fields/macros/work-package-quickinfo-macro.html
@@ -12,7 +12,8 @@
<a class="op-hover-card--preview-trigger"
target="_top"
[href]="workPackageLink"
- [attr.data-work-package-id]="workPackage.id">
+ [attr.data-work-package-id]="workPackage.id"
+ [attr.data-hover-card-url]="workPackageHoverCardUrl">
#{{workPackage.id}}:
</a>
<display-field [resource]="workPackage"
diff --git a/frontend/src/app/shared/components/modals/preview-modal/hover-card-modal/hover-card.modal.ts b/frontend/src/app/shared/components/modals/preview-modal/hover-card-modal/hover-card.modal.ts
index c6539e57940..b97bba4a17f 100644
--- a/frontend/src/app/shared/components/modals/preview-modal/hover-card-modal/hover-card.modal.ts
+++ b/frontend/src/app/shared/components/modals/preview-modal/hover-card-modal/hover-card.modal.ts
@@ -60,15 +60,12 @@ import {
hostDirectives: [WorkPackageIsolatedQuerySpaceDirective],
})
export class HoverCardComponent extends OpModalComponent implements OnInit {
- // TODO
- @Input() public turboFrameSrc:string = "/work_packages/50/hover_card";
+ turboFrameSrc:string;
@Input() public alignment?:Placement = 'bottom-end';
@Input() public allowRepositioning? = true;
- public test:string;
-
constructor(
readonly elementRef:ElementRef,
@Inject(OpModalLocalsToken) readonly locals:OpModalLocalsMap,
@@ -79,24 +76,7 @@ export class HoverCardComponent extends OpModalComponent implements OnInit {
ngOnInit() {
super.ngOnInit();
-
- this.test = this.turboFrameSrc;
-
- // TODO
- fromEvent(document, 'turbo:frame-load')
- .pipe(
- filter((event:CustomEvent) => {
- return (event.target as HTMLElement).id?.includes('op-hover-card-body');
- }),
- throttleTime(100),
- tap(() => {
- this.cdRef.detectChanges();
-
- const modal = this.elementRef.nativeElement as HTMLElement;
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-explicit-any
- void this.reposition(modal, this.locals.event.target as HTMLElement);
- }),
- );
+ this.turboFrameSrc = this.locals.turboFrameSrc;
}
public async reposition(element:HTMLElement, target:HTMLElement) {
diff --git a/lib/open_project/text_formatting/filters/mention_filter.rb b/lib/open_project/text_formatting/filters/mention_filter.rb
index 4b7ac6a2bd9..9ced1b421ca 100644
--- a/lib/open_project/text_formatting/filters/mention_filter.rb
+++ b/lib/open_project/text_formatting/filters/mention_filter.rb
@@ -75,7 +75,8 @@ module OpenProject::TextFormatting
def work_package_mention(work_package)
link_to("##{work_package.id}",
work_package_path_or_url(id: work_package.id, only_path: context[:only_path]),
- class: "issue work_package op-hover-card--preview-trigger")
+ class: "issue work_package op-hover-card--preview-trigger",
+ data: { "hover-card-url": hover_card_work_package_path(work_package.id) })
end
def class_from_mention(mention)
diff --git a/lib/open_project/text_formatting/matchers/link_handlers/work_packages.rb b/lib/open_project/text_formatting/matchers/link_handlers/work_packages.rb
index 4b2fd7bff2e..42128b5a873 100644
--- a/lib/open_project/text_formatting/matchers/link_handlers/work_packages.rb
+++ b/lib/open_project/text_formatting/matchers/link_handlers/work_packages.rb
@@ -66,7 +66,8 @@ module OpenProject::TextFormatting::Matchers
def render_work_package_link(wp_id)
link_to("##{wp_id}",
work_package_path_or_url(id: wp_id, only_path: context[:only_path]),
- class: "issue work_package op-hover-card--preview-trigger")
+ class: "issue work_package op-hover-card--preview-trigger",
+ data: { "hover-card-url": hover_card_work_package_path(wp_id) })
end
end
end