src/app/core/filter/filters/entityFilter.ts
SelectableFilter<T>
No results matching.
SelectableFilter<T>
Properties |
|
Methods |
|
constructor(name: string, label: string, filterEntities: Entity[])
|
| Public label |
Type : string
|
|
Inherited from
Filter
|
|
The user-friendly label describing this filter-selection
(optional, defaults to the name of the selection)
|
| Public name |
Type : string
|
|
Inherited from
Filter
|
|
The name or id describing this filter
|
| Public options |
Type : FilterSelectionOption<T>[]
|
|
Inherited from
SelectableFilter
|
|
An array of different filtering variants to chose between
|
| Public singleSelectOnly |
Type : boolean
|
|
Inherited from
SelectableFilter
|
|
if true, only one option can be selected at a time
|
| component |
Type : Type<any>
|
Default value : ListFilterComponent
|
|
Inherited from
Filter
|
|
The component used to display filter option to the user. |
| selectedOptionChange |
Type : unknown
|
Default value : new EventEmitter<string[]>()
|
|
Inherited from
Filter
|
|
Triggered when this filter changes value (e.g. when the user selects a new value in a FilterComponent). This is part of the filter object because dynamic filter components can't expose @Outputs |
| Public selectedOptionValues |
Type : string[]
|
Default value : []
|
|
Inherited from
Filter
|
| Static generateOptions | ||||||||||||
generateOptions<T>(valuesToMatchAsOptions: (string | number)[], attributeName: string)
|
||||||||||||
|
Inherited from
SelectableFilter
|
||||||||||||
Type parameters :
|
||||||||||||
|
Generate filter options dynamically from the given value to be matched. This is a utility function to make it easier to generate FilterSelectionOptions for standard cases if you simply want each option to filter items having the given attribute matching different values. If you have more sophisticated filtering needs, use the constructor to set FilterSelectionOptions that you created yourself. Example :
Parameters :
Returns :
FilterSelectionOption[]
|
| Public getFilter |
getFilter()
|
|
Inherited from
Filter
|
|
Get the filter query for the given option. If the given key is undefined or invalid, the returned filter matches any elements.
Returns :
DataFilter | undefined
|
| getOption | ||||||||
getOption(key: string)
|
||||||||
|
Inherited from
SelectableFilter
|
||||||||
|
Get the full filter option by its key.
Parameters :
Returns :
FilterSelectionOption | undefined
|
| clone | ||||||||
clone(changes: Partial
|
||||||||
|
Inherited from
Filter
|
||||||||
|
Parameters :
Returns :
unknown
|
import { Entity } from "../../entity/model/entity";
import { FilterSelectionOption, SelectableFilter } from "./filters";
export class EntityFilter<T extends Entity> extends SelectableFilter<T> {
constructor(name: string, label: string, filterEntities: Entity[]) {
filterEntities.sort((a, b) => a.toString().localeCompare(b.toString()));
const options: FilterSelectionOption<T>[] = filterEntities.map(
(filterEntity) => ({
key: filterEntity.getId(),
label: filterEntity.toString(),
filter: {
$or: [
{ [name]: filterEntity.getId() },
{ [name]: { $elemMatch: { $eq: filterEntity.getId() } } },
],
},
}),
);
super(name, options, label);
}
}