libs/facet-search/src/lib/components/parameter-facet/parameter-facet.component.ts
selector | n52-parameter-facet |
styleUrls | ./parameter-facet.component.scss |
templateUrl | ./parameter-facet.component.html |
Properties |
|
Methods |
|
Inputs |
constructor()
|
facetSearchService | |
Type : FacetSearchService
|
|
sort | |
Type : ParameterFacetSort
|
|
Default value : ParameterFacetSort.descCount
|
|
textualFilter | |
Type : string
|
|
type | |
Type : ParameterFacetType
|
|
Private fetchFacetParameter |
fetchFacetParameter()
|
Returns :
void
|
ngOnDestroy |
ngOnDestroy()
|
Returns :
void
|
ngOnInit |
ngOnInit()
|
Returns :
void
|
Public toggleFacet | ||||||
toggleFacet(parameter: FacetParameter)
|
||||||
Parameters :
Returns :
void
|
Public parameterList |
Type : FacetParameter[]
|
Private resultSubs |
Type : Subscription
|
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import { Required } from '@helgoland/core';
import { Subscription } from 'rxjs';
import { FacetParameter, ParameterFacetSort, ParameterFacetType } from '../../facet-search-model';
import { FacetSearchService } from '../../facet-search.service';
@Component({
selector: 'n52-parameter-facet',
templateUrl: './parameter-facet.component.html',
styleUrls: ['./parameter-facet.component.scss']
})
export class ParameterFacetComponent implements OnInit, OnDestroy {
@Input() @Required public facetSearchService: FacetSearchService;
@Input() @Required public type: ParameterFacetType;
@Input() public sort: ParameterFacetSort = ParameterFacetSort.descCount;
@Input() public textualFilter: string;
public parameterList: FacetParameter[];
private resultSubs: Subscription;
constructor() { }
ngOnInit() {
this.resultSubs = this.facetSearchService.getResults().subscribe(() => this.fetchFacetParameter());
}
ngOnDestroy(): void {
this.resultSubs.unsubscribe();
}
public toggleFacet(parameter: FacetParameter) {
parameter.selected = !parameter.selected;
this.facetSearchService.selectParameter(this.type, parameter);
}
private fetchFacetParameter() {
this.parameterList = this.facetSearchService.getParameterList(this.type, this.sort);
}
}
<div *ngFor="let param of parameterList | matchLabel: textualFilter"
[ngStyle]="{'font-weight': param.selected ? 'bold' : 'normal'}" (click)="toggleFacet(param)">
<span>{{param.label}} ({{param.count}})</span>
</div>
./parameter-facet.component.scss