All files / app/ui-components/mat-sq-button mat-sq-button.component.ts

100% Statements 11/11
100% Branches 4/4
100% Functions 3/3
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40                    1x 98x   98x   98x       98x   98x       2x 1x   1x       1x 1x            
import {Component, Input} from '@angular/core';
import {faAngleRight, faCircleQuestion, IconDefinition} from "@fortawesome/free-solid-svg-icons";
import {MatDialog} from "@angular/material/dialog";
import {HelpComponent} from "../../modals/help/help.component";
 
@Component({
  selector: 'mat-sq-button',
  templateUrl: './mat-sq-button.component.html',
  styleUrls: ['./mat-sq-button.component.css']
})
export class MatSqButtonComponent {
  faAngleRight = faAngleRight;
 
  @Input() icon: IconDefinition = faCircleQuestion;
  @Input() help_topic: string | undefined;
  @Input() disabled: boolean = false;
 
 
  // reference any class decorated with @Component, that will be opened in a popup
  @Input() popup: { new(...args: any[]): any; } = HelpComponent;
 
  constructor(public dialog: MatDialog) {
  }
 
  onClickHandler() {
    if(this.help_topic === undefined && this.popup == HelpComponent){
      console.log("Nothing happened, either define help_topic or popup.")
    }else{
      const dialogRef = this.dialog.open(this.popup, {
        data: this.help_topic
      });
 
      dialogRef.afterClosed().subscribe(result => {
        console.log(`Dialog result: ${result}`);
      });
    }
 
  }
}