All files / app/codeCharta/ui/ribbonBar/searchPanel/searchBar searchBar.component.ts

100% Statements 25/25
100% Branches 0/0
100% Functions 5/5
100% Lines 23/23

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 444x 4x 4x 4x 4x 4x   4x 4x 4x 4x 4x 4x                 4x 11x 11x 11x 11x 11x   11x     3x 3x       1x       2x      
import { Component } from "@angular/core"
import { setSearchPattern } from "../../../../state/store/dynamicSettings/searchPattern/searchPattern.actions"
import { searchPatternSelector } from "../../../../state/store/dynamicSettings/searchPattern/searchPattern.selector"
import { isSearchPatternEmptySelector } from "./selectors/isSearchPatternEmpty.selector"
import { isFlattenPatternDisabledSelector } from "./selectors/isFlattenPatternDisabled.selector"
import { isExcludePatternDisabledSelector } from "./selectors/isExcludePatternDisabled.selector"
import { BlacklistType, CcState } from "../../../../codeCharta.model"
import { blacklistSearchPattern } from "./blacklistSearchPattern.effect"
import { debounce } from "../../../../util/debounce"
import { Store } from "@ngrx/store"
import { MatMenuTrigger, MatMenu, MatMenuItem } from "@angular/material/menu"
import { MatDivider } from "@angular/material/divider"
import { AsyncPipe } from "@angular/common"
 
@Component({
    selector: "cc-search-bar",
    templateUrl: "./searchBar.component.html",
    styleUrls: ["./searchBar.component.scss"],
    standalone: true,
    imports: [MatMenuTrigger, MatMenu, MatMenuItem, MatDivider, AsyncPipe]
})
export class SearchBarComponent {
    searchPattern$ = this.store.select(searchPatternSelector)
    isSearchPatternEmpty$ = this.store.select(isSearchPatternEmptySelector)
    isFlattenPatternDisabled$ = this.store.select(isFlattenPatternDisabledSelector)
    isExcludePatternDisabled$ = this.store.select(isExcludePatternDisabledSelector)
    setSearchPatternDebounced = debounce((event: Event) => this.setSearchPattern(event), 400)
 
    constructor(private store: Store<CcState>) {}
 
    setSearchPattern(event: Event) {
        const eventTarget = event.target as HTMLInputElement
        this.store.dispatch(setSearchPattern({ value: eventTarget.value }))
    }
 
    resetSearchPattern() {
        this.store.dispatch(setSearchPattern({ value: "" }))
    }
 
    blacklistSearchPattern(type: BlacklistType) {
        this.store.dispatch(blacklistSearchPattern(type))
    }
}