All files / src/app/shared/components/search/search-box search-box.component.html

100% Statements 1/1
100% Branches 0/0
100% Functions 0/0
100% Lines 1/1

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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 1464x                                                                                                                                                                                                                                                                                                  
<div #searchBox class="search clearfix" [ngClass]="{ focus: searchBoxFocus, 'scaled-up': searchBoxScaledUp }">
  <input
    #searchInput
    id="header-search-input"
    type="search"
    [placeholder]="configuration?.placeholder || ''"
    autocomplete="off"
    class="form-control searchTerm search-input"
    [value]="(inputSearchTerms$ | async) ?? ''"
    [attr.aria-label]="'search.searchbox.label' | translate"
    (input)="handleInput($event.target)"
    (focus)="handleFocus(true)"
    (keydown.enter)="submitSearch(searchInput.value)"
  />
 
  @if (configuration?.autoSuggest && suggestions$ | async; as results) { @if ((searchBoxResults$ | async) &&
  (hasMinimumCharCount$ | async)) {
  <div id="search-suggest-layer" class="search-suggest-container" aria-labelledby="header-search-input">
    <div
      class="col-12 d-flex flex-column"
      [ngClass]="{
        'col-md-5': results.products?.length
      }"
    >
      @if (results.keywords?.length) {
      <ish-suggest-keywords
        [keywords]="results.keywords"
        [inputTerms$]="inputSearchTerms$"
        (submitSearch)="submitSearch($event)"
        [maxAutoSuggests]="configuration?.maxAutoSuggests"
      />
      } @if (results.categories?.length) {
      <ish-suggest-categories
        [categories]="results.categories"
        [inputTerms$]="inputSearchTerms$"
        (routeChange)="resetInput()"
        [maxAutoSuggests]="3"
      />
      } @if (results.brands?.length) {
      <ish-suggest-brands
        [brands]="results.brands"
        [inputTerms$]="inputSearchTerms$"
        (routeChange)="resetInput($event)"
        [maxAutoSuggests]="3"
      />
      }
    </div>
    @if (results.products?.length) {
    <div
      [ngClass]="{
        'col-md-7': results.keywords.length || results.brands.length || results.categories.length,
        'products-only': !results.keywords.length && !results.brands.length && !results.categories.length
      }"
      class="col-12"
    >
      <ish-suggest-products
        [products]="results.products"
        [inputTerms$]="inputSearchTerms$"
        [deviceType]="deviceType"
        (routeChange)="resetInput()"
        [maxAutoSuggests]="8"
      />
    </div>
    }
    <div class="col-12">
      <div class="show-all">
        <button
          type="button"
          class="btn btn-link"
          [title]="'search.searchbox.button.title' | translate"
          (click)="submitSearch(searchInput.value)"
        >
          {{ 'suggest.view_all.link' | translate }}
        </button>
      </div>
    </div>
  </div>
  } @else { @if ((hasMinimumCharCount$ | async) || (searchedTerms$ | async)) {
  <div class="search-suggest-container" aria-live="polite">
    @if (hasMinimumCharCount$ | async) {
    <div class="col-12">
      <div class="d-flex justify-content-start headline">{{ 'suggest.no_results.headline' | translate }}</div>
      <p>{{ 'suggest.no_results.text' | translate }}</p>
    </div>
    } @if (searchedTerms$ | async) {
    <div class="col-12">
      <ish-suggest-search-terms
        [maxRecentlySearchedWords]="5"
        [inputTerms$]="inputSearchTerms$"
        (submitSearch)="submitSearch($event)"
      />
    </div>
    }
  </div>
  } } } @else { @if ((searchedTerms$ | async) && configuration?.autoSuggest) {
  <div class="search-suggest-container">
    <div class="col-12">
      <ish-suggest-search-terms
        [maxRecentlySearchedWords]="5"
        [inputTerms$]="inputSearchTerms$"
        (submitSearch)="submitSearch($event)"
      />
    </div>
  </div>
  } } @if (searchSuggestLoading$ | async) {
  <div class="loading"></div>
  }
 
  <div class="buttons">
    <!-- Clear input button -->
    @if (inputSearchTerms$ | async) {
    <button
      class="btn btn-reset"
      type="reset"
      name="reset"
      [title]="'search.searchbox.button.reset.title' | translate"
      (focus)="handleFocus(true)"
      (click)="handleResetButton($event); setFocusOnSearchInput()"
    >
      <i class="bi bi-x searchbox-icon"></i>
    </button>
    }
 
    <!-- Search button -->
    <button
      class="btn btn-secondary btn-search"
      type="submit"
      name="search"
      [title]="'search.searchbox.button.title' | translate"
      (focus)="handleFocus(true)"
      (click)="submitSearch(searchInput.value)"
    >
      <!-- search button with icon -->
      @if (!configuration?.buttonText) {
      <i class="searchbox-icon" [class]="'bi bi-' + usedIcon"></i>
      } @else {
      {{ configuration?.buttonText }}
      }
 
      <!-- search button with text -->
    </button>
  </div>
</div>
 
<div class="search-suggest-backdrop" [ngClass]="{ show: searchBoxFocus }"></div>