Skip to content
Snippets Groups Projects
element-component.directive.ts 781 B
Newer Older
  • Learn to ignore specific revisions
  • import {
    
    } from '@angular/core';
    
    import { UIElement } from 'common/models/elements/element';
    
    import { AspectError } from 'common/classes/aspect-error';
    
    
    @Directive()
    
    export abstract class ElementComponent implements AfterContentChecked {
    
    rhenck's avatar
    rhenck committed
      abstract elementModel: UIElement;
    
    rhenck's avatar
    rhenck committed
      project!: 'player' | 'editor';
    
      constructor(public elementRef: ElementRef) {}
    
    
      get domElement(): Element {
        return this.elementRef.nativeElement;
      }
    
      ngAfterContentChecked(): void {
    
        this.project = this.elementRef.nativeElement.closest('aspect-element-group-selection') ? 'player' : 'editor';
    
    
      // eslint-disable-next-line class-methods-use-this
      throwError(code: string, message: string) {
        throw new AspectError(code, message);
      }