All files / lib/ext-search/ext-search-text-range ext-search-text-range.component.ts

91.5% Statements 97/106
80% Branches 4/5
66.66% Functions 2/3
91.5% Lines 97/106

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 1071x 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 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 1x 1x 1x 2x 1x 1x 1x     2x 1x 1x               1x  
/*******************************************************************************
 * Copyright bei
 * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
 *
 *******************************************************************************/
import {
  Component,
  EventEmitter,
  Input,
  Output,
  ViewChild,
} from '@angular/core';
 
import {
  FocusableElementOwner,
  InvalidControlValue,
  WidgetKeySet,
} from '../../utils/util.types';
import { createWidgetKeySet } from '../../utils/utilities';
 
import { TextInputComponent } from '../../text-input-field/text-input-field.component';
import { TextInputFormatter } from '../../text-input-field/text-input-field.formatters';
import { BaseExtSearchComponent } from '../base-ext-search/base-ext-search-field.component';
import { BaseExtSearchRangeComponent } from '../base-ext-search/base-ext-search-range-field.component';
 
@Component({
  selector: 'gc-ext-search-text-range',
  templateUrl: './ext-search-text-range.component.html',
  styleUrls: ['./ext-search-text-range.component.css'],
  providers: [
    {
      provide: BaseExtSearchComponent,
      useExisting: ExtSearchTextRangeComponent,
    },
  ],
  standalone: false,
})
export class ExtSearchTextRangeComponent
  extends BaseExtSearchRangeComponent
  implements FocusableElementOwner
{
  @Input()
  public startSlotValue: string | InvalidControlValue = '';
 
  @Input()
  public endSlotValue: string | InvalidControlValue = '';
 
  /**
   * Formatter to display the value in a custom format and convert user input to the internal representation
   */
  @Input()
  public formatter?: TextInputFormatter;
 
  /**
   * Fires on a start slot value change.
   */
  @Output()
  public readonly startSlotValueChange: EventEmitter<
    string | InvalidControlValue
  > = new EventEmitter<string | InvalidControlValue>();
 
  /**
   * Fires on an end slot value change.
   */
  @Output()
  public readonly endSlotValueChange: EventEmitter<
    string | InvalidControlValue
  > = new EventEmitter<string | InvalidControlValue>();
 
  /** @ignore */
  @ViewChild('startSlotEl')
  protected startSlotElement?: TextInputComponent;
 
  /** @ignore */
  @ViewChild('endSlotEl')
  protected endSlotElement?: TextInputComponent;
 
  /** @ignore */
  protected _startSlotText = '';
 
  /** @ignore */
  protected _endSlotText = '';
 
  /** @ignore */
  protected override readonly _widgetKeys: WidgetKeySet = createWidgetKeySet(
    'gc-ext-search-text-range',
  );
 
  public override focusRangeSlot(slot: 'start' | 'end'): boolean {
    if (slot === 'start' && this.startSlotElement) {
      return this.startSlotElement.focusChild();
    } else if (slot === 'end' && this.endSlotElement) {
      return this.endSlotElement.focusChild();
    }
    return false;
  }
 
  public override focusChild(): boolean {
    if (this.startSlotElement) {
      return this.startSlotElement.focusChild();
    } else if (this.endSlotElement) {
      return this.endSlotElement.focusChild();
    }
    return false;
  }
}