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

100% Statements 97/97
100% Branches 9/9
100% Functions 5/5
100% Lines 97/97

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 981x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 1x 1x 1x 5x 5x 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 { MultiPickerComponent } from '../../multi-picker/multi-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-multi-picker',
  templateUrl: './ext-search-multi-picker.component.html',
  styleUrls: ['./ext-search-multi-picker.component.css'],
  providers: [
    {
      provide: BaseExtSearchComponent,
      useExisting: ExtSearchMultiPickerComponent,
    },
  ],
})
export class ExtSearchMultiPickerComponent<T>
  extends BaseExtSearchSingleFieldComponent
  implements FocusableElementOwner
{
  @Input()
  public items: readonly T[] = [];
 
  @Input()
  public value: ReadonlySet<T> = new Set();
 
  /**
   * Adapts the domain type T to the internal Item structure.
   */
  @Input()
  public itemAdapter: Converter<T, Item> | undefined = undefined;
 
  /**
   * Marks the input field as required.
   */
  @Input()
  public required = false;
 
  /**
   * Fires on a input slot value change.
   */
  @Output()
  public readonly valueChange: EventEmitter<ReadonlySet<T>> = new EventEmitter<
    ReadonlySet<T>
  >();
 
  /** @Ignore */
  @ViewChild('multiPickerField')
  protected multiPickerField?: MultiPickerComponent<T>;
 
  /**
   * Overrides focus border visibility.
   */
  protected hideFocusBorder = false;
 
  /** @ignore */
  protected override readonly _widgetKeys: WidgetKeySet = createWidgetKeySet(
    'gc-ext-search-multi-picker',
  );
 
  public override focusChild(): boolean {
    if (this.multiPickerField) {
      return this.multiPickerField.focusChild();
    }
    return false;
  }
 
  /** @ignore */
  protected handleValueChange(): void {
    this.valueChange.emit(this.value);
  }
 
  /** @ignore */
  protected handleFocusBorderVisibility(hideFocusBorder: boolean) {
    this.hideFocusBorder = hideFocusBorder;
  }
}