All files / lib/message-tile message-tile.component.ts

98.27% Statements 114/116
92.3% Branches 12/13
100% Functions 4/4
98.27% Lines 114/116

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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 1171x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 20x 1x 1x 5x 5x 5x 2x 3x 3x 3x     5x 5x 5x 1x 1x 1x 4x 4x 1x  
/*******************************************************************************
 * Copyright bei
 * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
 *
 *******************************************************************************/
import {
  Component,
  EventEmitter,
  Input,
  Output,
  QueryList,
  ViewChildren,
} from '@angular/core';
 
import { ActionEvent } from '../utils/event.types';
import { FocusableElementOwner } from '../utils/util.types';
 
import { ButtonComponent } from '../button/button.component';
 
/**
 * A message tile displays the entire content of a message, as well as actions, and can be arranged in different ways.
 */
@Component({
  selector: 'gc-message-tile',
  templateUrl: './message-tile.component.html',
  styleUrls: ['./message-tile.component.css'],
  standalone: false,
})
export class MessageTileComponent implements FocusableElementOwner {
  /**
   * Label of the message tile.
   */
  @Input()
  public label = '';
 
  /**
   * Variant of the message tile.
   */
  @Input()
  public variant: 'info' | 'warning' = 'info';
 
  /**
   * Main text content of the message tile.
   */
  @Input()
  public textContent = '';
 
  /**
   * Label for the primary button of the message tile.
   * The button will be shown if the button label is not empty.
   */
  @Input()
  public buttonLabel = '';
 
  /**
   * Decides if the archive button will be shown.
   */
  @Input()
  public archiveButtonEnabled = false;
 
  /**
   * Decides if the close button will be shown.
   */
  @Input()
  public closeButtonEnabled = false;
 
  /**
   * Decides if the notification icon will be shown next to the message tile.
   */
  @Input()
  public notificationIconEnabled = false;
 
  /**
   * Fired on a primary button action.
   */
  @Output()
  public readonly onButtonAction: EventEmitter<ActionEvent> =
    new EventEmitter<ActionEvent>();
 
  /**
   * Fired on a close button action.
   */
  @Output()
  public readonly onCloseButtonAction: EventEmitter<ActionEvent> =
    new EventEmitter<ActionEvent>();
 
  /**
   * Fired on a archive button action.
   */
  @Output()
  public readonly onArchiveButtonAction: EventEmitter<ActionEvent> =
    new EventEmitter<ActionEvent>();
 
  /** @ignore */
  @ViewChildren(ButtonComponent)
  private buttons?: QueryList<ButtonComponent>;
 
  focusChild(): boolean {
    const primaryButton = this.buttons?.find(btn => btn.variant === 'primary');
 
    if (primaryButton) {
      return primaryButton.focusChild();
    } else {
      if (this.buttons && this.buttons.length > 0) {
        return this.buttons.last.focusChild();
      } else {
        return false;
      }
    }
  }
 
  /** @ignore */
  _hideButtonTooltips(): void {
    this.buttons?.forEach(b => b._hideTooltip());
  }
}