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

95.23% Statements 100/105
100% Branches 7/7
75% Functions 3/4
95.23% Lines 100/105

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 1061x 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 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 6x 1x 1x 1x           1x 1x 1x 1x 1x 1x  
/*******************************************************************************
 * Copyright bei
 * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
 *
 *******************************************************************************/
import {
  Component,
  EventEmitter,
  Input,
  Output,
  ViewChild,
} from '@angular/core';
 
import {
  Converter,
  FocusableElementOwner,
  Key,
  TreeItem,
  WidgetKeySet,
} from '../../utils/util.types';
import { createWidgetKeySet } from '../../utils/utilities';
 
import { TreePickerComponent } from '../../tree-picker/tree-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-tree-picker',
  templateUrl: './ext-search-tree-picker.component.html',
  styleUrls: ['./ext-search-tree-picker.component.css'],
  providers: [
    {
      provide: BaseExtSearchComponent,
      useExisting: ExtSearchTreePickerComponent,
    },
  ],
})
export class ExtSearchTreePickerComponent<T>
  extends BaseExtSearchSingleFieldComponent
  implements FocusableElementOwner
{
  /**
   * Items to display in the picker.
   */
  @Input()
  public items: readonly (T | null)[] = [];
 
  /**
   * Selected item.
   */
  @Input()
  public value: T | null = null;
 
  /**
   * Adapts the domain type T to the internal Item structure.
   */
  @Input()
  public itemAdapter?: Converter<T, TreeItem<T>>;
 
  /**
   * Marks the input field as required.
   */
  @Input()
  public required = false;
 
  /**
   * Set of item keys that will be rendered as disabled items.
   */
  @Input()
  public disabledItems: ReadonlySet<Key> = new Set();
 
  /**
   * Shows full path to the selected item if set to true, else shows only the selected item.
   */
  @Input()
  public showSelectedPath = true;
 
  /**
   * Fires on a input slot value change.
   */
  @Output()
  public readonly valueChange: EventEmitter<T | null> =
    new EventEmitter<T | null>();
 
  /** @ignore */
  @ViewChild('treePickerField')
  protected treePickerField?: TreePickerComponent<T>;
 
  /** @ignore */
  protected override readonly _widgetKeys: WidgetKeySet = createWidgetKeySet(
    'gc-ext-search-tree-picker',
  );
 
  public override focusChild(): boolean {
    if (this.treePickerField?.tree) {
      return this.treePickerField.tree.focusChild();
    }
    return false;
  }
 
  /** @ignore */
  protected handleValueChange(): void {
    this.valueChange.emit(this.value);
  }
}