src/app/core/filter/filters/entityFilter.ts

Extends

SelectableFilter<T>

Relationships

Used by

No results matching.

Depends on

  • SelectableFilter<T>

Index

Properties
Methods

Constructor

constructor(name: string, label: string, filterEntities: Entity[])
Parameters :
Name Type Optional
name string No
label string No
filterEntities Entity[] No

Properties

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

Methods

Static generateOptions
generateOptions<T>(valuesToMatchAsOptions: (string | number)[], attributeName: string)
Inherited from SelectableFilter
Type parameters :
  • T

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 :
   A separate FilterSelectionOption is created for each value with a filter
   that is true of a data item's property exactly matches that value.
Parameters :
Name Type Optional Description
valuesToMatchAsOptions (string | number)[] No

An array of values to be matched. A separate FilterSelectionOption is created for each value with a filter that is true of a data item's property exactly matches that value.

attributeName string No

The name of the property of a data item that is compared to the value in the filter function.

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.

getOption
getOption(key: string)
Inherited from SelectableFilter

Get the full filter option by its key.

Parameters :
Name Type Optional Description
key string No

The identifier of the requested option

clone
clone(changes: Partial)
Inherited from Filter
Parameters :
Name Type Optional Default value
changes Partial<this> No {}
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);
  }
}

results matching ""

    No results matching ""