All files / lib/ext-search/ext-search-picker ext-search-picker.component.ts

98% Statements 98/100
90% Branches 9/10
100% Functions 5/5
98% Lines 98/100

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 1011x 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 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 7x 7x 1x 1x 1x 1x 1x     1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 1x  
/*******************************************************************************
 * Copyright bei
 * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
 *
 *******************************************************************************/
import {
  Component,
  EventEmitter,
  Input,
  Output,
  ViewChild,
} from '@angular/core';
 
import {
  Converter,
  FocusableElementOwner,
  Item,
  WidgetKeySet,
} from '../../utils/util.types';
import { createWidgetKeySet } from '../../utils/utilities';
 
import { PickerComponent } from '../../picker/picker.component';
import { BaseExtSearchComponent } from '../base-ext-search/base-ext-search-field.component';
import { BaseExtSearchSingleFieldComponent } from '../base-ext-search/base-ext-search-single-field.component';
 
@Component({
  selector: 'gc-ext-search-picker',
  templateUrl: './ext-search-picker.component.html',
  styleUrls: ['./ext-search-picker.component.css'],
  providers: [
    { provide: BaseExtSearchComponent, useExisting: ExtSearchPickerComponent },
  ],
  standalone: false,
})
export class ExtSearchPickerComponent<T>
  extends BaseExtSearchSingleFieldComponent
  implements FocusableElementOwner
{
  /**
   * Items to display in the picker.
   */
  @Input()
  public items: readonly T[] = [];
 
  /**
   * Selected item.
   */
  @Input()
  public value: T | null = null;
 
  /**
   * Adapts the domain type T to the internal Item structure.
   */
  @Input()
  public itemAdapter?: Converter<T, Item>;
 
  /**
   * Fires on a input slot value change.
   */
  @Output()
  public readonly valueChange: EventEmitter<T | null> =
    new EventEmitter<T | null>();
 
  /**
   * Marks the input field as required.
   */
  @Input()
  public required = false;
 
  /** @ignore */
  @ViewChild('pickerField')
  protected pickerField?: PickerComponent<T>;
 
  /**
   * Overrides focus border visibility.
   */
  protected hideFocusBorder = false;
 
  /** @ignore */
  protected override readonly _widgetKeys: WidgetKeySet = createWidgetKeySet(
    'gc-ext-search-picker',
  );
 
  public override focusChild(): boolean {
    if (this.pickerField) {
      return this.pickerField.focusChild();
    }
    return false;
  }
 
  /** @ignore */
  protected handleValueChange(): void {
    this.valueChange.emit(this.value);
  }
 
  /** @ignore */
  protected handleFocusBorderVisibility(hideFocusBorder: boolean) {
    this.hideFocusBorder = hideFocusBorder;
  }
}