|
|
@ -11,11 +11,11 @@ import { |
|
|
EventEmitter, |
|
|
EventEmitter, |
|
|
Input, |
|
|
Input, |
|
|
OnChanges, |
|
|
OnChanges, |
|
|
OnDestroy, |
|
|
|
|
|
Output, |
|
|
Output, |
|
|
SimpleChanges, |
|
|
SimpleChanges, |
|
|
ViewChild |
|
|
ViewChild |
|
|
} from '@angular/core'; |
|
|
} from '@angular/core'; |
|
|
|
|
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; |
|
|
import { FormControl, ReactiveFormsModule } from '@angular/forms'; |
|
|
import { FormControl, ReactiveFormsModule } from '@angular/forms'; |
|
|
import { |
|
|
import { |
|
|
MatAutocomplete, |
|
|
MatAutocomplete, |
|
|
@ -31,7 +31,6 @@ import { addIcons } from 'ionicons'; |
|
|
import { closeOutline, searchOutline } from 'ionicons/icons'; |
|
|
import { closeOutline, searchOutline } from 'ionicons/icons'; |
|
|
import { groupBy } from 'lodash'; |
|
|
import { groupBy } from 'lodash'; |
|
|
import { BehaviorSubject, Observable, Subject } from 'rxjs'; |
|
|
import { BehaviorSubject, Observable, Subject } from 'rxjs'; |
|
|
import { takeUntil } from 'rxjs/operators'; |
|
|
|
|
|
|
|
|
|
|
|
import { translate } from '../i18n'; |
|
|
import { translate } from '../i18n'; |
|
|
|
|
|
|
|
|
@ -53,7 +52,7 @@ import { translate } from '../i18n'; |
|
|
styleUrls: ['./activities-filter.component.scss'], |
|
|
styleUrls: ['./activities-filter.component.scss'], |
|
|
templateUrl: './activities-filter.component.html' |
|
|
templateUrl: './activities-filter.component.html' |
|
|
}) |
|
|
}) |
|
|
export class GfActivitiesFilterComponent implements OnChanges, OnDestroy { |
|
|
export class GfActivitiesFilterComponent implements OnChanges { |
|
|
@Input() allFilters: Filter[]; |
|
|
@Input() allFilters: Filter[]; |
|
|
@Input() isLoading: boolean; |
|
|
@Input() isLoading: boolean; |
|
|
@Input() placeholder: string; |
|
|
@Input() placeholder: string; |
|
|
@ -70,11 +69,9 @@ export class GfActivitiesFilterComponent implements OnChanges, OnDestroy { |
|
|
public selectedFilters: Filter[] = []; |
|
|
public selectedFilters: Filter[] = []; |
|
|
public separatorKeysCodes: number[] = [ENTER, COMMA]; |
|
|
public separatorKeysCodes: number[] = [ENTER, COMMA]; |
|
|
|
|
|
|
|
|
private unsubscribeSubject = new Subject<void>(); |
|
|
|
|
|
|
|
|
|
|
|
public constructor() { |
|
|
public constructor() { |
|
|
this.searchControl.valueChanges |
|
|
this.searchControl.valueChanges |
|
|
.pipe(takeUntil(this.unsubscribeSubject)) |
|
|
.pipe(takeUntilDestroyed()) |
|
|
.subscribe((filterOrSearchTerm) => { |
|
|
.subscribe((filterOrSearchTerm) => { |
|
|
if (filterOrSearchTerm) { |
|
|
if (filterOrSearchTerm) { |
|
|
const searchTerm = |
|
|
const searchTerm = |
|
|
@ -131,11 +128,6 @@ export class GfActivitiesFilterComponent implements OnChanges, OnDestroy { |
|
|
this.searchControl.setValue(null); |
|
|
this.searchControl.setValue(null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public ngOnDestroy() { |
|
|
|
|
|
this.unsubscribeSubject.next(); |
|
|
|
|
|
this.unsubscribeSubject.complete(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private getGroupedFilters(searchTerm?: string) { |
|
|
private getGroupedFilters(searchTerm?: string) { |
|
|
const filterGroupsMap = groupBy( |
|
|
const filterGroupsMap = groupBy( |
|
|
this.allFilters |
|
|
this.allFilters |
|
|
|