Skip to content

Commit ce0fbf0

Browse files
committed
[#68834] Fix Time Entry tooltips in My spent time
Implements tooltips using Primer's `tool-tip` custom element.
1 parent 45559cc commit ce0fbf0

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

frontend/src/app/features/calendar/te-calendar/te-calendar.component.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ import { DayResourceService } from 'core-app/core/state/days/day.service';
5555
import allLocales from '@fullcalendar/core/locales-all';
5656
import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.service';
5757
import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';
58+
import { ensureId } from 'core-app/shared/helpers/dom-helpers';
5859

5960
interface TimeEntrySchema extends SchemaResource {
6061
activity:IFieldSchema;
@@ -534,23 +535,28 @@ export class TimeEntryCalendarComponent implements AfterViewInit, OnDestroy {
534535

535536
const schema = (await this.schemaCache.ensureLoaded(entry as TimeEntryResource)) as TimeEntrySchema;
536537

538+
const forEl = event.el;
539+
const forId = ensureId(forEl);
540+
537541
const tooltip = document.createElement('tool-tip');
538-
tooltip.textContent = this.tooltipContentString(event.event.extendedProps.entry as TimeEntryResource, schema);
539-
event.el.appendChild(tooltip);
542+
tooltip.innerHTML = this.tooltipContentString(event.event.extendedProps.entry as TimeEntryResource, schema);
543+
ensureId(tooltip, 'tooltip');
544+
tooltip.setAttribute('for', forId);
545+
tooltip.setAttribute('popover', 'manual');
546+
tooltip.setAttribute('data-direction', 'sw');
547+
tooltip.setAttribute('data-type', 'label');
548+
tooltip.classList.add('position-absolute');
540549

541-
// TODO: port tooltips
542-
// jQuery(event.el).tooltip({
543-
// content: this.tooltipContentString(event.event.extendedProps.entry as TimeEntryResource, schema),
544-
// items: '.fc-event',
545-
// close() {
546-
// document.querySelectorAll('.ui-helper-hidden-accessible').forEach(element => element.remove());
547-
// },
548-
// track: true,
549-
// });
550+
event.el.appendChild(tooltip);
550551
}
551552

552553
private removeTooltip(event:CalendarViewEvent):void {
553-
// TODO: port tooltips
554+
const forId = event.el.id;
555+
if (!forId) {
556+
return;
557+
}
558+
559+
document.querySelector(`tool-tip[for="${forId}"]`)?.remove();
554560
}
555561

556562
private prependDuration(event:CalendarViewEvent):void {

frontend/src/global_styles/content/_tooltip.sass

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,9 @@
3838
opacity: 1
3939

4040
.tooltip--map
41-
margin-top: 1em
42-
margin-bottom: 0
41+
margin: 0
4342
list-style: none
44-
margin-left: 0
45-
font-size: 13.6px
46-
47-
&:first-child
48-
margin-top: 0
43+
text-align: left
4944

5045
.tooltip--map--key
5146
font-weight: var(--base-text-weight-bold)

0 commit comments

Comments
 (0)