2022-07-01 14:44:05 +02:00
|
|
|
import {Component, ElementRef, Input, ViewChild} from "@angular/core";
|
2022-06-30 12:40:37 +02:00
|
|
|
|
|
|
|
declare var UIkit;
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'dropdown-filter',
|
|
|
|
template: `
|
2022-07-01 14:44:05 +02:00
|
|
|
<button class="uk-button uk-button-default uk-flex uk-flex-middle"
|
|
|
|
[class.uk-disabled]="disabled" [disabled]="disabled">
|
2022-06-30 12:40:37 +02:00
|
|
|
<span>{{name}}<span *ngIf="count > 0">({{count}})</span></span>
|
2022-07-01 14:44:05 +02:00
|
|
|
<icon [flex]="true" class="uk-margin-xsmall-left" [name]="'expand_' + (isOpen?'less':'more')"></icon>
|
2022-06-30 12:40:37 +02:00
|
|
|
</button>
|
2022-07-13 19:25:19 +02:00
|
|
|
<div #dropdownElement class="uk-dropdown uk-height-max-medium uk-overflow-auto" [ngClass]="dropdownClass" uk-dropdown="mode: click; delay-hide: 0;">
|
|
|
|
<div>
|
|
|
|
<ng-content></ng-content>
|
|
|
|
</div>
|
2022-06-30 12:40:37 +02:00
|
|
|
</div>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
export class DropdownFilterComponent {
|
|
|
|
@Input()
|
|
|
|
public name;
|
|
|
|
@Input()
|
|
|
|
public count: number = 0;
|
|
|
|
@Input()
|
|
|
|
public dropdownClass: string;
|
2022-07-01 14:44:05 +02:00
|
|
|
@Input()
|
|
|
|
public disabled = false;
|
|
|
|
@ViewChild("dropdownElement") dropdownElement: ElementRef;
|
2022-06-30 12:40:37 +02:00
|
|
|
|
2022-07-01 14:44:05 +02:00
|
|
|
get isOpen() {
|
|
|
|
return this.dropdownElement && UIkit.dropdown(this.dropdownElement.nativeElement).isActive();
|
2022-06-30 12:40:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
closeDropdown() {
|
2022-07-01 14:44:05 +02:00
|
|
|
UIkit.dropdown(this.dropdownElement.nativeElement).hide();
|
2022-06-30 12:40:37 +02:00
|
|
|
}
|
|
|
|
}
|