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

1.2 KB
Raw Blame
import {
  ChangeDetectionStrategy,
  ChangeDetectorRef,
  Component,
  ElementRef,
  HostBinding,
  OnInit,
} from '@angular/core';
import { SpotDropModalTeleportationService, TeleportInstance } from './drop-modal-teleportation.service';
import { UntilDestroyedMixin } from 'core-app/shared/helpers/angular/until-destroyed.mixin';

@Component({
  selector: 'opce-spot-drop-modal-portal',
  template: '<ng-container *ngTemplateOutlet="template" />',
  changeDetection: ChangeDetectionStrategy.OnPush,
  standalone: false,
})
export class SpotDropModalPortalComponent extends UntilDestroyedMixin implements OnInit {
  @HostBinding('class.spot-drop-modal-portal') className = true;

  template:TeleportInstance|null = null;

  constructor(
    readonly cdRef:ChangeDetectorRef,
    readonly template$:SpotDropModalTeleportationService,
    readonly elementRef:ElementRef<HTMLElement>,
  ) {
    super();
  }

  ngOnInit() {
    this
      .template$
      .templateRef$
      .pipe(
        this.untilDestroyed(),
      )
      .subscribe((templ) => {
        this.template = templ;
        this.cdRef.detectChanges();
        this.template$.hasRendered$.next(!!this.elementRef.nativeElement.children.length);
      });
  }
}