-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into wip/DEV-2328-eu-remove-a-user-from-a-project…
…-e2e
- Loading branch information
Showing
26 changed files
with
1,508 additions
and
987 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export class ResourcePage { | ||
visit(id: string) { | ||
cy.visit(`/project/00FF/ontology/00FF/images/${id}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
libs/vre/resource-editor/resource-properties/src/lib/footnote-tooltip.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { animate, state, style, transition, trigger } from '@angular/animations'; | ||
import { Component, Input } from '@angular/core'; | ||
import { SafeHtml } from '@angular/platform-browser'; | ||
|
||
@Component({ | ||
selector: 'app-footnote-tooltip', | ||
template: ` <div class="content" [@fadeIn]="'in'"> | ||
<div [innerHTML]="content"></div> | ||
</div>`, | ||
animations: [ | ||
trigger('fadeIn', [ | ||
state('in', style({ opacity: 1 })), | ||
transition(':enter', [style({ opacity: 0 }), animate(100)]), | ||
]), | ||
], | ||
styles: [ | ||
` | ||
:host { | ||
position: absolute; | ||
z-index: 1000; | ||
} | ||
.content { | ||
font-size: 0.8em; | ||
background: white; | ||
color: black; | ||
padding: 8px; | ||
min-width: 200px; | ||
border-radius: 4px; | ||
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); | ||
} | ||
`, | ||
], | ||
}) | ||
export class FootnoteTooltipComponent { | ||
@Input({ required: true }) content!: SafeHtml; | ||
} |
108 changes: 108 additions & 0 deletions
108
libs/vre/resource-editor/resource-properties/src/lib/footnote.directive.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
import { Overlay, OverlayPositionBuilder, OverlayRef } from '@angular/cdk/overlay'; | ||
import { ComponentPortal } from '@angular/cdk/portal'; | ||
import { Directive, HostListener } from '@angular/core'; | ||
import { DomSanitizer } from '@angular/platform-browser'; | ||
import { AppError } from '@dasch-swiss/vre/core/error-handler'; | ||
import { FootnoteTooltipComponent } from './footnote-tooltip.component'; | ||
|
||
@Directive({ | ||
selector: '[appFootnote]', | ||
}) | ||
export class FootnoteDirective { | ||
private _overlayRef: OverlayRef | null = null; | ||
private _hideTimeout?: any; | ||
|
||
constructor( | ||
private _overlay: Overlay, | ||
private _positionBuilder: OverlayPositionBuilder, | ||
private _sanitizer: DomSanitizer | ||
) {} | ||
|
||
@HostListener('mouseover', ['$event']) | ||
onMouseOver(event: MouseEvent) { | ||
const targetElement = event.target as HTMLElement; | ||
if (targetElement.nodeName.toLowerCase() === 'footnote') { | ||
const content = targetElement.getAttribute('content'); | ||
if (content === null) { | ||
throw new AppError('Footnote content is null'); | ||
} | ||
this.showTooltip(content, event.clientX, event.clientY); | ||
} | ||
} | ||
|
||
@HostListener('mouseout', ['$event.target']) | ||
onMouseOut(targetElement: HTMLElement) { | ||
if (targetElement.nodeName.toLowerCase() === 'footnote') { | ||
this.hideTooltipWithDelay(); | ||
} | ||
} | ||
|
||
@HostListener('click', ['$event']) | ||
onClick(event: MouseEvent): void { | ||
const targetElement = event.target as HTMLElement; | ||
|
||
if (targetElement.nodeName.toLowerCase() === 'footnote') { | ||
const uuid = targetElement.getAttribute('id'); | ||
|
||
if (uuid) { | ||
// Find the footnote with the same UUID and scroll to it | ||
const targetFootnote = document.querySelector(`.footnote[data-uuid="${uuid}"]`); | ||
|
||
if (targetFootnote) { | ||
console.log('d', event); | ||
// Scroll to the target footnote element | ||
targetFootnote.scrollIntoView({ behavior: 'smooth', block: 'center' }); | ||
} | ||
} | ||
} | ||
} | ||
|
||
private showTooltip(content: string, mouseX: number, mouseY: number) { | ||
if (this._overlayRef) { | ||
this._overlayRef.detach(); | ||
} | ||
const positionStrategy = this._positionBuilder.flexibleConnectedTo({ x: mouseX, y: mouseY }).withPositions([ | ||
{ | ||
overlayX: 'center', | ||
overlayY: 'top', | ||
originX: 'center', | ||
originY: 'bottom', | ||
offsetY: 10, | ||
}, | ||
]); | ||
|
||
this._overlayRef = this._overlay.create({ | ||
positionStrategy, | ||
scrollStrategy: this._overlay.scrollStrategies.reposition(), | ||
}); | ||
|
||
const tooltipPortal = new ComponentPortal(FootnoteTooltipComponent); | ||
if (this._overlayRef.hasAttached()) { | ||
this._overlayRef.detach(); | ||
clearTimeout(this._hideTimeout); | ||
} | ||
|
||
const tooltipRef = this._overlayRef.attach(tooltipPortal); | ||
tooltipRef.instance.content = this._sanitizer.bypassSecurityTrustHtml(content); | ||
|
||
this._overlayRef.overlayElement.addEventListener('mouseenter', () => { | ||
clearTimeout(this._hideTimeout); | ||
}); | ||
|
||
this._overlayRef.overlayElement.addEventListener('mouseleave', () => { | ||
this.hideTooltipWithDelay(); | ||
}); | ||
} | ||
|
||
private hideTooltipWithDelay() { | ||
this._hideTimeout = setTimeout(() => { | ||
this.hideTooltip(); | ||
}, 300); | ||
} | ||
|
||
private hideTooltip() { | ||
if (this._overlayRef) { | ||
this._overlayRef.detach(); | ||
} | ||
} | ||
} |
Oops, something went wrong.