All files / lib/ext-search/ext-search-group-container ext-search-group-container.component.ts

97.75% Statements 87/89
94.44% Branches 17/18
100% Functions 5/5
97.75% Lines 87/89

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 901x 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 1x 1x 1x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 1x 1x 2x 1x 1x 1x     2x 2x 1x 1x 1x 1x 1x 1x 61x 61x 61x 61x 1x  
/*******************************************************************************
 * Copyright bei
 * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
 *
 *******************************************************************************/
import {
  Component,
  ContentChildren,
  EventEmitter,
  Input,
  Output,
  QueryList,
  ViewChild,
  forwardRef,
} from '@angular/core';
 
import { FocusableElementOwner } from '../../utils/util.types';
 
import { ButtonComponent } from '../../button/button.component';
import { GlobalVerticalModeChange } from '../base-ext-search/base-ext-search-field.component';
import { ExtSearchGroupComponent } from '../ext-search-group/ext-search-group.component';
 
/**
 * `gc-ext-search-group-container`: is used to make a region of one or more related extended search groups (e.g. `gc-ext-search-group`) with an optional button to add more groups into the container
 */
@Component({
  selector: 'gc-ext-search-group-container',
  templateUrl: './ext-search-group-container.component.html',
  styleUrls: ['./ext-search-group-container.component.css'],
  standalone: false,
})
export class ExtSearchGroupContainerComponent implements FocusableElementOwner {
  /**
   * Sets the accessibility label for the filter-container region
   */
  @Input({ required: true })
  public label = '';
 
  /**
   * Show add-to-container button with the given label if not empty
   */
  @Input()
  public addButtonLabel = '';
 
  /**
   * Action that is fired when clicked on add-to-container button
   */
  @Output()
  public readonly onAdd: EventEmitter<void> = new EventEmitter<void>();
 
  /**
   * @ignore
   */
  @ContentChildren(forwardRef(() => ExtSearchGroupComponent))
  protected content?: QueryList<ExtSearchGroupComponent>;
 
  /**
   * @ignore
   */
  @ViewChild('addButton', { read: ButtonComponent })
  private addButtonComponent?: ButtonComponent;
 
  /**
   * @ignore
   * (Internal) Event is fired, when vertical-mode of group changes
   */
  public readonly _onVerticalModeChange: EventEmitter<GlobalVerticalModeChange> =
    new EventEmitter<GlobalVerticalModeChange>();
 
  public focusChild(): boolean {
    if (this.content?.get(0)?.focusChild()) {
      return true;
    } else if (this.addButtonComponent) {
      return this.addButtonComponent.focusChild();
    } else {
      return false;
    }
  }
 
  /**
   * @ignore
   * Refresh and update the global vertical state for all components
   */
  public _updateGlobalVertState(onDestroy: boolean) {
    const newState: boolean =
      this.content?.some(entry => entry._getInternalVerticalMode()) ?? false;
    this._onVerticalModeChange.emit({ newState, onDestroy });
  }
}