UNPKG

@firestitch/filter

Version:
136 lines (135 loc) 4.15 kB
import { EventEmitter, OnDestroy, OnInit } from '@angular/core'; import { Location } from '@angular/common'; import { ActivatedRoute } from '@angular/router'; import { FsStore } from '@firestitch/store'; import { FsFilterConfig } from '../../models/filter-config'; import { FilterConfig } from '../../interfaces/config.interface'; import { FsFilterConfigItem } from '../../models/filter-item'; export declare class FilterComponent implements OnInit, OnDestroy { private _store; private route; private location; filter: FilterConfig; sortUpdate: EventEmitter<any>; showSortBy: any; showFilterInput: boolean; keyEvent(event: KeyboardEvent): void; searchTextInput: any; changedFilters: any[]; config: FsFilterConfig; searchText: string; persists: any; activeFiltersCount: number; activeFiltersWithInputCount: number; showFilterMenu: boolean; modelChanged: EventEmitter<{}>; private _searchTextInput; private _firstOpen; private _query; private _sort; constructor(_store: FsStore, route: ActivatedRoute, location: Location); ngOnInit(): void; ngOnDestroy(): void; /** * * Do update value of some field * * @param {any} values - values for update * @param {boolean} changeEvent - should change event to be fired * * To update text value just pass new text value * * public updateSelectValue(val) { * this.filterEl.updateValues({ keyword: val }); * } * * To update select or observable select you could pass suitable value * * public updateSelectValue(val: number) { * this.filterEl.updateValues({ simple_select: val }, { observable_select: val }); * } * * To update checkbox value just pass true/false as value * * public updateCheckox(val: boolean) { * this.filterEl.updateValues({ checkbox: val }); * } * * To update range value just pass object with min&max object or just with one of targets * * Ex.: { min: 10, max 15 }, { min: 5 }, { max 5 } * * public updateRange(val) { * this.filterEl.updateValues({ range: val }); * } * * To update autocomplete just pass object with name/value fields * * Ex.: { name: 'John Doe', value: 1 } * * public updateAutocomplete(val) { * this.filterEl.updateValues({ autocomplete_user_id: val }); * } * * To update autocompletechips just pass: * * 1) object with name/value fields - will be appended to existing set of values * * { name: 'John Doe', value: 1 } * * 2) array of objects - will be appended to existing set of values * * [{ name: 'John Doe', value: 1 }, { name: 'Darya Filipova', value: 2 }] * * 3) null - clear existing set of values * * public updateAutocomplete(val) { * this.filterEl.updateValues({ autocompletechips_user_id: val }); * } * */ updateValues(values: any, changeEvent?: boolean): void; watchSearchInput(): void; modelChange(text: any): void; backdropClick(event: any): void; done(): void; switchFilterVisibility(event?: any): void; filterInputClick(event: KeyboardEvent): void; changeVisibility(state: boolean): void; clear(event?: any): void; /** * Close filter window and do change callback */ search(): void; /** * Call change callback and apply new filter values */ change(): void; /** * Do update count of filled filters */ updateFilledCounter(): void; /** * Store updated filter data into localstorage * @param changedItem */ filterChange(changedItem?: FsFilterConfigItem): void; /** * Just reload with same values */ reload(event: any): void; /** * Restoring values from local storage */ restorePersistValues(): void; /** * Store values to local storage */ storePersistValues(): void; /** * Reset filter * @param item */ resetFilter(item: FsFilterConfigItem): void; private updateSearchText; }