- Components
-
ListFiltersComponent
ecosystem/shared/list-filters/list-filters.component.ts
<form
class="d-flex a-i-center"
[formGroup]="formGroup"
>
<c8y-filter
[filterTerm]="currentFilterTerm"
(onSearch)="setFilterTerm($event)"
></c8y-filter>
@if (predefinedFiltersVisible) {
<div
class="dropdown m-l-8 m-r-4"
dropdown
(isOpenChange)="toggleDropdown($event)"
#filtersDropdown="bs-dropdown"
[cdkTrapFocus]="filtersDropdown.isOpen"
[insideClick]="true"
>
<div class="input-group d-inline-flex">
<button
class="btn-clean form-control p-l-8 p-r-16 a-s-stretch d-flex a-i-center gap-4 w-auto flex-no-shrink"
title="{{ 'Filters' | translate }}"
dropdownToggle
>
<span [ngPlural]="chips.length">
<ng-template ngPluralCase="=0">
{{ 'Filters' | translate }}
</ng-template>
<ng-template ngPluralCase="=1">
<span class="badge badge-info">{{ chips.length }}</span>
{{ 'Filter' | translate }}
</ng-template>
<ng-template ngPluralCase="other">
<span class="badge badge-info">{{ chips.length }}</span>
{{ 'Filters' | translate }}
</ng-template>
</span>
<span class="caret"></span>
</button>
@if (chips.length > 0) {
<div class="input-group-addon p-t-0 p-b-0 d-flex gap-4 a-i-center inner-scroll">
@for (chip of chips; track chip[1]) {
@if (chip[1].value) {
<span class="tag tag--info chip">
<button
class="btn btn-xs btn-clean text-10"
title="{{ 'Remove' | translate }}"
type="button"
(click)="deselectChip(chip)"
>
<i c8yIcon="times"></i>
</button>
{{ chip[0] | translate | titlecase }}
</span>
}
}
</div>
}
</div>
<div
class="dropdown-menu"
*dropdownMenu
>
<div class="dropdown-form">
@if (packageTypes.length) {
<c8y-form-group formGroupName="type">
<label class="m-b-16">
{{ 'Type' | translate }}
</label>
@for (type of packageTypes; track type) {
<label
class="c8y-checkbox"
[title]="type | translate"
>
<input
type="checkbox"
[formControlName]="type"
[value]="type"
/>
<span></span>
<span>{{ type | translate | titlecase }}</span>
</label>
}
</c8y-form-group>
}
@if (packageAvailabilities.length) {
<c8y-form-group formGroupName="availability">
<label class="m-b-16">
{{ 'Availability`of package based on app state`' | translate }}
</label>
@for (availability of packageAvailabilities; track availability) {
<label
class="c8y-checkbox"
[title]="availability | translate"
>
<input
type="checkbox"
[formControlName]="availability"
[value]="availability"
/>
<span></span>
<span>{{ availability | translate }}</span>
</label>
}
</c8y-form-group>
}
@if (packageContents.length) {
<c8y-form-group formGroupName="content">
<label class="m-b-16">
{{ 'Content' | translate }}
</label>
@for (content of packageContents; track content) {
<label
class="c8y-checkbox"
[title]="content | translate"
>
<input
type="checkbox"
[formControlName]="content"
[value]="content"
/>
<span></span>
<span>{{ content | translate }}</span>
</label>
}
</c8y-form-group>
}
<c8y-form-group formGroupName="custom">
<ng-content></ng-content>
</c8y-form-group>
</div>
<div class="p-16 d-flex gap-8 separator-top">
<button
class="btn btn-default btn-sm flex-grow"
title="{{ 'Reset' | translate }}"
type="button"
(click)="reset(); filtersDropdown.hide()"
>
{{ 'Reset' | translate }}
</button>
<button
class="btn btn-primary btn-sm flex-grow"
title="{{ 'Apply' | translate }}"
type="button"
(click)="applyPredefinedFilters(); filtersDropdown.hide()"
[disabled]="formGroup.pristine && formGroup.untouched"
>
{{ 'Apply' | translate }}
</button>
</div>
</div>
</div>
}
</form>