@@ -57,6 +57,7 @@ import { TurboRequestsService } from 'core-app/core/turbo/turbo-requests.service
5757import { PathHelperService } from 'core-app/core/path-helper/path-helper.service' ;
5858import { ensureId , generateId } from 'core-app/shared/helpers/dom-helpers' ;
5959import { target } from 'core-app/shared/helpers/event-helpers' ;
60+ import { html , render } from 'lit-html' ;
6061
6162interface TimeEntrySchema extends SchemaResource {
6263 activity :IFieldSchema ;
@@ -540,28 +541,22 @@ export class TimeEntryCalendarComponent implements AfterViewInit, OnDestroy {
540541 const anchorId = ensureId ( anchorEl ) ;
541542 anchorEl . role = 'button' ;
542543
543- const popoverEl = document . createElement ( 'anchored-position' ) ;
544- popoverEl . id = generateId ( 'popover' ) ;
545- popoverEl . role = 'dialog' ;
546- popoverEl . innerHTML = this . popoverContentString ( event . event . extendedProps . entry as TimeEntryResource , schema ) ;
547- popoverEl . setAttribute ( 'align' , 'start' ) ;
548- popoverEl . setAttribute ( 'anchor' , anchorId ) ;
549- popoverEl . setAttribute ( 'anchor-offset' , 'condensed' ) ;
550- popoverEl . setAttribute ( 'popover' , 'hint' ) ;
551- popoverEl . setAttribute ( 'side' , 'outside-right' ) ;
544+ const popoverId = generateId ( 'popover' ) ;
545+ const popoverHtml = this . popoverHtml ( popoverId , anchorId , event . event . extendedProps . entry as TimeEntryResource , schema ) ;
546+
547+ render ( popoverHtml , anchorEl ) ;
552548
553549 anchorEl . setAttribute ( 'aria-haspopup' , 'true' ) ;
554- anchorEl . setAttribute ( 'popovertarget' , popoverEl . id ) ;
550+ anchorEl . setAttribute ( 'popovertarget' , popoverId ) ;
555551
552+ const popoverEl = document . getElementById ( popoverId ) ! ;
556553 const showPopover = ( ) => { popoverEl . showPopover ( ) ; } ;
557554 const hidePopover = ( ) => { popoverEl . hidePopover ( ) ; } ;
558555
559556 target ( anchorEl ) . on ( 'mouseenter.anchor' , showPopover ) ;
560557 target ( anchorEl ) . on ( 'focus.anchor' , showPopover ) ;
561558 target ( anchorEl ) . on ( 'mouseleave.anchor' , hidePopover ) ;
562559 target ( anchorEl ) . on ( 'blur.anchor' , hidePopover ) ;
563-
564- anchorEl . appendChild ( popoverEl ) ;
565560 }
566561
567562 private removePopover ( event :CalendarViewEvent ) :void {
@@ -641,8 +636,27 @@ export class TimeEntryCalendarComponent implements AfterViewInit, OnDestroy {
641636 return `#${ idFromLink ( entity . href ) } : ${ entity . name } ` ;
642637 }
643638
644- private popoverContentString ( entry :TimeEntryResource , schema :TimeEntrySchema ) :string {
645- return `
639+ private popoverHtml (
640+ popoverId :string ,
641+ anchorId :string ,
642+ entry :TimeEntryResource ,
643+ schema :TimeEntrySchema ) {
644+ return html `
645+ < anchored-position
646+ id ="${ popoverId } "
647+ role ="dialog "
648+ align ="start "
649+ anchor ="${ anchorId } "
650+ anchor-offset ="condensed "
651+ popover ="hint "
652+ side ="outside-right ">
653+ ${ this . popoverContentHtml ( entry , schema ) }
654+ </ anchored-position >
655+ ` ;
656+ }
657+
658+ private popoverContentHtml ( entry :TimeEntryResource , schema :TimeEntrySchema ) {
659+ return html `
646660 < div class ="Popover ">
647661 < div class ="Box Popover-message Popover-message--left-top ml-2 mx-auto p-2 text-left text-small ">
648662 < ul class ="list-style-none ml-0 ">
0 commit comments