All files / lib/ext-search/ext-search-time-range ext-search-time-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 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 7x 7x 1x 1x 1x               1x 1x 2x 1x 1x 1x     2x 1x  
/*******************************************************************************
 * Copyright bei
 * Entwicklungs- und Pflegeverbund für das gemeinsame Fachverfahren gefa
 *
 *******************************************************************************/
import {
  Component,
  EventEmitter,
  Input,
  Output,
  ViewChild,
} from '@angular/core';
 
import {
  FocusableElementOwner,
  InvalidControlValue,
  Nullable,
  WidgetKeySet,
} from '../../utils/util.types';
import { createWidgetKeySet } from '../../utils/utilities';
 
import { TimeInputComponent } from '../../time-input/time-input.component';
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-time-range',
  templateUrl: './ext-search-time-range.component.html',
  styleUrls: ['./ext-search-time-range.component.css'],
  providers: [
    {
      provide: BaseExtSearchComponent,
      useExisting: ExtSearchTimeRangeComponent,
    },
  ],
  standalone: false,
})
export class ExtSearchTimeRangeComponent
  extends BaseExtSearchRangeComponent
  implements FocusableElementOwner
{
  /**
   * Current value of the start slot time input, in HH:mm format.
   */
  @Input()
  public startSlotValue: Nullable<string | InvalidControlValue> = null;
 
  /**
   * Current value of the end slot time input, in HH:mm format.
   */
  @Input()
  public endSlotValue: Nullable<string | InvalidControlValue> = null;
 
  /**
   * Fires on a start slot value change.
   */
  @Output()
  public readonly startSlotValueChange: EventEmitter<
    Nullable<string | InvalidControlValue>
  > = new EventEmitter<Nullable<string | InvalidControlValue>>();
 
  /**
   * Fires on an end slot value change.
   */
  @Output()
  public readonly endSlotValueChange: EventEmitter<
    Nullable<string | InvalidControlValue>
  > = new EventEmitter<Nullable<string | InvalidControlValue>>();
 
  /** @ignore */
  @ViewChild('startSlotEl')
  protected startSlotElement?: TimeInputComponent;
 
  /** @ignore */
  @ViewChild('endSlotEl')
  protected endSlotElement?: TimeInputComponent;
 
  /** @ignore */
  protected startSlotText = '';
 
  /** @ignore */
  protected endSlotText = '';
 
  /** @ignore */
  protected override readonly _widgetKeys: WidgetKeySet = createWidgetKeySet(
    'gc-ext-search-time-range',
  );
 
  public override focusChild(): boolean {
    if (this.startSlotElement) {
      return this.startSlotElement.focusChild();
    } else if (this.endSlotElement) {
      return this.endSlotElement.focusChild();
    }
    return false;
  }
 
  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;
  }
}